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 diff
     1.1 --- a/api/Factories/AbstractNativeWarFoundryFactory.cs	Sat Jan 30 17:21:15 2010 +0000
     1.2 +++ b/api/Factories/AbstractNativeWarFoundryFactory.cs	Sat Feb 20 20:57:13 2010 +0000
     1.3 @@ -22,11 +22,7 @@
     1.4  	/// Base abstract class for all factories that load native WarFoundry data.
     1.5  	/// </summary>
     1.6  	public abstract class AbstractNativeWarFoundryFactory : AbstractWarFoundryFactory<ZipFile>, INativeWarFoundryFactory
     1.7 -	{
     1.8 -		public static readonly string SYSTEM_ZIP_IDENTIFIER = "WarFoundry_System";
     1.9 -		public static readonly string RACE_ZIP_IDENTIFIER = "WarFoundry_Race";
    1.10 -		public static readonly string ARMY_ZIP_IDENTIFIER = "WarFoundry_Army";
    1.11 -				
    1.12 +	{				
    1.13  		protected AbstractNativeWarFoundryFactory()
    1.14  		{
    1.15  			//Do nothing - just make the constructor non-public
    1.16 @@ -59,21 +55,21 @@
    1.17  		
    1.18  		protected override bool CheckCanHandleFileAsGameSystem(ZipFile file)
    1.19  		{
    1.20 -			return file.ZipFileComment.StartsWith(SYSTEM_ZIP_IDENTIFIER) && CheckCanFindSystemFileContent(file);
    1.21 +			return CheckCanFindSystemFileContent(file);
    1.22  		}
    1.23  		
    1.24  		protected abstract bool CheckCanFindSystemFileContent(ZipFile file);
    1.25  		
    1.26  		protected override bool CheckCanHandleFileAsRace(ZipFile file)
    1.27  		{
    1.28 -			return file.ZipFileComment.StartsWith(RACE_ZIP_IDENTIFIER) && CheckCanFindRaceFileContent(file);
    1.29 +			return CheckCanFindRaceFileContent(file);
    1.30  		}
    1.31  		
    1.32  		protected abstract bool CheckCanFindRaceFileContent(ZipFile file);
    1.33  		
    1.34  		protected override bool CheckCanHandleFileAsArmy(ZipFile file)
    1.35  		{
    1.36 -			return file.ZipFileComment.StartsWith(ARMY_ZIP_IDENTIFIER) && CheckCanFindArmyFileContent(file);
    1.37 +			return CheckCanFindArmyFileContent(file);
    1.38  		}
    1.39  		
    1.40  		protected abstract bool CheckCanFindArmyFileContent(ZipFile file);
    1.41 @@ -81,20 +77,19 @@
    1.42  		protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile (ZipFile file)
    1.43  		{
    1.44  			ICollection<IWarFoundryObject> objects = null;
    1.45 -			string comment = file.ZipFileComment;
    1.46  			IWarFoundryObject obj = null;
    1.47  
    1.48  			try
    1.49  			{
    1.50 -				if (comment.StartsWith(SYSTEM_ZIP_IDENTIFIER))
    1.51 +				if (CheckCanFindSystemFileContent(file))
    1.52  				{
    1.53  					obj = CreateGameSystemFromFile(file);
    1.54  				}
    1.55 -				else if (comment.StartsWith(RACE_ZIP_IDENTIFIER))
    1.56 +				else if (CheckCanFindRaceFileContent(file))
    1.57  				{
    1.58  					obj = CreateRaceFromFile(file);
    1.59  				}
    1.60 -				else if (comment.StartsWith(ARMY_ZIP_IDENTIFIER))
    1.61 +				else if (CheckCanFindArmyFileContent(file))
    1.62  				{
    1.63  					obj = CreateArmyFromFile(file);
    1.64  				}
     2.1 --- a/api/Factories/Xml/WarFoundryXmlSaver.cs	Sat Jan 30 17:21:15 2010 +0000
     2.2 +++ b/api/Factories/Xml/WarFoundryXmlSaver.cs	Sat Feb 20 20:57:13 2010 +0000
     2.3 @@ -36,7 +36,6 @@
     2.4  				file = ZipFile.Create(savePath);
     2.5  				file.BeginUpdate();
     2.6  				file.Add(new StringZipEntrySource(CreateXmlString(toSave)), "data.armyx");
     2.7 -				file.SetComment(AbstractNativeWarFoundryFactory.ARMY_ZIP_IDENTIFIER);
     2.8  				file.CommitUpdate();
     2.9  				success = true;
    2.10  			}