Changeset 455 for binary-improvements/7dtd-server-fixes/src/PersistentData
- Timestamp:
- Jul 31, 2023, 4:06:13 PM (17 months ago)
- Location:
- binary-improvements/7dtd-server-fixes/src/PersistentData
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/PersistentData/Attributes.cs
r326 r455 8 8 9 9 public bool HideChatCommands { 10 get { return hideChatCommands; }11 set { hideChatCommands = value; }10 get => hideChatCommands; 11 set => hideChatCommands = value; 12 12 } 13 13 14 14 public string HideChatCommandPrefix { 15 get { 16 if (hideChatCommandPrefix == null) { 17 hideChatCommandPrefix = ""; 18 } 19 20 return hideChatCommandPrefix; 21 } 22 set { hideChatCommandPrefix = value; } 15 get => hideChatCommandPrefix ??= ""; 16 set => hideChatCommandPrefix = value; 23 17 } 24 18 } -
binary-improvements/7dtd-server-fixes/src/PersistentData/Inventory.cs
r351 r455 24 24 } 25 25 26 private void ProcessInv ( List<InvItem> _target, ItemStack[]_sourceFields, int _id) {26 private void ProcessInv (ICollection<InvItem> _target, IReadOnlyList<ItemStack> _sourceFields, int _id) { 27 27 _target.Clear (); 28 for (int i = 0; i < _sourceFields. Length; i++) {28 for (int i = 0; i < _sourceFields.Count; i++) { 29 29 InvItem item = CreateInvItem (_sourceFields [i].itemValue, _sourceFields [i].count, _id); 30 30 if (item != null && _sourceFields [i].itemValue.Modifications != null) { … … 43 43 } 44 44 45 private void ProcessParts (I temValue[]_parts, InvItem _item, int _playerId) {46 InvItem[] itemParts = new InvItem[_parts. Length];47 for (int i = 0; i < _parts. Length; i++) {45 private void ProcessParts (IReadOnlyList<ItemValue> _parts, InvItem _item, int _playerId) { 46 InvItem[] itemParts = new InvItem[_parts.Count]; 47 for (int i = 0; i < _parts.Count; i++) { 48 48 InvItem partItem = CreateInvItem (_parts [i], 1, _playerId); 49 49 if (partItem != null && _parts [i].Modifications != null) { … … 67 67 68 68 if (_count > maxAllowed) { 69 Log.Out ("Player with ID " + _playerId + " has stack for \"" + name + "\" greater than allowed (" + 70 _count + " > " + maxAllowed + ")"); 69 Log.Out ($"Player with ID {_playerId} has stack for \"{name}\" greater than allowed ({_count} > {maxAllowed})"); 71 70 } 72 71 -
binary-improvements/7dtd-server-fixes/src/PersistentData/PersistentContainer.cs
r448 r455 12 12 [OptionalField] private Attributes attributes; 13 13 14 public Players Players { 15 get { 16 if (players == null) { 17 players = new Players (); 18 } 14 public Players Players => players ??= new Players (); 19 15 20 return players; 21 } 22 } 23 24 public Attributes Attributes { 25 get { 26 if (attributes == null) { 27 attributes = new Attributes (); 28 } 29 30 return attributes; 31 } 32 } 16 public Attributes Attributes => attributes ??= new Attributes (); 33 17 34 18 private static PersistentContainer instance; 35 19 36 public static PersistentContainer Instance { 37 get { 38 if (instance == null) { 39 instance = new PersistentContainer (); 40 } 41 42 return instance; 43 } 44 } 20 public static PersistentContainer Instance => instance ??= new PersistentContainer (); 45 21 46 22 private PersistentContainer () { … … 49 25 public void Save () { 50 26 lock (fileLockObject) { 51 using Stream stream = File.Open ( GameIO.GetSaveGameDir () + persistentDataFileName, FileMode.Create);27 using Stream stream = File.Open ($"{GameIO.GetSaveGameDir ()}{persistentDataFileName}", FileMode.Create); 52 28 BinaryFormatter bFormatter = new BinaryFormatter (); 53 29 bFormatter.Serialize (stream, this); … … 56 32 57 33 public static bool Load () { 58 if (!File.Exists (GameIO.GetSaveGameDir () + persistentDataFileName)) { 34 var filePath = $"{GameIO.GetSaveGameDir ()}{persistentDataFileName}"; 35 36 if (!File.Exists (filePath)) { 59 37 return false; 60 38 } … … 63 41 PersistentContainer obj; 64 42 lock (fileLockObject) { 65 using Stream stream = File.Open ( GameIO.GetSaveGameDir () + persistentDataFileName, FileMode.Open);43 using Stream stream = File.Open (filePath, FileMode.Open); 66 44 BinaryFormatter bFormatter = new BinaryFormatter (); 67 45 obj = (PersistentContainer)bFormatter.Deserialize (stream); -
binary-improvements/7dtd-server-fixes/src/PersistentData/Player.cs
r447 r455 124 124 } 125 125 126 Log.Out ( "Player set to offline: " + InternalId);126 Log.Out ($"Player set to offline: {InternalId}"); 127 127 lastOnline = DateTime.Now; 128 128 try { … … 140 140 141 141 public void SetOnline (ClientInfo _ci) { 142 Log.Out ( "Player set to online: " + InternalId);142 Log.Out ($"Player set to online: {InternalId}"); 143 143 clientInfo = _ci; 144 144 entityId = _ci.entityId; -
binary-improvements/7dtd-server-fixes/src/PersistentData/Players.cs
r446 r455 19 19 } 20 20 21 Log.Out ( "Created new player entry for ID: " + _internalId);21 Log.Out ($"Created new player entry for ID: {_internalId}"); 22 22 Player p = new Player (_internalId, _platformId, _crossPlatformId); 23 23 Dict.Add (_internalId, p);
Note:
See TracChangeset
for help on using the changeset viewer.