mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Fix locking of mutexes by StupidAI
This commit is contained in:
parent
a280cc8845
commit
e23166df88
@ -59,7 +59,8 @@ class CBattleAI : public CBattleGameInterface
|
||||
std::shared_ptr<Environment> env;
|
||||
|
||||
//Previous setting of cb
|
||||
bool wasWaitingForRealize, wasUnlockingGs;
|
||||
bool wasWaitingForRealize;
|
||||
bool wasUnlockingGs;
|
||||
int movesSkippedByDefense;
|
||||
|
||||
public:
|
||||
|
@ -18,14 +18,21 @@ static std::shared_ptr<CBattleCallback> cbc;
|
||||
|
||||
CStupidAI::CStupidAI()
|
||||
: side(-1)
|
||||
, wasWaitingForRealize(false)
|
||||
, wasUnlockingGs(false)
|
||||
{
|
||||
print("created");
|
||||
}
|
||||
|
||||
|
||||
CStupidAI::~CStupidAI()
|
||||
{
|
||||
print("destroyed");
|
||||
if(cb)
|
||||
{
|
||||
//Restore previous state of CB - it may be shared with the main AI (like VCAI)
|
||||
cb->waitTillRealize = wasWaitingForRealize;
|
||||
cb->unlockGsWhenWaiting = wasUnlockingGs;
|
||||
}
|
||||
}
|
||||
|
||||
void CStupidAI::initBattleInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CBattleCallback> CB)
|
||||
@ -33,6 +40,11 @@ void CStupidAI::initBattleInterface(std::shared_ptr<Environment> ENV, std::share
|
||||
print("init called, saving ptr to IBattleCallback");
|
||||
env = ENV;
|
||||
cbc = cb = CB;
|
||||
|
||||
wasWaitingForRealize = CB->waitTillRealize;
|
||||
wasUnlockingGs = CB->unlockGsWhenWaiting;
|
||||
CB->waitTillRealize = false;
|
||||
CB->unlockGsWhenWaiting = false;
|
||||
}
|
||||
|
||||
void CStupidAI::actionFinished(const BattleAction &action)
|
||||
|
@ -20,6 +20,9 @@ class CStupidAI : public CBattleGameInterface
|
||||
std::shared_ptr<CBattleCallback> cb;
|
||||
std::shared_ptr<Environment> env;
|
||||
|
||||
bool wasWaitingForRealize;
|
||||
bool wasUnlockingGs;
|
||||
|
||||
void print(const std::string &text) const;
|
||||
public:
|
||||
CStupidAI();
|
||||
|
Loading…
Reference in New Issue
Block a user