Mercurial > repos > snowblizz-super-API-ideas
changeset 236:ca2905c9b225
Fixes #252: Remove need for text in zip file comments
* Made checks work on just content rather than zip comment to determine what file type it is
* Remove public static strings with comment strings in them
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 20 Feb 2010 20:57:13 +0000 |
parents | 0ebb1b80a2bd |
children | ec7fe85116cf |
files | api/Factories/AbstractNativeWarFoundryFactory.cs api/Factories/Xml/WarFoundryXmlSaver.cs |
diffstat | 2 files changed, 7 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/AbstractNativeWarFoundryFactory.cs Sat Jan 30 17:21:15 2010 +0000 +++ b/api/Factories/AbstractNativeWarFoundryFactory.cs Sat Feb 20 20:57:13 2010 +0000 @@ -22,11 +22,7 @@ /// Base abstract class for all factories that load native WarFoundry data. /// </summary> public abstract class AbstractNativeWarFoundryFactory : AbstractWarFoundryFactory<ZipFile>, INativeWarFoundryFactory - { - public static readonly string SYSTEM_ZIP_IDENTIFIER = "WarFoundry_System"; - public static readonly string RACE_ZIP_IDENTIFIER = "WarFoundry_Race"; - public static readonly string ARMY_ZIP_IDENTIFIER = "WarFoundry_Army"; - + { protected AbstractNativeWarFoundryFactory() { //Do nothing - just make the constructor non-public @@ -59,21 +55,21 @@ protected override bool CheckCanHandleFileAsGameSystem(ZipFile file) { - return file.ZipFileComment.StartsWith(SYSTEM_ZIP_IDENTIFIER) && CheckCanFindSystemFileContent(file); + return CheckCanFindSystemFileContent(file); } protected abstract bool CheckCanFindSystemFileContent(ZipFile file); protected override bool CheckCanHandleFileAsRace(ZipFile file) { - return file.ZipFileComment.StartsWith(RACE_ZIP_IDENTIFIER) && CheckCanFindRaceFileContent(file); + return CheckCanFindRaceFileContent(file); } protected abstract bool CheckCanFindRaceFileContent(ZipFile file); protected override bool CheckCanHandleFileAsArmy(ZipFile file) { - return file.ZipFileComment.StartsWith(ARMY_ZIP_IDENTIFIER) && CheckCanFindArmyFileContent(file); + return CheckCanFindArmyFileContent(file); } protected abstract bool CheckCanFindArmyFileContent(ZipFile file); @@ -81,20 +77,19 @@ protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile (ZipFile file) { ICollection<IWarFoundryObject> objects = null; - string comment = file.ZipFileComment; IWarFoundryObject obj = null; try { - if (comment.StartsWith(SYSTEM_ZIP_IDENTIFIER)) + if (CheckCanFindSystemFileContent(file)) { obj = CreateGameSystemFromFile(file); } - else if (comment.StartsWith(RACE_ZIP_IDENTIFIER)) + else if (CheckCanFindRaceFileContent(file)) { obj = CreateRaceFromFile(file); } - else if (comment.StartsWith(ARMY_ZIP_IDENTIFIER)) + else if (CheckCanFindArmyFileContent(file)) { obj = CreateArmyFromFile(file); }
--- a/api/Factories/Xml/WarFoundryXmlSaver.cs Sat Jan 30 17:21:15 2010 +0000 +++ b/api/Factories/Xml/WarFoundryXmlSaver.cs Sat Feb 20 20:57:13 2010 +0000 @@ -36,7 +36,6 @@ file = ZipFile.Create(savePath); file.BeginUpdate(); file.Add(new StringZipEntrySource(CreateXmlString(toSave)), "data.armyx"); - file.SetComment(AbstractNativeWarFoundryFactory.ARMY_ZIP_IDENTIFIER); file.CommitUpdate(); success = true; }