From 65548c37a840ca48378180df1bf8857b087f7329 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 23 May 2018 11:48:01 +0100 Subject: [PATCH] Change: Extend map array by 2 bytes with a uint16. --- docs/landscape_grid.html | 27 +++++++++++++++++++++++++++ src/map_type.h | 5 +++-- src/saveload/map_sl.cpp | 27 ++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/docs/landscape_grid.html b/docs/landscape_grid.html index d34fe9840c..f5404a5777 100644 --- a/docs/landscape_grid.html +++ b/docs/landscape_grid.html @@ -37,6 +37,7 @@ the array so you can quickly see what is used and what is not.
  • m5 - 8 bits in size, is used for general storage
  • m6 - 8 bits in size, is used for general storage
  • m7 - 8 bits in size, is used for general storage
  • +
  • m8 - 16 bits in size, is used for general storage
  • @@ -52,6 +53,7 @@ the array so you can quickly see what is used and what is not. + @@ -64,6 +66,7 @@ the array so you can quickly see what is used and what is not. + @@ -77,6 +80,7 @@ the array so you can quickly see what is used and what is not. + @@ -89,6 +93,7 @@ the array so you can quickly see what is used and what is not. + @@ -102,6 +107,7 @@ the array so you can quickly see what is used and what is not. + @@ -114,6 +120,7 @@ the array so you can quickly see what is used and what is not. + @@ -126,6 +133,7 @@ the array so you can quickly see what is used and what is not. + @@ -139,6 +147,7 @@ the array so you can quickly see what is used and what is not. + @@ -151,6 +160,7 @@ the array so you can quickly see what is used and what is not. + @@ -163,6 +173,7 @@ the array so you can quickly see what is used and what is not. + @@ -176,6 +187,7 @@ the array so you can quickly see what is used and what is not. + @@ -189,6 +201,7 @@ the array so you can quickly see what is used and what is not. + @@ -202,6 +215,7 @@ the array so you can quickly see what is used and what is not. + @@ -214,6 +228,7 @@ the array so you can quickly see what is used and what is not. + @@ -226,6 +241,7 @@ the array so you can quickly see what is used and what is not. + @@ -238,6 +254,7 @@ the array so you can quickly see what is used and what is not. + @@ -250,6 +267,7 @@ the array so you can quickly see what is used and what is not. + @@ -262,6 +280,7 @@ the array so you can quickly see what is used and what is not. + @@ -274,6 +293,7 @@ the array so you can quickly see what is used and what is not. + @@ -287,6 +307,7 @@ the array so you can quickly see what is used and what is not. + @@ -299,6 +320,7 @@ the array so you can quickly see what is used and what is not. + @@ -311,6 +333,7 @@ the array so you can quickly see what is used and what is not. + @@ -324,6 +347,7 @@ the array so you can quickly see what is used and what is not. + @@ -337,6 +361,7 @@ the array so you can quickly see what is used and what is not. + @@ -349,6 +374,7 @@ the array so you can quickly see what is used and what is not. + @@ -362,6 +388,7 @@ the array so you can quickly see what is used and what is not. +
    m5 (8) m6 (8) m7 (8)m8 (16)
    bits7654 3210 7654 3210 7654 3210FEDC BA98 7654 3210
    0XXXX XXXX OOOX XXOO OOOO OOOOOOOO OOOO OOOO OOOO
    farmland-inherit- OOOX XXOO OOOO OOOO-inherit-
    1XXXX XXXX OOOO OOOO OOOO OOOOOOOO OOOO OOOO OOOO
    rail with signals-inherit- OOOO OOOO OOOO OOOO-inherit-
    depotXXOX OOXX OOOO OOOO OOOO OOOO-inherit-
    2XXXX XXXX OOXX XOOO XXXO XXXXOOOO OOOO OOOO OOOO
    level crossingXXXX OOOX OOXX XOOO XXXX XXXX-inherit-
    road depotXXOO OOXX OOOO OOOO XXXO XXXX-inherit-
    3XXXX XXXX XXXX XXOO XXXX XXXXOOOO OOOO OOOO OOOO
    4XXOO OXXX OOOO OOOO OOOO OOOOOOOO OOOO OOOO OOOO
    5XXXX XXXX OOXX XXOO XXXX XXXXOOOO OOOO OOOO OOOO
    rail waypoint-inherit- -inherit- -inherit--inherit-
    road stop~~~~ ~XXX OOXX XOOO XXOX XXXX-inherit-
    dock~~~~ ~XXX OOXX XOOO OOOO OOOO-inherit-
    airportXXXX XXXX OOXX XOOO XXXX XXXX-inherit-
    buoy~~~~ ~~~~ OOXX XOOO OOOO OOOO-inherit-
    oilrig~~~~ ~~~~ OOXX XOOO OOOO OOOO-inherit-
    6X~~X XXXX OOOO OOOO OOOO OOOOOOOO OOOO OOOO OOOO
    canal, river-inherit- OOOO OOOO OOOO OOOO-inherit-
    shipdepot-inherit- OOOO OOOO OOOO OOOO-inherit-
    8XXXX XXXX OOXX XXOO XXXX XXXXOOOO OOOO OOOO OOOO
    9XOOX XXXX OOOO OOOO XXXX XXXXOOOO OOOO OOOO OOOO
    bridge ramp-inherit- OOXX XXOO -inherit--inherit-
    AXXXX XXXX OOOO OOOO XXXX XXXXOOOO OOOO OOOO OOOO
    diff --git a/src/map_type.h b/src/map_type.h index 620885e5da..7af391b46c 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 86a185ca42..693ddb7ce3 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 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 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 }, };