mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-27 12:22:45 +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
|
//tidy up
|
||||||
BattleAction ret = *(b->givenCommand->data);
|
BattleAction ret = *(b->givenCommand->data);
|
||||||
//todo: remove this evil hack
|
vstd::clear_pointer(b->givenCommand->data);
|
||||||
//dirty evil hack...
|
|
||||||
//if active stack was changed, new thread was started for new active stack but we will receive notification too
|
if(ret.actionType == Battle::CANCEL)
|
||||||
//we need check that givenCommand is for our stack (use ID as stack object may be even destroyed)
|
|
||||||
if(stackId != ret.stackNumber)
|
|
||||||
{
|
{
|
||||||
logGlobal->traceStream() << "Interrupted command for " << stackName;
|
if(stackId != ret.stackNumber)
|
||||||
throw boost::thread_interrupted();
|
logGlobal->error("Not current active stack action canceled");
|
||||||
|
logGlobal->traceStream() << "Canceled command for " << stackName;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
logGlobal->traceStream() << "Giving command for " << stackName;
|
||||||
|
|
||||||
delete b->givenCommand->data;
|
|
||||||
b->givenCommand->data = nullptr;
|
|
||||||
|
|
||||||
//return command
|
|
||||||
logGlobal->traceStream() << "Giving command for " << stackName;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,9 +140,12 @@ void CClient::waitForMoveAndSend(PlayerColor color)
|
|||||||
setThreadName("CClient::waitForMoveAndSend");
|
setThreadName("CClient::waitForMoveAndSend");
|
||||||
assert(vstd::contains(battleints, color));
|
assert(vstd::contains(battleints, color));
|
||||||
BattleAction ba = battleints[color]->activeStack(gs->curB->battleGetStackByID(gs->curB->activeStack, false));
|
BattleAction ba = battleints[color]->activeStack(gs->curB->battleGetStackByID(gs->curB->activeStack, false));
|
||||||
logNetwork->traceStream() << "Send battle action to server: " << ba;
|
if(ba.actionType != Battle::CANCEL)
|
||||||
MakeAction temp_action(ba);
|
{
|
||||||
sendRequest(&temp_action, color);
|
logNetwork->traceStream() << "Send battle action to server: " << ba;
|
||||||
|
MakeAction temp_action(ba);
|
||||||
|
sendRequest(&temp_action, color);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch(boost::thread_interrupted&)
|
catch(boost::thread_interrupted&)
|
||||||
|
@ -1009,6 +1009,11 @@ void CBattleInterface::stackRemoved(int stackID)
|
|||||||
{
|
{
|
||||||
if(activeStack->ID == 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);
|
setActiveStack(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,6 +700,7 @@ namespace Battle
|
|||||||
{
|
{
|
||||||
enum ActionType
|
enum ActionType
|
||||||
{
|
{
|
||||||
|
CANCEL = -3,
|
||||||
END_TACTIC_PHASE = -2,
|
END_TACTIC_PHASE = -2,
|
||||||
INVALID = -1,
|
INVALID = -1,
|
||||||
NO_ACTION = 0,
|
NO_ACTION = 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user