← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1786597-test-suite into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1786597-test-suite into lp:widelands.

Commit message:
Added savegame compatibility for carriers

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1786597 in widelands: "Congestion branch broke the test suite"
  https://bugs.launchpad.net/widelands/+bug/1786597

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1786597-test-suite/+merge/352928

This should unbreak the test suite
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1786597-test-suite into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/carrier.cc'
--- src/logic/map_objects/tribes/carrier.cc	2018-08-09 11:11:15 +0000
+++ src/logic/map_objects/tribes/carrier.cc	2018-08-11 11:58:45 +0000
@@ -421,7 +421,9 @@
 
 ==============================
 */
-
+// Increasing the version number will break the test suite,
+// so we need to provide savegame compatibility here.
+// Compatibility is not needed for map loading.
 constexpr uint8_t kCurrentPacketVersion = 2;
 
 Carrier::Loader::Loader() {
@@ -433,9 +435,14 @@
 	try {
 
 		uint8_t packet_version = fr.unsigned_8();
-		if (packet_version == kCurrentPacketVersion) {
+		if (packet_version >= 1 && packet_version <= kCurrentPacketVersion) {
 			Carrier& carrier = get<Carrier>();
 			carrier.operation_ = fr.signed_32();
+			if (packet_version == 1) {
+				if (carrier.operation_ == NO_OPERATION) {
+					carrier.operation_ == INIT;
+				}
+			}
 		} else {
 			throw UnhandledVersionError("Carrier", packet_version, kCurrentPacketVersion);
 		}


Follow ups