Commit 76ae09da authored by Gerhard Stein's avatar Gerhard Stein

Loadgame is nearly possible

parent c16e2fe0
......@@ -199,158 +199,43 @@ void CMapPlayGalaxy::operator>>(CSaveGameController &savedGame)
// This is for loading the game
bool CMapPlayGalaxy::operator<<(CSaveGameController &savedGame)
{
/*CSaveGameController &savedGame = *(gpSaveGameController);
// load the number of objects on screen
Uint32 size;
Uint32 x, y;
savedGame.decodeData(size);
// This fills the datablock from CSavedGame object
if(savedGame.load())
std::vector< SmartPointer<CGalaxySpriteObject> >::iterator it = mObjectPtr.begin();
for( ; it != mObjectPtr.end() ; it++ )
{
// Create the special merge effect (Fadeout)
CColorMerge *pColorMergeFX = new CColorMerge(8);
// Prepare for loading the new level map and the players.
cleanup();
// get the episode, level and difficulty
char newLevel;
savedGame.decodeData(m_Episode);
savedGame.decodeData(newLevel);
bool loadmusic = ( m_Level != newLevel || m_Level == 80 );
m_Level = newLevel;
savedGame.decodeData(g_pBehaviorEngine->mDifficulty);
bool dark, checkpointset;
int checkx, checky;
savedGame.decodeData(checkpointset);
savedGame.decodeData(checkx);
savedGame.decodeData(checky);
savedGame.decodeData(dark);
// Load number of Players
savedGame.decodeData(m_NumPlayers);
if(!m_Player.empty())
m_Player.clear();
m_Player.assign(m_NumPlayers, CPlayer(m_Episode, m_Level,
mp_level_completed, m_Object, *mMap.get() ) );
for( size_t i=0 ; i < m_Player.size() ; i++ )
{
m_Player.at(i).m_index = i;
m_Player.at(i).setDatatoZero();
}
CVorticonMapLoader Maploader(mMap, &m_Player);
Maploader.mp_objvect = &m_Object;
m_checkpointset = checkpointset;
Maploader.m_checkpointset = m_checkpointset;
if(!Maploader.load(m_Episode, m_Level, m_Gamepath, loadmusic, false))
return false;
m_checkpoint_x = checkx;
m_checkpoint_y = checky;
m_level_command = START_LEVEL;
std::vector<CPlayer> :: iterator player;
for( player=m_Player.begin() ; player != m_Player.end() ; player++ ) {
int x, y;
player->setupforLevelPlay();
savedGame.decodeData(x);
savedGame.decodeData(y);
player->moveToForce(VectorD2<int>(x,y));
savedGame.decodeData(player->blockedd);
savedGame.decodeData(player->blockedu);
savedGame.decodeData(player->blockedl);
savedGame.decodeData(player->blockedr);
savedGame.decodeData(player->inventory);
player->pdie = 0;
}
// load the number of objects on screen
Uint32 size;
savedGame.decodeData(size);
for( Uint32 i=0 ; i<size ; i++ )
{
unsigned int x,y;
if(i >= m_Object.size())
{
CVorticonSpriteObject *object = new CVorticonSpriteObject( mMap.get(), 0, 0, OBJ_NONE);
object->exists = false;
m_Object.push_back(object);
}
CVorticonSpriteObject* object = dynamic_cast<CVorticonSpriteObject*>(m_Object.at(i));
savedGame.decodeData(object->m_type);
savedGame.decodeData(x);
savedGame.decodeData(y);
object->moveToForce(VectorD2<int>(x,y));
savedGame.decodeData(object->dead);
savedGame.decodeData(object->onscreen);
savedGame.decodeData(object->hasbeenonscreen);
savedGame.decodeData(object->exists);
savedGame.decodeData(object->blockedd);
savedGame.decodeData(object->blockedu);
savedGame.decodeData(object->blockedl);
savedGame.decodeData(object->blockedr);
savedGame.decodeData(object->mHealthPoints);
savedGame.decodeData(object->canbezapped);
savedGame.decodeData(object->cansupportplayer);
savedGame.decodeData(object->inhibitfall);
savedGame.decodeData(object->honorPriority);
savedGame.decodeData(object->sprite);
object->performCollisions();
if(object->m_type == OBJ_DOOR or
object->m_type == OBJ_RAY or
object->m_type == OBJ_SNDWAVE or
object->m_type == OBJ_FIREBALL or
object->m_type == OBJ_ICECHUNK or
object->m_type == OBJ_ICEBIT or
object->m_type == OBJ_GOTPOINTS or
object->m_type == OBJ_ANKHSHIELD) // Some objects are really not needed. So don't load them
object->exists = false;
}
// TODO: An algorithm for comparing the number of players saved and we actually have need to be in sync
// Load the map_data as it was left last
savedGame.decodeData(mMap->m_width);
savedGame.decodeData(mMap->m_height);
savedGame.readDataBlock( reinterpret_cast<byte*>(mMap->getForegroundData()) );
// Load completed levels
savedGame.readDataBlock( (byte*)(mp_level_completed) );
m_Player[0].setMapData(mMap.get());
m_Player[0].setupCameraObject();
m_Player[0].mp_camera->attachObject(&m_Player[0]);
while(m_Player[0].mp_camera->m_moving)
{
m_Player[0].mp_camera->process();
m_Player[0].mp_camera->processEvents();
}
mMap->drawAll();
// Create the special merge effect (Fadeout)
g_pGfxEngine->setupEffect(pColorMergeFX);
// save all the objects states
savedGame.decodeData(x);
savedGame.decodeData(y);
(*it)->moveToForce(VectorD2<int>(x,y));
savedGame.decodeData( (*it)->dead );
savedGame.decodeData( (*it)->onscreen );
savedGame.decodeData( (*it)->hasbeenonscreen );
savedGame.decodeData( (*it)->exists );
savedGame.decodeData( (*it)->blockedd );
savedGame.decodeData( (*it)->blockedu );
savedGame.decodeData( (*it)->blockedl );
savedGame.decodeData( (*it)->blockedr );
savedGame.decodeData( (*it)->mHealthPoints );
savedGame.decodeData( (*it)->canbezapped );
savedGame.decodeData( (*it)->cansupportplayer );
savedGame.decodeData( (*it)->inhibitfall );
savedGame.decodeData( (*it)->honorPriority );
savedGame.decodeData( (*it)->sprite );
savedGame.decodeData( (*it)->m_ActionNumber );
}
mpObjectAI = new CVorticonSpriteObjectAI(mMap.get(), m_Object, m_Player,
m_NumPlayers, m_Episode, m_Level,
mMap->m_Dark);
setupPlayers();
savedGame.decodeData( mActive );
mMap->m_Dark = dark;
g_pGfxEngine->Palette.setdark(mMap->m_Dark);
// Save the map_data as it is left
savedGame.decodeData(mMap.m_width);
savedGame.decodeData(mMap.m_height);
return true;
}*/
savedGame.readDataBlock( reinterpret_cast<byte*>(mMap.getBackgroundData()) );
savedGame.readDataBlock( reinterpret_cast<byte*>(mMap.getForegroundData()) );
return false;
return true;
}
......@@ -17,6 +17,7 @@
#include "sdl/music/CMusic.h"
#include "StringUtils.h"
#include "common/Menu/CMenuController.h"
#include "graphics/effects/CColorMerge.h"
namespace galaxy
{
......@@ -36,19 +37,31 @@ bool CPlayGameGalaxy::loadGameState()
{
CSaveGameController &savedGame = *(gpSaveGameController);
// This fills the datablock from CSavedGame object
if(!savedGame.load())
return false;
// Create the special merge effect (Fadeout)
CColorMerge *pColorMergeFX = new CColorMerge(8);
/// Save the Game in the CSavedGame object
// store the episode, level and difficulty
savedGame.decodeData(m_Episode);
savedGame.decodeData(m_Level);
savedGame.decodeData(g_pBehaviorEngine->mDifficulty);
// Save number of Players
// Load number of Players
savedGame.decodeData(m_NumPlayers);
// TODO: We need to load both Levels first, before we do the writing from the saved state.
m_Inventory << savedGame;
m_WorldMap << savedGame;
m_LevelPlay << savedGame;
// Create the special merge effect (Fadeout)
g_pGfxEngine->setupEffect(pColorMergeFX);
return savedGame.load();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment