mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +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:
parent
d51c9a1ff0
commit
4bcc43d3d0
@ -101,6 +101,7 @@ VCAI::VCAI(void)
|
||||
VCAI::~VCAI(void)
|
||||
{
|
||||
LOG_TRACE(logAi);
|
||||
finish();
|
||||
}
|
||||
|
||||
void VCAI::availableCreaturesChanged(const CGDwelling *town)
|
||||
@ -2750,7 +2751,10 @@ void VCAI::recruitHero(const CGTownInstance * t, bool throwing)
|
||||
void VCAI::finish()
|
||||
{
|
||||
if(makingTurn)
|
||||
{
|
||||
makingTurn->interrupt();
|
||||
makingTurn->join();
|
||||
}
|
||||
}
|
||||
|
||||
void VCAI::requestActionASAP(std::function<void()> whatToDo)
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
std::unique_ptr<boost::thread> makingTurn;
|
||||
|
||||
VCAI(void);
|
||||
~VCAI(void);
|
||||
virtual ~VCAI(void);
|
||||
|
||||
//TODO: use only smart pointers?
|
||||
void tryRealize(Goals::Explore & g);
|
||||
|
@ -321,6 +321,8 @@ void CCallback::castSpell(const CGHeroInstance *hero, SpellID spellID, const int
|
||||
|
||||
void CCallback::unregisterAllInterfaces()
|
||||
{
|
||||
for (auto& pi : cl->playerint)
|
||||
pi.second->finish();
|
||||
cl->playerint.clear();
|
||||
cl->battleints.clear();
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ void CClient::save(const std::string & fname)
|
||||
void CClient::endGame( bool closeConnection /*= true*/ )
|
||||
{
|
||||
//suggest interfaces to finish their stuff (AI should interrupt any bg working threads)
|
||||
for(auto i : playerint)
|
||||
for(auto& i : playerint)
|
||||
i.second->finish();
|
||||
|
||||
// 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)
|
||||
|
||||
CServerHandler(bool runServer = false);
|
||||
~CServerHandler();
|
||||
virtual ~CServerHandler();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -72,7 +72,6 @@ class ThreadSafeVector
|
||||
boost::condition_variable cond;
|
||||
|
||||
public:
|
||||
|
||||
void pushBack(const T &item)
|
||||
{
|
||||
TLock lock(mx);
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
class DLL_LINKAGE CGameInterface : public CBattleGameInterface, public IGameEventsReceiver
|
||||
{
|
||||
public:
|
||||
virtual ~CGameInterface() = default;
|
||||
virtual void init(std::shared_ptr<CCallback> CB){};
|
||||
virtual void yourTurn(){}; //called AFTER playerStartsTurn(player)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user