From 36a6123dd24e7f61ee5a12f0ff9e6e41ee23104e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 9 Apr 2010 19:59:16 +1200 Subject: [PATCH] Fix GPS/Disabled shroud --- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/Graphics/TerrainRenderer.cs | 11 +++++++---- OpenRA.Game/Graphics/WorldRenderer.cs | 2 +- OpenRA.Game/ShroudRenderer.cs | 18 +++++++++++++----- OpenRA.Mods.RA/GpsPower.cs | 4 ++-- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 1f604f6b4a..f57193e974 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -151,7 +151,7 @@ namespace OpenRA public static void LoadMap(string mapName) { Timer.Time( "----LoadMap" ); - + SheetBuilder.Initialize(renderer); var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods); Timer.Time( "manifest: {0}" ); diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index 5ccc5c4610..5a94f93748 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -17,7 +17,7 @@ * along with OpenRA. If not, see . */ #endregion - +using System; using System.Drawing; using OpenRA.FileFormats; using OpenRA.FileFormats.Graphics; @@ -47,6 +47,8 @@ namespace OpenRA.Graphics Vertex[] vertices = new Vertex[4 * map.Height * map.Width]; ushort[] indices = new ushort[6 * map.Height * map.Width]; + terrainSheet = tileMapping[map.MapTiles[map.TopLeft.X, map.TopLeft.Y]].sheet; + int nv = 0; int ni = 0; for( int j = map.TopLeft.Y ; j < map.BottomRight.Y; j++ ) @@ -58,10 +60,11 @@ namespace OpenRA.Graphics Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size); nv += 4; ni += 6; + + if (tileMapping[map.MapTiles[i, j]].sheet != terrainSheet) + throw new InvalidOperationException("Terrain sprites span multiple sheets"); } - terrainSheet = tileMapping[map.MapTiles[map.TopLeft.X, map.TopLeft.Y]].sheet; - vertexBuffer = renderer.Device.CreateVertexBuffer( vertices.Length ); vertexBuffer.SetData( vertices ); @@ -85,7 +88,7 @@ namespace OpenRA.Graphics if (firstRow < 0) firstRow = 0; if (lastRow > map.Height) lastRow = map.Height; - if (!Game.world.LocalPlayer.Shroud.HasGPS && Game.world.LocalPlayer.Shroud.bounds.HasValue) + if (!Game.world.LocalPlayer.Shroud.Disabled && Game.world.LocalPlayer.Shroud.bounds.HasValue) { var r = Game.world.LocalPlayer.Shroud.bounds.Value; if (firstRow < r.Top - map.YOffset) diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 670ff89f45..6599b305f4 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -84,7 +84,7 @@ namespace OpenRA.Graphics Rectangle GetBoundsRect() { - if (!world.LocalPlayer.Shroud.HasGPS && world.LocalPlayer.Shroud.bounds.HasValue) + if (!world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.bounds.HasValue) { var r = world.LocalPlayer.Shroud.bounds.Value; diff --git a/OpenRA.Game/ShroudRenderer.cs b/OpenRA.Game/ShroudRenderer.cs index 0c32d136ef..5f3977e7a6 100644 --- a/OpenRA.Game/ShroudRenderer.cs +++ b/OpenRA.Game/ShroudRenderer.cs @@ -32,7 +32,7 @@ namespace OpenRA Sprite[,] sprites, fogSprites; bool dirty = true; - bool hasGPS = false; + bool disabled = false; Player owner; Map map; @@ -50,14 +50,19 @@ namespace OpenRA shroud.Dirty += () => dirty = true; } - public bool HasGPS + public bool Disabled { - get { return hasGPS; } - set { hasGPS = value; dirty = true;} + get { return disabled; } + set { disabled = value; dirty = true;} } public bool IsExplored(int2 xy) { return IsExplored(xy.X, xy.Y); } - bool IsExplored(int x, int y) { return shroud.exploredCells[x,y]; } + bool IsExplored(int x, int y) + { + if (disabled) + return true; + return shroud.exploredCells[x,y]; + } public bool DisplayOnRadar(int x, int y) { return IsExplored(x, y); } @@ -132,6 +137,9 @@ namespace OpenRA internal void Draw(SpriteRenderer r) { + if (disabled) + return; + if (dirty) { dirty = false; diff --git a/OpenRA.Mods.RA/GpsPower.cs b/OpenRA.Mods.RA/GpsPower.cs index a2f78654b5..c6aa8f7610 100644 --- a/OpenRA.Mods.RA/GpsPower.cs +++ b/OpenRA.Mods.RA/GpsPower.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA w.Add(new SatelliteLaunch(launchSite)); w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25, - () => Owner.Shroud.HasGPS = true)); + () => Owner.Shroud.Disabled = true)); }); FinishActivate();