1
0
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:
Ivan Savenko 2023-08-11 18:50:00 +03:00
parent ad2bd897d0
commit 4b307dc0e4
2 changed files with 8 additions and 0 deletions

View File

@ -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;

View File

@ -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);