mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed (unnecessary?) deadlock in BattleStacksRemoved. Daemon summoning is pretty functional.
This commit is contained in:
parent
07b8f87fb7
commit
f1f416c890
@ -640,6 +640,7 @@ void CPlayerInterface::battleNewStackAppeared(const CStack * stack)
|
||||
|
||||
//changing necessary things in battle interface
|
||||
battleInt->newStack(stack);
|
||||
//battleInt->addNewAnim(new CDummyAnim(battleInt, 2)); //wait a moment
|
||||
}
|
||||
|
||||
void CPlayerInterface::battleObstaclesRemoved(const std::set<si32> & removedObstacles)
|
||||
@ -682,7 +683,7 @@ void CPlayerInterface::battleStacksRemoved(const BattleStacksRemoved & bsr)
|
||||
return;
|
||||
}
|
||||
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
//boost::unique_lock<boost::recursive_mutex> un(*pim); //fixme: this one caused deadlock
|
||||
for(std::set<ui32>::const_iterator it = bsr.stackIDs.begin(); it != bsr.stackIDs.end(); ++it) //for each removed stack
|
||||
{
|
||||
battleInt->stackRemoved(*it);
|
||||
|
@ -1502,6 +1502,26 @@ struct BattleStackAdded : public CPackForClient //3017
|
||||
}
|
||||
};
|
||||
|
||||
struct BattleSetStackProperty : public CPackForClient //3018
|
||||
{
|
||||
struct BattleSetStackProperty(){type = 3018;};
|
||||
|
||||
enum BattleStackProperty {CASTS, CURRENT_SPELL};
|
||||
|
||||
DLL_EXPORT void applyGs(CGameState *gs);
|
||||
//void applyCl(CClient *cl){};
|
||||
|
||||
int stackID;
|
||||
int which; //using enum values
|
||||
int val;
|
||||
int absolute;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & stackID & which & val & absolute;
|
||||
}
|
||||
};
|
||||
|
||||
struct ShowInInfobox : public CPackForClient //107
|
||||
{
|
||||
ShowInInfobox(){type = 107;};
|
||||
|
@ -1276,6 +1276,22 @@ DLL_EXPORT void BattleStackAdded::applyGs(CGameState *gs)
|
||||
gs->curB->stacks.push_back(summonedStack); //the stack is not "SUMMONED", it is permanent
|
||||
}
|
||||
|
||||
DLL_EXPORT void BattleSetStackProperty::applyGs(CGameState *gs)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
case CASTS:
|
||||
{
|
||||
if (absolute)
|
||||
gs->curB->stacks[stackID]->casts = val;
|
||||
else
|
||||
gs->curB->stacks[stackID]->casts--;
|
||||
amax(gs->curB->stacks[stackID]->casts, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT void YourTurn::applyGs( CGameState *gs )
|
||||
{
|
||||
gs->currentPlayer = player;
|
||||
|
@ -150,6 +150,7 @@ void registerTypes2(Serializer &s)
|
||||
s.template registerType<EndAction>();
|
||||
s.template registerType<BattleSpellCast>();
|
||||
s.template registerType<SetStackEffect>();
|
||||
s.template registerType<BattleSetStackProperty>();
|
||||
s.template registerType<StacksInjured>();
|
||||
s.template registerType<BattleResultsApplied>();
|
||||
s.template registerType<StacksHealedOrResurrected>();
|
||||
|
@ -3309,6 +3309,13 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
bsr.stackIDs.insert(destStack->ID);
|
||||
sendAndApply(&bsr);
|
||||
sendAndApply(&bsa);
|
||||
|
||||
BattleSetStackProperty ssp;
|
||||
ssp.stackID = ba.stackNumber;
|
||||
ssp.which = BattleSetStackProperty::CASTS;
|
||||
ssp.val = -1;
|
||||
ssp.absolute = false;
|
||||
sendAndApply(&ssp);
|
||||
}
|
||||
|
||||
sendAndApply(&end_action);
|
||||
|
Loading…
Reference in New Issue
Block a user