From 5b213473ad7bf14ec4e49ff034dae54e3465e20b Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 19 Nov 2009 18:07:57 +1300 Subject: [PATCH] moved starting units into session.ini --- OpenRa.Game/Game.cs | 13 +++++++++---- OpenRa.Game/GameRules/Rules.cs | 1 + OpenRa.Game/MainWindow.cs | 13 ++----------- session.ini | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 session.ini diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 93b998d6cb..88c7697972 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -11,6 +11,7 @@ using OpenRa.Game.Graphics; using OpenRa.Game.Traits; using OpenRa.Game.Support; using System.Net.Sockets; +using System.Windows.Forms; namespace OpenRa.Game { @@ -50,8 +51,10 @@ namespace OpenRa.Game Rules.LoadRules(mapName); for (int i = 0; i < 8; i++) - players.Add(i, new Player(i, i, string.Format("Multi{0}", i), - Race.Allies)); + players.Add(i, + new Player(i, i, + string.Format("Multi{0}", i), + Race.Allies)); localPlayerIndex = localPlayer; @@ -113,9 +116,11 @@ namespace OpenRa.Game foreach (var s in mapfile.GetSection("UNITS", true)) { //num=owner,type,health,location,facing,action,trigger - var parts = s.Value.ToLowerInvariant().Split(','); + var parts = s.Value.Split(','); var loc = int.Parse(parts[3]); - world.Add(new Actor(parts[1], new int2(loc % 128, loc / 128), players[0])); + world.Add(new Actor(parts[1].ToLowerInvariant(), new int2(loc % 128, loc / 128), + players.Values.FirstOrDefault(p => p.PlayerName == parts[0]) + ?? players[0])); } } diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 465129b66c..3eed563b64 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -24,6 +24,7 @@ namespace OpenRa.Game public static void LoadRules(string mapFileName) { AllRules = new IniFile( + FileSystem.Open("session.ini"), FileSystem.Open(mapFileName), FileSystem.Open("rules.ini"), FileSystem.Open("units.ini"), diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index bb360b0fbb..e0b2702bf5 100755 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -3,6 +3,8 @@ using System.Windows.Forms; using OpenRa.FileFormats; using OpenRa.Game.Graphics; using System.Runtime.InteropServices; +using OpenRa.Game.Traits; +using System.IO; namespace OpenRa.Game { @@ -58,17 +60,6 @@ namespace OpenRa.Game SequenceProvider.ForcePrecache(); - Game.world.Add( new Actor( "mcv", Rules.Map.Offset + new int2( 5, 5 ), Game.players[ 1 ] ) ); - Game.world.Add( new Actor( "mcv", Rules.Map.Offset + new int2( 7, 5 ), Game.players[ 2 ] ) ); - Game.world.Add( new Actor( "mcv", Rules.Map.Offset + new int2( 9, 5 ), Game.players[ 0 ] ) ); - Game.world.Add( new Actor( "jeep", Rules.Map.Offset + new int2( 9, 14 ), Game.players[ 1 ] ) ); - Game.world.Add( new Actor( "3tnk", Rules.Map.Offset + new int2( 12, 7 ), Game.players[ 1 ] ) ); - Game.world.Add( new Actor( "apc", Rules.Map.Offset + new int2( 13, 7 ), Game.players[ 1 ] ) ); - Game.world.Add( new Actor( "ca", Rules.Map.Offset + new int2( 40, 7 ), Game.players[ 1 ] ) ); - Game.world.Add( new Actor( "e1", Rules.Map.Offset + new int2( 9, 13 ), Game.players[ 1 ] ) ); - Game.world.Add( new Actor( "arty", Rules.Map.Offset + new int2( 10, 13 ), Game.players[ 1 ] ) ); - Game.world.Add( new Actor( "heli", Rules.Map.Offset + new int2( 11, 12 ), Game.players[ 1 ] ) ); - renderer.BuildPalette( Rules.Map ); ShowCursor(false); Game.ResetTimer(); diff --git a/session.ini b/session.ini new file mode 100644 index 0000000000..afbb66a0ab --- /dev/null +++ b/session.ini @@ -0,0 +1,16 @@ +; start positions for test units. + +; eventually, we'll generate this on the host as part of the pre-game setup, +; and then copy it to all the clients. + +[UNITS] +s0=Multi1,mcv,600,2580,0,Guard,None +s1=Multi2,mcv,600,2582,0,Guard,None +s2=Multi0,mcv,600,2584,0,Guard,None +s3=Multi1,jeep,150,3736,0,Guard,None +s4=Multi1,3tnk,400,2843,0,Guard,None +s5=Multi1,apc,200,2844,0,Guard,None +s6=Multi1,ca,700,2871,0,Guard,None +s7=Multi1,e1,50,3608,0,Guard,None +s8=Multi1,arty,75,3609,0,Guard,None +s9=Multi1,heli,225,3482,0,Guard,None