1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Better handling of AI shutdown

This commit is contained in:
Ivan Savenko
2025-03-02 12:56:01 +00:00
parent 5f052165fe
commit 219eea86ff
6 changed files with 46 additions and 18 deletions

View File

@ -46,8 +46,6 @@
#include "lib/CAndroidVMHelper.h"
#endif
ThreadSafeVector<int> CClient::waitingRequest;
CPlayerEnvironment::CPlayerEnvironment(PlayerColor player_, CClient * cl_, std::shared_ptr<CCallback> mainCallback_)
: player(player_),
cl(cl_),
@ -181,25 +179,28 @@ void CClient::endNetwork()
}
}
void CClient::finishGameplay()
{
waitingRequest.requestTermination();
//suggest interfaces to finish their stuff (AI should interrupt any bg working threads)
for(auto & i : playerint)
i.second->finish();
}
void CClient::endGame()
{
#if SCRIPTING_ENABLED
clientScripts.reset();
#endif
//suggest interfaces to finish their stuff (AI should interrupt any bg working threads)
for(auto & i : playerint)
i.second->finish();
logNetwork->info("Ending current game!");
removeGUI();
{
logNetwork->info("Ending current game!");
removeGUI();
GAME->setMapInstance(nullptr);
vstd::clear_pointer(gs);
GAME->setMapInstance(nullptr);
vstd::clear_pointer(gs);
logNetwork->info("Deleted mapHandler and gameState.");
}
logNetwork->info("Deleted mapHandler and gameState.");
CPlayerInterface::battleInt.reset();
playerint.clear();