Merge branch 'master' into jgrpp
# Conflicts: # src/aircraft_cmd.cpp # src/autoreplace_cmd.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/yapf/yapf_rail.cpp # src/saveload/afterload.cpp # src/saveload/saveload.cpp # src/script/api/ai/ai_station.hpp.sq # src/script/api/game/game_station.hpp.sq # src/script/api/script_station.hpp # src/track_func.h # src/vehicle_base.h
This commit is contained in:
@@ -3308,6 +3308,36 @@ bool AfterLoadGame()
|
||||
t->grow_counter = TownTicksToGameTicks(t->grow_counter) + t->index % TOWN_GROWTH_TICKS;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSavegameVersionBefore(202)) {
|
||||
/* Make sure added industry cargo slots are cleared */
|
||||
Industry *i;
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
for (size_t ci = 2; ci < lengthof(i->produced_cargo); ci++) {
|
||||
i->produced_cargo[ci] = CT_INVALID;
|
||||
i->produced_cargo_waiting[ci] = 0;
|
||||
i->production_rate[ci] = 0;
|
||||
i->last_month_production[ci] = 0;
|
||||
i->last_month_transported[ci] = 0;
|
||||
i->last_month_pct_transported[ci] = 0;
|
||||
i->this_month_production[ci] = 0;
|
||||
i->this_month_transported[ci] = 0;
|
||||
}
|
||||
for (size_t ci = 3; ci < lengthof(i->accepts_cargo); ci++) {
|
||||
i->accepts_cargo[ci] = CT_INVALID;
|
||||
i->incoming_cargo_waiting[ci] = 0;
|
||||
}
|
||||
/* Make sure last_cargo_accepted_at is copied to elements for every valid input cargo.
|
||||
* The loading routine should put the original singular value into the first array element. */
|
||||
for (size_t ci = 0; ci < lengthof(i->accepts_cargo); ci++) {
|
||||
if (i->accepts_cargo[ci] != CT_INVALID) {
|
||||
i->last_cargo_accepted_at[ci] = i->last_cargo_accepted_at[0];
|
||||
} else {
|
||||
i->last_cargo_accepted_at[ci] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SlXvIsFeatureMissing(XSLFI_TIMETABLES_START_TICKS)) {
|
||||
// savegame timetable start is in days, but we want it in ticks, fix it up
|
||||
|
@@ -26,18 +26,28 @@ static const SaveLoad _industry_desc[] = {
|
||||
SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16),
|
||||
SLE_REF(Industry, town, REF_TOWN),
|
||||
SLE_CONDNULL( 2, 0, 60), ///< used to be industry's produced_cargo
|
||||
SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 2, 78, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, incoming_cargo_waiting, SLE_UINT16, 3, 70, SL_MAX_VERSION),
|
||||
SLE_ARR(Industry, produced_cargo_waiting, SLE_UINT16, 2),
|
||||
SLE_ARR(Industry, production_rate, SLE_UINT8, 2),
|
||||
SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 2, 78, 201),
|
||||
SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, incoming_cargo_waiting, SLE_UINT16, 3, 70, 201),
|
||||
SLE_CONDARR(Industry, incoming_cargo_waiting, SLE_UINT16, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, produced_cargo_waiting, SLE_UINT16, 2, 0, 201),
|
||||
SLE_CONDARR(Industry, produced_cargo_waiting, SLE_UINT16, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, production_rate, SLE_UINT8, 2, 0, 201),
|
||||
SLE_CONDARR(Industry, production_rate, SLE_UINT8, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDNULL( 3, 0, 60), ///< used to be industry's accepts_cargo
|
||||
SLE_CONDARR(Industry, accepts_cargo, SLE_UINT8, 3, 78, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, accepts_cargo, SLE_UINT8, 3, 78, 201),
|
||||
SLE_CONDARR(Industry, accepts_cargo, SLE_UINT8, 16, 202, SL_MAX_VERSION),
|
||||
SLE_VAR(Industry, prod_level, SLE_UINT8),
|
||||
SLE_ARR(Industry, this_month_production, SLE_UINT16, 2),
|
||||
SLE_ARR(Industry, this_month_transported, SLE_UINT16, 2),
|
||||
SLE_ARR(Industry, last_month_pct_transported, SLE_UINT8, 2),
|
||||
SLE_ARR(Industry, last_month_production, SLE_UINT16, 2),
|
||||
SLE_ARR(Industry, last_month_transported, SLE_UINT16, 2),
|
||||
SLE_CONDARR(Industry, this_month_production, SLE_UINT16, 2, 0, 201),
|
||||
SLE_CONDARR(Industry, this_month_production, SLE_UINT16, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, this_month_transported, SLE_UINT16, 2, 0, 201),
|
||||
SLE_CONDARR(Industry, this_month_transported, SLE_UINT16, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, last_month_pct_transported, SLE_UINT8, 2, 0, 201),
|
||||
SLE_CONDARR(Industry, last_month_pct_transported, SLE_UINT8, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, last_month_production, SLE_UINT16, 2, 0, 201),
|
||||
SLE_CONDARR(Industry, last_month_production, SLE_UINT16, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDARR(Industry, last_month_transported, SLE_UINT16, 2, 0, 201),
|
||||
SLE_CONDARR(Industry, last_month_transported, SLE_UINT16, 16, 202, SL_MAX_VERSION),
|
||||
|
||||
SLE_VAR(Industry, counter, SLE_UINT16),
|
||||
|
||||
@@ -51,7 +61,8 @@ static const SaveLoad _industry_desc[] = {
|
||||
SLE_CONDVAR(Industry, founder, SLE_UINT8, 70, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Industry, construction_date, SLE_INT32, 70, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Industry, construction_type, SLE_UINT8, 70, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Industry, last_cargo_accepted_at, SLE_INT32, 70, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Industry, last_cargo_accepted_at[0], SLE_INT32, 70, 201),
|
||||
SLE_CONDARR(Industry, last_cargo_accepted_at, SLE_INT32, 16, 202, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Industry, selected_layout, SLE_UINT8, 73, SL_MAX_VERSION),
|
||||
|
||||
SLEG_CONDARR(_old_ind_persistent_storage.storage, SLE_UINT32, 16, 76, 160),
|
||||
|
@@ -140,7 +140,7 @@ static const SaveLoad _edge_desc[] = {
|
||||
|
||||
/**
|
||||
* Save/load a link graph.
|
||||
* @param comp Link graph to be saved or loaded.
|
||||
* @param lg Link graph to be saved or loaded.
|
||||
*/
|
||||
void SaveLoad_LinkGraph(LinkGraph &lg)
|
||||
{
|
||||
|
@@ -265,7 +265,7 @@ static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *l
|
||||
case SGT_TTD: title = strecpy(title, "(TTD) ", last); break;
|
||||
default: title = strecpy(title, "(broken) ", last); break;
|
||||
}
|
||||
title = strecpy(title, temp, last);
|
||||
strecpy(title, temp, last);
|
||||
}
|
||||
|
||||
return type;
|
||||
|
@@ -278,8 +278,9 @@
|
||||
* 199
|
||||
* 200 #6805 Extend railtypes to 64, adding uint16 to map array.
|
||||
* 201 #6885 Extend NewGRF persistant storages.
|
||||
* 202 #6867 Increase industry cargo slots to 16 in, 16 out
|
||||
*/
|
||||
extern const uint16 SAVEGAME_VERSION = 201; ///< Current savegame version of OpenTTD.
|
||||
extern const uint16 SAVEGAME_VERSION = 202; ///< Current savegame version of OpenTTD.
|
||||
const uint16 SAVEGAME_VERSION_EXT = 0x8000; ///< Savegame extension indicator mask
|
||||
|
||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||
@@ -3087,7 +3088,7 @@ SaveOrLoadResult LoadWithFilter(LoadFilter *reader)
|
||||
* Main Save or Load function where the high-level saveload functions are
|
||||
* handled. It opens the savegame, selects format and checks versions
|
||||
* @param filename The name of the savegame being created/loaded
|
||||
* @param mode Save or load mode. Load can also be a TTD(Patch) game. Use #SL_LOAD, #SL_OLD_LOAD, #SL_LOAD_CHECK, or #SL_SAVE.
|
||||
* @param fop Save or load mode. Load can also be a TTD(Patch) game.
|
||||
* @param sb The sub directory to save the savegame in
|
||||
* @param threaded True when threaded saving is allowed
|
||||
* @return Return the result of the action. #SL_OK, #SL_ERROR, or #SL_REINIT ("unload" the game)
|
||||
|
@@ -640,7 +640,7 @@ static inline bool SlIsObjectCurrentlyValid(uint16 version_from, uint16 version_
|
||||
* Get the NumberType of a setting. This describes the integer type
|
||||
* as it is represented in memory
|
||||
* @param type VarType holding information about the variable-type
|
||||
* @return return the SLE_VAR_* part of a variable-type description
|
||||
* @return the SLE_VAR_* part of a variable-type description
|
||||
*/
|
||||
static inline VarType GetVarMemType(VarType type)
|
||||
{
|
||||
@@ -648,10 +648,10 @@ static inline VarType GetVarMemType(VarType type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the #FileType of a setting. This describes the integer type
|
||||
* Get the FileType of a setting. This describes the integer type
|
||||
* as it is represented in a savegame/file
|
||||
* @param type VarType holding information about the file-type
|
||||
* @param return the SLE_FILE_* part of a variable-type description
|
||||
* @return the SLE_FILE_* part of a variable-type description
|
||||
*/
|
||||
static inline VarType GetVarFileType(VarType type)
|
||||
{
|
||||
|
Reference in New Issue
Block a user