moved starting units into session.ini

This commit is contained in:
Chris Forbes
2009-11-19 18:07:57 +13:00
parent 732f3c6c63
commit 5b213473ad
4 changed files with 28 additions and 15 deletions

View File

@@ -11,6 +11,7 @@ using OpenRa.Game.Graphics;
using OpenRa.Game.Traits; using OpenRa.Game.Traits;
using OpenRa.Game.Support; using OpenRa.Game.Support;
using System.Net.Sockets; using System.Net.Sockets;
using System.Windows.Forms;
namespace OpenRa.Game namespace OpenRa.Game
{ {
@@ -50,7 +51,9 @@ namespace OpenRa.Game
Rules.LoadRules(mapName); Rules.LoadRules(mapName);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
players.Add(i, new Player(i, i, string.Format("Multi{0}", i), players.Add(i,
new Player(i, i,
string.Format("Multi{0}", i),
Race.Allies)); Race.Allies));
localPlayerIndex = localPlayer; localPlayerIndex = localPlayer;
@@ -113,9 +116,11 @@ namespace OpenRa.Game
foreach (var s in mapfile.GetSection("UNITS", true)) foreach (var s in mapfile.GetSection("UNITS", true))
{ {
//num=owner,type,health,location,facing,action,trigger //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]); 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]));
} }
} }

View File

@@ -24,6 +24,7 @@ namespace OpenRa.Game
public static void LoadRules(string mapFileName) public static void LoadRules(string mapFileName)
{ {
AllRules = new IniFile( AllRules = new IniFile(
FileSystem.Open("session.ini"),
FileSystem.Open(mapFileName), FileSystem.Open(mapFileName),
FileSystem.Open("rules.ini"), FileSystem.Open("rules.ini"),
FileSystem.Open("units.ini"), FileSystem.Open("units.ini"),

View File

@@ -3,6 +3,8 @@ using System.Windows.Forms;
using OpenRa.FileFormats; using OpenRa.FileFormats;
using OpenRa.Game.Graphics; using OpenRa.Game.Graphics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using OpenRa.Game.Traits;
using System.IO;
namespace OpenRa.Game namespace OpenRa.Game
{ {
@@ -58,17 +60,6 @@ namespace OpenRa.Game
SequenceProvider.ForcePrecache(); 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 ); renderer.BuildPalette( Rules.Map );
ShowCursor(false); ShowCursor(false);
Game.ResetTimer(); Game.ResetTimer();

16
session.ini Normal file
View File

@@ -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