summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorPeterN <peter@fuzzle.org>2019-01-31 13:57:44 +0000
committerIngo von Borstel <github@planetmaker.de>2019-01-31 14:57:44 +0100
commit23960d0f2c82a634e0ca1be720c229ac22f14962 (patch)
tree7a7c75a5e7ae19943377756d49c477d759873d3b /src/saveload
parentba38a7ca652c00a1d0851f4d97f0b7d360df853c (diff)
downloadopenttd-23960d0f2c82a634e0ca1be720c229ac22f14962.tar.xz
Feature: Group liveries, and livery window usability enhancements. (#7108)
* Change: Replace checkbox in livery selection window with Default option in drop down selection. This reduces clutter in the UI and allows for primary/secondary colours to independently follow the default scheme if desired. * Feature: Add vehicle group liveries.
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/company_sl.cpp11
-rw-r--r--src/saveload/group_sl.cpp10
-rw-r--r--src/saveload/saveload.cpp3
3 files changed, 22 insertions, 2 deletions
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index ce388e214..1782e7c28 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -403,7 +403,7 @@ static const SaveLoad _company_ai_build_rec_desc[] = {
};
static const SaveLoad _company_livery_desc[] = {
- SLE_CONDVAR(Livery, in_use, SLE_BOOL, 34, SL_MAX_VERSION),
+ SLE_CONDVAR(Livery, in_use, SLE_UINT8, 34, SL_MAX_VERSION),
SLE_CONDVAR(Livery, colour1, SLE_UINT8, 34, SL_MAX_VERSION),
SLE_CONDVAR(Livery, colour2, SLE_UINT8, 34, SL_MAX_VERSION),
SLE_END()
@@ -443,9 +443,18 @@ static void SaveLoad_PLYR_common(Company *c, CompanyProperties *cprops)
/* Write each livery entry. */
int num_liveries = IsSavegameVersionBefore(63) ? LS_END - 4 : (IsSavegameVersionBefore(85) ? LS_END - 2: LS_END);
+ bool update_in_use = IsSavegameVersionBefore(205);
if (c != NULL) {
for (i = 0; i < num_liveries; i++) {
SlObject(&c->livery[i], _company_livery_desc);
+ if (update_in_use && i != LS_DEFAULT) {
+ if (c->livery[i].in_use == 0) {
+ c->livery[i].colour1 = c->livery[LS_DEFAULT].colour1;
+ c->livery[i].colour2 = c->livery[LS_DEFAULT].colour2;
+ } else {
+ c->livery[i].in_use = 3;
+ }
+ }
}
if (num_liveries < LS_END) {
diff --git a/src/saveload/group_sl.cpp b/src/saveload/group_sl.cpp
index 93734f80f..27112a543 100644
--- a/src/saveload/group_sl.cpp
+++ b/src/saveload/group_sl.cpp
@@ -11,6 +11,7 @@
#include "../stdafx.h"
#include "../group.h"
+#include "../company_base.h"
#include "saveload.h"
@@ -23,6 +24,9 @@ static const SaveLoad _group_desc[] = {
SLE_VAR(Group, owner, SLE_UINT8),
SLE_VAR(Group, vehicle_type, SLE_UINT8),
SLE_VAR(Group, replace_protection, SLE_BOOL),
+ SLE_CONDVAR(Group, livery.in_use, SLE_UINT8, 205, SL_MAX_VERSION),
+ SLE_CONDVAR(Group, livery.colour1, SLE_UINT8, 205, SL_MAX_VERSION),
+ SLE_CONDVAR(Group, livery.colour2, SLE_UINT8, 205, SL_MAX_VERSION),
SLE_CONDVAR(Group, parent, SLE_UINT16, 189, SL_MAX_VERSION),
SLE_END()
};
@@ -47,6 +51,12 @@ static void Load_GRPS()
SlObject(g, _group_desc);
if (IsSavegameVersionBefore(189)) g->parent = INVALID_GROUP;
+
+ if (IsSavegameVersionBefore(205)) {
+ const Company *c = Company::Get(g->owner);
+ g->livery.colour1 = c->livery[LS_DEFAULT].colour1;
+ g->livery.colour2 = c->livery[LS_DEFAULT].colour2;
+ }
}
}
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 348ba93ba..e75e40d74 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -274,8 +274,9 @@
* 202 #6867 Increase industry cargo slots to 16 in, 16 out
* 203 #7072 Add path cache for ships
* 204 #7065 Add extra rotation stages for ships.
+ * 205 #7108 Livery storage change and group liveries.
*/
-extern const uint16 SAVEGAME_VERSION = 204; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 205; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading
FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop.