Commit 7c11c953 authored by Gerhard Stein's avatar Gerhard Stein

Fixes

parent d0cc5e78
...@@ -120,11 +120,21 @@ bool CPlayGameGalaxy::loadXMLGameState() ...@@ -120,11 +120,21 @@ bool CPlayGameGalaxy::loadXMLGameState()
mInventoryVec.resize(numPlayers); mInventoryVec.resize(numPlayers);
mDead.assign(numPlayers, false);
mGameOver.assign(numPlayers, false);
unsigned int variant; unsigned int variant;
for( auto &node : pt ) for( auto &node : pt )
{ {
if(node.first == "death")
{
ptree &deadNode = node.second;
const int id = deadNode.get<int>("<xmlattr>.player", 0);
mDead[id] = deadNode.get<bool>("<xmlattr>.dead", false);
mGameOver[id] = deadNode.get<bool>("<xmlattr>.gameover", false);
}
if(node.first == "Player") if(node.first == "Player")
{ {
ptree &playerNode = node.second; ptree &playerNode = node.second;
...@@ -174,6 +184,14 @@ bool CPlayGameGalaxy::saveXMLGameState() ...@@ -174,6 +184,14 @@ bool CPlayGameGalaxy::saveXMLGameState()
const unsigned int numPlayers = g_pBehaviorEngine->mPlayers; const unsigned int numPlayers = g_pBehaviorEngine->mPlayers;
stateNode.put("NumPlayer", numPlayers); stateNode.put("NumPlayer", numPlayers);
ptree &deadNode = pt.add("death", "");
for(unsigned int id = 0 ; id < mDead.size() ; id++ )
{
deadNode.put("<xmlattr>.player", id);
deadNode.put("<xmlattr>.dead", mDead[id]);
deadNode.put("<xmlattr>.gameover", mGameOver[id]);
}
for( unsigned int id=0 ; id<numPlayers ; id++ ) for( unsigned int id=0 ; id<numPlayers ; id++ )
{ {
ptree &playerNode = pt.add("Player", ""); ptree &playerNode = pt.add("Player", "");
......
...@@ -27,7 +27,7 @@ const Uint16 SPEED = 64; ...@@ -27,7 +27,7 @@ const Uint16 SPEED = 64;
CFlag::CFlag(CMap *pmap, const VectorD2<Uint32> &Location, CFlag::CFlag(CMap *pmap, const VectorD2<Uint32> &Location,
const VectorD2<Uint32> &Destination, const VectorD2<Uint32> &Destination,
const int sprVar, bool newAction ) : const int sprVar, bool newAction, const bool canLock ) :
CGalaxySpriteObject(pmap, FOE_ID, Location.x, Location.y, sprVar), CGalaxySpriteObject(pmap, FOE_ID, Location.x, Location.y, sprVar),
m_destination(Destination), m_destination(Destination),
m_baseframe(0) m_baseframe(0)
...@@ -40,6 +40,9 @@ m_baseframe(0) ...@@ -40,6 +40,9 @@ m_baseframe(0)
const auto episode = g_pBehaviorEngine->getEpisode(); const auto episode = g_pBehaviorEngine->getEpisode();
if(canLock)
mp_Map->lock();
if(episode == 6) if(episode == 6)
{ {
setupGalaxyObjectOnMap(0x13F4, A_FLAG_FLIP); setupGalaxyObjectOnMap(0x13F4, A_FLAG_FLIP);
...@@ -62,12 +65,15 @@ m_baseframe(0) ...@@ -62,12 +65,15 @@ m_baseframe(0)
void CFlag::getTouchedBy(CSpriteObject &theObject) void CFlag::getTouchedBy(CSpriteObject &theObject)
{ {
if( getActionNumber(A_FLAG_FLIP) ) if( getActionNumber(A_FLAG_FLIP) )
return; return;
// In case another flag is sitting in the pole, make that one non existent // In case another flag is sitting in the pole, make that one non existent
if( CFlag *flag = dynamic_cast<CFlag*>(&theObject) ) if( CFlag *flag = dynamic_cast<CFlag*>(&theObject) )
{ {
flag->exists = false; if( flag->getActionNumber(A_FLAG_WAVE) )
{
exists = false;
}
} }
} }
...@@ -97,8 +103,7 @@ void CFlag::process() ...@@ -97,8 +103,7 @@ void CFlag::process()
void CFlag::processFlipping() void CFlag::processFlipping()
{ {
if(m_Pos != m_destination) if(m_Pos != m_destination)
{ {
mp_Map->lock();
VectorD2<int> dir = m_destination - m_Pos; VectorD2<int> dir = m_destination - m_Pos;
float length = dir.GetLength(); float length = dir.GetLength();
VectorD2<float> base_dir( dir.x/length, dir.y/length ); VectorD2<float> base_dir( dir.x/length, dir.y/length );
...@@ -114,8 +119,7 @@ void CFlag::processFlipping() ...@@ -114,8 +119,7 @@ void CFlag::processFlipping()
} }
else else
{ {
setAction(A_FLAG_WAVE); setAction(A_FLAG_WAVE);
mp_Map->unlock();
setActionSprite(); setActionSprite();
g_pSound->playSound( SOUND_FLAG_LAND ); g_pSound->playSound( SOUND_FLAG_LAND );
...@@ -140,4 +144,9 @@ void CFlag::processFlipping() ...@@ -140,4 +144,9 @@ void CFlag::processFlipping()
void CFlag::processWaving() void CFlag::processWaving()
{} {}
bool CFlag::calcVisibility()
{
return true;
}
} }
...@@ -25,7 +25,7 @@ namespace galaxy { ...@@ -25,7 +25,7 @@ namespace galaxy {
CFlag(CMap *pmap, const VectorD2<Uint32> &Location, CFlag(CMap *pmap, const VectorD2<Uint32> &Location,
const VectorD2<Uint32> &Destination, const int sprVar, const VectorD2<Uint32> &Destination, const int sprVar,
const bool newAction); const bool newAction, const bool canLock );
void deserialize(CSaveGameController &savedGame) void deserialize(CSaveGameController &savedGame)
...@@ -55,6 +55,12 @@ namespace galaxy { ...@@ -55,6 +55,12 @@ namespace galaxy {
void processFlipping(); void processFlipping();
void processWaving(); void processWaving();
/**
* @brief Flag can always be visible and active, even if he is not seen.
* @return
*/
bool calcVisibility();
void setActionForce(const size_t ActionNumber); void setActionForce(const size_t ActionNumber);
private: private:
......
...@@ -1009,7 +1009,7 @@ bool CPlayerWM::finishLevel(const int object) ...@@ -1009,7 +1009,7 @@ bool CPlayerWM::finishLevel(const int object)
VectorD2<Uint32> dst(csfX, csfY); VectorD2<Uint32> dst(csfX, csfY);
CFlag *pFlag = new CFlag(mp_Map, src, dst, mSprVar, true); CFlag *pFlag = new CFlag(mp_Map, src, dst, mSprVar, true, true);
g_pBehaviorEngine->m_EventList.spawnObj(pFlag); g_pBehaviorEngine->m_EventList.spawnObj(pFlag);
......
...@@ -385,7 +385,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x, ...@@ -385,7 +385,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
// Not sure if after that there are more sprites to load // Not sure if after that there are more sprites to load
// This special sprite is only loaded by saved game. Normal gamemaps do not have that flag // This special sprite is only loaded by saved game. Normal gamemaps do not have that flag
case CFlag::FOE_ID: case CFlag::FOE_ID:
p_newfoe = new galaxy::CFlag(&Map, loc, loc, 0,false); p_newfoe = new galaxy::CFlag(&Map, loc, loc, 0, false, false);
break; break;
......
...@@ -368,7 +368,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp5::addFoe(CMap &Map, word foe, size_t x, ...@@ -368,7 +368,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp5::addFoe(CMap &Map, word foe, size_t x,
// Not sure if after that there are more sprites to load // Not sure if after that there are more sprites to load
// This special sprite is only loaded by saved game. Normal gamemaps do not have that flag // This special sprite is only loaded by saved game. Normal gamemaps do not have that flag
case CFlag::FOE_ID: case CFlag::FOE_ID:
p_newfoe = new galaxy::CFlag(&Map, loc, loc, false, 0); p_newfoe = new galaxy::CFlag(&Map, loc, loc, false, 0, false);
break; break;
default: default:
......
...@@ -317,7 +317,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x, ...@@ -317,7 +317,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x,
// Not sure if after that there are more sprites to load // Not sure if after that there are more sprites to load
// This special sprite is only loaded by saved game. Normal gamemaps do not have that flag // This special sprite is only loaded by saved game. Normal gamemaps do not have that flag
case CFlag::FOE_ID: case CFlag::FOE_ID:
p_newfoe = new galaxy::CFlag(&Map, loc, loc, 0,false); p_newfoe = new galaxy::CFlag(&Map, loc, loc, 0, false, false);
break; break;
case CRope::FOE_ID: case CRope::FOE_ID:
......
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