Esempio n. 1
0
 public static void Serialize(BinaryWriter bw, PlotID id, List <string> list)
 {
     //PLog.Info("PlotUpgrades: {0} | Writing {1} plot upgrades", id, list.Count);
     id.Serialize(bw);
     bw.Write((int)list.Count);
     foreach (string str in list)
     {
         bw.Write(str);
     }
 }
Esempio n. 2
0
        private static void Save_Plot_Upgrades(string fileName)
        {
            string tempFile = String.Concat(fileName, ".tmp");

            Stream strm = File.OpenWrite(tempFile);

            if (strm == null)
            {
                throw new IOException("Cannot open file for writing: " + fileName);
            }

            BinaryWriter bw = new BinaryWriter(strm);

            bw.Write((int)PlotUpgradeTracker.allTrackers.Count);
            foreach (PlotUpgradeTracker tracker in PlotUpgradeTracker.allTrackers)
            {
                tracker.Serialize(bw);
            }

            bw.Write((int)Plot_Upgrade_Data.Count);
            // Write all of the plot's upgrades' set data values
            foreach (var plot_kvp in Plot_Upgrade_Data)
            {
                PlotID plot = plot_kvp.Key;
                plot.Serialize(bw);

                bw.Write((int)plot_kvp.Value.Count);
                foreach (var upgr_kvp in plot_kvp.Value)
                {
                    string upgrade = upgr_kvp.Key;
                    bw.Write(upgrade);

                    bw.Write((int)upgr_kvp.Value.Count);
                    foreach (var kvp in upgr_kvp.Value)
                    {
                        bw.Write((string)kvp.Key);
                        bw.Write((int)kvp.Value.Length);
                        bw.Write(kvp.Value);
                    }
                }
            }

            strm.Close();
            File.Copy(tempFile, fileName, true);
            File.Delete(tempFile);
        }