pass world into CheckSync. don't pass world into Widget.DrawInner
This commit is contained in:
@@ -100,7 +100,7 @@ namespace OpenRA.Graphics
|
||||
renderer.BeginFrame(scrollPosition);
|
||||
wr.Draw();
|
||||
|
||||
Widget.DoDraw(world);
|
||||
Widget.DoDraw();
|
||||
|
||||
var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
|
||||
var c = new Cursor(cursorName);
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace OpenRA.Graphics
|
||||
world.OrderGenerator.RenderAfterWorld(this, world);
|
||||
|
||||
if (world.LocalPlayer != null)
|
||||
world.LocalPlayer.Shroud.Draw();
|
||||
world.LocalPlayer.Shroud.Draw( this );
|
||||
|
||||
Game.Renderer.DisableScissor();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Network
|
||||
if( packet.Length == 5 && packet[ 4 ] == 0xBF )
|
||||
frameData.ClientQuit( clientId, frame );
|
||||
else if( packet.Length >= 5 && packet[ 4 ] == 0x65 )
|
||||
CheckSync( packet );
|
||||
CheckSync( world, packet );
|
||||
else if( frame == 0 )
|
||||
immediatePackets.Add( Pair.New( clientId, packet ) );
|
||||
else
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Network
|
||||
|
||||
Dictionary<int, byte[]> syncForFrame = new Dictionary<int, byte[]>();
|
||||
|
||||
void CheckSync(byte[] packet)
|
||||
void CheckSync(World world, byte[] packet)
|
||||
{
|
||||
var frame = BitConverter.ToInt32(packet, 0);
|
||||
byte[] existingSync;
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Network
|
||||
if (i < SyncHeaderSize)
|
||||
OutOfSync(frame, "Tick");
|
||||
else
|
||||
OutOfSync(frame, (i - SyncHeaderSize) / 4);
|
||||
OutOfSync(world, frame, (i - SyncHeaderSize) / 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,9 +125,9 @@ namespace OpenRA.Network
|
||||
syncForFrame.Add(frame, packet);
|
||||
}
|
||||
|
||||
void OutOfSync(int frame, int index)
|
||||
void OutOfSync( World world, int frame, int index)
|
||||
{
|
||||
var order = frameData.OrdersForFrame( Game.world, frame ).ElementAt(index);
|
||||
var order = frameData.OrdersForFrame( world, frame ).ElementAt(index);
|
||||
throw new InvalidOperationException("Out of sync in frame {0}.\n {1}".F(frame, order.Order.ToString()));
|
||||
}
|
||||
|
||||
@@ -166,9 +166,9 @@ namespace OpenRA.Network
|
||||
var ss = sync.SerializeSync( FrameNumber );
|
||||
Connection.Send( ss );
|
||||
|
||||
syncReport.UpdateSyncReport();
|
||||
syncReport.UpdateSyncReport( world );
|
||||
|
||||
CheckSync( ss );
|
||||
CheckSync( world, ss );
|
||||
|
||||
++FrameNumber;
|
||||
}
|
||||
|
||||
@@ -19,21 +19,21 @@ namespace OpenRA.Network
|
||||
syncReports[i] = new SyncReport.Report();
|
||||
}
|
||||
|
||||
internal void UpdateSyncReport()
|
||||
internal void UpdateSyncReport( World world )
|
||||
{
|
||||
if (!Game.Settings.Debug.RecordSyncReports)
|
||||
return;
|
||||
|
||||
GenerateSyncReport(syncReports[curIndex]);
|
||||
GenerateSyncReport(world, syncReports[curIndex]);
|
||||
curIndex = ++curIndex % numSyncReports;
|
||||
}
|
||||
|
||||
void GenerateSyncReport(Report report)
|
||||
void GenerateSyncReport(World world, Report report)
|
||||
{
|
||||
report.Frame = Game.orderManager.FrameNumber;
|
||||
report.SyncedRandom = Game.world.SharedRandom.Last;
|
||||
report.SyncedRandom = world.SharedRandom.Last;
|
||||
report.Traits.Clear();
|
||||
foreach (var a in Game.world.Queries.WithTraitMultiple<object>())
|
||||
foreach (var a in world.Queries.WithTraitMultiple<object>())
|
||||
{
|
||||
var sync = Sync.CalculateSyncHash(a.Trait);
|
||||
if (sync != 0)
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA
|
||||
return shadowBits[SpecialShroudTiles[u ^ uSides][v]];
|
||||
}
|
||||
|
||||
internal void Draw()
|
||||
internal void Draw( WorldRenderer wr )
|
||||
{
|
||||
if (disabled)
|
||||
return;
|
||||
@@ -150,13 +150,13 @@ namespace OpenRA
|
||||
var minx = clipRect.Left;
|
||||
var maxx = clipRect.Right;
|
||||
|
||||
DrawShroud( minx, miny, maxx, maxy, fogSprites, "fog" );
|
||||
DrawShroud( minx, miny, maxx, maxy, sprites, "shroud" );
|
||||
DrawShroud( wr, minx, miny, maxx, maxy, fogSprites, "fog" );
|
||||
DrawShroud( wr, minx, miny, maxx, maxy, sprites, "shroud" );
|
||||
}
|
||||
|
||||
void DrawShroud( int minx, int miny, int maxx, int maxy, Sprite[,] s, string pal )
|
||||
void DrawShroud( WorldRenderer wr, int minx, int miny, int maxx, int maxy, Sprite[,] s, string pal )
|
||||
{
|
||||
var shroudPalette = Game.world.WorldRenderer.GetPaletteIndex(pal);
|
||||
var shroudPalette = wr.GetPaletteIndex(pal);
|
||||
|
||||
for (var j = miny; j < maxy; j++)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public readonly string Background = "dialog";
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
WidgetUtils.DrawPanel(Background, RenderBounds);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace OpenRA.Widgets
|
||||
return Depressed;
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
|
||||
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Widgets
|
||||
: base(widget) { }
|
||||
|
||||
public override Rectangle EventBounds { get { return Rectangle.Empty; } }
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var pos = RenderOrigin;
|
||||
var chatLogArea = new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Widgets
|
||||
bool composing = false;
|
||||
bool teamChat = false;
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
if (composing)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Widgets
|
||||
public bool Bold = false;
|
||||
public Func<bool> Checked = () => false;
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var font = Bold ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
|
||||
var pos = RenderOrigin;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Widgets
|
||||
return new ColorBlockWidget(this);
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
WidgetUtils.FillRectWithColor(RenderBounds, GetColor());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override Widget Clone() { return new ImageWidget(this); }
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var name = GetImageName();
|
||||
var collection = GetImageCollection();
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Widgets
|
||||
GetBackground = other.GetBackground;
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var bg = GetBackground();
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace OpenRA.Widgets
|
||||
DownPressed = other.DownPressed;
|
||||
}
|
||||
|
||||
public override void DrawInner(World world) {}
|
||||
public override void Draw(World world)
|
||||
public override void DrawInner() {}
|
||||
public override void Draw()
|
||||
{
|
||||
if (!IsVisible())
|
||||
return;
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Widgets
|
||||
Game.Renderer.EnableScissor(backgroundRect.X, backgroundRect.Y + HeaderHeight, backgroundRect.Width, backgroundRect.Height - HeaderHeight);
|
||||
|
||||
foreach (var child in Children)
|
||||
child.Draw(world);
|
||||
child.Draw();
|
||||
|
||||
Game.Renderer.DisableScissor();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Widgets
|
||||
static Sprite UnownedSpawn = null;
|
||||
static Sprite OwnedSpawn = null;
|
||||
|
||||
public override void DrawInner( World world )
|
||||
public override void DrawInner()
|
||||
{
|
||||
if (UnownedSpawn == null)
|
||||
UnownedSpawn = ChromeProvider.GetImage("spawnpoints", "unowned");
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public PerfGraphWidget() : base() { }
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var rect = RenderBounds;
|
||||
float2 origin = Game.viewport.Location + new float2(rect.Right, rect.Bottom);
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Widgets
|
||||
Text = Text.Replace("\r", "");
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var bg = GetBackground();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Widgets
|
||||
Sprite sprite = null;
|
||||
string cachedImage = null;
|
||||
int cachedFrame= -1;
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var image = GetImage();
|
||||
var frame = GetFrame();
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
if (!IsVisible())
|
||||
return;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA.Widgets
|
||||
base.Tick(world);
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
int margin = 5;
|
||||
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
@@ -20,13 +20,13 @@ namespace OpenRA.Widgets
|
||||
public TimerWidget ()
|
||||
{
|
||||
IsVisible = () => Game.Settings.Game.MatchTimer;
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
var s = WorldUtils.FormatTime(Game.LocalTick);
|
||||
var size = Game.Renderer.TitleFont.Measure(s);
|
||||
Game.Renderer.TitleFont.DrawText(s, new float2(RenderBounds.Left - size.X / 2, RenderBounds.Top - 20), Color.White);
|
||||
}
|
||||
|
||||
public override void DrawInner()
|
||||
{
|
||||
var s = WorldUtils.FormatTime(Game.LocalTick);
|
||||
var size = Game.Renderer.TitleFont.Measure(s);
|
||||
Game.Renderer.TitleFont.DrawText(s, new float2(RenderBounds.Left - size.X / 2, RenderBounds.Top - 20), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public ViewportScrollControllerWidget() : base() { }
|
||||
protected ViewportScrollControllerWidget(ViewportScrollControllerWidget widget) : base(widget) {}
|
||||
public override void DrawInner( World world ) {}
|
||||
public override void DrawInner() {}
|
||||
|
||||
public override bool HandleInputInner(MouseInput mi)
|
||||
{
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Support;
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace OpenRA.Widgets
|
||||
overlaySprite.sheet.Texture.SetData(overlay);
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
public override void DrawInner()
|
||||
{
|
||||
if (video == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -269,15 +269,15 @@ namespace OpenRA.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract void DrawInner( World world );
|
||||
public abstract void DrawInner();
|
||||
|
||||
public virtual void Draw(World world)
|
||||
public virtual void Draw()
|
||||
{
|
||||
if (IsVisible())
|
||||
{
|
||||
DrawInner( world );
|
||||
DrawInner();
|
||||
foreach (var child in Children)
|
||||
child.Draw(world);
|
||||
child.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,9 +344,9 @@ namespace OpenRA.Widgets
|
||||
++Viewport.TicksSinceLastMove;
|
||||
}
|
||||
|
||||
public static void DoDraw(World world)
|
||||
public static void DoDraw()
|
||||
{
|
||||
RootWidget.Draw(world);
|
||||
RootWidget.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public ContainerWidget(Widget other) : base(other) { }
|
||||
|
||||
public override void DrawInner( World world ) { }
|
||||
public override void DrawInner() { }
|
||||
|
||||
public override string GetCursor(int2 pos) { return null; }
|
||||
public override Widget Clone() { return new ContainerWidget(this); }
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Widgets
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public override void DrawInner( World world )
|
||||
public override void DrawInner()
|
||||
{
|
||||
var selbox = SelectionBox;
|
||||
if (selbox == null) return;
|
||||
|
||||
@@ -20,8 +20,9 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public int TooltipDelay = 10;
|
||||
public WorldTooltipWidget() : base() { }
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var world = Game.world;
|
||||
if (Viewport.TicksSinceLastMove < TooltipDelay || world == null || world.LocalPlayer == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
public readonly string BuildPaletteClose = "bleep13.aud";
|
||||
public readonly string TabClick = "ramenu1.aud";
|
||||
|
||||
readonly World world;
|
||||
[ObjectCreator.UseCtor]
|
||||
public BuildPaletteWidget( [ObjectCreator.Param] World world )
|
||||
readonly World world;
|
||||
[ObjectCreator.UseCtor]
|
||||
public BuildPaletteWidget( [ObjectCreator.Param] World world )
|
||||
{
|
||||
this.world = world;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -176,7 +176,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
int paletteHeight = 0;
|
||||
int numActualRows = 0;
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
if (!IsVisible()) return;
|
||||
// todo: fix
|
||||
|
||||
@@ -21,8 +21,9 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
public MoneyBinWidget() : base() { }
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var world = Game.world;
|
||||
if( world.LocalPlayer == null ) return;
|
||||
|
||||
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
GetLongDesc = () => LongDesc;
|
||||
}
|
||||
|
||||
public override void DrawInner (World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var image = ChromeProvider.GetImage(Image + "-button", GetImage());
|
||||
var rect = new Rectangle(RenderBounds.X, RenderBounds.Y, (int)image.size.X, (int)image.size.Y);
|
||||
|
||||
@@ -25,8 +25,9 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
float? lastPowerDrainedPos;
|
||||
string powerCollection;
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
var world = Game.world;
|
||||
if( world.LocalPlayer == null ) return;
|
||||
|
||||
powerCollection = "power-" + world.LocalPlayer.Country.Race;
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
get { return new Rectangle((int)mapRect.X, (int)mapRect.Y, (int)mapRect.Width, (int)mapRect.Height);}
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
public override void DrawInner()
|
||||
{
|
||||
if( world.LocalPlayer == null ) return;
|
||||
|
||||
|
||||
@@ -63,8 +63,9 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
public override void DrawInner()
|
||||
{
|
||||
var world = Game.world;
|
||||
buttons.Clear();
|
||||
|
||||
if( world.LocalPlayer == null ) return;
|
||||
|
||||
Reference in New Issue
Block a user