train_cmd.c
changeset 1236 928560eaf613
parent 1235 b9938f523286
child 1237 1c7a3f9c94b9
equal deleted inserted replaced
1235:b9938f523286 1236:928560eaf613
    59 
    59 
    60 enum AccelType {
    60 enum AccelType {
    61 	AM_ACCEL,
    61 	AM_ACCEL,
    62 	AM_BRAKE
    62 	AM_BRAKE
    63 };
    63 };
       
    64 
       
    65 static bool TrainShouldStop(Vehicle *v, TileIndex tile)
       
    66 {
       
    67 	Order *o = &v->current_order;
       
    68 	assert(v->type == VEH_Train);
       
    69 	assert(IsTileType(v->tile, MP_STATION));
       
    70 	//When does a train drive through a station
       
    71 	//first we deal with the "new nonstop handling"
       
    72 	if ( _patches.new_nonstop && o->flags & OF_NON_STOP && _map2[tile] == o->station )
       
    73 		return false;
       
    74 
       
    75 	if (v->last_station_visited == _map2[tile])
       
    76 		return false;
       
    77 
       
    78 	if ( _map2[tile] != o->station && (o->flags & OF_NON_STOP || _patches.new_nonstop))
       
    79 		return false;
       
    80 
       
    81 	return true;
       
    82 }
    64 
    83 
    65 //new acceleration
    84 //new acceleration
    66 static int GetTrainAcceleration(Vehicle *v, bool mode)
    85 static int GetTrainAcceleration(Vehicle *v, bool mode)
    67 {
    86 {
    68 	Vehicle *u = v;
    87 	Vehicle *u = v;
   135 	if (IsTileType(v->tile, MP_STATION) && v->subtype == TS_Front_Engine) {
   154 	if (IsTileType(v->tile, MP_STATION) && v->subtype == TS_Front_Engine) {
   136 		static const TileIndexDiffC _station_dir_from_vdir[] = {
   155 		static const TileIndexDiffC _station_dir_from_vdir[] = {
   137 			{0, 0}, {-1, 0}, {0, 0}, {0, 1}, {0, 0}, {1, 0}, {0, 0}, {0, -1}
   156 			{0, 0}, {-1, 0}, {0, 0}, {0, 1}, {0, 0}, {1, 0}, {0, 0}, {0, -1}
   138 		};
   157 		};
   139 
   158 
   140 		if (((v->current_order.station == _map2[v->tile]) || !(v->current_order.flags & OF_NON_STOP)) && v->last_station_visited != _map2[v->tile]) {
   159 		if (TrainShouldStop(v, v->tile)) {
   141 			int station_length = 0;
   160 			int station_length = 0;
   142 			TileIndex tile = v->tile;
   161 			TileIndex tile = v->tile;
   143 			int delta_v;
   162 			int delta_v;
   144 
   163 
   145 			max_speed = 120;
   164 			max_speed = 120;