1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Client: implement spectator mode via command-line options

If running with --spectate/-s CPlayerInterface will appear even without human players.
Following command-line options also available:
 --spectate-ignore-hero
 --spectate-hero-speed=N
 --spectate-battle-speed=N
 --spectate-skip-battle
 --spectate-skip-battle-result
Boolean options can also be changed in runtime via client console:
 set spectate-ignore-hero on / off
Spectator mode also:
 - Work with --onlyAI option when starting game or loading saves.
 - Allow to use any cheat codes.
 - Give recon on towns and heroes.
This commit is contained in:
Arseniy Shestakov
2017-06-03 08:25:10 +03:00
parent d95c74941b
commit 18161d3688
24 changed files with 196 additions and 54 deletions

View File

@ -1021,7 +1021,12 @@ void CAdvMapInt::show(SDL_Surface * to)
#endif
for(int i = 0; i < 4; i++)
gems[i]->setFrame(LOCPLINT->playerID.getNum());
{
if(settings["session"]["spectate"].Bool())
gems[i]->setFrame(PlayerColor(1).getNum());
else
gems[i]->setFrame(LOCPLINT->playerID.getNum());
}
if(updateScreen)
{
int3 betterPos = LOCPLINT->repairScreenPos(position);
@ -1481,7 +1486,8 @@ void CAdvMapInt::setPlayer(PlayerColor Player)
void CAdvMapInt::startTurn()
{
state = INGAME;
if(LOCPLINT->cb->getCurrentPlayer() == LOCPLINT->playerID)
if(LOCPLINT->cb->getCurrentPlayer() == LOCPLINT->playerID
|| settings["session"]["spectate"].Bool())
{
adjustActiveness(false);
minimap.setAIRadar(false);
@ -1490,6 +1496,9 @@ void CAdvMapInt::startTurn()
void CAdvMapInt::endingTurn()
{
if(settings["session"]["spectate"].Bool())
return;
if(LOCPLINT->cingconsole->active)
LOCPLINT->cingconsole->deactivate();
LOCPLINT->makingTurn = false;
@ -1817,6 +1826,9 @@ const IShipyard * CAdvMapInt::ourInaccessibleShipyard(const CGObjectInstance *ob
void CAdvMapInt::aiTurnStarted()
{
if(settings["session"]["spectate"].Bool())
return;
adjustActiveness(true);
CCS->musich->playMusicFromSet("enemy-turn", true);
adventureInt->minimap.setAIRadar(true);