From f6ceaa1c7e4a97a79f0f715a499c7f86ebe57a6b Mon Sep 17 00:00:00 2001 From: nvhaizi1 Date: Tue, 24 May 2022 18:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9JudgeOnStation=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bus.c b/src/bus.c index f99e32f..3994ed6 100644 --- a/src/bus.c +++ b/src/bus.c @@ -22,11 +22,19 @@ int GetBusPosition() } int JudgeOnStation() { - if(abs(the_bus->distance) == rails->last_node_distance) + if(abs(the_bus->distance) == rails->last_node_distance)//表示逆时针 { + the_bus->distance=0; + the_bus->rail_node_pos=rails->last_node;//逆时针往上一个 return BUS_TRUE; } - else + else if(abs(the_bus->distance) == rails->next_node_distance)//表示顺时针 + { + the_bus->distance=0; + the_bus->rail_node_pos=rails->next_node;//顺时针往下一个 + return BUS_TRUE; + } + else { return BUS_FAlSE; }