mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed action cancel on active stack remove
This commit is contained in:
parent
02c15085be
commit
2677d4a677
@ -813,21 +813,17 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
|
||||
|
||||
//tidy up
|
||||
BattleAction ret = *(b->givenCommand->data);
|
||||
//todo: remove this evil hack
|
||||
//dirty evil hack...
|
||||
//if active stack was changed, new thread was started for new active stack but we will receive notification too
|
||||
//we need check that givenCommand is for our stack (use ID as stack object may be even destroyed)
|
||||
if(stackId != ret.stackNumber)
|
||||
vstd::clear_pointer(b->givenCommand->data);
|
||||
|
||||
if(ret.actionType == Battle::CANCEL)
|
||||
{
|
||||
logGlobal->traceStream() << "Interrupted command for " << stackName;
|
||||
throw boost::thread_interrupted();
|
||||
if(stackId != ret.stackNumber)
|
||||
logGlobal->error("Not current active stack action canceled");
|
||||
logGlobal->traceStream() << "Canceled command for " << stackName;
|
||||
}
|
||||
|
||||
delete b->givenCommand->data;
|
||||
b->givenCommand->data = nullptr;
|
||||
|
||||
//return command
|
||||
else
|
||||
logGlobal->traceStream() << "Giving command for " << stackName;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -140,9 +140,12 @@ void CClient::waitForMoveAndSend(PlayerColor color)
|
||||
setThreadName("CClient::waitForMoveAndSend");
|
||||
assert(vstd::contains(battleints, color));
|
||||
BattleAction ba = battleints[color]->activeStack(gs->curB->battleGetStackByID(gs->curB->activeStack, false));
|
||||
if(ba.actionType != Battle::CANCEL)
|
||||
{
|
||||
logNetwork->traceStream() << "Send battle action to server: " << ba;
|
||||
MakeAction temp_action(ba);
|
||||
sendRequest(&temp_action, color);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch(boost::thread_interrupted&)
|
||||
|
@ -1009,6 +1009,11 @@ void CBattleInterface::stackRemoved(int stackID)
|
||||
{
|
||||
if(activeStack->ID == stackID)
|
||||
{
|
||||
BattleAction * action = new BattleAction();
|
||||
action->side = defendingHeroInstance ? (curInt->playerID == defendingHeroInstance->tempOwner) : false;
|
||||
action->actionType = Battle::CANCEL;
|
||||
action->stackNumber = activeStack->ID;
|
||||
givenCommand->setn(action);
|
||||
setActiveStack(nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -700,6 +700,7 @@ namespace Battle
|
||||
{
|
||||
enum ActionType
|
||||
{
|
||||
CANCEL = -3,
|
||||
END_TACTIC_PHASE = -2,
|
||||
INVALID = -1,
|
||||
NO_ACTION = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user