Render shellmap / don't assume Game.Localplayer exists

This commit is contained in:
Paul Chote
2010-04-09 20:11:29 +12:00
parent 36a6123dd2
commit 1078fc380a
6 changed files with 10 additions and 14 deletions

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Graphics
if (firstRow < 0) firstRow = 0;
if (lastRow > map.Height) lastRow = map.Height;
if (!Game.world.LocalPlayer.Shroud.Disabled && Game.world.LocalPlayer.Shroud.bounds.HasValue)
if (Game.world.LocalPlayer != null && !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)

View File

@@ -72,12 +72,10 @@ namespace OpenRA.Graphics
float2 r2 = new float2(-1, 1);
renderer.BeginFrame(r1, r2, scrollPosition.ToInt2());
world.WorldRenderer.Draw();
if( Game.orderManager.GameStarted )
{
world.WorldRenderer.Draw();
Game.chrome.Draw( world );
Game.chrome.Draw( world );
if( Game.orderManager.Connection.ConnectionState == ConnectionState.NotConnected )
Game.chrome.DrawDialog("Connection lost.");

View File

@@ -84,7 +84,7 @@ namespace OpenRA.Graphics
Rectangle GetBoundsRect()
{
if (!world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.bounds.HasValue)
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.bounds.HasValue)
{
var r = world.LocalPlayer.Shroud.bounds.Value;
@@ -136,7 +136,8 @@ namespace OpenRA.Graphics
if (Game.controller.orderGenerator != null)
Game.controller.orderGenerator.Render(world);
world.LocalPlayer.Shroud.Draw(spriteRenderer);
if (world.LocalPlayer != null)
world.LocalPlayer.Shroud.Draw(spriteRenderer);
spriteRenderer.Flush();

View File

@@ -85,7 +85,6 @@ namespace OpenRA.Traits
public void Render()
{
var shroud = world.LocalPlayer.Shroud;
var tl = world.Map.TopLeft;
var br = world.Map.BottomRight;
@@ -93,7 +92,7 @@ namespace OpenRA.Traits
for (int y = tl.Y; y < br.Y; y++)
{
var t = new int2(x, y);
if (!shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
spriteRenderer.DrawSprite(bibSprites[tiles[x,y].type- 1][tiles[x,y].image],
Game.CellSize * (float2)t, "terrain");

View File

@@ -44,13 +44,12 @@ namespace OpenRA.Traits
public void Render()
{
var shroud = Game.world.LocalPlayer.Shroud;
var map = Game.world.Map;
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
for (int x = map.XOffset; x < map.XOffset + map.Width; x++)
{
if (!shroud.IsExplored(new int2(x, y))) continue;
if (Game.world.LocalPlayer != null && !Game.world.LocalPlayer.Shroud.IsExplored(new int2(x, y))) continue;
var c = content[x, y];
if (c.image != null)

View File

@@ -83,7 +83,6 @@ namespace OpenRA.Traits
public void Render()
{
var shroud = world.LocalPlayer.Shroud;
var tl = world.Map.TopLeft;
var br = world.Map.BottomRight;
@@ -91,8 +90,8 @@ namespace OpenRA.Traits
for (int y = tl.Y; y < br.Y; y++)
{
var t = new int2(x, y);
if (!shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
spriteRenderer.DrawSprite(smudgeSprites[tiles[x,y].type- 1][tiles[x,y].image],
Game.CellSize * (float2)t, "terrain");
}