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)
{
var t = Environment.TickCount;
var dt = t - orderManager.LastTickTime;
var tick = Environment.TickCount;
var uiTickDelta = tick - Ui.LastTickTime;
if (uiTickDelta >= Timestep)
{
Ui.LastTickTime += Timestep;
Ui.Tick();
cursorFrame += 0.5f;
}
var world = orderManager.world;
var timestep = world == null ? Timestep : world.Timestep;
if (timestep == 0)
return;
if (dt >= timestep)
var worldTimestep = world == null ? Timestep : world.Timestep;
var worldTickDelta = tick - orderManager.LastTickTime;
if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
using (new PerfSample("tick_time"))
{
orderManager.LastTickTime += timestep;
Ui.Tick();
orderManager.LastTickTime += worldTimestep;
if (orderManager.GameStarted)
++Viewport.TicksSinceLastMove;
@@ -208,8 +215,6 @@ namespace OpenRA
orderManager.LastTickTime = Environment.TickCount;
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 int LastTickTime = Environment.TickCount;
static Stack<Widget> WindowList = new Stack<Widget>();
public static Widget MouseFocusWidget;