From d691021553a883ebde69693674189cf59904c2c2 Mon Sep 17 00:00:00 2001 From: Yerolling <2911328695@qq.com> Date: Sat, 28 May 2022 21:54:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86FCFSDirection?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/controller.c b/src/controller.c index 4d87cb8..130c710 100644 --- a/src/controller.c +++ b/src/controller.c @@ -9,29 +9,23 @@ int chosen_strategy = -1; int FCFSDirection() { bus_query_t *p = queries; - int id = the_bus->rail_node_pos->id; //获取当前站点的id - while(p->node->id == p->next_node->node->id) //如果下一个请求对应的站点与当前是同一个站点 - { - p = p->next_node; - } //处理完所有连续相同站点请求 - - if(p->next_node == NULL) + if(p == NULL) { return BUS_STOP; - } //如果没有请求了,公交车停止 + } //如果没有请求,公交车停止 else { int clockwise = 0; int counterclockwise = 0; //用于顺,逆时针方向所经站台计数 - while(p->node->id != p->next_node->node->id) + while(p->node != p->next_node->node) { p->node = p->node->next_node; clockwise++; }//顺时针方向计数 - while(p->node->id != p->next_node->node->id) + while(p->node != p->next_node->node) { p->next_node->node = p->next_node->node->next_node; counterclockwise++;