Import Improved Breakdowns patch
Fix trailing whitespace http://www.tt-forums.net/viewtopic.php?p=1146419#p1146419
This commit is contained in:
committed by
Jonathan G Rennison
parent
c8a727d3fc
commit
9f5164b403
@@ -2817,6 +2817,38 @@ bool AfterLoadGame()
|
||||
}
|
||||
}
|
||||
|
||||
/* Set some breakdown-related variables to the correct values. */
|
||||
if (IsSavegameVersionBefore(SL_IB)) {
|
||||
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
switch(v->type) {
|
||||
case VEH_TRAIN: {
|
||||
if (Train::From(v)->IsFrontEngine()) {
|
||||
if (v->breakdown_ctr == 1) SetBit(Train::From(v)->flags, VRF_BREAKDOWN_STOPPED);
|
||||
} else if (Train::From(v)->IsEngine() || Train::From(v)->IsMultiheaded()) {
|
||||
/** Non-front engines could have a reliability of 0.
|
||||
* Set it to the reliability of the front engine or the maximum, whichever is lower. */
|
||||
const Engine *e = Engine::Get(v->engine_type);
|
||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||
v->reliability = min(v->First()->reliability, e->reliability);
|
||||
}
|
||||
}
|
||||
case VEH_ROAD:
|
||||
v->breakdown_chance = 128;
|
||||
break;
|
||||
case VEH_SHIP:
|
||||
v->breakdown_chance = 64;
|
||||
break;
|
||||
case VEH_AIRCRAFT:
|
||||
v->breakdown_chance = Clamp(64 + (AircraftVehInfo(v->engine_type)->max_speed >> 3), 0, 255);
|
||||
v->breakdown_severity = 40;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The road owner of standard road stops was not properly accounted for. */
|
||||
if (IsSavegameVersionBefore(172)) {
|
||||
for (TileIndex t = 0; t < map_size; t++) {
|
||||
|
||||
@@ -262,8 +262,10 @@
|
||||
* 192 26700
|
||||
* 193 26802
|
||||
* 194 26881 1.5.x
|
||||
*
|
||||
* 250 Improved Breakdowns
|
||||
*/
|
||||
extern const uint16 SAVEGAME_VERSION = 194; ///< Current savegame version of OpenTTD.
|
||||
extern const uint16 SAVEGAME_VERSION = 250; ///< Current savegame version of OpenTTD.
|
||||
|
||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ enum SLRefType {
|
||||
|
||||
/** Highest possible savegame version. */
|
||||
#define SL_MAX_VERSION UINT16_MAX
|
||||
#define SL_IB 250
|
||||
|
||||
/** Flags of a chunk. */
|
||||
enum ChunkType {
|
||||
|
||||
@@ -671,6 +671,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
||||
SLE_VAR(Vehicle, breakdown_delay, SLE_UINT8),
|
||||
SLE_VAR(Vehicle, breakdowns_since_last_service, SLE_UINT8),
|
||||
SLE_VAR(Vehicle, breakdown_chance, SLE_UINT8),
|
||||
SLE_CONDVAR(Vehicle, breakdown_type, SLE_UINT8, SL_IB, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, breakdown_severity, SLE_UINT8, SL_IB, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Vehicle, build_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
|
||||
SLE_CONDVAR(Vehicle, build_year, SLE_INT32, 31, SL_MAX_VERSION),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user