00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef loadersH
00029 #define loadersH
00030
00031 #include <sigc++/sigc++.h>
00032
00033 #include "loki/Functor.h"
00034
00035 #include "ascstring.h"
00036 #include "sgstream.h"
00037 #include "messages.h"
00038 #include "graphics/blitter.h"
00039
00040
00041
00042 extern const int fileterminator;
00043
00044 extern const char* savegameextension;
00045 extern const char* mapextension;
00046 extern const char* tournamentextension;
00047
00048
00049
00051 extern void savemap( const ASCString& name, GameMap* gamemap );
00052
00054 extern void savegame( const ASCString& name, GameMap* gamemap);
00055
00056
00057 typedef Loki::Functor<GameMap*, LOKI_TYPELIST_1(const ASCString&) > MapLoadingFunction;
00058 extern GameMap* mapLoadingExceptionChecker( const ASCString& filename, MapLoadingFunction loader );
00059
00060
00061
00062 extern GameMap* loadreplay( MemoryStreamStorage* streambuf );
00063
00065 extern void savereplay( GameMap* gamemap, int num );
00066
00067
00068 class tspfldloaders {
00069 public:
00070 tnstream* stream;
00071 GameMap* spfld;
00072
00073 static SigC::Signal1<void,GameMap*> mapLoaded;
00074
00075 void readoldevents ( void );
00076
00077
00078 void writedissections ( void );
00079 void readdissections ( void );
00080
00081 void readLegacyNetwork ( void );
00082
00083 virtual void initmap ( void ) = 0;
00084
00085 void writemap ( void );
00086 void readmap ( void );
00087
00088 void writefields ( void );
00089 void readfields ( void );
00090
00091 void writemessages ( void );
00092 void writemessagelist( MessagePntrContainer& lst );
00093 void readmessages ( void );
00094 void readmessagelist( MessagePntrContainer& lst );
00095
00096 void chainitems ( GameMap* actmap );
00097 void setplayerexistencies ( void );
00098 virtual ~tspfldloaders();
00099 tspfldloaders ( void );
00100 };
00101
00102
00103
00104 class tmaploaders : public tspfldloaders {
00105 void initmap ( void );
00106 GameMap* _loadmap ( const ASCString& name );
00107 public:
00108 static GameMap* loadmap ( const ASCString& name );
00109
00110
00111 int savemap ( const ASCString& name, GameMap* gamemap );
00112 tmaploaders (void ) {};
00113 };
00114
00115
00116
00117 class tgameloaders : public tspfldloaders {
00118 protected:
00119 void initmap ( void );
00120 void readAI( );
00121 void writeAI( );
00122 };
00123
00124 class tnetworkloaders : public tgameloaders {
00125 public:
00126 GameMap* loadnwgame ( tnstream* strm );
00127 int savenwgame ( tnstream* strm, const GameMap* gamemap );
00128 };
00129
00130 class GameFileInformation {
00131 public:
00132 GameFileInformation() : turn(0) {};
00133 ASCString maptitle;
00134 ASCString playername;
00135 int turn;
00136 Surface image;
00137 };
00138
00139 class tsavegameloaders : public tgameloaders {
00140 public:
00141 GameMap* loadgame ( tnstream* strm );
00142 static GameMap* loadGameFromFile ( const ASCString& name );
00143 GameFileInformation loadMapimageFromFile( const ASCString& filename );
00144 void savegame ( tnstream* strm, GameMap* gamemap, bool writeReplays = true );
00145 void savegame ( GameMap* gamemap, const ASCString& name );
00146 };
00147
00148
00150 extern bool validatemapfile ( const ASCString& filename );
00151
00153 extern bool validatesavfile ( const ASCString& filename );
00154
00156 extern bool validateemlfile ( const ASCString& filename );
00157
00158
00159 struct MapConinuationInfo {
00160 ASCString title;
00161 ASCString codeword;
00162 ASCString filename;
00163 };
00164
00165 extern MapConinuationInfo findNextCampaignMap( int id = -1 );
00166
00167 extern bool suppressMapTriggerExecution;
00168
00171 extern GameMap* eventLocalizationMap;
00172
00173
00174 #endif