private static Sisco_Return onGameSaved(ref object sender, ref object[] args, ref object return_value) { string gameName = (string)args[0]; string plyUpgradesFile = String.Concat(gameName, ".pug"); string plotUpgradesFile = String.Concat(gameName, ".plu"); SLog.Debug("Writing: {0}", plyUpgradesFile); SLog.Debug("Writing: {0}", plotUpgradesFile); // SAVE PLAYER UPGRADES // Always write to a temp file first when saving data string tmpFile = String.Concat(plyUpgradesFile, ".tmp"); List <string> upgrades_list = new List <string>(Player_Upgrades_Missing); upgrades_list.AddRange(PlayerUpgrades.Select(o => o.ID).ToArray()); File.WriteAllText(tmpFile, String.Join("\n", upgrades_list.Distinct(StringComparer.OrdinalIgnoreCase).ToArray())); File.Copy(tmpFile, plyUpgradesFile, true); File.Delete(tmpFile); // SAVE PLOT UPGRADES Save_Plot_Upgrades(plotUpgradesFile); return(null); }