Advanced Strategic Command
Macros | Functions | Variables
loaders.cpp File Reference

procedure for loading and writing savegames, maps etc. More...

#include <algorithm>
#include <cstring>
#include <stdlib.h>
#include <stdio.h>
#include "typen.h"
#include "misc.h"
#include "buildingtype.h"
#include "vehicletype.h"
#include "spfst.h"
#include "loaders.h"
#include "dlg_box.h"
#include "dialog.h"
#include "sgstream.h"
#include "attack.h"
#include "errors.h"
#include "strtmesg.h"
#include "textfileparser.h"
#include "itemrepository.h"
#include "prehistoricevents.h"
#include "gamemap.h"
#include "gameeventsystem.h"
#include "graphicset.h"
#include "gameoptions.h"
#include "lua/luarunner.h"
#include "lua/luastate.h"
#include "packagemanager.h"
#include "i18n.h"
#include "mapimageexport.h"
#include "ai/ai.h"
Include dependency graph for loaders.cpp:

Go to the source code of this file.

Macros

#define csm_typid32   1 /* b1 */
 
#define csm_direction   2 /* b1 */
 
#define csm_vehicle   4 /* b1 */
 
#define csm_building   8 /* b1 */
 
#define csm_height   32 /* b1 */
 
#define csm_cnt2   64 /* b1 */
 
#define csm_b3   128 /* b1 */
 
#define csm_material   1 /* b3 */
 
#define csm_fuel   2 /* b3 */
 
#define csm_visible   4 /* b3 */
 
#define csm_weather   16 /* b3 */
 
#define csm_object   64 /* b3 */
 
#define csm_b4   128 /* b3 */
 
#define csm_resources   1 /* b4 */
 
#define csm_connection   2
 
#define csm_newobject   4
 

Functions

void seteventtriggers (GameMap *actmap)
 
void checkForUniqueUnitIDs (GameMap *gamemap)
 
void readLegacyNetworkData (tnstream &stream)
 
void weatherSystemRequired ()
 
void loadLocalizedMessageFile (GameMap *map, const ASCString &filename)
 
void loadLocalizedMessages (GameMap *map, const ASCString &name)
 
ASCString getLuaQuote (bool open, int n)
 
ASCString luaQuote (const ASCString &text)
 
void writeMessageFile (GameMap *gamemap, tnstream &stream)
 
void savemap (const ASCString &name, GameMap *gamemap)
 saves the map located in actmap to the map file name More...
 
void savegame (const ASCString &name, GameMap *gamemap)
 saves the game located in actmap to the savegame file name More...
 
void savereplay (GameMap *gamemap, int num)
 writes all replay relevant map information of player num to the replay variable of actmap More...
 
GameMaploadreplay (MemoryStreamStorage *streambuf)
 
GameMapmapLoadingExceptionChecker (const ASCString &filename, MapLoadingFunction loader)
 
bool validatemapfile (const ASCString &filename)
 checks, whether filename is a valid map file More...
 
bool validateemlfile (const ASCString &filename)
 checks, whether filename is a valid email game More...
 
bool validatesavfile (const ASCString &filename)
 checks, whether filename is a valid savegame More...
 
MapConinuationInfo findNextCampaignMap (int id)
 

Variables

const int actsavegameversion = 0xff63
 
const int minsavegameversion = 0xff31
 
const int actmapversion = 0xfe51
 
const int minmapversion = 0xfe24
 
const int actnetworkversion = 0x0032
 
const int minnetworkversion = 0x0004
 
const int actreplayversion = 0x0003
 
const int minreplayversion = 0x0001
 
const int fileterminator = 0xa01a
 
const char * savegameextension = "*.sav"
 
const char * mapextension = "*.map"
 
const char * tournamentextension = ".ascpbm"
 
bool suppressMapTriggerExecution = true
 
const int messageVersion = 0xabcdf1
 
const int messageMinVersion = 0xabcdef
 
const int objectstreamversion = 4
 
GameMapeventLocalizationMap = NULL
 used by setLocalizedEventMessage to get the map being loaded It's not nice having a global variable for that, but we need to persist the data for the Lua callbacks More...
 

Detailed Description

procedure for loading and writing savegames, maps etc.

IO for basic types like vehicletype, buildingtype etc which are also used by the small editors are found in sgstream

Definition in file loaders.cpp.

Macro Definition Documentation

#define csm_b3   128 /* b1 */

Definition at line 102 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_b4   128 /* b3 */

Definition at line 109 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_building   8 /* b1 */

Definition at line 99 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_cnt2   64 /* b1 */

Definition at line 101 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_connection   2

Definition at line 112 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_direction   2 /* b1 */

Definition at line 97 of file loaders.cpp.

Referenced by tspfldloaders::readfields().

#define csm_fuel   2 /* b3 */

Definition at line 105 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_height   32 /* b1 */

Definition at line 100 of file loaders.cpp.

#define csm_material   1 /* b3 */

Definition at line 104 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_newobject   4

Definition at line 113 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_object   64 /* b3 */

Definition at line 108 of file loaders.cpp.

Referenced by tspfldloaders::readfields().

#define csm_resources   1 /* b4 */

Definition at line 111 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_typid32   1 /* b1 */

Definition at line 96 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_vehicle   4 /* b1 */

Definition at line 98 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_visible   4 /* b3 */

Definition at line 106 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

#define csm_weather   16 /* b3 */

