Functions | Variables

# map_sl.cpp File Reference

Code handling saving and loading of map. More...

`#include "../stdafx.h"`
`#include "../map_func.h"`
`#include "../core/bitmath_func.hpp"`
`#include "../fios.h"`
`#include "../tile_map.h"`
`#include "saveload.h"`

Go to the source code of this file.

## Functions
static void | Save_MAPS ()
static void | Load_MAPS ()
static void | Check_MAPS ()
static void | Load_MAPT ()
static void | Save_MAPT ()
static void | Load_MAP1 ()
static void | Save_MAP1 ()
static void | Load_MAP2 ()
static void | Save_MAP2 ()
static void | Load_MAP3 ()
static void | Save_MAP3 ()
static void | Load_MAP4 ()
static void | Save_MAP4 ()
static void | Load_MAP5 ()
static void | Save_MAP5 ()
static void | Load_MAP6 ()
static void | Save_MAP6 ()
static void | Load_MAP7 ()
static void | Save_MAP7 ()
static void | Load_MAPH ()
| The general idea behind loading and saving MAPH: =============================================== The _map_heightdata array is not NULL if and only if AllowMoreHeightlevels(), defined in tile_map.h is true.
static void | Save_MAPH ()
## Variables
static uint32 | _map_dim_x
static uint32 | _map_dim_y
static const SaveLoadGlobVarList | _map_dimensions []
static const uint | MAP_SL_BUF_SIZE = 4096
const ChunkHandler | _map_chunk_handlers []

## Detailed Description

Code handling saving and loading of map.

Definition in file map_sl.cpp.

## Function Documentation

static void Load_MAPH | ( |  | ) | `[static]`

The general idea behind loading and saving MAPH: =============================================== The _map_heightdata array is not NULL if and only if AllowMoreHeightlevels(), defined in tile_map.h is true.

Saving: ====== So if AllowMoreHeightlevels is true, we have to save it and do so. However, if AllowMoreHeightlevels is false, we just save a junk named MAPH with length 0.

Loading: ======= If we load an old savegame without MAPH, then Load_MAPH is not even called. So, in AfterLoadGame, we set _map_heightdata to NULL and allow_more_heightlevels to false. (The player may turn on this setting afterwards in game.)

If, however, we load a new savegame (where MAPH was already introduced), SlGetFieldLength() was already set to the length of the chunk by LoadChunk. So, if AllowMoreHeightLevels is false, we get SlGetFieldLength() == 0 here and set _map_heightdata to NULL accordingly. Otherwise, we just load _map_heightdata from the chunk..

For background information about how and where _map_heightdata is constructed and freed see comment of AllocateMap() in map_func.h.

See also:
  AllocateMap() in map_func.h.

Definition at line 281 of file map_sl.cpp.

References _map_heightdata, MapSize(), SlArray(), and SlGetFieldLength().

## Variable Documentation

const ChunkHandler _map_chunk_handlers[]

Initial value:

     {
      { 'MAPS', Save_MAPS, Load_MAPS, NULL, Check_MAPS, CH_RIFF },
      { 'MAPT', Save_MAPT, Load_MAPT, NULL, NULL,       CH_RIFF },
      { 'MAPO', Save_MAP1, Load_MAP1, NULL, NULL,       CH_RIFF },
      { 'MAP2', Save_MAP2, Load_MAP2, NULL, NULL,       CH_RIFF },
      { 'M3LO', Save_MAP3, Load_MAP3, NULL, NULL,       CH_RIFF },
      { '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 },
      { 'MAPH', Save_MAPH, Load_MAPH, NULL, NULL,       CH_RIFF | CH_LAST },
    }

const SaveLoadGlobVarList _map_dimensions[]`[static]`

Initial value:

     {
      SLEG_CONDVAR(_map_dim_x, SLE_UINT32, 6, SL_MAX_VERSION),
      SLEG_CONDVAR(_map_dim_y, SLE_UINT32, 6, SL_MAX_VERSION),

    }

Definition at line 23 of file map_sl.cpp.