- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/PersistentData/PersistentContainer.cs
r273 r325 4 4 using System.Runtime.Serialization.Formatters.Binary; 5 5 6 namespace AllocsFixes.PersistentData 7 { 6 namespace AllocsFixes.PersistentData { 8 7 [Serializable] 9 public class PersistentContainer 10 { 8 public class PersistentContainer { 11 9 private Players players; 12 [OptionalField] 13 private Attributes attributes; 10 [OptionalField] private Attributes attributes; 14 11 15 12 public Players Players { 16 13 get { 17 if (players == null) 14 if (players == null) { 18 15 players = new Players (); 16 } 17 19 18 return players; 20 19 } 21 20 } 22 21 23 public Attributes Attributes 24 { 22 public Attributes Attributes { 25 23 get { 26 24 if (attributes == null) { 27 attributes = new Attributes ();25 attributes = new Attributes (); 28 26 } 27 29 28 return attributes; 30 29 } … … 38 37 instance = new PersistentContainer (); 39 38 } 39 40 40 return instance; 41 41 } 42 42 } 43 43 44 private PersistentContainer () 45 { 44 private PersistentContainer () { 46 45 } 47 46 48 public void Save () 49 { 47 public void Save () { 50 48 Stream stream = File.Open (GameUtils.GetSaveGameDir () + "/AllocsPeristentData.bin", FileMode.Create); 51 49 BinaryFormatter bFormatter = new BinaryFormatter (); … … 54 52 } 55 53 56 public static bool Load () 57 { 54 public static bool Load () { 58 55 if (File.Exists (GameUtils.GetSaveGameDir () + "/AllocsPeristentData.bin")) { 59 56 try { … … 61 58 Stream stream = File.Open (GameUtils.GetSaveGameDir () + "/AllocsPeristentData.bin", FileMode.Open); 62 59 BinaryFormatter bFormatter = new BinaryFormatter (); 63 obj = (PersistentContainer) bFormatter.Deserialize (stream);60 obj = (PersistentContainer) bFormatter.Deserialize (stream); 64 61 stream.Close (); 65 62 instance = obj; … … 70 67 } 71 68 } 69 72 70 return false; 73 71 } 74 75 72 } 76 73 } 77
Note:
See TracChangeset
for help on using the changeset viewer.