mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +02:00
"More stable" opening AI.
This commit is contained in:
parent
0e826915ed
commit
5b919d88eb
@ -71,9 +71,12 @@ CBattleAI::~CBattleAI(void)
|
|||||||
{
|
{
|
||||||
print("destroyed");
|
print("destroyed");
|
||||||
|
|
||||||
//Restore previous state of CB - it may be shared with the main AI (like VCAI)
|
if(cb)
|
||||||
cb->waitTillRealize = wasWaitingForRealize;
|
{
|
||||||
cb->unlockGsWhenWaiting = wasUnlockingGs;
|
//Restore previous state of CB - it may be shared with the main AI (like VCAI)
|
||||||
|
cb->waitTillRealize = wasWaitingForRealize;
|
||||||
|
cb->unlockGsWhenWaiting = wasUnlockingGs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleAI::init( CBattleCallback * CB )
|
void CBattleAI::init( CBattleCallback * CB )
|
||||||
|
@ -616,16 +616,20 @@ void processCommand(const std::string &message)
|
|||||||
std::string fname;
|
std::string fname;
|
||||||
readed >> fname;
|
readed >> fname;
|
||||||
tlog0 << "Will try loading that AI to see if it is correct name...\n";
|
tlog0 << "Will try loading that AI to see if it is correct name...\n";
|
||||||
if(auto ai = CDynLibHandler::getNewBattleAI(fname)) //test that given AI is indeed available... heavy but it is easy to make a typo and break the game
|
try
|
||||||
{
|
{
|
||||||
delete ai;
|
if(auto ai = CDynLibHandler::getNewBattleAI(fname)) //test that given AI is indeed available... heavy but it is easy to make a typo and break the game
|
||||||
Settings neutralAI = settings.write["server"]["neutralAI"];
|
{
|
||||||
neutralAI->String() = fname;
|
delete ai;
|
||||||
tlog0 << "Setting changed, from now the battle ai will be " << fname << "!\n";
|
Settings neutralAI = settings.write["server"]["neutralAI"];
|
||||||
|
neutralAI->String() = fname;
|
||||||
|
tlog0 << "Setting changed, from now the battle ai will be " << fname << "!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
tlog3 << "Setting not changes, no such AI found!\n";
|
tlog3 << "Failed opening " << fname << ": " << e.what() << std::endl;
|
||||||
|
tlog3 << "Setting not changes, AI not found or invalid!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(client && client->serv && client->serv->connected && LOCPLINT) //send to server
|
else if(client && client->serv && client->serv->connected && LOCPLINT) //send to server
|
||||||
|
@ -51,6 +51,12 @@ rett * createAny(std::string dllname, std::string methodName)
|
|||||||
tlog1 << "Cannot open dynamic library ("<<dllname<<"). Throwing..."<<std::endl;
|
tlog1 << "Cannot open dynamic library ("<<dllname<<"). Throwing..."<<std::endl;
|
||||||
throw std::runtime_error("Cannot open dynamic library");
|
throw std::runtime_error("Cannot open dynamic library");
|
||||||
}
|
}
|
||||||
|
else if(!getName || !getAI)
|
||||||
|
{
|
||||||
|
tlog1 << dllname << " does not export method " << methodName << std::endl;
|
||||||
|
FreeLibrary(dll);
|
||||||
|
throw std::runtime_error("Cannot find method " + methodName);
|
||||||
|
}
|
||||||
|
|
||||||
getName(temp);
|
getName(temp);
|
||||||
tlog0 << "Loaded " << temp << std::endl;
|
tlog0 << "Loaded " << temp << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user