Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/DefaultWarFoundryLoader.cs @ 301:4219d79f262f
Re #99: added points name system to schema
author | snowblizz |
---|---|
date | Mon, 24 Jan 2011 16:51:29 +0000 |
parents | 24e7b571f50f |
children |
rev | line source |
---|---|
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (DefaultWarFoundryLoader.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System.Collections.Generic; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using IBBoard.WarFoundry.API.Objects; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 namespace IBBoard.WarFoundry.API |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 /// The default implementation of a <see cref="AbstractWarFoundryLoader"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 public class DefaultWarFoundryLoader : AbstractWarFoundryLoader |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 private Dictionary<string, GameSystem> systemsTable; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 private Dictionary<string, Dictionary<string, Dictionary<string, Race>>> racesTable; //Keys are: System, Race, SubRace |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
18 private bool loaded = false; |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
19 private bool loading = false; |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
21 public DefaultWarFoundryLoader() |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 { |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
23 systemsTable = new Dictionary<string,GameSystem>(); |
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
24 racesTable = new Dictionary<string,Dictionary<string,Dictionary<string,Race>>>(); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
26 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 protected override void PrepareForFileLoad() |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
29 loading = true; |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
30 systemsTable.Clear(); |
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
31 racesTable.Clear(); |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
33 |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
34 protected override void FinishFileLoad() |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
35 { |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
36 loaded = true; |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
37 loading = false; |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
38 } |
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
39 |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
40 protected override GameSystem GetExistingSystemForSystem(GameSystem system) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 return DictionaryUtils.GetValue(systemsTable, system.ID.ToLower()); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
44 |
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
45 protected override void DoStoreGameSystem(GameSystem system) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 systemsTable[system.ID.ToLower()] = system; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
50 protected override void DoStoreRace(Race race) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 Dictionary<string, Dictionary<string, Race>> systemRaces; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 string systemID = race.GameSystem.ID.ToLower(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 racesTable.TryGetValue(systemID, out systemRaces); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
57 if (systemRaces == null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 systemRaces = new Dictionary<string,Dictionary<string,Race>>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 racesTable.Add(systemID, systemRaces); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 Dictionary<string, Race> subRaces; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 systemRaces.TryGetValue(race.ID.ToLower(), out subRaces); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
66 if (subRaces == null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 subRaces = new Dictionary<string,Race>(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 systemRaces.Add(race.ID.ToLower(), subRaces); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 string subID = race.SubID.ToLower(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 if (subRaces.ContainsKey(subID)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 Race existingRace = subRaces[subID]; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 if (!race.Equals(existingRace)) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 //TODO: Raise an event to say we got a different duplicate |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 //We can't just fail, because failing is for completely unhandled files, not for objects in a file |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 else |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 subRaces.Add(race.SubID.ToLower(), race); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
89 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 public override GameSystem[] GetGameSystems() |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
92 if (!loaded && !loading) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 LoadFiles(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 return DictionaryUtils.ToArray<string, GameSystem>(systemsTable); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
99 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 public override GameSystem GetGameSystem(string systemID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
102 if (!loaded && !loading) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 LoadFiles(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
107 GameSystem system; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
108 systemsTable.TryGetValue(systemID.ToLower(), out system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
109 return system; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
110 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
111 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
112 protected internal override void RemoveGameSystem(GameSystem system) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
113 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
114 systemsTable.Remove(system.ID.ToLower()); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
116 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
117 public override Race[] GetRaces(GameSystem system) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
119 return GetRaces(system.ID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
120 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
121 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
122 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
123 /// Gets an array of the races for a game system by ID. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
124 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
125 /// <param name="systemID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 /// The <see cref="System.String"/> ID of the game system to get races for |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 /// An array of <see cref="Race"/>s for the specified game system |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 public Race[] GetRaces(string systemID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
133 if (!loaded && !loading) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 LoadFiles(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
137 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
138 systemID = systemID.ToLower(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
139 Dictionary<string, Dictionary<string, Race>> system; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 racesTable.TryGetValue(systemID, out system); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
141 |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
142 if (system == null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 return new Race[0]; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
145 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
146 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
147 int count = 0; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
148 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
149 foreach (Dictionary<string, Race> racesDict in system.Values) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
150 { |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
151 count += racesDict.Count; |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
152 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
153 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
154 Race[] races = new Race[count]; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
155 int i = 0; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
156 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
157 foreach (string raceID in system.Keys) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
158 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
159 foreach (string raceSubId in system[raceID].Keys) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
160 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 races[i++] = GetRace(systemID, raceID, raceSubId); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 return races; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
167 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 public override Race GetRace(GameSystem system, string raceID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
170 return GetRace(system.ID, raceID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 /// Gets a single race for a given game system by ID of the game system and race. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 /// <param name="systemID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 /// The <see cref="System.String"/> ID of the game system that the race is part of. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 /// <param name="raceID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 /// The <see cref="System.String"/> ID for the race to load. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
182 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 /// A <see cref="Race"/> with the specified ID from the game system with the specified ID, or <code>null</code> if there is no race or game system with those IDs. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
184 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
185 public Race GetRace(string systemID, string raceID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
186 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 return GetRace(systemID, raceID, ""); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
188 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
189 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 public override Race GetRace(GameSystem system, string raceID, string raceSubID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 return GetRace(system.ID, raceID, raceSubID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
193 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
195 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
196 /// Gets a single race for a given game system by the game system's ID and the race's ID and sub-race ID. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
198 /// <param name="systemID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
199 /// The <see cref="System.String"/> ID of the game system that the race is part of. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
200 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 /// <param name="raceID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 /// The <see cref="System.String"/> ID for the race to load. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
203 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 /// <param name="raceSubID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
205 /// A <see cref="System.String"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
207 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
208 /// A <see cref="Race"/> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
209 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
210 public Race GetRace(string systemID, string raceID, string raceSubID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
211 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
212 if (!loaded && !loading) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
213 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
214 LoadFiles(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
215 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
217 Race race = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
218 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
219 Dictionary<string, Race> subraces = GetRaceTable(systemID, raceID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
220 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 if (subraces != null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
222 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
223 subraces.TryGetValue(raceSubID.ToLower(), out race); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
224 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
225 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
226 return race; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
227 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
228 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
229 private Dictionary<string, Race> GetRaceTable(string systemID, string raceID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
230 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
231 Dictionary<string, Dictionary<string, Race>> races; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
232 racesTable.TryGetValue(systemID.ToLower(), out races); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
233 Dictionary<string, Race> subraces = null; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
234 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
235 if (races != null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
236 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
237 races.TryGetValue(raceID.ToLower(), out subraces); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
238 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
239 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
240 return subraces; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
241 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
243 protected internal override void RemoveRace(Race race) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
244 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
245 Dictionary<string, Race> subraces = GetRaceTable(race.GameSystem.ID, race.ID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
246 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
247 if (subraces != null) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
248 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 subraces.Remove(race.SubID.ToLower()); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
251 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
252 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
253 public override string[] GetGameSystemIDs() |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
254 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
255 if (!loaded && !loading) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
256 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
257 LoadFiles(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
258 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
259 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
260 return DictionaryUtils.ToKeyArray(systemsTable); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
261 } |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
262 |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
263 public override string[] GetSystemRaceIDs(GameSystem system) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 return GetSystemRaceIDs(system.ID); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
266 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
267 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
268 /// <summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
269 /// Gets the IDs of all of the races of a specified game system. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
270 /// </summary> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
271 /// <param name="systemID"> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
272 /// The <see cref="System.String"/> ID of the game system to get the available races for. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
273 /// </param> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
274 /// <returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
275 /// An array of <see cref="System.String"/>s representing the IDs of the races of the specified game system. |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
276 /// </returns> |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
277 public string[] GetSystemRaceIDs(string systemID) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
278 { |
291
24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
290
diff
changeset
|
279 if (!loaded && !loading) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
280 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
281 LoadFiles(); |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
282 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
283 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
284 Dictionary<string, Dictionary<string, Race>> races = racesTable[systemID.ToLower()]; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
285 |
290
5ed39187b0e3
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
IBBoard <dev@ibboard.co.uk>
parents:
233
diff
changeset
|
286 if (races == null) |
233
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
287 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
288 return new string[0]; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
289 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
290 else |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
291 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
292 string[] keys = new string[races.Keys.Count]; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
293 int i = 0; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
294 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
295 foreach (string key in races.Keys) |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
296 { |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
297 keys[i++] = key; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
298 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
299 |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
300 return keys; |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
301 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
302 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
303 } |
a36a0e9cc05d
Re #228: Crash with missing abilityID
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
304 } |