mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-11 13:15:38 +02:00
[programming challenge] Don't dramatically crash upon illegal tatics movement.
This commit is contained in:
parent
7b081de638
commit
2691fd62f4
@ -16,6 +16,16 @@ CBattleCallback::CBattleCallback(CGameState *GS, int Player, IConnectionHandler
|
|||||||
bool CBattleCallback::battleMakeTacticAction( BattleAction * action )
|
bool CBattleCallback::battleMakeTacticAction( BattleAction * action )
|
||||||
{
|
{
|
||||||
assert(gs->curB->tacticDistance);
|
assert(gs->curB->tacticDistance);
|
||||||
|
if(action->actionType == BattleAction::WALK)
|
||||||
|
{
|
||||||
|
if(!gs->curB->isInTacticRange(action->destinationTile))
|
||||||
|
{
|
||||||
|
tlog0 << "Requesting movement to tile that is not in tactics range? Illegal!\n";
|
||||||
|
if(!action->destinationTile.isValid())
|
||||||
|
tlog0 << "Moreover the hex is invalid!!!\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
MakeAction ma;
|
MakeAction ma;
|
||||||
ma.ba = *action;
|
ma.ba = *action;
|
||||||
sendRequest(&ma);
|
sendRequest(&ma);
|
||||||
|
@ -643,7 +643,7 @@ void CVCMIServer::startDuel(const std::string &battle, const std::string &leftAI
|
|||||||
testMem.set(true);
|
testMem.set(true);
|
||||||
boost::thread* memMon = new boost::thread(boost::bind(memoryMonitor, PIDs[0], PIDs[1], PIDs[2]));
|
boost::thread* memMon = new boost::thread(boost::bind(memoryMonitor, PIDs[0], PIDs[1], PIDs[2]));
|
||||||
|
|
||||||
std::string logFName = LOGS_DIR + "/duel_log.vdat";
|
std::string logFName = LOGS_DIR + "/" + leftAI + "_vs_"+rightAI+"_on_" + battle + ".vdat";
|
||||||
tlog0 << "Logging battle activities (for replay possibility) in " << logFName << std::endl;
|
tlog0 << "Logging battle activities (for replay possibility) in " << logFName << std::endl;
|
||||||
gh->gameLog = new CSaveFile(logFName);
|
gh->gameLog = new CSaveFile(logFName);
|
||||||
gh->gameLog->smartPointerSerialization = false;
|
gh->gameLog->smartPointerSerialization = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user