merge Game.Init into PreInit; fix exploit involving chrome.CheckDeadTab; fixed cancel behaviour wrt canceling an item not currently in the queue (because of orderlag, etc)

This commit is contained in:
Bob
2010-04-16 14:18:30 +12:00
parent db46502123
commit 55352d7df9
4 changed files with 28 additions and 37 deletions

View File

@@ -136,7 +136,6 @@ namespace OpenRA
foreach (var q in tabImageNames)
if (!Rules.TechTree.BuildableItems(world.LocalPlayer, q.Key).Any())
{
CheckDeadTab(world, q.Key);
if (currentTab == q.Key)
currentTab = null;
}
@@ -544,13 +543,6 @@ namespace OpenRA
paletteAnimating = true;
}
void CheckDeadTab( World world, string groupName )
{
var queue = world.LocalPlayer.PlayerActor.traits.Get<Traits.ProductionQueue>();
foreach( var item in queue.AllItems( groupName ) )
Game.IssueOrder(Order.CancelProduction(world.LocalPlayer, item.Item));
}
float? lastPowerProvidedPos;
float? lastPowerDrainedPos;

View File

@@ -181,29 +181,6 @@ namespace OpenRA
viewport.Center(loc);
}
internal static void Initialize(Renderer renderer, int2 clientSize, int localPlayer, Controller controller)
{
Game.renderer = renderer;
Game.clientSize = clientSize;
Sound.Initialize();
PerfHistory.items["render"].hasNormalTick = false;
PerfHistory.items["batches"].hasNormalTick = false;
PerfHistory.items["text"].hasNormalTick = false;
PerfHistory.items["cursor"].hasNormalTick = false;
Game.controller = controller;
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
ChangeMods();
if( Settings.Replay != "" )
orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) );
else
JoinLocal();
LoadShellMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid);
}
public static string CurrentHost = "";
public static int CurrentPort = 0;
internal static void JoinServer(string host, int port)
@@ -493,7 +470,7 @@ namespace OpenRA
desktopResolution.Height);
}
public static void PreInit(Settings settings)
public static void Initialize(Settings settings)
{
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
while (!Directory.Exists("mods"))
@@ -517,9 +494,24 @@ namespace OpenRA
renderer = new Renderer(resolution, windowed);
resolution = renderer.Resolution;
var controller = new Controller();
Game.controller = new Controller();
Game.clientSize = new int2(resolution);
Game.Initialize(renderer, new int2(resolution), Game.Settings.Player, controller);
Sound.Initialize();
PerfHistory.items["render"].hasNormalTick = false;
PerfHistory.items["batches"].hasNormalTick = false;
PerfHistory.items["text"].hasNormalTick = false;
PerfHistory.items["cursor"].hasNormalTick = false;
AvailableMaps = FindMaps(LobbyInfo.GlobalSettings.Mods);
ChangeMods();
if( Settings.Replay != "" )
orderManager = new OrderManager( new ReplayConnection( Settings.Replay ) );
else
JoinLocal();
LoadShellMap(new Manifest(LobbyInfo.GlobalSettings.Mods).ShellmapUid);
Game.ResetTimer();
}

View File

@@ -47,7 +47,7 @@ namespace OpenRA
static void Run( string[] args )
{
Game.PreInit( new Settings( args ) );
Game.Initialize( new Settings( args ) );
Game.Run();
}
}

View File

@@ -44,9 +44,16 @@ namespace OpenRA.Traits
public void Tick( Actor self )
{
foreach( var p in production )
{
while( p.Value.Count > 0 && !Rules.TechTree.BuildableItems( self.Owner, p.Key ).Contains( p.Value[ 0 ].Item ) )
{
self.Owner.GiveCash(p.Value[0].TotalCost - p.Value[0].RemainingCost); // refund what's been paid so far.
FinishProduction(p.Key);
}
if( p.Value.Count > 0 )
( p.Value )[ 0 ].Tick( self.Owner );
}
}
public void ResolveOrder( Actor self, Order order )
{
@@ -127,7 +134,7 @@ namespace OpenRA.Traits
{
queue.RemoveAt(lastIndex);
}
else
else if( lastIndex == 0 )
{
var item = queue[0];
self.Owner.GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.