loaders.h

Go to the documentation of this file.
00001 
00008 /*
00009     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00010     Copyright (C) 1994-2010  Martin Bickel  and  Marc Schellenberger
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; see the file COPYING. If not, write to the
00024     Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00025     Boston, MA  02111-1307  USA
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

Generated on Mon May 21 01:26:34 2012 for Advanced Strategic Command by  doxygen 1.5.1