separate World and Ui LastTickTime

This commit is contained in:
Matthias Mailänder
2014-02-17 10:41:04 +01:00
parent 0c20e38443
commit 212cf93ca4
2 changed files with 17 additions and 10 deletions

View File

@@ -163,17 +163,24 @@ namespace OpenRA
static void TickInner(OrderManager orderManager) static void TickInner(OrderManager orderManager)
{ {
var t = Environment.TickCount; var tick = Environment.TickCount;
var dt = t - orderManager.LastTickTime;
var uiTickDelta = tick - Ui.LastTickTime;
if (uiTickDelta >= Timestep)
{
Ui.LastTickTime += Timestep;
Ui.Tick();
cursorFrame += 0.5f;
}
var world = orderManager.world; var world = orderManager.world;
var timestep = world == null ? Timestep : world.Timestep; var worldTimestep = world == null ? Timestep : world.Timestep;
if (timestep == 0) var worldTickDelta = tick - orderManager.LastTickTime;
return; if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
if (dt >= timestep)
using (new PerfSample("tick_time")) using (new PerfSample("tick_time"))
{ {
orderManager.LastTickTime += timestep; orderManager.LastTickTime += worldTimestep;
Ui.Tick();
if (orderManager.GameStarted) if (orderManager.GameStarted)
++Viewport.TicksSinceLastMove; ++Viewport.TicksSinceLastMove;
@@ -208,8 +215,6 @@ namespace OpenRA
orderManager.LastTickTime = Environment.TickCount; orderManager.LastTickTime = Environment.TickCount;
Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer));
cursorFrame += 0.5f;
} }
} }
} }

View File

@@ -21,6 +21,8 @@ namespace OpenRA.Widgets
{ {
public static Widget Root = new ContainerWidget(); public static Widget Root = new ContainerWidget();
public static int LastTickTime = Environment.TickCount;
static Stack<Widget> WindowList = new Stack<Widget>(); static Stack<Widget> WindowList = new Stack<Widget>();
public static Widget MouseFocusWidget; public static Widget MouseFocusWidget;