Merge branch 'master' into jgrpp
# Conflicts: # regression/regression/result.txt # src/autoreplace_cmd.cpp # src/industry_gui.cpp # src/landscape.cpp # src/network/network_content.cpp # src/newgrf_roadstop.cpp # src/pathfinder/yapf/yapf_ship.cpp # src/road_gui.cpp # src/saveload/ai_sl.cpp # src/saveload/saveload.h # src/saveload/vehicle_sl.cpp # src/station.cpp # src/station_gui.cpp # src/video/cocoa/cocoa_ogl.h # src/video/sdl2_opengl_v.h # src/video/video_driver.hpp # src/video/win32_v.h # src/widget_type.h # src/widgets/dropdown.cpp # src/widgets/dropdown_type.h # src/window.cpp
This commit is contained in:
@@ -29,31 +29,9 @@ static const SaveLoad _ai_company[] = {
|
||||
SLEG_SSTR(_ai_saveload_name, SLE_STR),
|
||||
SLEG_SSTR(_ai_saveload_settings, SLE_STR),
|
||||
SLEG_CONDVAR(_ai_saveload_version, SLE_UINT32, SLV_108, SL_MAX_VERSION),
|
||||
SLEG_CONDVAR(_ai_saveload_is_random, SLE_BOOL, SLV_136, SL_MAX_VERSION),
|
||||
SLEG_CONDVAR(_ai_saveload_is_random, SLE_BOOL, SLV_136, SLV_AI_LOCAL_CONFIG),
|
||||
};
|
||||
|
||||
static void SaveReal_AIPL(int *index_ptr)
|
||||
{
|
||||
CompanyID index = (CompanyID)*index_ptr;
|
||||
AIConfig *config = AIConfig::GetConfig(index);
|
||||
|
||||
if (config->HasScript()) {
|
||||
_ai_saveload_name = config->GetName();
|
||||
_ai_saveload_version = config->GetVersion();
|
||||
} else {
|
||||
/* No AI is configured for this so store an empty string as name. */
|
||||
_ai_saveload_name.clear();
|
||||
_ai_saveload_version = -1;
|
||||
}
|
||||
|
||||
_ai_saveload_is_random = config->IsRandom();
|
||||
_ai_saveload_settings = config->SettingsToString();
|
||||
|
||||
SlObject(nullptr, _ai_company);
|
||||
/* If the AI was active, store its data too */
|
||||
if (Company::IsValidAiID(index)) AI::Save(index);
|
||||
}
|
||||
|
||||
static void Load_AIPL()
|
||||
{
|
||||
/* Free all current data */
|
||||
@@ -75,15 +53,15 @@ static void Load_AIPL()
|
||||
}
|
||||
|
||||
AIConfig *config = AIConfig::GetConfig(index, AIConfig::SSS_FORCE_GAME);
|
||||
if (_ai_saveload_name.empty()) {
|
||||
if (_ai_saveload_name.empty() || _ai_saveload_is_random) {
|
||||
/* A random AI. */
|
||||
config->Change(std::nullopt, -1, false, true);
|
||||
config->Change(std::nullopt, -1, false);
|
||||
} else {
|
||||
config->Change(_ai_saveload_name, _ai_saveload_version, false, _ai_saveload_is_random);
|
||||
config->Change(_ai_saveload_name, _ai_saveload_version, false);
|
||||
if (!config->HasScript()) {
|
||||
/* No version of the AI available that can load the data. Try to load the
|
||||
* latest version of the AI instead. */
|
||||
config->Change(_ai_saveload_name, -1, false, _ai_saveload_is_random);
|
||||
config->Change(_ai_saveload_name, -1, false);
|
||||
if (!config->HasScript()) {
|
||||
if (_ai_saveload_name.compare("%_dummy") != 0) {
|
||||
DEBUG(script, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name.c_str(), _ai_saveload_version);
|
||||
@@ -109,16 +87,8 @@ static void Load_AIPL()
|
||||
}
|
||||
}
|
||||
|
||||
static void Save_AIPL()
|
||||
{
|
||||
for (int i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
||||
SlSetArrayIndex(i);
|
||||
SlAutolength((AutolengthProc *)SaveReal_AIPL, &i);
|
||||
}
|
||||
}
|
||||
|
||||
static const ChunkHandler ai_chunk_handlers[] = {
|
||||
{ 'AIPL', Save_AIPL, Load_AIPL, nullptr, nullptr, CH_ARRAY },
|
||||
MakeSaveUpstreamFeatureConditionalLoadUpstreamChunkHandler<'AIPL', XSLFI_TABLE_SCRIPT_SL>(Load_AIPL, nullptr, nullptr),
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _ai_chunk_handlers(ai_chunk_handlers);
|
||||
|
@@ -213,6 +213,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
|
||||
{ XSLFI_TABLE_PATS, XSCF_NULL, 1, 1, "table_pats", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TABLE_MISC_SL, XSCF_NULL, 1, 1, "table_misc_sl", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TABLE_SCRIPT_SL, XSCF_NULL, 1, 1, "table_script_sl", nullptr, nullptr, nullptr },
|
||||
|
||||
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr }, // This is the end marker
|
||||
};
|
||||
|
@@ -162,6 +162,7 @@ enum SlXvFeatureIndex {
|
||||
|
||||
XSLFI_TABLE_PATS, ///< Use upstream table format for PATS
|
||||
XSLFI_TABLE_MISC_SL, ///< Use upstream table format for miscellaneous chunks, so far: DATE, VIEW, MAPS
|
||||
XSLFI_TABLE_SCRIPT_SL, ///< Use upstream table format for script chunks
|
||||
|
||||
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
|
||||
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk
|
||||
|
@@ -32,26 +32,6 @@ static const SaveLoad _game_script[] = {
|
||||
SLEG_VAR(_game_saveload_is_random, SLE_BOOL),
|
||||
};
|
||||
|
||||
static void SaveReal_GSDT(int *index_ptr)
|
||||
{
|
||||
GameConfig *config = GameConfig::GetConfig();
|
||||
|
||||
if (config->HasScript()) {
|
||||
_game_saveload_name = config->GetName();
|
||||
_game_saveload_version = config->GetVersion();
|
||||
} else {
|
||||
/* No GameScript is configured for this so store an empty string as name. */
|
||||
_game_saveload_name.clear();
|
||||
_game_saveload_version = -1;
|
||||
}
|
||||
|
||||
_game_saveload_is_random = config->IsRandom();
|
||||
_game_saveload_settings = config->SettingsToString();
|
||||
|
||||
SlObject(nullptr, _game_script);
|
||||
Game::Save();
|
||||
}
|
||||
|
||||
static void Load_GSDT()
|
||||
{
|
||||
/* Free all current data */
|
||||
@@ -70,11 +50,11 @@ static void Load_GSDT()
|
||||
|
||||
GameConfig *config = GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME);
|
||||
if (!_game_saveload_name.empty()) {
|
||||
config->Change(_game_saveload_name, _game_saveload_version, false, _game_saveload_is_random);
|
||||
config->Change(_game_saveload_name, _game_saveload_version, false);
|
||||
if (!config->HasScript()) {
|
||||
/* No version of the GameScript available that can load the data. Try to load the
|
||||
* latest version of the GameScript instead. */
|
||||
config->Change(_game_saveload_name, -1, false, _game_saveload_is_random);
|
||||
config->Change(_game_saveload_name, -1, false);
|
||||
if (!config->HasScript()) {
|
||||
if (_game_saveload_name.compare("%_dummy") != 0) {
|
||||
DEBUG(script, 0, "The savegame has an GameScript by the name '%s', version %d which is no longer available.", _game_saveload_name.c_str(), _game_saveload_version);
|
||||
@@ -101,12 +81,6 @@ static void Load_GSDT()
|
||||
if ((CompanyID)SlIterateArray() != (CompanyID)-1) SlErrorCorrupt("Too many GameScript configs");
|
||||
}
|
||||
|
||||
static void Save_GSDT()
|
||||
{
|
||||
SlSetArrayIndex(0);
|
||||
SlAutolength((AutolengthProc *)SaveReal_GSDT, nullptr);
|
||||
}
|
||||
|
||||
extern GameStrings *_current_data;
|
||||
|
||||
static std::string _game_saveload_string;
|
||||
@@ -121,18 +95,6 @@ static const SaveLoad _game_language_string[] = {
|
||||
SLEG_SSTR(_game_saveload_string, SLE_STR | SLF_ALLOW_CONTROL),
|
||||
};
|
||||
|
||||
static void SaveReal_GSTR(const LanguageStrings *ls)
|
||||
{
|
||||
_game_saveload_string = ls->language.c_str();
|
||||
_game_saveload_strings = (uint)ls->lines.size();
|
||||
|
||||
SlObject(nullptr, _game_language_header);
|
||||
for (const auto &i : ls->lines) {
|
||||
_game_saveload_string = i.c_str();
|
||||
SlObject(nullptr, _game_language_string);
|
||||
}
|
||||
}
|
||||
|
||||
static void Load_GSTR()
|
||||
{
|
||||
delete _current_data;
|
||||
@@ -162,19 +124,9 @@ static void Load_GSTR()
|
||||
ReconsiderGameScriptLanguage();
|
||||
}
|
||||
|
||||
static void Save_GSTR()
|
||||
{
|
||||
if (_current_data == nullptr) return;
|
||||
|
||||
for (uint i = 0; i < _current_data->raw_strings.size(); i++) {
|
||||
SlSetArrayIndex(i);
|
||||
SlAutolength((AutolengthProc *)SaveReal_GSTR, &_current_data->raw_strings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static const ChunkHandler game_chunk_handlers[] = {
|
||||
{ 'GSTR', Save_GSTR, Load_GSTR, nullptr, nullptr, CH_ARRAY },
|
||||
{ 'GSDT', Save_GSDT, Load_GSDT, nullptr, nullptr, CH_ARRAY },
|
||||
MakeSaveUpstreamFeatureConditionalLoadUpstreamChunkHandler<'GSTR', XSLFI_TABLE_SCRIPT_SL>(Load_GSTR, nullptr, nullptr),
|
||||
MakeSaveUpstreamFeatureConditionalLoadUpstreamChunkHandler<'GSDT', XSLFI_TABLE_SCRIPT_SL>(Load_GSDT, nullptr, nullptr),
|
||||
};
|
||||
|
||||
extern const ChunkHandlerTable _game_chunk_handlers(game_chunk_handlers);
|
||||
|
@@ -386,6 +386,8 @@ enum SaveLoadVersion : uint16_t {
|
||||
SLV_SHIP_ACCELERATION, ///< 329 PR#10734 Start using Vehicle's acceleration field for ships too.
|
||||
SLV_MAX_LOAN_FOR_COMPANY, ///< 330 PR#11224 Separate max loan for each company.
|
||||
SLV_DEPOT_UNBUNCHING, ///< 331 PR#11945 Allow unbunching shared order vehicles at a depot.
|
||||
SLV_AI_LOCAL_CONFIG, ///< 332 PR#12003 Config of running AI is stored inside Company.
|
||||
SLV_SCRIPT_RANDOMIZER, ///< 333 PR#12063 Save script randomizers.
|
||||
|
||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||
|
||||
|
Reference in New Issue
Block a user