mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-07 00:58:39 +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:
@ -54,7 +54,7 @@ struct NeighborTilesInfo
|
||||
if ( dx + pos.x < 0 || dx + pos.x >= sizes.x
|
||||
|| dy + pos.y < 0 || dy + pos.y >= sizes.y)
|
||||
return false;
|
||||
return visibilityMap[dx+pos.x][dy+pos.y][pos.z];
|
||||
return settings["session"]["spectate"].Bool() ? true : visibilityMap[dx+pos.x][dy+pos.y][pos.z];
|
||||
};
|
||||
d7 = getTile(-1, -1); //789
|
||||
d8 = getTile( 0, -1); //456
|
||||
@ -563,7 +563,7 @@ void CMapHandler::CMapWorldViewBlitter::drawTileOverlay(SDL_Surface * targetSurf
|
||||
const CGObjectInstance * obj = object.obj;
|
||||
|
||||
const bool sameLevel = obj->pos.z == pos.z;
|
||||
const bool isVisible = (*info->visibilityMap)[pos.x][pos.y][pos.z];
|
||||
const bool isVisible = settings["session"]["spectate"].Bool() ? true : (*info->visibilityMap)[pos.x][pos.y][pos.z];
|
||||
const bool isVisitable = obj->visitableAt(pos.x, pos.y);
|
||||
|
||||
if(sameLevel && isVisible && isVisitable)
|
||||
@ -895,7 +895,7 @@ void CMapHandler::CMapBlitter::blit(SDL_Surface * targetSurf, const MapDrawingIn
|
||||
{
|
||||
const TerrainTile2 & tile = parent->ttiles[pos.x][pos.y][pos.z];
|
||||
|
||||
if (!(*info->visibilityMap)[pos.x][pos.y][topTile.z] && !info->showAllTerrain)
|
||||
if(!settings["session"]["spectate"].Bool() && !(*info->visibilityMap)[pos.x][pos.y][topTile.z] && !info->showAllTerrain)
|
||||
drawFow(targetSurf);
|
||||
|
||||
// overlay needs to be drawn over fow, because of artifacts-aura-like spells
|
||||
@ -1099,6 +1099,9 @@ bool CMapHandler::CMapBlitter::canDrawObject(const CGObjectInstance * obj) const
|
||||
|
||||
bool CMapHandler::CMapBlitter::canDrawCurrentTile() const
|
||||
{
|
||||
if(settings["session"]["spectate"].Bool())
|
||||
return true;
|
||||
|
||||
const NeighborTilesInfo neighbors(pos, parent->sizes, *info->visibilityMap);
|
||||
return !neighbors.areAllHidden();
|
||||
}
|
||||
|
Reference in New Issue
Block a user