Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/DefaultWarFoundryLoader.cs @ 291:24e7b571f50f
Re #318: DefaultWarFoundryLoader throws null ref when loading individual files
* Fix quick fix so that it actually works and loads files - but it is still a quick-fix that needs double-checking
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 14 Dec 2010 20:17:07 +0000 |
parents | 5ed39187b0e3 |
children |
line wrap: on
line diff
--- a/api/DefaultWarFoundryLoader.cs Mon Dec 13 21:03:02 2010 +0000 +++ b/api/DefaultWarFoundryLoader.cs Tue Dec 14 20:17:07 2010 +0000 @@ -15,6 +15,8 @@ { private Dictionary<string, GameSystem> systemsTable; private Dictionary<string, Dictionary<string, Dictionary<string, Race>>> racesTable; //Keys are: System, Race, SubRace + private bool loaded = false; + private bool loading = false; public DefaultWarFoundryLoader() { @@ -24,11 +26,17 @@ protected override void PrepareForFileLoad() { - //Just set up blank dictionaries for now - may try different and more complex handling in future + loading = true; systemsTable.Clear(); racesTable.Clear(); } + protected override void FinishFileLoad() + { + loaded = true; + loading = false; + } + protected override GameSystem GetExistingSystemForSystem(GameSystem system) { return DictionaryUtils.GetValue(systemsTable, system.ID.ToLower()); @@ -81,7 +89,7 @@ public override GameSystem[] GetGameSystems() { - if (systemsTable == null) + if (!loaded && !loading) { LoadFiles(); } @@ -91,7 +99,7 @@ public override GameSystem GetGameSystem(string systemID) { - if (systemsTable == null) + if (!loaded && !loading) { LoadFiles(); } @@ -122,7 +130,7 @@ /// </returns> public Race[] GetRaces(string systemID) { - if (racesTable == null) + if (!loaded && !loading) { LoadFiles(); } @@ -201,7 +209,7 @@ /// </returns> public Race GetRace(string systemID, string raceID, string raceSubID) { - if (racesTable == null) + if (!loaded && !loading) { LoadFiles(); } @@ -244,7 +252,7 @@ public override string[] GetGameSystemIDs() { - if (systemsTable == null) + if (!loaded && !loading) { LoadFiles(); } @@ -268,7 +276,7 @@ /// </returns> public string[] GetSystemRaceIDs(string systemID) { - if (racesTable == null) + if (!loaded && !loading) { LoadFiles(); }