Definition at line 107 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

Function Documentation

void checkForUniqueUnitIDs ( GameMap gamemap)
MapConinuationInfo findNextCampaignMap ( int  id)
ASCString getLuaQuote ( bool  open,
int  n 
)

Definition at line 1383 of file loaders.cpp.

Referenced by luaQuote().

void loadLocalizedMessageFile ( GameMap map,
const ASCString filename 
)

Definition at line 1017 of file loaders.cpp.

References errorMessage(), LuaRunner::getErrors(), and LuaRunner::runFile().

Referenced by loadLocalizedMessages().

void loadLocalizedMessages ( GameMap map,
const ASCString name 
)

Definition at line 1030 of file loaders.cpp.

References exist(), Locale::getLocalizedFile(), and loadLocalizedMessageFile().

Referenced by tmaploaders::loadmap().

GameMap* loadreplay ( MemoryStreamStorage streambuf)
ASCString luaQuote ( const ASCString text)

Definition at line 1391 of file loaders.cpp.

References getLuaQuote().

Referenced by writeMessageFile().

GameMap* mapLoadingExceptionChecker ( const ASCString filename,
MapLoadingFunction  loader 
)
void readLegacyNetworkData ( tnstream stream)
void savegame ( const ASCString name,
GameMap gamemap 
)

saves the game located in actmap to the savegame file name

Definition at line 1456 of file loaders.cpp.

References displaymessage(), tfileerror::getFileName(), and tsavegameloaders::savegame().

Referenced by GuiFunctions::EndTurn::execute(), NextMap::execute(), executeUserAction(), GameMap::read(), and saveGame().

void savemap ( const ASCString name,
GameMap gamemap 
)
void savereplay ( GameMap gamemap,
int  num 
)

writes all replay relevant map information of player num to the replay variable of actmap

Definition at line 1470 of file loaders.cpp.

References actreplayversion, displaymessage(), fatalError(), GameMap::ReplayInfo::map, GameMap::replayinfo, tsavegameloaders::savegame(), tnstream::writeInt(), and tnstream::writing.

Referenced by initReplayLogging().

void seteventtriggers ( GameMap actmap)
bool validateemlfile ( const ASCString filename)

checks, whether filename is a valid email game

Definition at line 1615 of file loaders.cpp.

References actnetworkversion, fileterminator, minnetworkversion, tnstream::reading, tnstream::readInt(), tnstream::readpchar(), and tnstream::readWord().

Referenced by loadStartupMap().

bool validatemapfile ( const ASCString filename)

checks, whether filename is a valid map file

Definition at line 1579 of file loaders.cpp.

References actmapversion, fileterminator, minmapversion, tnstream::reading, tnstream::readInt(), tnstream::readpchar(), and tnstream::readWord().

Referenced by loadStartupMap().

bool validatesavfile ( const ASCString filename)

checks, whether filename is a valid savegame

Definition at line 1648 of file loaders.cpp.

References actsavegameversion, fileterminator, minsavegameversion, tnstream::reading, tnstream::readInt(), tnstream::readpchar(), and tnstream::readWord().

Referenced by loadStartupMap().

void weatherSystemRequired ( )

Definition at line 929 of file loaders.cpp.

Referenced by tsavegameloaders::loadgame(), and tnetworkloaders::loadnwgame().

void writeMessageFile ( GameMap gamemap,
tnstream stream 
)

Variable Documentation

const int actmapversion = 0xfe51

Definition at line 67 of file loaders.cpp.

Referenced by findNextCampaignMap(), tmaploaders::savemap(), and validatemapfile().

const int actnetworkversion = 0x0032
const int actreplayversion = 0x0003

Definition at line 71 of file loaders.cpp.

Referenced by loadreplay(), and savereplay().

const int actsavegameversion = 0xff63
GameMap* eventLocalizationMap = NULL

used by setLocalizedEventMessage to get the map being loaded It's not nice having a global variable for that, but we need to persist the data for the Lua callbacks

Definition at line 1013 of file loaders.cpp.

Referenced by getLoadingMap().

const int fileterminator = 0xa01a
const char* mapextension = "*.map"
const int messageMinVersion = 0xabcdef

Definition at line 188 of file loaders.cpp.

Referenced by tspfldloaders::readmessages().

const int messageVersion = 0xabcdf1

Definition at line 187 of file loaders.cpp.

Referenced by tspfldloaders::readmessages(), and tspfldloaders::writemessages().

const int minmapversion = 0xfe24

Definition at line 68 of file loaders.cpp.

Referenced by findNextCampaignMap(), and validatemapfile().

const int minnetworkversion = 0x0004

Definition at line 70 of file loaders.cpp.

Referenced by tnetworkloaders::loadnwgame(), and validateemlfile().

const int minreplayversion = 0x0001

Definition at line 72 of file loaders.cpp.

Referenced by loadreplay().

const int minsavegameversion = 0xff31

Definition at line 66 of file loaders.cpp.

Referenced by tsavegameloaders::loadgame(), and validatesavfile().

const int objectstreamversion = 4

Definition at line 453 of file loaders.cpp.

Referenced by tspfldloaders::readfields(), and tspfldloaders::writefields().

const char* savegameextension = "*.sav"
bool suppressMapTriggerExecution = true

Definition at line 82 of file loaders.cpp.

Referenced by gamethread(), runTester(), and seteventtriggers().

const char* tournamentextension = ".ascpbm"