1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Client: fix headless mode and add automated testing mode

Command-line option --noGUI replaced with --headless.
Added option --testmap that will run specified map with AI players
This commit is contained in:
Arseniy Shestakov
2017-03-12 10:54:24 +03:00
parent 9f1451c1a3
commit f7f7fe1d32
3 changed files with 76 additions and 40 deletions

View File

@@ -283,13 +283,13 @@ void GiveBonus::applyCl(CClient *cl)
void ChangeObjPos::applyFirstCl(CClient *cl)
{
CGObjectInstance *obj = GS(cl)->getObjInstance(objid);
if(flags & 1)
if(flags & 1 && CGI->mh)
CGI->mh->hideObject(obj);
}
void ChangeObjPos::applyCl(CClient *cl)
{
CGObjectInstance *obj = GS(cl)->getObjInstance(objid);
if(flags & 1)
if(flags & 1 && CGI->mh)
CGI->mh->printObject(obj);
cl->invalidatePaths();
@@ -335,7 +335,8 @@ void RemoveObject::applyFirstCl(CClient *cl)
{
const CGObjectInstance *o = cl->getObj(id);
CGI->mh->hideObject(o, true);
if(CGI->mh)
CGI->mh->hideObject(o, true);
//notify interfaces about removal
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
@@ -365,10 +366,12 @@ void TryMoveHero::applyFirstCl(CClient *cl)
humanKnows = true;
}
if(!CGI->mh)
return;
if(result == TELEPORTATION || result == EMBARK || result == DISEMBARK || !humanKnows)
CGI->mh->hideObject(h, result == EMBARK && humanKnows);
if(result == DISEMBARK)
CGI->mh->printObject(h->boat);
}
@@ -378,13 +381,14 @@ void TryMoveHero::applyCl(CClient *cl)
const CGHeroInstance *h = cl->getHero(id);
cl->invalidatePaths();
if(result == TELEPORTATION || result == EMBARK || result == DISEMBARK)
if(CGI->mh)
{
CGI->mh->printObject(h, result == DISEMBARK);
}
if(result == TELEPORTATION || result == EMBARK || result == DISEMBARK)
CGI->mh->printObject(h, result == DISEMBARK);
if(result == EMBARK)
CGI->mh->hideObject(h->boat);
if(result == EMBARK)
CGI->mh->hideObject(h->boat);
}
PlayerColor player = h->tempOwner;
@@ -403,10 +407,10 @@ void TryMoveHero::applyCl(CClient *cl)
}
}
if(!humanKnows) //maphandler didn't get update from playerint, do it now
{ //TODO: restructure nicely
//maphandler didn't get update from playerint, do it now
//TODO: restructure nicely
if(!humanKnows && CGI->mh)
CGI->mh->printObject(h);
}
}
void NewStructures::applyCl(CClient *cl)
@@ -482,22 +486,22 @@ void HeroRecruited::applyCl(CClient *cl)
needsPrinting = false;
}
}
if (needsPrinting)
{
if(needsPrinting && CGI->mh)
CGI->mh->printObject(h);
}
}
void GiveHero::applyCl(CClient *cl)
{
CGHeroInstance *h = GS(cl)->getHero(id);
CGI->mh->printObject(h);
if(CGI->mh)
CGI->mh->printObject(h);
cl->playerint[h->tempOwner]->heroCreated(h);
}
void GiveHero::applyFirstCl(CClient *cl)
{
CGI->mh->hideObject(GS(cl)->getHero(id));
if(CGI->mh)
CGI->mh->hideObject(GS(cl)->getHero(id));
}
void InfoWindow::applyCl(CClient *cl)
@@ -904,7 +908,8 @@ void NewObject::applyCl(CClient *cl)
cl->invalidatePaths();
const CGObjectInstance *obj = cl->getObj(id);
CGI->mh->printObject(obj, true);
if(CGI->mh)
CGI->mh->printObject(obj, true);
for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
{