From 7dd5fd6ed497e1da40c13075d6e37b54ab12a082 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Mon, 14 Jun 2021 10:05:30 +0200 Subject: Feature: framework to make savegames self-descriptive We won't be able to make it fully self-descriptive (looking at you MAP-chunks), but anything else can. With this framework, we can add headers for each chunk explaining how each chunk looks like in detail. They also will all be tables, making it a lot easier to read in external tooling, and opening the way to consider a database (like SQLite) to use as savegame format. Lastly, with the headers in the savegame, you can freely add fields without needing a savegame version bump; older versions of OpenTTD will simply ignore the new field. This also means we can remove all the SLE_CONDNULL, as they are irrelevant. The next few commits will start using this framework. --- src/saveload/company_sl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/saveload/company_sl.cpp') diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 880fc9e89..7abec8041 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -294,7 +294,7 @@ public: SLE_CONDNULL(32, SL_MIN_VERSION, SLV_107), SLE_CONDNULL(64, SLV_2, SLV_107), - SLEG_STRUCTLIST(SlCompanyOldAIBuildRec), + SLEG_STRUCTLIST("build_rec", SlCompanyOldAIBuildRec), }; void GenericSaveLoad(CompanyProperties *c) const @@ -513,11 +513,11 @@ static const SaveLoad _company_desc[] = { SLE_CONDVAR(CompanyProperties, terraform_limit, SLE_UINT32, SLV_156, SL_MAX_VERSION), SLE_CONDVAR(CompanyProperties, clear_limit, SLE_UINT32, SLV_156, SL_MAX_VERSION), SLE_CONDVAR(CompanyProperties, tree_limit, SLE_UINT32, SLV_175, SL_MAX_VERSION), - SLEG_STRUCT(SlCompanySettings), - SLEG_CONDSTRUCT(SlCompanyOldAI, SL_MIN_VERSION, SLV_107), - SLEG_STRUCT(SlCompanyEconomy), - SLEG_STRUCTLIST(SlCompanyOldEconomy), - SLEG_CONDSTRUCTLIST(SlCompanyLiveries, SLV_34, SL_MAX_VERSION), + SLEG_STRUCT("settings", SlCompanySettings), + SLEG_CONDSTRUCT("old_ai", SlCompanyOldAI, SL_MIN_VERSION, SLV_107), + SLEG_STRUCT("cur_economy", SlCompanyEconomy), + SLEG_STRUCTLIST("old_economy", SlCompanyOldEconomy), + SLEG_CONDSTRUCTLIST("liveries", SlCompanyLiveries, SLV_34, SL_MAX_VERSION), }; static void Save_PLYR() -- cgit v1.2.3-54-g00ecf