train_cmd.c
changeset 4344 5d0e40cd67b9
parent 4329 9759d5c52010
child 4351 63ae31104f07
equal deleted inserted replaced
4343:c5b7f4f03168 4344:5d0e40cd67b9
    33 #include "date.h"
    33 #include "date.h"
    34 
    34 
    35 static bool TrainCheckIfLineEnds(Vehicle *v);
    35 static bool TrainCheckIfLineEnds(Vehicle *v);
    36 static void TrainController(Vehicle *v);
    36 static void TrainController(Vehicle *v);
    37 
    37 
    38 static const byte _vehicle_initial_x_fract[4] = {10,8,4,8};
    38 static const byte _vehicle_initial_x_fract[4] = {10, 8, 4,  8};
    39 static const byte _vehicle_initial_y_fract[4] = {8,4,8,10};
    39 static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10};
    40 static const byte _state_dir_table[4] = { 0x20, 8, 0x10, 4 };
    40 static const byte _state_dir_table[4] = { 0x20, 8, 0x10, 4 };
    41 
    41 
    42 /**
    42 /**
    43  * Recalculates the cached weight of a train and its vehicles. Should be called each time the cargo on
    43  * Recalculates the cached weight of a train and its vehicles. Should be called each time the cargo on
    44  * the consist changes.
    44  * the consist changes.
  2169 		fd->station_index = INVALID_STATION;
  2169 		fd->station_index = INVALID_STATION;
  2170 	}
  2170 	}
  2171 }
  2171 }
  2172 
  2172 
  2173 static const byte _initial_tile_subcoord[6][4][3] = {
  2173 static const byte _initial_tile_subcoord[6][4][3] = {
  2174 {{ 15, 8, 1 },{ 0, 0, 0 },{ 0, 8, 5 },{ 0, 0, 0 }},
  2174 {{ 15, 8, 1 }, { 0, 0, 0 }, { 0, 8, 5 }, { 0,  0, 0 }},
  2175 {{  0, 0, 0 },{ 8, 0, 3 },{ 0, 0, 0 },{ 8,15, 7 }},
  2175 {{  0, 0, 0 }, { 8, 0, 3 }, { 0, 0, 0 }, { 8, 15, 7 }},
  2176 {{  0, 0, 0 },{ 7, 0, 2 },{ 0, 7, 6 },{ 0, 0, 0 }},
  2176 {{  0, 0, 0 }, { 7, 0, 2 }, { 0, 7, 6 }, { 0,  0, 0 }},
  2177 {{ 15, 8, 2 },{ 0, 0, 0 },{ 0, 0, 0 },{ 8,15, 6 }},
  2177 {{ 15, 8, 2 }, { 0, 0, 0 }, { 0, 0, 0 }, { 8, 15, 6 }},
  2178 {{ 15, 7, 0 },{ 8, 0, 4 },{ 0, 0, 0 },{ 0, 0, 0 }},
  2178 {{ 15, 7, 0 }, { 8, 0, 4 }, { 0, 0, 0 }, { 0,  0, 0 }},
  2179 {{  0, 0, 0 },{ 0, 0, 0 },{ 0, 8, 4 },{ 7,15, 0 }},
  2179 {{  0, 0, 0 }, { 0, 0, 0 }, { 0, 8, 4 }, { 7, 15, 0 }},
  2180 };
  2180 };
  2181 
  2181 
  2182 static const uint32 _reachable_tracks[4] = {
  2182 static const uint32 _reachable_tracks[4] = {
  2183 	0x10091009,
  2183 	0x10091009,
  2184 	0x00160016,
  2184 	0x00160016,
  2710 	byte z_down; // fraction to remove when moving down
  2710 	byte z_down; // fraction to remove when moving down
  2711 } RailtypeSlowdownParams;
  2711 } RailtypeSlowdownParams;
  2712 
  2712 
  2713 static const RailtypeSlowdownParams _railtype_slowdown[] = {
  2713 static const RailtypeSlowdownParams _railtype_slowdown[] = {
  2714 	// normal accel
  2714 	// normal accel
  2715 	{256/4, 256/2, 256/4, 2}, // normal
  2715 	{256 / 4, 256 / 2, 256 / 4, 2}, // normal
  2716 	{256/4, 256/2, 256/4, 2}, // electrified
  2716 	{256 / 4, 256 / 2, 256 / 4, 2}, // electrified
  2717 	{256/4, 256/2, 256/4, 2}, // monorail
  2717 	{256 / 4, 256 / 2, 256 / 4, 2}, // monorail
  2718 	{0,     256/2, 256/4, 2}, // maglev
  2718 	{0,       256 / 2, 256 / 4, 2}, // maglev
  2719 };
  2719 };
  2720 
  2720 
  2721 /* Modify the speed of the vehicle due to a turn */
  2721 /* Modify the speed of the vehicle due to a turn */
  2722 static void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
  2722 static void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
  2723 {
  2723 {