From 99325433799d791d959d84bebf057a0b409f3a5b Mon Sep 17 00:00:00 2001 From: nvhaizi1 Date: Mon, 30 May 2022 22:44:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9getbusposition=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 | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/bus.c b/src/bus.c index 4c1ae83..5114608 100644 --- a/src/bus.c +++ b/src/bus.c @@ -20,14 +20,25 @@ int GetBusPosition() b = 0; rail_node_t *p = rails; a = the_bus->rail_node_pos->id;//指向站点的指针以及这个指针对应的站台id - - while (p->id != a){ + if (a == 1 && (the_bus->distance < 0)) + { + while(p->id != p->last_node->id) + { + b += p->next_node_distance; + p = p->next_node; + } b += p->next_node_distance; - p = p->next_node; + c = b + (the_bus->distance); } + else + { + while (p->id != a){ + b += p->next_node_distance; + p = p->next_node; + } - c = b + (the_bus->distance); - + c = b + (the_bus->distance); + } return c; }