Merge pull request #2359 from IvanSavenko/crashfixing
Fix crashes from 1.2.1 statistics on Google Play
This commit is contained in:
28 files changed
+413
-511
No files matched your search
+21
-56
@@ -657,7 +657,7 @@ void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet
|
||||
//quick combat with neutral creatures only
|
||||
auto * army2_object = dynamic_cast<const CGObjectInstance *>(army2);
|
||||
if((!autoBattleResultRefused && !allowBattleReplay && army2_object
|
||||
&& army2_object->getOwner() == PlayerColor::UNFLAGGABLE
|
||||
&& (army2_object->getOwner() == PlayerColor::UNFLAGGABLE || army2_object->getOwner() == PlayerColor::NEUTRAL)
|
||||
&& settings["adventure"]["quickCombat"].Bool())
|
||||
|| settings["adventure"]["alwaysSkipCombat"].Bool())
|
||||
{
|
||||
@@ -785,27 +785,29 @@ void CPlayerInterface::actionFinished(const BattleAction &action)
|
||||
curAction = nullptr;
|
||||
}
|
||||
|
||||
BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when it's turn of that stack
|
||||
void CPlayerInterface::activeStack(const CStack * stack) //called when it's turn of that stack
|
||||
{
|
||||
THREAD_CREATED_BY_CLIENT;
|
||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||
logGlobal->trace("Awaiting command for %s", stack->nodeName());
|
||||
auto stackId = stack->unitId();
|
||||
auto stackName = stack->nodeName();
|
||||
|
||||
assert(!cb->battleIsFinished());
|
||||
if (cb->battleIsFinished())
|
||||
{
|
||||
logGlobal->error("Received CPlayerInterface::activeStack after battle is finished!");
|
||||
|
||||
cb->battleMakeUnitAction(BattleAction::makeDefend(stack));
|
||||
return ;
|
||||
}
|
||||
|
||||
if (autofightingAI)
|
||||
{
|
||||
if (isAutoFightOn)
|
||||
{
|
||||
auto ret = autofightingAI->activeStack(stack);
|
||||
|
||||
if(cb->battleIsFinished())
|
||||
{
|
||||
return BattleAction::makeDefend(stack); // battle finished with spellcast
|
||||
}
|
||||
|
||||
if (isAutoFightOn)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
//FIXME: we want client rendering to proceed while AI is making actions
|
||||
// so unlock mutex while AI is busy since this might take quite a while, especially if hero has many spells
|
||||
auto unlockPim = vstd::makeUnlockGuard(*pim);
|
||||
autofightingAI->activeStack(stack);
|
||||
return;
|
||||
}
|
||||
|
||||
cb->unregisterBattleInterface(autofightingAI);
|
||||
@@ -813,16 +815,10 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
|
||||
}
|
||||
|
||||
assert(battleInt);
|
||||
|
||||
if(!battleInt)
|
||||
{
|
||||
return BattleAction::makeDefend(stack); // probably battle is finished already
|
||||
}
|
||||
|
||||
if(BattleInterface::givenCommand.get())
|
||||
{
|
||||
logGlobal->error("Command buffer must be clean! (we don't want to use old command)");
|
||||
vstd::clear_pointer(BattleInterface::givenCommand.data);
|
||||
// probably battle is finished already
|
||||
cb->battleMakeUnitAction(BattleAction::makeDefend(stack));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -830,29 +826,6 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
|
||||
battleInt->stackActivated(stack);
|
||||
//Regeneration & mana drain go there
|
||||
}
|
||||
//wait till BattleInterface sets its command
|
||||
boost::unique_lock<boost::mutex> lock(BattleInterface::givenCommand.mx);
|
||||
while(!BattleInterface::givenCommand.data)
|
||||
{
|
||||
BattleInterface::givenCommand.cond.wait(lock);
|
||||
if (!battleInt) //battle ended while we were waiting for movement (eg. because of spell)
|
||||
throw boost::thread_interrupted(); //will shut the thread peacefully
|
||||
}
|
||||
|
||||
//tidy up
|
||||
BattleAction ret = *(BattleInterface::givenCommand.data);
|
||||
vstd::clear_pointer(BattleInterface::givenCommand.data);
|
||||
|
||||
if(ret.actionType == EActionType::CANCEL)
|
||||
{
|
||||
if(stackId != ret.stackNumber)
|
||||
logGlobal->error("Not current active stack action canceled");
|
||||
logGlobal->trace("Canceled command for %s", stackName);
|
||||
}
|
||||
else
|
||||
logGlobal->trace("Giving command for %s", stackName);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleEnd(const BattleResult *br, QueryID queryID)
|
||||
@@ -1004,15 +977,7 @@ void CPlayerInterface::battleGateStateChanged(const EGateState state)
|
||||
|
||||
void CPlayerInterface::yourTacticPhase(int distance)
|
||||
{
|
||||
THREAD_CREATED_BY_CLIENT;
|
||||
while(battleInt && battleInt->tacticsMode)
|
||||
boost::this_thread::sleep(boost::posix_time::millisec(1));
|
||||
}
|
||||
|
||||
void CPlayerInterface::forceEndTacticPhase()
|
||||
{
|
||||
if (battleInt)
|
||||
battleInt->tacticsMode = false;
|
||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||
}
|
||||
|
||||
void CPlayerInterface::showInfoDialog(EInfoWindowMode type, const std::string &text, const std::vector<Component> & components, int soundID)
|
||||
|
||||
Reference in new issue
Block a user