Changeset 448 for binary-improvements/7dtd-server-fixes
- Timestamp:
 - Jun 16, 2023, 3:31:26 PM (2 years ago)
 - Location:
 - binary-improvements/7dtd-server-fixes
 - Files:
 - 
      
- 3 edited
 
- 
          
  ModInfo.xml (modified) (1 diff)
 - 
          
  src/LandClaimList.cs (modified) (1 diff)
 - 
          
  src/PersistentData/PersistentContainer.cs (modified) (4 diffs)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
binary-improvements/7dtd-server-fixes/ModInfo.xml
r447 r448 5 5 <Description value="Common functions" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 8" />7 <Version value="29" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo>  - 
      
binary-improvements/7dtd-server-fixes/src/LandClaimList.cs
r446 r448 45 45 PlatformUserIdentifierAbs platformId = kvp.Key.PlatformUserIdentifier; 46 46 PlatformUserIdentifierAbs internalId = kvp.Key.UserIdentifier; 47 PlatformUserIdentifierAbs crossPlatformId = platformId .Equals (internalId) ? null : internalId;47 PlatformUserIdentifierAbs crossPlatformId = platformId == null || platformId.Equals (internalId) ? null : internalId; 48 48 p = new Player (internalId, platformId, crossPlatformId); 49 49 }  - 
      
binary-improvements/7dtd-server-fixes/src/PersistentData/PersistentContainer.cs
r369 r448 7 7 [Serializable] 8 8 public class PersistentContainer { 9 private const string persistentDataFileName = "/AllocsPersistentData.bin"; 10 9 11 private Players players; 10 12 [OptionalField] private Attributes attributes; … … 44 46 private PersistentContainer () { 45 47 } 46 48 47 49 public void Save () { 48 Stream stream = File.Open (GameIO.GetSaveGameDir () + "/AllocsPeristentData.bin", FileMode.Create); 49 BinaryFormatter bFormatter = new BinaryFormatter (); 50 bFormatter.Serialize (stream, this); 51 stream.Close (); 50 lock (fileLockObject) { 51 using Stream stream = File.Open (GameIO.GetSaveGameDir () + persistentDataFileName, FileMode.Create); 52 BinaryFormatter bFormatter = new BinaryFormatter (); 53 bFormatter.Serialize (stream, this); 54 } 52 55 } 53 56 54 57 public static bool Load () { 55 if (!File.Exists (GameIO.GetSaveGameDir () + "/AllocsPeristentData.bin")) {58 if (!File.Exists (GameIO.GetSaveGameDir () + persistentDataFileName)) { 56 59 return false; 57 60 } … … 59 62 try { 60 63 PersistentContainer obj; 61 Stream stream = File.Open (GameIO.GetSaveGameDir () + "/AllocsPeristentData.bin", FileMode.Open); 62 BinaryFormatter bFormatter = new BinaryFormatter (); 63 obj = (PersistentContainer) bFormatter.Deserialize (stream); 64 stream.Close (); 64 lock (fileLockObject) { 65 using Stream stream = File.Open (GameIO.GetSaveGameDir () + persistentDataFileName, FileMode.Open); 66 BinaryFormatter bFormatter = new BinaryFormatter (); 67 obj = (PersistentContainer)bFormatter.Deserialize (stream); 68 } 69 65 70 instance = obj; 66 71 return true; … … 72 77 return false; 73 78 } 79 80 private static readonly object fileLockObject = new(); 74 81 } 75 82 }  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  ![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)