#include <playgame.h>
Public Member Functions | |
| PlayGame (void) | |
| ~PlayGame (void) | |
Protected Member Functions | |
| const bool | evMessage (const UserMessage &msg) |
Private Member Functions | |
| void | Load (string filename) |
| void | Save (string filename) |
|
|
Definition at line 3 of file playgame.cpp.
00004 {
00005 MessageServer::Instance().RegisterMessageClient( this , Message::USER );
00006 }
|
|
|
Definition at line 8 of file playgame.cpp.
00009 {
00010 }
|
|
|
Definition at line 12 of file playgame.cpp. References itoa(), Load(), LOAD_SPECIES, Save(), and SAVE_SPECIES.
00013 {
00014 char temp[10];
00015
00016 if( msg.SubMessage() == SAVE_SPECIES )
00017 {
00018 Save( Cfg::GetCfg().GetCfgString( "SavedGames" , itoa( (int)msg.Data() , temp , 10 ) ) + ".spc" );
00019 return true;
00020 }
00021 else if( msg.SubMessage() == LOAD_SPECIES )
00022 {
00023 Load( Cfg::GetCfg().GetCfgString( "SavedGames" , itoa( (int)msg.Data() , temp , 10 ) ) + ".spc" );
00024 return true;
00025 }
00026
00027 return false;
00028 }
|
|
|
Definition at line 30 of file playgame.cpp. References Planet::allPlanets, Parameters::allSpecies, icstring, Planet::IsPlanetName(), SpeciesInfo::IsSpecies(), Colony::ResetAllColonies(), and Parameters::species. Referenced by evMessage().
00031 {
00032 Colony::ResetAllColonies();
00033 Parameters::species.clear();
00034 ifstream inf( filename.c_str() , ios::in );
00035
00036 if( inf.good() && !inf.fail() )
00037 {
00038 char buffer[4096];
00039 inf.getline( buffer , sizeof( buffer ) , '~' );
00040
00041 while( !inf.eof() )
00042 {
00043 icstring ics = buffer;
00044 ics = Rsrc::GetList( ics );
00045 icstring species = Rsrc::GetId( ics );
00046 ics = Rsrc::GetList( ics );
00047 const string ssName = Rsrc::GetStr( ics );
00048 const bool hw = Rsrc::GetInt( ics ) != 0;
00049 vector<Planet *>::iterator pos = find_if( Planet::allPlanets.begin() , Planet::allPlanets.end() , bind2nd( mem_fun( &Planet::IsPlanetName ) , ssName.c_str() ) );
00050 if( pos != Planet::allPlanets.end() )
00051 (*pos)->Colonize( species , hw );
00052
00053 vector<SpeciesInfo *>::iterator pos2 = find_if( Parameters::allSpecies.begin() , Parameters::allSpecies.end() , bind2nd( mem_fun( &SpeciesInfo::IsSpecies ) , species.c_str() ) );
00054 if( pos2 != Parameters::allSpecies.end() )
00055 {
00056 (*pos2)->humidity = (int)(*pos)->GetTotalHumidity();
00057 (*pos2)->atmPressure = (int)(*pos)->GetTotalPressure();
00058 (*pos2)->surfaceTemperature = (int)(*pos)->GetTotalSurfaceTemperature();
00059 Parameters::species.insert( make_pair( (*pos2)->name , (*pos2) ) );
00060 }
00061 inf.getline( buffer , sizeof( buffer ) , '~' );
00062 }
00063 }
00064 }
|
|
|
Definition at line 66 of file playgame.cpp. References Colony::colonies, and Parameters::species. Referenced by evMessage().
00067 {
00068 ofstream of( filename.c_str() , ios::out );
00069
00070 for( map<icstring,SpeciesInfo *>::iterator sp = Parameters::species.begin() ; sp != Parameters::species.end() ; ++sp )
00071 {
00072 of << "(" << sp->first.c_str() << " ";
00073
00074 for( multimap<icstring,Colony *>::iterator it = Colony::colonies.lower_bound( sp->first ) ; it != Colony::colonies.upper_bound( sp->first ) ; ++it )
00075 it->second->Save( of );
00076
00077 of << ")~" << endl;
00078 }
00079 }
|
1.3.3