equal
deleted
inserted
replaced
32 #include "direction.h" |
32 #include "direction.h" |
33 #include "yapf/yapf.h" |
33 #include "yapf/yapf.h" |
34 #include "date.h" |
34 #include "date.h" |
35 |
35 |
36 static bool TrainCheckIfLineEnds(Vehicle *v); |
36 static bool TrainCheckIfLineEnds(Vehicle *v); |
37 static void TrainController(Vehicle *v); |
37 static void TrainController(Vehicle *v, bool update_image); |
38 |
38 |
39 static const byte _vehicle_initial_x_fract[4] = {10, 8, 4, 8}; |
39 static const byte _vehicle_initial_x_fract[4] = {10, 8, 4, 8}; |
40 static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10}; |
40 static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10}; |
41 static const byte _state_dir_table[4] = { 0x20, 8, 0x10, 4 }; |
41 static const byte _state_dir_table[4] = { 0x20, 8, 0x10, 4 }; |
42 |
42 |
1660 |
1660 |
1661 // disconnect last car to make sure only this subset moves |
1661 // disconnect last car to make sure only this subset moves |
1662 tempnext = last->next; |
1662 tempnext = last->next; |
1663 last->next = NULL; |
1663 last->next = NULL; |
1664 |
1664 |
1665 for (i = 0; i < differential; i++) TrainController(first); |
1665 for (i = 0; i < differential; i++) TrainController(first, false); |
1666 |
1666 |
1667 last->next = tempnext; |
1667 last->next = tempnext; |
1668 } |
1668 } |
1669 |
1669 |
1670 base = first; |
1670 base = first; |
3005 if (diff == DIRDIFF_90RIGHT || (v->cur_speed <= 5 && diff <= DIRDIFF_REVERSE)) return v; |
3005 if (diff == DIRDIFF_90RIGHT || (v->cur_speed <= 5 && diff <= DIRDIFF_REVERSE)) return v; |
3006 } |
3006 } |
3007 return NULL; |
3007 return NULL; |
3008 } |
3008 } |
3009 |
3009 |
3010 static void TrainController(Vehicle *v) |
3010 static void TrainController(Vehicle *v, bool update_image) |
3011 { |
3011 { |
3012 Vehicle *prev; |
3012 Vehicle *prev; |
3013 GetNewVehiclePosResult gp; |
3013 GetNewVehiclePosResult gp; |
3014 uint32 r, tracks,ts; |
3014 uint32 r, tracks,ts; |
3015 int i; |
3015 int i; |
3166 } |
3166 } |
3167 |
3167 |
3168 /* update image of train, as well as delta XY */ |
3168 /* update image of train, as well as delta XY */ |
3169 newdir = GetNewVehicleDirection(v, gp.x, gp.y); |
3169 newdir = GetNewVehicleDirection(v, gp.x, gp.y); |
3170 UpdateTrainDeltaXY(v, newdir); |
3170 UpdateTrainDeltaXY(v, newdir); |
3171 v->cur_image = GetTrainImage(v, newdir); |
3171 if (update_image) v->cur_image = GetTrainImage(v, newdir); |
3172 |
3172 |
3173 v->x_pos = gp.x; |
3173 v->x_pos = gp.x; |
3174 v->y_pos = gp.y; |
3174 v->y_pos = gp.y; |
3175 |
3175 |
3176 /* update the Z position of the vehicle */ |
3176 /* update the Z position of the vehicle */ |
3518 if (v->cur_speed != 0) return; |
3518 if (v->cur_speed != 0) return; |
3519 } else { |
3519 } else { |
3520 TrainCheckIfLineEnds(v); |
3520 TrainCheckIfLineEnds(v); |
3521 |
3521 |
3522 do { |
3522 do { |
3523 TrainController(v); |
3523 TrainController(v, true); |
3524 CheckTrainCollision(v); |
3524 CheckTrainCollision(v); |
3525 if (v->cur_speed <= 0x100) |
3525 if (v->cur_speed <= 0x100) |
3526 break; |
3526 break; |
3527 } while (--j != 0); |
3527 } while (--j != 0); |
3528 } |
3528 } |