mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
More locks to avoid data races on server
This commit is contained in:
parent
ad2bd897d0
commit
4b307dc0e4
@ -6464,6 +6464,8 @@ void CGameHandler::runBattle()
|
||||
|
||||
bool CGameHandler::makeAutomaticAction(const CStack *stack, BattleAction &ba)
|
||||
{
|
||||
boost::unique_lock lock(battleActionMutex);
|
||||
|
||||
BattleSetActiveStack bsa;
|
||||
bsa.stack = stack->unitId();
|
||||
bsa.askPlayerInterface = false;
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "../lib/spells/ISpellMechanics.h"
|
||||
#include "../lib/serializer/Cast.h"
|
||||
|
||||
extern boost::recursive_mutex battleActionMutex;
|
||||
|
||||
void ApplyGhNetPackVisitor::visitSaveGame(SaveGame & pack)
|
||||
{
|
||||
gh.save(pack.fname);
|
||||
@ -280,6 +282,8 @@ void ApplyGhNetPackVisitor::visitQueryReply(QueryReply & pack)
|
||||
|
||||
void ApplyGhNetPackVisitor::visitMakeAction(MakeAction & pack)
|
||||
{
|
||||
boost::unique_lock lock(battleActionMutex);
|
||||
|
||||
const BattleInfo * b = gs.curB;
|
||||
if(!b)
|
||||
gh.throwAndComplain(&pack, "Can not make action - there is no battle ongoing!");
|
||||
@ -307,6 +311,8 @@ void ApplyGhNetPackVisitor::visitMakeAction(MakeAction & pack)
|
||||
|
||||
void ApplyGhNetPackVisitor::visitMakeCustomAction(MakeCustomAction & pack)
|
||||
{
|
||||
boost::unique_lock lock(battleActionMutex);
|
||||
|
||||
const BattleInfo * b = gs.curB;
|
||||
if(!b)
|
||||
gh.throwNotAllowedAction(&pack);
|
||||
|
Loading…
x
Reference in New Issue
Block a user