diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index 77411dac6..d01ea5e22 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -588,6 +588,8 @@ float RewardEvaluator::getSkillReward(const CGObjectInstance * target, const CGH case Obj::PANDORAS_BOX: //Can contains experience, spells, or skills (only on custom maps) return 2.5f; + case Obj::PYRAMID: + return 3.0f; case Obj::HERO: return ai->cb->getPlayerRelations(target->tempOwner, ai->playerID) == PlayerRelations::ENEMIES ? enemyHeroEliminationSkillRewardRatio * dynamic_cast(target)->level diff --git a/client/CMT.cpp b/client/CMT.cpp index e3b6780f9..8ad12ae73 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -462,9 +462,9 @@ static void mainLoop() { if(CSH->client) CSH->endGameplay(); - } - GH.windows().clear(); + GH.windows().clear(); + } CMM.reset(); diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index 4b3ef7adf..ee3f47164 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -617,7 +617,9 @@ bool CServerHandler::validateGameStart(bool allowOnlyAI) const void CServerHandler::sendStartGame(bool allowOnlyAI) const { verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool()); - GH.windows().createAndPushWindow(); + + if(!settings["session"]["headless"].Bool()) + GH.windows().createAndPushWindow(); LobbyStartGame lsg; if(client) diff --git a/client/Client.cpp b/client/Client.cpp index 10c2b64e9..f5cba4024 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -411,7 +411,7 @@ void CClient::initPlayerEnvironments() hasHumanPlayer = true; } - if(!hasHumanPlayer) + if(!hasHumanPlayer && !settings["session"]["headless"].Bool()) { Settings session = settings.write["session"]; session["spectate"].Bool() = true; @@ -436,7 +436,7 @@ void CClient::initPlayerInterfaces() if(!vstd::contains(playerint, color)) { logNetwork->info("Preparing interface for player %s", color.toString()); - if(playerInfo.second.isControlledByAI()) + if(playerInfo.second.isControlledByAI() || settings["session"]["onlyai"].Bool()) { bool alliedToHuman = false; for(auto & allyInfo : gs->scenarioOps->playerInfos) diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 1b7ab14c1..2d9e89eaf 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -157,6 +157,9 @@ void ApplyClientNetPackVisitor::visitSetMana(SetMana & pack) const CGHeroInstance *h = cl.getHero(pack.hid); callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroManaPointsChanged, h); + if(settings["session"]["headless"].Bool()) + return; + for (auto window : GH.windows().findWindows()) window->heroManaPointsChanged(h); } @@ -467,7 +470,8 @@ void ApplyFirstClientNetPackVisitor::visitRemoveObject(RemoveObject & pack) i->second->objectRemoved(o, pack.initiator); } - CGI->mh->waitForOngoingAnimations(); + if(CGI->mh) + CGI->mh->waitForOngoingAnimations(); } void ApplyClientNetPackVisitor::visitRemoveObject(RemoveObject & pack) @@ -553,9 +557,11 @@ void ApplyClientNetPackVisitor::visitNewStructures(NewStructures & pack) } // invalidate section of map view with our object and force an update - CGI->mh->onObjectInstantRemove(town, town->getOwner()); - CGI->mh->onObjectInstantAdd(town, town->getOwner()); - + if(CGI->mh) + { + CGI->mh->onObjectInstantRemove(town, town->getOwner()); + CGI->mh->onObjectInstantAdd(town, town->getOwner()); + } } void ApplyClientNetPackVisitor::visitRazeStructures(RazeStructures & pack) { @@ -566,8 +572,11 @@ void ApplyClientNetPackVisitor::visitRazeStructures(RazeStructures & pack) } // invalidate section of map view with our object and force an update - CGI->mh->onObjectInstantRemove(town, town->getOwner()); - CGI->mh->onObjectInstantAdd(town, town->getOwner()); + if(CGI->mh) + { + CGI->mh->onObjectInstantRemove(town, town->getOwner()); + CGI->mh->onObjectInstantAdd(town, town->getOwner()); + } } void ApplyClientNetPackVisitor::visitSetAvailableCreatures(SetAvailableCreatures & pack) @@ -651,7 +660,7 @@ void ApplyFirstClientNetPackVisitor::visitSetObjectProperty(SetObjectProperty & } // invalidate section of map view with our object and force an update with new flag color - if (pack.what == ObjProperty::OWNER) + if (pack.what == ObjProperty::OWNER && CGI->mh) { auto object = gs.getObjInstance(pack.id); CGI->mh->onObjectInstantRemove(object, object->getOwner()); @@ -668,7 +677,7 @@ void ApplyClientNetPackVisitor::visitSetObjectProperty(SetObjectProperty & pack) } // invalidate section of map view with our object and force an update with new flag color - if (pack.what == ObjProperty::OWNER) + if (pack.what == ObjProperty::OWNER && CGI->mh) { auto object = gs.getObjInstance(pack.id); CGI->mh->onObjectInstantAdd(object, object->getOwner()); @@ -1023,7 +1032,9 @@ void ApplyClientNetPackVisitor::visitNewObject(NewObject & pack) if(gs.isVisible(obj, i->first)) i->second->newObject(obj); } - CGI->mh->waitForOngoingAnimations(); + + if(CGI->mh) + CGI->mh->waitForOngoingAnimations(); } void ApplyClientNetPackVisitor::visitSetAvailableArtifacts(SetAvailableArtifacts & pack)