ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Serialization/SearchResultWriter.cs
(Generate patch)

Comparing trunk/RomCheater/Serialization/SearchResultWriter.cs (file contents):
Revision 443 by william, Tue May 28 15:16:05 2013 UTC vs.
Revision 444 by william, Sun Jun 2 18:56:41 2013 UTC

--- trunk/RomCheater/Serialization/SearchResultWriter.cs	2013/05/28 20:44:13	443
+++ trunk/RomCheater/Serialization/SearchResultWriter.cs	2013/06/02 18:56:41	444
@@ -16,11 +16,11 @@ namespace RomCheater.Serialization
 
         private int ResultsWritten = 0;
 
-        public SearchResultWriter() : base() { }
-        public SearchResultWriter(int resultCount) : base(resultCount) { WriteHeader(); }
-        public SearchResultWriter(string filename) : base(filename) { WriteHeader(); }
-        public SearchResultWriter(string filename, int resultCount) : base(filename, resultCount, false) { WriteHeader(); }
-        public SearchResultWriter(string filename, int resultCount, bool delete) : base(filename, resultCount, delete) { WriteHeader(); }
+        //public SearchResultWriter() : base() { }
+        public SearchResultWriter(int resultCount, Guid guid) : base(resultCount, guid) { WriteHeader(guid); }
+        //public SearchResultWriter(string filename, Guid guid) : base(CreateFileName(filename,guid), guid) { WriteHeader(guid); }
+        //public SearchResultWriter(string filename, int resultCount, Guid guid) : base(filename, resultCount, guid, false) { WriteHeader(guid); }
+        //public SearchResultWriter(string filename, int resultCount, Guid guid, bool delete) : base(filename, resultCount, guid, delete) { WriteHeader(guid); }      
         #region ISearchResultWriter members
         public void WriteResult<TValue>(uint address, TValue value) where TValue : IConvertible
         {
@@ -59,12 +59,23 @@ namespace RomCheater.Serialization
         }
         #endregion
 
-        private void WriteHeader()
+        private void WriteHeader(Guid guid)
         {
             // write magic: SRD
             binWriter.Write(Encoding.UTF8.GetBytes("SRD"));
-            // write version (int)
-            binWriter.Write((int)1);
+
+            if (guid == Guid.Empty)
+            {
+                binWriter.Write((int)1);
+            }
+            else
+            {
+                binWriter.Write((int)2);
+                // related guid - length
+                binWriter.Write(guid.ToByteArray().Length);
+                // related guid - data
+                binWriter.Write(guid.ToByteArray());
+            }            
             // write count (int)
             binWriter.Write(ResultCount);
         }