Merge pull request #5850 from pavlos256/game-loop

Improve the game loop
This commit is contained in:
Paul Chote
2014-07-24 20:24:08 +12:00
8 changed files with 246 additions and 159 deletions

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Server
public void Tick(S server)
{
if ((Environment.TickCount - lastPing > MasterPingInterval * 1000) || isInitialPing)
if ((Game.RunTime - lastPing > MasterPingInterval * 1000) || isInitialPing)
PingMasterServer(server);
else
lock (masterServerMessages)
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Server
{
if (isBusy || !server.Settings.AdvertiseOnline) return;
lastPing = Environment.TickCount;
lastPing = Game.RunTime;
isBusy = true;
var mod = server.ModData.Manifest.Mod;

View File

@@ -25,12 +25,12 @@ namespace OpenRA.Mods.RA.Server
bool isInitialPing = true;
public void Tick(S server)
{
if ((Environment.TickCount - lastPing > PingInterval) || isInitialPing)
if ((Game.RunTime - lastPing > PingInterval) || isInitialPing)
{
isInitialPing = false;
lastPing = Environment.TickCount;
lastPing = Game.RunTime;
foreach (var p in server.Conns)
server.SendOrderTo(p, "Ping", Environment.TickCount.ToString());
server.SendOrderTo(p, "Ping", Game.RunTime.ToString());
}
}
}

View File

@@ -185,9 +185,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
int fps;
Exts.TryParseIntegerInvariant(frameLimitTextfield.Text, out fps);
ds.MaxFramerate = fps.Clamp(20, 200);
ds.MaxFramerate = fps.Clamp(1, 1000);
frameLimitTextfield.Text = ds.MaxFramerate.ToString();
Game.SetIdealFrameTime(ds.MaxFramerate);
};
frameLimitTextfield.OnEnterKey = () => { frameLimitTextfield.YieldKeyboardFocus(); return true; };
frameLimitTextfield.IsDisabled = () => !ds.CapFramerate;
@@ -213,7 +212,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
gs.ShowShellmap = dgs.ShowShellmap;
ds.CapFramerate = dds.CapFramerate;
Game.SetIdealFrameTime(ds.MaxFramerate);
ds.MaxFramerate = dds.MaxFramerate;
ds.Language = dds.Language;
ds.Mode = dds.Mode;