Mercurial > repos > IBDev-IBBoard.WarFoundry.API
changeset 238:d1068f4b6d1c
Fixes #141: Check IDs of units on loading army
* IDs were already checked - now exceptions instead of ignoring (exception is already caught for other reasons)
Also:
* Code cleanup of main XML file factory
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 21 Feb 2010 20:25:52 +0000 |
parents | ec7fe85116cf |
children | 7c14537d4a23 |
files | api/Factories/Xml/WarFoundryXmlArmyParser.cs api/Factories/Xml/WarFoundryXmlFactory.cs |
diffstat | 2 files changed, 20 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlArmyParser.cs Sun Feb 21 20:13:44 2010 +0000 +++ b/api/Factories/Xml/WarFoundryXmlArmyParser.cs Sun Feb 21 20:25:52 2010 +0000 @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Xml; +using IBBoard.IO; using IBBoard.Xml; using ICSharpCode.SharpZipLib.Zip; using IBBoard.WarFoundry.API.Objects; @@ -85,6 +86,10 @@ LoadUnitEquipment(unitElem, unit); } + else + { + throw new InvalidFileException("Duplicate unit ID found in army file: "+id); + } } }
--- a/api/Factories/Xml/WarFoundryXmlFactory.cs Sun Feb 21 20:13:44 2010 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs Sun Feb 21 20:25:52 2010 +0000 @@ -135,14 +135,14 @@ { LogNotifier.DebugFormat(GetType(), "Complete loading of {0} with ID {1}", obj.GetType().Name, obj.ID); - if (obj is GameSystem) - { - CompleteLoadingGameSystem((GameSystem) obj); - } - else if (obj is Race) - { - CompleteLoadingRace((Race) obj); - } + if (obj is GameSystem) + { + CompleteLoadingGameSystem((GameSystem) obj); + } + else if (obj is Race) + { + CompleteLoadingRace((Race) obj); + } } private void CompleteLoadingRace(Race race) @@ -162,14 +162,13 @@ { try { - gameSystemFactory.CompleteLoading(system); - - } - catch (InvalidFileException ex) - { - WarFoundryLoader.GetDefault().RemoveGameSystem(system); - throw; - } + gameSystemFactory.CompleteLoading(system); + } + catch (InvalidFileException ex) + { + WarFoundryLoader.GetDefault().RemoveGameSystem(system); + throw; + } } } } \ No newline at end of file