private static void Load_Plot_Upgrades(string fileName) { // LOAD PLOT UPGRADES if (File.Exists(fileName)) { Stream strm = File.OpenRead(fileName); if (strm == null) { throw new IOException("Cannot open file for reading: " + fileName); } BinaryReader br = new BinaryReader(strm); int total = br.ReadInt32(); for (int i = 0; i < total; i++) { Plot_Upgrades up = Plot_Upgrades.Deserialize(br); Plot_Upgrades_Cache.Add(up); } // Load the upgrade data cache int pidTotal = br.ReadInt32(); for (int p = 0; p < pidTotal; p++) { PlotID pid = PlotID.Deserialize(br); int upgrTotal = br.ReadInt32(); for (int u = 0; u < upgrTotal; u++) { string upgrade = br.ReadString(); int kTotal = br.ReadInt32(); // Make sure we can add keys/values without issue. Setup_Upgrade_Data_Dict(pid, upgrade); for (int k = 0; k < kTotal; k++) { string key = br.ReadString(); int blen = br.ReadInt32(); byte[] value = br.ReadBytes(blen); //PLog.Info("[{0}][{1}] [{2}]: ({3}){4}", pid, upgrade, key, blen, Util.FormatByteArray(value)); if (!Plot_Upgrade_Data[pid][upgrade].ContainsKey(key)) { Plot_Upgrade_Data[pid][upgrade].Add(key, value); } else { Plot_Upgrade_Data[pid][upgrade][key] = value; } } } } strm.Close(); } }