From d7a1898676d857c921b119f3fddd3a861098c5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Mon, 22 Feb 2010 13:30:46 +0000 Subject: [PATCH] Many fixes, mostly related to hot-seat. --- client/CBattleInterface.cpp | 4 ++-- client/CPlayerInterface.cpp | 18 ++++++++++++++---- lib/Connection.cpp | 4 ++-- lib/Connection.h | 2 +- mapHandler.cpp | 7 ------- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index 2d999c270..f4f1bd0ec 100644 --- a/client/CBattleInterface.cpp +++ b/client/CBattleInterface.cpp @@ -2543,9 +2543,9 @@ void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca) void CBattleInterface::battleFinished(const BattleResult& br) { bresult = &br; - curInt->pim->unlock(); + LOCPLINT->pim->unlock(); animsAreDisplayed.waitUntil(false); - curInt->pim->lock(); + LOCPLINT->pim->lock(); displayBattleFinished(); } diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 8b6b8ed05..4ba0d0dc8 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -120,9 +120,16 @@ CPlayerInterface::~CPlayerInterface() delete pim; delete showingDialog; delete mainFPSmng; - if(adventureInt->active & CIntObject::KEYBOARD) - adventureInt->deactivateKeys(); - delete adventureInt; + if(adventureInt) + { + if(adventureInt->active & CIntObject::KEYBOARD) + adventureInt->deactivateKeys(); + delete adventureInt; + adventureInt = NULL; + } + + if(cingconsole->active) //TODO + cingconsole->deactivate(); delete cingconsole; for(std::map::iterator i=graphics->heroWins.begin(); i!= graphics->heroWins.end(); i++) @@ -838,7 +845,7 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector pom.push_back(std::pair >("IOKAY.DEF",0)); CInfoWindow * temp = new CInfoWindow(text,playerID,0,components,pom,false); - if(/*makingTurn && */GH.listInt.size()) + if(makingTurn && GH.listInt.size() && LOCPLINT == this) { CGI->soundh->playSound(static_cast(soundID)); showingDialog->set(true); @@ -1691,6 +1698,9 @@ void CPlayerInterface::finishMovement( const TryMoveHero &details, const int3 &h void CPlayerInterface::gameOver(ui8 player, bool victory ) { + if(LOCPLINT != this) + return; + if(player == playerID) { if(!victory) diff --git a/lib/Connection.cpp b/lib/Connection.cpp index 73beb0aeb..d265d31c0 100644 --- a/lib/Connection.cpp +++ b/lib/Connection.cpp @@ -255,7 +255,7 @@ int CSaveFile::write( const void * data, unsigned size ) return size; } -CLoadFile::CLoadFile( const std::string &fname ) +CLoadFile::CLoadFile( const std::string &fname, bool requireLatest ) :sfile(new std::ifstream(fname.c_str(),std::ios::binary)) { registerTypes(*this); @@ -278,7 +278,7 @@ CLoadFile::CLoadFile( const std::string &fname ) } *this >> myVersion; - if(myVersion != version) + if(myVersion != version && requireLatest) { tlog1 << "Error: Not supported save format! (file " << fname << " )\n"; delete sfile; diff --git a/lib/Connection.h b/lib/Connection.h index 363fab506..5f9dce573 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -694,7 +694,7 @@ class DLL_EXPORT CLoadFile } public: std::ifstream *sfile; - CLoadFile(const std::string &fname); + CLoadFile(const std::string &fname, bool requireLatest = true); ~CLoadFile(); int read(const void * data, unsigned size); }; diff --git a/mapHandler.cpp b/mapHandler.cpp index 811081e04..b70964e44 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -434,13 +434,6 @@ void CMapHandler::init() initObjectRects(); tlog0<<"\tMaking object rects: "<defInfo->name << ' '; - - } } // Update map window screen