mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Fix Mantis #2234
CPlayerInterface instances were removed from CClient::playerint with clear() and finish() was not called on each. Added multiple insurance.
This commit is contained in:
@ -101,6 +101,7 @@ VCAI::VCAI(void)
|
|||||||
VCAI::~VCAI(void)
|
VCAI::~VCAI(void)
|
||||||
{
|
{
|
||||||
LOG_TRACE(logAi);
|
LOG_TRACE(logAi);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCAI::availableCreaturesChanged(const CGDwelling *town)
|
void VCAI::availableCreaturesChanged(const CGDwelling *town)
|
||||||
@ -2750,7 +2751,10 @@ void VCAI::recruitHero(const CGTownInstance * t, bool throwing)
|
|||||||
void VCAI::finish()
|
void VCAI::finish()
|
||||||
{
|
{
|
||||||
if(makingTurn)
|
if(makingTurn)
|
||||||
|
{
|
||||||
makingTurn->interrupt();
|
makingTurn->interrupt();
|
||||||
|
makingTurn->join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCAI::requestActionASAP(std::function<void()> whatToDo)
|
void VCAI::requestActionASAP(std::function<void()> whatToDo)
|
||||||
|
@ -159,7 +159,7 @@ public:
|
|||||||
std::unique_ptr<boost::thread> makingTurn;
|
std::unique_ptr<boost::thread> makingTurn;
|
||||||
|
|
||||||
VCAI(void);
|
VCAI(void);
|
||||||
~VCAI(void);
|
virtual ~VCAI(void);
|
||||||
|
|
||||||
//TODO: use only smart pointers?
|
//TODO: use only smart pointers?
|
||||||
void tryRealize(Goals::Explore & g);
|
void tryRealize(Goals::Explore & g);
|
||||||
|
@ -321,6 +321,8 @@ void CCallback::castSpell(const CGHeroInstance *hero, SpellID spellID, const int
|
|||||||
|
|
||||||
void CCallback::unregisterAllInterfaces()
|
void CCallback::unregisterAllInterfaces()
|
||||||
{
|
{
|
||||||
|
for (auto& pi : cl->playerint)
|
||||||
|
pi.second->finish();
|
||||||
cl->playerint.clear();
|
cl->playerint.clear();
|
||||||
cl->battleints.clear();
|
cl->battleints.clear();
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ void CClient::save(const std::string & fname)
|
|||||||
void CClient::endGame( bool closeConnection /*= true*/ )
|
void CClient::endGame( bool closeConnection /*= true*/ )
|
||||||
{
|
{
|
||||||
//suggest interfaces to finish their stuff (AI should interrupt any bg working threads)
|
//suggest interfaces to finish their stuff (AI should interrupt any bg working threads)
|
||||||
for(auto i : playerint)
|
for(auto& i : playerint)
|
||||||
i.second->finish();
|
i.second->finish();
|
||||||
|
|
||||||
// Game is ending
|
// Game is ending
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
static CConnection * justConnectToServer(const std::string &host = "", const std::string &port = ""); //connects to given host without taking any other actions (like setting up server)
|
static CConnection * justConnectToServer(const std::string &host = "", const std::string &port = ""); //connects to given host without taking any other actions (like setting up server)
|
||||||
|
|
||||||
CServerHandler(bool runServer = false);
|
CServerHandler(bool runServer = false);
|
||||||
~CServerHandler();
|
virtual ~CServerHandler();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -72,7 +72,6 @@ class ThreadSafeVector
|
|||||||
boost::condition_variable cond;
|
boost::condition_variable cond;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void pushBack(const T &item)
|
void pushBack(const T &item)
|
||||||
{
|
{
|
||||||
TLock lock(mx);
|
TLock lock(mx);
|
||||||
|
@ -19,7 +19,7 @@ extern boost::mutex eventsM;
|
|||||||
CondSh<bool> CGuiHandler::terminate_cond;
|
CondSh<bool> CGuiHandler::terminate_cond;
|
||||||
boost::thread_specific_ptr<bool> inGuiThread;
|
boost::thread_specific_ptr<bool> inGuiThread;
|
||||||
|
|
||||||
SObjectConstruction::SObjectConstruction( CIntObject *obj )
|
SObjectConstruction::SObjectConstruction(CIntObject *obj)
|
||||||
:myObj(obj)
|
:myObj(obj)
|
||||||
{
|
{
|
||||||
GH.createdObj.push_front(obj);
|
GH.createdObj.push_front(obj);
|
||||||
@ -86,7 +86,7 @@ void CGuiHandler::handleElementDeActivate(CIntObject * elem, ui16 activityFlag)
|
|||||||
elem->active_m &= ~activityFlag;
|
elem->active_m &= ~activityFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiHandler::popInt( IShowActivatable *top )
|
void CGuiHandler::popInt(IShowActivatable *top)
|
||||||
{
|
{
|
||||||
assert(listInt.front() == top);
|
assert(listInt.front() == top);
|
||||||
top->deactivate();
|
top->deactivate();
|
||||||
@ -97,7 +97,7 @@ void CGuiHandler::popInt( IShowActivatable *top )
|
|||||||
totalRedraw();
|
totalRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiHandler::popIntTotally( IShowActivatable *top )
|
void CGuiHandler::popIntTotally(IShowActivatable *top)
|
||||||
{
|
{
|
||||||
assert(listInt.front() == top);
|
assert(listInt.front() == top);
|
||||||
popInt(top);
|
popInt(top);
|
||||||
@ -105,7 +105,7 @@ void CGuiHandler::popIntTotally( IShowActivatable *top )
|
|||||||
fakeMouseMove();
|
fakeMouseMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiHandler::pushInt( IShowActivatable *newInt )
|
void CGuiHandler::pushInt(IShowActivatable *newInt)
|
||||||
{
|
{
|
||||||
assert(newInt);
|
assert(newInt);
|
||||||
assert(boost::range::find(listInt, newInt) == listInt.end()); // do not add same object twice
|
assert(boost::range::find(listInt, newInt) == listInt.end()); // do not add same object twice
|
||||||
@ -121,7 +121,7 @@ void CGuiHandler::pushInt( IShowActivatable *newInt )
|
|||||||
totalRedraw();
|
totalRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiHandler::popInts( int howMany )
|
void CGuiHandler::popInts(int howMany)
|
||||||
{
|
{
|
||||||
if(!howMany) return; //senseless but who knows...
|
if(!howMany) return; //senseless but who knows...
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ void CGuiHandler::simpleRedraw()
|
|||||||
objsToBlit.back()->show(screen); //blit active interface/window
|
objsToBlit.back()->show(screen); //blit active interface/window
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiHandler::handleMoveInterested( const SDL_MouseMotionEvent & motion )
|
void CGuiHandler::handleMoveInterested(const SDL_MouseMotionEvent & motion)
|
||||||
{
|
{
|
||||||
//sending active, MotionInterested objects mouseMoved() call
|
//sending active, MotionInterested objects mouseMoved() call
|
||||||
std::list<CIntObject*> miCopy = motioninterested;
|
std::list<CIntObject*> miCopy = motioninterested;
|
||||||
@ -463,7 +463,7 @@ void CGuiHandler::drawFPSCounter()
|
|||||||
graphics->fonts[FONT_BIG]->renderTextLeft(screen, fps, yellow, Point(10, 10));
|
graphics->fonts[FONT_BIG]->renderTextLeft(screen, fps, yellow, Point(10, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Keycode CGuiHandler::arrowToNum(SDL_Keycode key )
|
SDL_Keycode CGuiHandler::arrowToNum(SDL_Keycode key)
|
||||||
{
|
{
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
|
@ -82,6 +82,7 @@ public:
|
|||||||
class DLL_LINKAGE CGameInterface : public CBattleGameInterface, public IGameEventsReceiver
|
class DLL_LINKAGE CGameInterface : public CBattleGameInterface, public IGameEventsReceiver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~CGameInterface() = default;
|
||||||
virtual void init(std::shared_ptr<CCallback> CB){};
|
virtual void init(std::shared_ptr<CCallback> CB){};
|
||||||
virtual void yourTurn(){}; //called AFTER playerStartsTurn(player)
|
virtual void yourTurn(){}; //called AFTER playerStartsTurn(player)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user