This commit is contained in:
Chris Forbes
2009-11-16 21:29:48 +13:00
parent 99275fac36
commit 2a5ef4e830
4 changed files with 43 additions and 31 deletions

View File

@@ -16,8 +16,13 @@ namespace OpenRA.Server
var right = new TcpListener(1235); var right = new TcpListener(1235);
right.Start(); right.Start();
var l = left.AcceptTcpClient().GetStream(); var lc = left.AcceptTcpClient();
var r = right.AcceptTcpClient().GetStream(); lc.NoDelay = true;
var l = lc.GetStream();
var rc = right.AcceptTcpClient();
rc.NoDelay = true;
var r = rc.GetStream();
var ll = new Thread(RW(l, r)); var ll = new Thread(RW(l, r));
var rr = new Thread(RW(r, l)); var rr = new Thread(RW(r, l));

View File

@@ -65,7 +65,7 @@ namespace OpenRa.Game
DrawBuildPalette("Building"); DrawBuildPalette("Building");
} }
static string[] groups = new string[] { "Building", "Vehicle", "Ship", "Infantry", "Plane" }; static string[] groups = new string[] { "Building", "Defense", "Vehicle", "Ship", "Infantry", "Plane" };
Dictionary<string, Sprite> sprites; Dictionary<string, Sprite> sprites;
void DrawBuildPalette(string queueName) void DrawBuildPalette(string queueName)
@@ -75,7 +75,9 @@ namespace OpenRa.Game
var y = 0; var y = 0;
var buildableItems = Rules.TechTree.BuildableItems(Game.LocalPlayer, queueName).ToArray(); var buildableItems = Rules.TechTree.BuildableItems(Game.LocalPlayer, queueName).ToArray();
foreach (var item in Rules.TechTree.AllItems(Game.LocalPlayer, queueName)) var allItems = Rules.TechTree.AllItems(Game.LocalPlayer, queueName)
.OrderBy( a => Rules.UnitInfo[a].TechLevel );
foreach (var item in allItems)
{ {
if (Rules.UnitInfo[item].TechLevel == -1) continue; if (Rules.UnitInfo[item].TechLevel == -1) continue;
var rect = new Rectangle(Game.viewport.Width - (3 - x) * 64 - 20, 32 + 48 * y, 64, 48); var rect = new Rectangle(Game.viewport.Width - (3 - x) * 64 - 20, 32 + 48 * y, 64, 48);

View File

@@ -10,7 +10,7 @@ namespace OpenRa.Game
static class Rules static class Rules
{ {
public static IniFile AllRules; public static IniFile AllRules;
public static Dictionary<string, List<string>> Categories = new Dictionary<string,List<string>>(); public static Dictionary<string, List<string>> Categories = new Dictionary<string, List<string>>();
public static Dictionary<string, string> UnitCategory; public static Dictionary<string, string> UnitCategory;
public static InfoLoader<UnitInfo> UnitInfo; public static InfoLoader<UnitInfo> UnitInfo;
public static InfoLoader<WeaponInfo> WeaponInfo; public static InfoLoader<WeaponInfo> WeaponInfo;
@@ -19,41 +19,43 @@ namespace OpenRa.Game
public static GeneralInfo General; public static GeneralInfo General;
public static TechTree TechTree; public static TechTree TechTree;
public static void LoadRules( string mapFileName ) public static void LoadRules(string mapFileName)
{ {
AllRules = new IniFile( AllRules = new IniFile(
FileSystem.Open( mapFileName ), FileSystem.Open(mapFileName),
FileSystem.Open( "rules.ini" ), FileSystem.Open("rules.ini"),
FileSystem.Open( "units.ini" ), FileSystem.Open("units.ini"),
FileSystem.Open( "campaignUnits.ini" ) ); FileSystem.Open("campaignUnits.ini"));
General = new GeneralInfo(); General = new GeneralInfo();
FieldLoader.Load(General, AllRules.GetSection("General")); FieldLoader.Load(General, AllRules.GetSection("General"));
LoadCategories( LoadCategories(
"Building", "Building",
"Defense",
"Infantry", "Infantry",
"Vehicle", "Vehicle",
"Ship", "Ship",
"Plane" ); "Plane");
UnitCategory = Categories.SelectMany( x => x.Value.Select( y => new KeyValuePair<string, string>( y, x.Key ) ) ).ToDictionary( x => x.Key, x => x.Value ); UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair<string, string>(y, x.Key))).ToDictionary(x => x.Key, x => x.Value);
UnitInfo = new InfoLoader<UnitInfo>( UnitInfo = new InfoLoader<UnitInfo>(
Pair.New<string,Func<string,UnitInfo>>( "Building", s => new UnitInfo.BuildingInfo(s)), Pair.New<string, Func<string, UnitInfo>>("Building", s => new UnitInfo.BuildingInfo(s)),
Pair.New<string,Func<string,UnitInfo>>( "Infantry", s => new UnitInfo.InfantryInfo(s)), Pair.New<string, Func<string, UnitInfo>>("Defense", s => new UnitInfo.BuildingInfo(s)),
Pair.New<string,Func<string,UnitInfo>>( "Vehicle", s => new UnitInfo.VehicleInfo(s)), Pair.New<string, Func<string, UnitInfo>>("Infantry", s => new UnitInfo.InfantryInfo(s)),
Pair.New<string,Func<string,UnitInfo>>( "Ship", s => new UnitInfo.VehicleInfo(s)), Pair.New<string, Func<string, UnitInfo>>("Vehicle", s => new UnitInfo.VehicleInfo(s)),
Pair.New<string,Func<string,UnitInfo>>( "Plane", s => new UnitInfo.VehicleInfo(s))); Pair.New<string, Func<string, UnitInfo>>("Ship", s => new UnitInfo.VehicleInfo(s)),
Pair.New<string, Func<string, UnitInfo>>("Plane", s => new UnitInfo.VehicleInfo(s)));
LoadCategories( LoadCategories(
"Weapon", "Weapon",
"Warhead", "Warhead",
"Projectile" ); "Projectile");
WeaponInfo = new InfoLoader<WeaponInfo>( WeaponInfo = new InfoLoader<WeaponInfo>(
Pair.New<string,Func<string,WeaponInfo>>("Weapon", _ => new WeaponInfo())); Pair.New<string, Func<string, WeaponInfo>>("Weapon", _ => new WeaponInfo()));
WarheadInfo = new InfoLoader<WarheadInfo>( WarheadInfo = new InfoLoader<WarheadInfo>(
Pair.New<string,Func<string,WarheadInfo>>("Warhead", _ => new WarheadInfo())); Pair.New<string, Func<string, WarheadInfo>>("Warhead", _ => new WarheadInfo()));
ProjectileInfo = new InfoLoader<ProjectileInfo>( ProjectileInfo = new InfoLoader<ProjectileInfo>(
Pair.New<string, Func<string, ProjectileInfo>>("Projectile", _ => new ProjectileInfo())); Pair.New<string, Func<string, ProjectileInfo>>("Projectile", _ => new ProjectileInfo()));
@@ -61,10 +63,10 @@ namespace OpenRa.Game
TechTree = new TechTree(); TechTree = new TechTree();
} }
static void LoadCategories( params string[] types ) static void LoadCategories(params string[] types)
{ {
foreach( var t in types ) foreach (var t in types)
Categories[ t ] = AllRules.GetSection( t + "Types" ).Select( x => x.Key.ToLowerInvariant() ).ToList(); Categories[t] = AllRules.GetSection(t + "Types").Select(x => x.Key.ToLowerInvariant()).ToList();
} }
} }
} }

View File

@@ -143,27 +143,30 @@ Traits=Mobile, RenderUnitRotor
[BuildingTypes] [DefenseTypes]
IRON IRON
ATEK
PDOX PDOX
WEAP
SYRD
SPEN
PBOX PBOX
HBOX HBOX
TSLA TSLA
GUN GUN
AGUN AGUN
FTUR FTUR
GAP
SAM
MSLO
[BuildingTypes]
ATEK
WEAP
SYRD
SPEN
FACT FACT
PROC PROC
SILO SILO
HPAD HPAD
DOME DOME
GAP
SAM
MSLO
AFLD AFLD
POWR POWR
APWR APWR