diff src/saveload/afterload.cpp @ 15669:1cb744e35ef3 draft

(svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
author rubidium <rubidium@openttd.org>
date Tue, 03 Aug 2010 08:09:45 +0000 (2010-08-03)
parents c62577640878
children 92bc4ee3d682
line wrap: on
line diff
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1792,13 +1792,25 @@
 			if (IsTileType(t, MP_UNMOVABLE) && HasBit(_m[t].m5, 7)) {
 				/* Move size and part identification of HQ out of the m5 attribute,
 				 * on new locations */
-				uint8 old_m5 = _m[t].m5;
+				_m[t].m3 = GB(_m[t].m5, 0, 5);
 				_m[t].m5 = UNMOVABLE_HQ;
-				SetCompanyHQSize(t, GB(old_m5, 2, 3));
-				SetCompanyHQSection(t, GB(old_m5, 0, 2));
 			}
 		}
 	}
+	if (CheckSavegameVersion(144)) {
+		for (TileIndex t = 0; t < map_size; t++) {
+			if (!IsTileType(t, MP_UNMOVABLE)) continue;
+
+			/* Reordering/generalisation of the unmovable bits. */
+			UnmovableType type = GetUnmovableType(t);
+			SetCompanyHQSize(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 2, 3) : 0);
+			SetCompanyHQSection(t, type == UNMOVABLE_HQ ? GB(_m[t].m3, 1, 1) << 4 | GB(_m[t].m3, 0, 1) : 0);
+
+			/* Make sure those bits are clear as well! */
+			_m[t].m4 = 0;
+			_me[t].m7 = 0;
+		}
+	}
 
 	if (CheckSavegameVersion(113)) {
 		/* allow_town_roads is added, set it if town_layout wasn't TL_NO_ROADS */