mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-27 21:49:10 +02:00
Fix headless mode
This commit is contained in:
parent
6b760089a4
commit
cc7fc4a2c6
@ -588,6 +588,8 @@ float RewardEvaluator::getSkillReward(const CGObjectInstance * target, const CGH
|
|||||||
case Obj::PANDORAS_BOX:
|
case Obj::PANDORAS_BOX:
|
||||||
//Can contains experience, spells, or skills (only on custom maps)
|
//Can contains experience, spells, or skills (only on custom maps)
|
||||||
return 2.5f;
|
return 2.5f;
|
||||||
|
case Obj::PYRAMID:
|
||||||
|
return 3.0f;
|
||||||
case Obj::HERO:
|
case Obj::HERO:
|
||||||
return ai->cb->getPlayerRelations(target->tempOwner, ai->playerID) == PlayerRelations::ENEMIES
|
return ai->cb->getPlayerRelations(target->tempOwner, ai->playerID) == PlayerRelations::ENEMIES
|
||||||
? enemyHeroEliminationSkillRewardRatio * dynamic_cast<const CGHeroInstance *>(target)->level
|
? enemyHeroEliminationSkillRewardRatio * dynamic_cast<const CGHeroInstance *>(target)->level
|
||||||
|
@ -462,9 +462,9 @@ static void mainLoop()
|
|||||||
{
|
{
|
||||||
if(CSH->client)
|
if(CSH->client)
|
||||||
CSH->endGameplay();
|
CSH->endGameplay();
|
||||||
}
|
|
||||||
|
|
||||||
GH.windows().clear();
|
GH.windows().clear();
|
||||||
|
}
|
||||||
|
|
||||||
CMM.reset();
|
CMM.reset();
|
||||||
|
|
||||||
|
@ -617,7 +617,9 @@ bool CServerHandler::validateGameStart(bool allowOnlyAI) const
|
|||||||
void CServerHandler::sendStartGame(bool allowOnlyAI) const
|
void CServerHandler::sendStartGame(bool allowOnlyAI) const
|
||||||
{
|
{
|
||||||
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
|
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
|
||||||
GH.windows().createAndPushWindow<CLoadingScreen>();
|
|
||||||
|
if(!settings["session"]["headless"].Bool())
|
||||||
|
GH.windows().createAndPushWindow<CLoadingScreen>();
|
||||||
|
|
||||||
LobbyStartGame lsg;
|
LobbyStartGame lsg;
|
||||||
if(client)
|
if(client)
|
||||||
|
@ -411,7 +411,7 @@ void CClient::initPlayerEnvironments()
|
|||||||
hasHumanPlayer = true;
|
hasHumanPlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!hasHumanPlayer)
|
if(!hasHumanPlayer && !settings["session"]["headless"].Bool())
|
||||||
{
|
{
|
||||||
Settings session = settings.write["session"];
|
Settings session = settings.write["session"];
|
||||||
session["spectate"].Bool() = true;
|
session["spectate"].Bool() = true;
|
||||||
@ -436,7 +436,7 @@ void CClient::initPlayerInterfaces()
|
|||||||
if(!vstd::contains(playerint, color))
|
if(!vstd::contains(playerint, color))
|
||||||
{
|
{
|
||||||
logNetwork->info("Preparing interface for player %s", color.toString());
|
logNetwork->info("Preparing interface for player %s", color.toString());
|
||||||
if(playerInfo.second.isControlledByAI())
|
if(playerInfo.second.isControlledByAI() || settings["session"]["onlyai"].Bool())
|
||||||
{
|
{
|
||||||
bool alliedToHuman = false;
|
bool alliedToHuman = false;
|
||||||
for(auto & allyInfo : gs->scenarioOps->playerInfos)
|
for(auto & allyInfo : gs->scenarioOps->playerInfos)
|
||||||
|
@ -157,6 +157,9 @@ void ApplyClientNetPackVisitor::visitSetMana(SetMana & pack)
|
|||||||
const CGHeroInstance *h = cl.getHero(pack.hid);
|
const CGHeroInstance *h = cl.getHero(pack.hid);
|
||||||
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroManaPointsChanged, h);
|
callInterfaceIfPresent(cl, h->tempOwner, &IGameEventsReceiver::heroManaPointsChanged, h);
|
||||||
|
|
||||||
|
if(settings["session"]["headless"].Bool())
|
||||||
|
return;
|
||||||
|
|
||||||
for (auto window : GH.windows().findWindows<BattleWindow>())
|
for (auto window : GH.windows().findWindows<BattleWindow>())
|
||||||
window->heroManaPointsChanged(h);
|
window->heroManaPointsChanged(h);
|
||||||
}
|
}
|
||||||
@ -467,7 +470,8 @@ void ApplyFirstClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
|
|||||||
i->second->objectRemoved(o, pack.initiator);
|
i->second->objectRemoved(o, pack.initiator);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGI->mh->waitForOngoingAnimations();
|
if(CGI->mh)
|
||||||
|
CGI->mh->waitForOngoingAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyClientNetPackVisitor::visitRemoveObject(RemoveObject & pack)
|
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
|
// invalidate section of map view with our object and force an update
|
||||||
CGI->mh->onObjectInstantRemove(town, town->getOwner());
|
if(CGI->mh)
|
||||||
CGI->mh->onObjectInstantAdd(town, town->getOwner());
|
{
|
||||||
|
CGI->mh->onObjectInstantRemove(town, town->getOwner());
|
||||||
|
CGI->mh->onObjectInstantAdd(town, town->getOwner());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void ApplyClientNetPackVisitor::visitRazeStructures(RazeStructures & pack)
|
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
|
// invalidate section of map view with our object and force an update
|
||||||
CGI->mh->onObjectInstantRemove(town, town->getOwner());
|
if(CGI->mh)
|
||||||
CGI->mh->onObjectInstantAdd(town, town->getOwner());
|
{
|
||||||
|
CGI->mh->onObjectInstantRemove(town, town->getOwner());
|
||||||
|
CGI->mh->onObjectInstantAdd(town, town->getOwner());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyClientNetPackVisitor::visitSetAvailableCreatures(SetAvailableCreatures & pack)
|
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
|
// 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);
|
auto object = gs.getObjInstance(pack.id);
|
||||||
CGI->mh->onObjectInstantRemove(object, object->getOwner());
|
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
|
// 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);
|
auto object = gs.getObjInstance(pack.id);
|
||||||
CGI->mh->onObjectInstantAdd(object, object->getOwner());
|
CGI->mh->onObjectInstantAdd(object, object->getOwner());
|
||||||
@ -1023,7 +1032,9 @@ void ApplyClientNetPackVisitor::visitNewObject(NewObject & pack)
|
|||||||
if(gs.isVisible(obj, i->first))
|
if(gs.isVisible(obj, i->first))
|
||||||
i->second->newObject(obj);
|
i->second->newObject(obj);
|
||||||
}
|
}
|
||||||
CGI->mh->waitForOngoingAnimations();
|
|
||||||
|
if(CGI->mh)
|
||||||
|
CGI->mh->waitForOngoingAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyClientNetPackVisitor::visitSetAvailableArtifacts(SetAvailableArtifacts & pack)
|
void ApplyClientNetPackVisitor::visitSetAvailableArtifacts(SetAvailableArtifacts & pack)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user