diff options
author | Peter Nelson <peter1138@openttd.org> | 2018-05-23 11:48:01 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2018-07-26 13:27:40 +0100 |
commit | 65548c37a840ca48378180df1bf8857b087f7329 (patch) | |
tree | a50d70c04fd9d7415426fa60d8439fed80f6655a /src | |
parent | 8090580f771b40c727f9a66e8bc43d443fbe5fbf (diff) | |
download | openttd-65548c37a840ca48378180df1bf8857b087f7329.tar.xz |
Change: Extend map array by 2 bytes with a uint16.
Diffstat (limited to 'src')
-rw-r--r-- | src/map_type.h | 5 | ||||
-rw-r--r-- | src/saveload/map_sl.cpp | 27 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/map_type.h b/src/map_type.h index 620885e5d..7af391b46 100644 --- a/src/map_type.h +++ b/src/map_type.h @@ -33,8 +33,9 @@ assert_compile(sizeof(Tile) == 8); * Look at docs/landscape.html for the exact meaning of the members. */ struct TileExtended { - byte m6; ///< General purpose - byte m7; ///< Primarily used for newgrf support + byte m6; ///< General purpose + byte m7; ///< Primarily used for newgrf support + uint16 m8; ///< General purpose }; /** diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp index 86a185ca4..693ddb7ce 100644 --- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -272,6 +272,30 @@ static void Save_MAP7() } } +static void Load_MAP8() +{ + SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf; + TileIndex size = MapSize(); + + for (TileIndex i = 0; i != size;) { + SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT16); + for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _me[i++].m8 = buf[j]; + } +} + +static void Save_MAP8() +{ + SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf; + TileIndex size = MapSize(); + + SlSetLength(size * sizeof(uint16)); + for (TileIndex i = 0; i != size;) { + for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m8; + SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT16); + } +} + + extern const ChunkHandler _map_chunk_handlers[] = { { 'MAPS', Save_MAPS, Load_MAPS, NULL, Check_MAPS, CH_RIFF }, { 'MAPT', Save_MAPT, Load_MAPT, NULL, NULL, CH_RIFF }, @@ -282,5 +306,6 @@ extern const ChunkHandler _map_chunk_handlers[] = { { 'M3HI', Save_MAP4, Load_MAP4, NULL, NULL, CH_RIFF }, { 'MAP5', Save_MAP5, Load_MAP5, NULL, NULL, CH_RIFF }, { 'MAPE', Save_MAP6, Load_MAP6, NULL, NULL, CH_RIFF }, - { 'MAP7', Save_MAP7, Load_MAP7, NULL, NULL, CH_RIFF | CH_LAST }, + { 'MAP7', Save_MAP7, Load_MAP7, NULL, NULL, CH_RIFF }, + { 'MAP8', Save_MAP8, Load_MAP8, NULL, NULL, CH_RIFF | CH_LAST }, }; |