diff --git a/src/controller.c b/src/controller.c index 2b05d6d..4d87cb8 100644 --- a/src/controller.c +++ b/src/controller.c @@ -11,7 +11,6 @@ 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; @@ -26,16 +25,15 @@ int FCFSDirection() { int clockwise = 0; int counterclockwise = 0; //用于顺,逆时针方向所经站台计数 - bus_query_t *t = p; //将指针p的地址暂存 while(p->node->id != p->next_node->node->id) { p->node = p->node->next_node; clockwise++; }//顺时针方向计数 - while(t->node->id != t->next_node->node->id) + while(p->node->id != p->next_node->node->id) { - t->next_node->node = t->next_node->node->next_node; + p->next_node->node = p->next_node->node->next_node; counterclockwise++; }//逆时针方向计数