mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
Prevent crashing when pressing auto-combat button on enemy turn
This commit is contained in:
@ -663,33 +663,30 @@ void BattleInterface::requestAutofightingAIToTakeAction()
|
|||||||
|
|
||||||
boost::thread aiThread([&]()
|
boost::thread aiThread([&]()
|
||||||
{
|
{
|
||||||
auto ba = std::make_unique<BattleAction>(curInt->autofightingAI->activeStack(stacksController->getActiveStack()));
|
|
||||||
|
|
||||||
if(curInt->cb->battleIsFinished())
|
if(curInt->cb->battleIsFinished())
|
||||||
{
|
{
|
||||||
return; // battle finished with spellcast
|
return; // battle finished with spellcast
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curInt->isAutoFightOn)
|
if (tacticsMode)
|
||||||
{
|
{
|
||||||
if (tacticsMode)
|
// Always end tactics mode. Player interface is blocked currently, so it's not possible that
|
||||||
{
|
// the AI can take any action except end tactics phase (AI actions won't be triggered)
|
||||||
// Always end tactics mode. Player interface is blocked currently, so it's not possible that
|
//TODO implement the possibility that the AI will be triggered for further actions
|
||||||
// the AI can take any action except end tactics phase (AI actions won't be triggered)
|
//TODO any solution to merge tactics phase & normal phase in the way it is handled by the player and battle interface?
|
||||||
//TODO implement the possibility that the AI will be triggered for further actions
|
stacksController->setActiveStack(nullptr);
|
||||||
//TODO any solution to merge tactics phase & normal phase in the way it is handled by the player and battle interface?
|
tacticsMode = false;
|
||||||
stacksController->setActiveStack(nullptr);
|
|
||||||
tacticsMode = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
givenCommand.setn(ba.release());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
|
const CStack* activeStack = stacksController->getActiveStack();
|
||||||
activateStack();
|
|
||||||
|
// If enemy is moving, activeStack can be null
|
||||||
|
if (activeStack)
|
||||||
|
{
|
||||||
|
auto ba = std::make_unique<BattleAction>(curInt->autofightingAI->activeStack(activeStack));
|
||||||
|
givenCommand.setn(ba.release());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user