Advanced Strategic Command
loaders.h
Go to the documentation of this file.
1 
8 /*
9  This file is part of Advanced Strategic Command; http://www.asc-hq.de
10  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; see the file COPYING. If not, write to the
24  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
25  Boston, MA 02111-1307 USA
26 */
27 
28 #ifndef loadersH
29 #define loadersH
30 
31 #include <sigc++/sigc++.h>
32 
33 #include "loki/Functor.h"
34 
35 #include "ascstring.h"
36 #include "sgstream.h"
37 #include "messages.h"
38 #include "graphics/blitter.h"
39 
40 
41 
42 extern const int fileterminator;
43 
44 extern const char* savegameextension;
45 extern const char* mapextension;
46 extern const char* tournamentextension;
47 
48 
49 
51 extern void savemap( const ASCString& name, GameMap* gamemap );
52 
54 extern void savegame( const ASCString& name, GameMap* gamemap);
55 
56 
57 typedef Loki::Functor<GameMap*, LOKI_TYPELIST_1(const ASCString&) > MapLoadingFunction;
58 extern GameMap* mapLoadingExceptionChecker( const ASCString& filename, MapLoadingFunction loader );
59 
60 
61 
62 extern GameMap* loadreplay( MemoryStreamStorage* streambuf );
63 
65 extern void savereplay( GameMap* gamemap, int num );
66 
67 
69  public:
72 
73  static sigc::signal<void,GameMap*> mapLoaded;
74 
75  void readoldevents ( void );
76 
77 
78  void writedissections ( void );
79  void readdissections ( void );
80 
81  void readLegacyNetwork ( void );
82 
83  virtual void initmap ( void ) = 0;
84 
85  void writemap ( void );
86  void readmap ( void );
87 
88  void writefields ( void );
89  void readfields ( void );
90 
91  void writemessages ( void );
93  void readmessages ( void );
95 
96  void chainitems ( GameMap* actmap );
97  void setplayerexistencies ( void );
98  virtual ~tspfldloaders();
99  tspfldloaders ( void );
100 };
101 
102 
103 
104 class tmaploaders : public tspfldloaders {
105  void initmap ( void );
106  GameMap* _loadmap ( const ASCString& name );
107  public:
108  static GameMap* loadmap ( const ASCString& name );
109 
110 
111  int savemap ( const ASCString& name, GameMap* gamemap );
112  tmaploaders (void ) {};
113 };
114 
115 
116 
117 class tgameloaders : public tspfldloaders {
118  protected:
119  void initmap ( void );
120  void readAI( );
121  void writeAI( );
122 };
123 
125  public:
126  GameMap* loadnwgame ( tnstream* strm );
127  int savenwgame ( tnstream* strm, const GameMap* gamemap );
128 };
129 
131  public:
135  int turn;
137 };
138 
140  public:
141  GameMap* loadgame ( tnstream* strm );
142  static GameMap* loadGameFromFile ( const ASCString& name );
144  void savegame ( tnstream* strm, GameMap* gamemap, bool writeReplays = true );
145  void savegame ( GameMap* gamemap, const ASCString& name );
146 };
147 
148 
150 extern bool validatemapfile ( const ASCString& filename );
151 
153 extern bool validatesavfile ( const ASCString& filename );
154 
156 extern bool validateemlfile ( const ASCString& filename );
157 
158 
163 };
164 
165 extern MapConinuationInfo findNextCampaignMap( int id = -1 );
166 
167 extern bool suppressMapTriggerExecution;
168 
172 
173 
174 #endif
bool validateemlfile(const ASCString &filename)
checks, whether filename is a valid email game
Definition: loaders.cpp:1615
void savemap(const ASCString &name, GameMap *gamemap)
saves the map located in actmap to the map file name
Definition: loaders.cpp:1428
void writemessages(void)
Definition: loaders.cpp:190
An in-memory storage of streamed data.
Definition: basestrm.h:172
void chainitems(GameMap *actmap)
Definition: loaders.cpp:843
GameMap * eventLocalizationMap
used by setLocalizedEventMessage to get the map being loaded It's not nice having a global variable f...
Definition: loaders.cpp:1013
bool validatemapfile(const ASCString &filename)
checks, whether filename is a valid map file
Definition: loaders.cpp:1579
void initmap(void)
Definition: loaders.cpp:381
Classes and Functions managing the in-game mails and the journal.
void writemessagelist(MessagePntrContainer &lst)
Definition: loaders.cpp:236
void savegame(const ASCString &name, GameMap *gamemap)
saves the game located in actmap to the savegame file name
Definition: loaders.cpp:1456
const char * tournamentextension
Definition: loaders.cpp:80
static GameMap * loadGameFromFile(const ASCString &name)
Definition: loaders.cpp:1135
const char * savegameextension
Definition: loaders.cpp:78
void readfields(void)
Definition: loaders.cpp:610
GameMap * loadnwgame(tnstream *strm)
Definition: loaders.cpp:1276
Loki::Functor< GameMap *, LOKI_TYPELIST_1(const ASCString &) > MapLoadingFunction
Definition: loaders.h:57
GameMap * mapLoadingExceptionChecker(const ASCString &filename, MapLoadingFunction loader)
Definition: loaders.cpp:1539
tspfldloaders(void)
Definition: loaders.cpp:863
The interface for all kinds of IO stream.
void readoldevents(void)
Definition: loaders.cpp:335
static GameMap * loadmap(const ASCString &name)
Definition: loaders.cpp:1039
tmaploaders(void)
Definition: loaders.h:112
virtual ~tspfldloaders()
Definition: loaders.cpp:869
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
tnstream * stream
Definition: loaders.h:70
void setplayerexistencies(void)
GameMap * spfld
Definition: loaders.h:71
int savemap(const ASCString &name, GameMap *gamemap)
Definition: loaders.cpp:892
void readdissections(void)
Definition: loaders.cpp:126
void savegame(tnstream *strm, GameMap *gamemap, bool writeReplays=true)
Definition: loaders.cpp:1060
bool validatesavfile(const ASCString &filename)
checks, whether filename is a valid savegame
Definition: loaders.cpp:1648
GameMap * loadgame(tnstream *strm)
Definition: loaders.cpp:1142
ASCString playername
Definition: loaders.h:134
ASCString maptitle
Definition: loaders.h:132
The IO for many basic classes and structurs of ACS.
GameFileInformation loadMapimageFromFile(const ASCString &filename)
Definition: loaders.cpp:1109
ASCString codeword
Definition: loaders.h:161
GameMap * loadreplay(MemoryStreamStorage *streambuf)
Definition: loaders.cpp:1495
list< Message * > MessagePntrContainer
Definition: messages.h:74
int savenwgame(tnstream *strm, const GameMap *gamemap)
Definition: loaders.cpp:1235
void savereplay(GameMap *gamemap, int num)
writes all replay relevant map information of player num to the replay variable of actmap ...
Definition: loaders.cpp:1470
void writeAI()
Definition: loaders.cpp:396
void readmap(void)
Definition: loaders.cpp:387
virtual void initmap(void)=0
void readAI()
Definition: loaders.cpp:414
const char * mapextension
Definition: loaders.cpp:79
ASCString filename
Definition: loaders.h:162
const int fileterminator
Definition: loaders.cpp:75
void writedissections(void)
Definition: loaders.cpp:158
bool suppressMapTriggerExecution
Definition: loaders.cpp:82
GameMap * actmap
Definition: spfst.cpp:64
void readmessages(void)
Definition: loaders.cpp:272
void writemap(void)
Definition: loaders.cpp:365
static sigc::signal< void, GameMap * > mapLoaded
Definition: loaders.h:73
void writefields(void)
Definition: loaders.cpp:455
MapConinuationInfo findNextCampaignMap(int id=-1)
Definition: loaders.cpp:1682
void readLegacyNetwork(void)
Definition: loaders.cpp:440
ASCString title
Definition: loaders.h:160
void readmessagelist(MessagePntrContainer &lst)
Definition: loaders.cpp:253
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182