Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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 "newfont.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 "ai/ai.h"

Include dependency graph for loaders.cpp:

Go to the source code of this file.

Defines

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

Functions

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

Variables

const int actsavegameversion = 0xff61
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"
const int messageVersion = 0xabcdf1
const int messageMinVersion = 0xabcdef
const int objectstreamversion = 3


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.


Define Documentation

#define csm_b3   128
 

Definition at line 98 of file loaders.cpp.

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

#define csm_b4   128
 

Definition at line 107 of file loaders.cpp.

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

#define csm_building   8
 

Definition at line 95 of file loaders.cpp.

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

#define csm_cnt2   64
 

Definition at line 97 of file loaders.cpp.

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

#define csm_connection   2
 

Definition at line 110 of file loaders.cpp.

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

#define csm_direction   2
 

Definition at line 93 of file loaders.cpp.

Referenced by tspfldloaders::readfields().

#define csm_fuel   2
 

Definition at line 101 of file loaders.cpp.

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

#define csm_height   32
 

Definition at line 96 of file loaders.cpp.

#define csm_material   1
 

Definition at line 100 of file loaders.cpp.

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

#define csm_newobject   4
 

Definition at line 111 of file loaders.cpp.

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

#define csm_object   64
 

Definition at line 106 of file loaders.cpp.

Referenced by tspfldloaders::readfields().

#define csm_resources   1
 

Definition at line 109 of file loaders.cpp.

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

#define csm_typid32   1
 

Definition at line 92 of file loaders.cpp.

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

#define csm_vehicle   4
 

Definition at line 94 of file loaders.cpp.

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

#define csm_visible   4
 

Definition at line 102 of file loaders.cpp.

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

#define csm_weather   16
 

Definition at line 104 of file loaders.cpp.

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


Function Documentation

void checkForUniqueUnitIDs GameMap gamemap  ) 
 

Definition at line 348 of file loaders.cpp.

References GameMap::getNewNetworkID(), GameMap::getPlayer(), ASCString::toString(), and warning().

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

MapConinuationInfo findNextCampaignMap int  id  ) 
 

Definition at line 1553 of file loaders.cpp.

References actmapversion, GameMap::Campaign::avail, CharBuf::buf, GameMap::campaign, MapConinuationInfo::codeword, GameMap::codeWord, MapConinuationInfo::filename, fileterminator, tfindfile::getnextname(), GameMap::Campaign::id, mapextension, GameMap::maptitle, minmapversion, tnstream::reading, tnstream::readInt(), tspfldloaders::readmap(), tnstream::readpchar(), tnstream::readWord(), tspfldloaders::spfld, tspfldloaders::stream, and MapConinuationInfo::title.

Referenced by NextCampaignMap::search().

GameMap* loadreplay tmemorystreambuf streambuf  ) 
 

Definition at line 1367 of file loaders.cpp.

References actreplayversion, displaymessage(), ASCmsgException::getMessage(), tsavegameloaders::loadgame(), minreplayversion, tnstream::reading, and tnstream::readInt().

Referenced by trunreplay::run().

GameMap* mapLoadingExceptionChecker const ASCString filename,
MapLoadingFunction  loader
 

Definition at line 1412 of file loaders.cpp.

References displaymessage(), and ASCmsgException::getMessage().

Referenced by StartMultiplayerGame::Apply(), continuenetworkgame(), NextCampaignMap::getMap(), k_loadmap(), loadGame(), loadmap(), mapeditorMainThread(), networksupervisor(), and StartMultiplayerGame::start().

void readLegacyNetworkData tnstream stream  ) 
 

Definition at line 66 of file legacynetworkloaders.cpp.

References tnetwork::computer, tnetwork::computernum, tnetwork::tglobalparams::dummy, tnetwork::tglobalparams::enablesaveloadofgames, tnetworkcomputer::existent, tnetwork::globalparams, tnetworkcomputer::name, tnetwork::player, tnstream::readChar(), tnstream::readInt(), tnstream::readString(), tnetwork::tglobalparams::reaskpasswords, tnetworkcomputer::receive, tnetworkcomputer::send, and tnetwork::turn.

Referenced by tspfldloaders::readLegacyNetwork().

void savegame const ASCString name  ) 
 

saves the game located in actmap to the savegame file name

Definition at line 1326 of file loaders.cpp.

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

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

void savemap const char *  name,
GameMap gamemap
 

saves the map located in actmap to the map file name

Definition at line 1304 of file loaders.cpp.

References displaymessage(), and tmaploaders::savemap().

Referenced by editpolygon(), and k_savemap().

void savereplay GameMap gamemap,
int  num
 

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

Definition at line 1341 of file loaders.cpp.

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

Referenced by initReplayLogging().

void seteventtriggers GameMap actmap  ) 
 

Definition at line 78 of file loaders.cpp.

References GameMap::events, GameMap::player, and Player::queuedEvents.

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

bool validateemlfile const ASCString filename  ) 
 

checks, whether filename is a valid email game

Definition at line 1486 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 1450 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 1519 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 920 of file loaders.cpp.

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


Variable Documentation

const int actmapversion = 0xfe51
 

Definition at line 61 of file loaders.cpp.

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

const int actnetworkversion = 0x0032
 

Definition at line 63 of file loaders.cpp.

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

const int actreplayversion = 0x0003
 

Definition at line 65 of file loaders.cpp.

Referenced by loadreplay(), and savereplay().

const int actsavegameversion = 0xff61
 

Definition at line 59 of file loaders.cpp.

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

const int fileterminator = 0xa01a
 

Definition at line 69 of file loaders.cpp.

Referenced by findNextCampaignMap(), tsavegameloaders::loadgame(), tnetworkloaders::loadnwgame(), tsavegameloaders::savegame(), tmaploaders::savemap(), tnetworkloaders::savenwgame(), validateemlfile(), validatemapfile(), and validatesavfile().

const char* mapextension = "*.map"
 

Definition at line 73 of file loaders.cpp.

Referenced by findNextCampaignMap(), k_loadmap(), k_savemap(), loadStartupMap(), mapeditorMainThread(), and StartMultiplayerGame::userHandler().

const int messageMinVersion = 0xabcdef
 

Definition at line 186 of file loaders.cpp.

Referenced by tspfldloaders::readmessages().

const int messageVersion = 0xabcdf1
 

Definition at line 185 of file loaders.cpp.

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

const int minmapversion = 0xfe24
 

Definition at line 62 of file loaders.cpp.

Referenced by findNextCampaignMap(), and validatemapfile().

const int minnetworkversion = 0x0004
 

Definition at line 64 of file loaders.cpp.

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

const int minreplayversion = 0x0001
 

Definition at line 66 of file loaders.cpp.

Referenced by loadreplay().

const int minsavegameversion = 0xff31
 

Definition at line 60 of file loaders.cpp.

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

const int objectstreamversion = 3
 

Definition at line 451 of file loaders.cpp.

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

const char* savegameextension = "*.sav"
 

Definition at line 72 of file loaders.cpp.

Referenced by GuiFunctions::EndTurn::execute(), NextMap::execute(), loadGame(), loadStartupMap(), and saveGame().

const char* tournamentextension = ".ascpbm"
 

Definition at line 74 of file loaders.cpp.

Referenced by FileTransfer::constructFileName(), continuenetworkgame(), loadStartupMap(), networksupervisor(), and FileTransfer::send().


Generated on Tue Jun 24 01:48:33 2008 for Advanced Strategic Command by  doxygen 1.4.2