添加了求与请求距离的函数
添加了表示整个轨道长度的全局变量
This commit is contained in:
26
src/bus.c
26
src/bus.c
@@ -82,4 +82,30 @@ int JudgeOnStation()
|
||||
{
|
||||
return BUS_FAlSE;
|
||||
}
|
||||
}
|
||||
|
||||
int GetQueryDistance(bus_query_t *query, int orientation)
|
||||
{
|
||||
rail_node_t *target_node = query->node;
|
||||
rail_node_t *now_node = the_bus->rail_node_pos;
|
||||
int distance = 0;
|
||||
|
||||
if(orientation == BUS_CLOCK_WISE)
|
||||
{
|
||||
while (now_node != target_node)
|
||||
{
|
||||
distance += now_node->next_node_distance;
|
||||
now_node = now_node->next_node;
|
||||
}
|
||||
}
|
||||
else if(orientation == BUS_COUNTER_CLOCK_WISE)
|
||||
{
|
||||
while (now_node != target_node)
|
||||
{
|
||||
distance += now_node->last_node_distance;
|
||||
now_node = now_node->last_node;
|
||||
}
|
||||
}
|
||||
|
||||
return distance;
|
||||
}
|
@@ -151,6 +151,7 @@ rail_node_t *ReadConfigFile()
|
||||
chosen_strategy = BUS_FCFS;
|
||||
}
|
||||
|
||||
all_distance = distance * total_station;
|
||||
rail_node_t *head = CreateRails(distance, total_station);
|
||||
return head;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
rail_node_t *rails = NULL;
|
||||
int bus_time = 0;
|
||||
int all_distance = 0;
|
||||
|
||||
rail_node_t *CreateRails(int length, int node_num)
|
||||
{
|
||||
|
Reference in New Issue
Block a user