Changeset 446
- Timestamp:
- Jun 12, 2023, 3:21:34 PM (17 months ago)
- Location:
- binary-improvements
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/ModInfo.xml
r443 r446 5 5 <Description value="Common functions" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 6" />7 <Version value="27" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/7dtd-server-fixes/src/API.cs
r443 r446 23 23 24 24 public void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) { 25 PersistentContainer.Instance.Players [_cInfo.InternalId, true].Update (_cInfo, _playerDataFile);25 PersistentContainer.Instance.Players.GetOrCreate (_cInfo.InternalId, _cInfo.PlatformId, _cInfo.CrossplatformId).Update (_cInfo, _playerDataFile); 26 26 } 27 27 … … 43 43 44 44 public void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) { 45 Player p = PersistentContainer.Instance.Players [_cInfo.InternalId, false];45 Player p = PersistentContainer.Instance.Players.GetByInternalId (_cInfo.InternalId); 46 46 if (p != null) { 47 47 p.SetOffline (); … … 54 54 55 55 public void PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) { 56 PersistentContainer.Instance.Players [_cInfo.InternalId, true].SetOnline (_cInfo);56 PersistentContainer.Instance.Players.GetOrCreate (_cInfo.InternalId, _cInfo.PlatformId, _cInfo.CrossplatformId).SetOnline (_cInfo); 57 57 PersistentContainer.Instance.Save (); 58 58 } -
binary-improvements/7dtd-server-fixes/src/LandClaimList.cs
r369 r446 41 41 42 42 foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) { 43 Player p = PersistentContainer.Instance.Players [kvp.Key.UserIdentifier, false];43 Player p = PersistentContainer.Instance.Players.GetByInternalId (kvp.Key.UserIdentifier); 44 44 if (p == null) { 45 p = new Player (kvp.Key.UserIdentifier); 45 PlatformUserIdentifierAbs platformId = kvp.Key.PlatformUserIdentifier; 46 PlatformUserIdentifierAbs internalId = kvp.Key.UserIdentifier; 47 PlatformUserIdentifierAbs crossPlatformId = platformId.Equals (internalId) ? null : internalId; 48 p = new Player (internalId, platformId, crossPlatformId); 46 49 } 47 50 … … 68 71 69 72 public static OwnerFilter UserIdFilter (PlatformUserIdentifierAbs _userId) { 70 return _p => _p. PlatformId.Equals (_userId);73 return _p => _p.InternalId.Equals (_userId); 71 74 } 72 75 -
binary-improvements/7dtd-server-fixes/src/PersistentData/Player.cs
r443 r446 5 5 [Serializable] 6 6 public class Player { 7 private readonly PlatformUserIdentifierAbs platformId;8 7 private int entityId; 9 8 private string name; … … 26 25 [NonSerialized] private ClientInfo clientInfo; 27 26 28 public PlatformUserIdentifierAbs PlatformId => platformId; 27 public PlatformUserIdentifierAbs InternalId { get; } 28 public PlatformUserIdentifierAbs PlatformId { get; } 29 public PlatformUserIdentifierAbs CrossPlatformId { get; } 29 30 30 31 public int EntityID => entityId; … … 34 35 public string IP => ip ?? string.Empty; 35 36 36 public Inventory Inventory => inventory ?? (inventory = new Inventory ());37 public Inventory Inventory => inventory ??= new Inventory (); 37 38 38 39 public bool IsOnline => clientInfo != null; … … 58 59 public bool LandProtectionActive => 59 60 GameManager.Instance.World.IsLandProtectionValidForPlayer (GameManager.Instance 60 .GetPersistentPlayerList ().GetPlayerData ( PlatformId));61 .GetPersistentPlayerList ().GetPlayerData (InternalId)); 61 62 62 63 public float LandProtectionMultiplier => 63 64 GameManager.Instance.World.GetLandProtectionHardnessModifierForPlayer (GameManager.Instance 64 .GetPersistentPlayerList ().GetPlayerData ( PlatformId));65 .GetPersistentPlayerList ().GetPlayerData (InternalId)); 65 66 66 67 public float Level { … … 107 108 } 108 109 109 public Player (PlatformUserIdentifierAbs _platformId) { 110 platformId = _platformId; 110 public Player (PlatformUserIdentifierAbs _internalId, PlatformUserIdentifierAbs _platformId, PlatformUserIdentifierAbs _crossPlatformId) { 111 InternalId = _internalId; 112 PlatformId = _platformId; 113 CrossPlatformId = _crossPlatformId; 111 114 inventory = new Inventory (); 112 115 } … … 117 120 } 118 121 119 Log.Out ("Player set to offline: " + platformId);122 Log.Out ("Player set to offline: " + InternalId); 120 123 lastOnline = DateTime.Now; 121 124 try { … … 133 136 134 137 public void SetOnline (ClientInfo _ci) { 135 Log.Out ("Player set to online: " + platformId);138 Log.Out ("Player set to online: " + InternalId); 136 139 clientInfo = _ci; 137 140 entityId = _ci.entityId; -
binary-improvements/7dtd-server-fixes/src/PersistentData/Players.cs
r369 r446 2 2 using System.Collections.Generic; 3 3 using System.Text.RegularExpressions; 4 using Platform.Steam;5 4 6 5 namespace AllocsFixes.PersistentData { … … 9 8 public readonly Dictionary<PlatformUserIdentifierAbs, Player> Dict = new Dictionary<PlatformUserIdentifierAbs, Player> (); 10 9 11 public Player this [PlatformUserIdentifierAbs _platformId, bool _create] { 12 get { 13 if (_platformId == null) { 14 return null; 15 } 10 public int Count => Dict.Count; 16 11 17 if (Dict.TryGetValue (_platformId, out Player pOld)) { 18 return pOld; 19 } 12 public Player GetOrCreate (PlatformUserIdentifierAbs _internalId, PlatformUserIdentifierAbs _platformId, PlatformUserIdentifierAbs _crossPlatformId) { 13 if (_internalId == null) { 14 return null; 15 } 20 16 21 if (!_create) {22 return null;23 17 if (Dict.TryGetValue (_internalId, out Player pOld)) { 18 return pOld; 19 } 24 20 25 Log.Out ("Created new player entry for ID: " + _platformId); 26 Player p = new Player (_platformId); 27 Dict.Add (_platformId, p); 28 return p; 29 } 21 Log.Out ("Created new player entry for ID: " + _internalId); 22 Player p = new Player (_internalId, _platformId, _crossPlatformId); 23 Dict.Add (_internalId, p); 24 return p; 30 25 } 31 26 32 public int Count => Dict.Count; 27 public Player GetByInternalId (PlatformUserIdentifierAbs _internalId) { 28 if (_internalId == null) { 29 return null; 30 } 33 31 34 public PlatformUserIdentifierAbs GetSteamID (string _nameOrId, bool _ignoreColorCodes) { 32 return Dict.TryGetValue (_internalId, out Player pOld) ? pOld : null; 33 } 34 35 public Player GetByUserId (PlatformUserIdentifierAbs _userId) { 36 foreach ((_, Player p) in Dict) { 37 if (p.PlatformId.Equals (_userId) || p.CrossPlatformId.Equals (_userId)) { 38 return p; 39 } 40 } 41 42 return null; 43 } 44 45 public Player GetByString (string _nameOrId, bool _ignoreColorCodes) { 35 46 if (string.IsNullOrEmpty (_nameOrId)) { 36 47 return null; … … 38 49 39 50 if (PlatformUserIdentifierAbs.TryFromCombinedString (_nameOrId, out PlatformUserIdentifierAbs userId)) { 40 return userId;51 return GetByUserId (userId); 41 52 } 42 53 43 54 if (int.TryParse (_nameOrId, out int entityId)) { 44 foreach ( KeyValuePair<PlatformUserIdentifierAbs, Player> kvpin Dict) {45 if ( kvp.Value.IsOnline && kvp.Value.EntityID == entityId) {46 return kvp.Key;55 foreach ((_, Player p) in Dict) { 56 if (p.IsOnline && p.EntityID == entityId) { 57 return p; 47 58 } 48 59 } 49 60 } 50 61 51 foreach ( KeyValuePair<PlatformUserIdentifierAbs, Player> kvpin Dict) {52 string name = kvp.Value.Name;62 foreach ((_, Player p) in Dict) { 63 string name = p.Name; 53 64 if (_ignoreColorCodes) { 54 65 name = Regex.Replace (name, "\\[[0-9a-fA-F]{6}\\]", ""); 55 66 } 56 67 57 if ( kvp.Value.IsOnline && name.EqualsCaseInsensitive (_nameOrId)) {58 return kvp.Key;68 if (p.IsOnline && name.EqualsCaseInsensitive (_nameOrId)) { 69 return p; 59 70 } 60 71 } -
binary-improvements/AllocsCommands/Commands/ListKnownPlayers.cs
r420 r446 45 45 46 46 if (userIdFilter != null) { 47 Player p = PersistentContainer.Instance.Players [userIdFilter, false];47 Player p = PersistentContainer.Instance.Players.GetByInternalId (userIdFilter); 48 48 49 49 if (p != null) { -
binary-improvements/AllocsCommands/Commands/ListLandProtection.cs
r420 r446 105 105 "Player \"{0} ({1})\" owns {4} keystones (protected: {2}, current hardness multiplier: {3})", 106 106 kvp.Key.Name, 107 kvp.Key. PlatformId,107 kvp.Key.InternalId, 108 108 kvp.Key.LandProtectionActive, 109 109 kvp.Key.LandProtectionMultiplier, … … 112 112 foreach (Vector3i v in kvp.Value) { 113 113 if (parseableOutput) { 114 SdtdConsole.Instance.Output ("LandProtectionOf: id=" + kvp.Key. PlatformId +114 SdtdConsole.Instance.Output ("LandProtectionOf: id=" + kvp.Key.InternalId + 115 115 ", playerName=" + kvp.Key.Name + ", location=" + v); 116 116 } else { -
binary-improvements/AllocsCommands/Commands/ShowInventory.cs
r420 r446 1 using System;2 1 using System.Collections.Generic; 3 2 using AllocsFixes.PersistentData; … … 30 29 } 31 30 32 Pla tformUserIdentifierAbs steamid = PersistentContainer.Instance.Players.GetSteamID(_params [0], true);33 if ( steamid== null) {31 Player p = PersistentContainer.Instance.Players.GetByString (_params [0], true); 32 if (p == null) { 34 33 SdtdConsole.Instance.Output ( 35 34 "Playername or entity/steamid id not found or no inventory saved (first saved after a player has been online for 30s)."); … … 42 41 } 43 42 44 Player p = PersistentContainer.Instance.Players [steamid, false];45 43 PersistentData.Inventory inv = p.Inventory; 46 44 … … 164 162 } 165 163 166 DoParts (_parts [i].parts, _indent + 1, _currentMessage);164 DoParts (_parts [i].parts, _indent + 1, null); 167 165 } else { 168 166 // currentMessage given -> parseable output -
binary-improvements/AllocsCommands/ModInfo.xml
r442 r446 5 5 <Description value="Additional commands for server operation" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 3" />7 <Version value="24" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/ModInfo.xml
r442 r446 5 5 <Description value="Render the game map to image map tiles as it is uncovered" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="4 0" />7 <Version value="41" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/Web/API/GetLandClaims.cs
r420 r446 51 51 52 52 owner.Add ("steamid", new JSONString (kvp.Key.PlatformId.CombinedString)); 53 owner.Add ("crossplatformid", new JSONString (kvp.Key.CrossPlatformId?.CombinedString ?? "")); 53 54 owner.Add ("claimactive", new JSONBoolean (kvp.Key.LandProtectionActive)); 54 55 -
binary-improvements/MapRendering/Web/API/GetPlayerInventories.cs
r369 r446 20 20 21 21 if (p.IsOnline) { 22 AllInventoriesResult.Add (GetPlayerInventory.DoPlayer ( kvp.Key.CombinedString,p, showIconColor, showIconName));22 AllInventoriesResult.Add (GetPlayerInventory.DoPlayer (p, showIconColor, showIconName)); 23 23 } 24 24 } -
binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs
r369 r446 21 21 } 22 22 23 Player p = PersistentContainer.Instance.Players [userId, false];23 Player p = PersistentContainer.Instance.Players.GetByUserId (userId); 24 24 if (p == null) { 25 25 _resp.StatusCode = (int) HttpStatusCode.NotFound; … … 30 30 GetInventoryArguments (_req, out bool showIconColor, out bool showIconName); 31 31 32 JSONObject result = DoPlayer ( userIdString,p, showIconColor, showIconName);32 JSONObject result = DoPlayer (p, showIconColor, showIconName); 33 33 34 34 WriteJSON (_resp, result); … … 45 45 } 46 46 47 internal static JSONObject DoPlayer ( string _steamId,Player _player, bool _showIconColor, bool _showIconName) {47 internal static JSONObject DoPlayer (Player _player, bool _showIconColor, bool _showIconName) { 48 48 PersistentData.Inventory inv = _player.Inventory; 49 49 … … 53 53 JSONArray belt = new JSONArray (); 54 54 JSONObject equipment = new JSONObject (); 55 result.Add ("userid", new JSONString (_steamId)); 55 result.Add ("userid", new JSONString (_player.PlatformId.CombinedString)); 56 result.Add ("crossplatformid", new JSONString (_player.CrossPlatformId?.CombinedString ?? "")); 56 57 result.Add ("entityid", new JSONNumber (_player.EntityID)); 57 58 result.Add ("playername", new JSONString (_player.Name)); -
binary-improvements/MapRendering/Web/API/GetPlayerList.cs
r420 r446 49 49 Player p = kvp.Value; 50 50 51 if (bViewAll || p. PlatformId.Equals (userId)) {51 if (bViewAll || p.InternalId.Equals (userId)) { 52 52 JSONObject pos = new JSONObject (); 53 53 pos.Add ("x", new JSONNumber (p.LastPosition.x)); … … 56 56 57 57 JSONObject pJson = new JSONObject (); 58 pJson.Add ("steamid", new JSONString (kvp.Key.CombinedString)); 58 pJson.Add ("steamid", new JSONString (kvp.Value.PlatformId.CombinedString)); 59 pJson.Add ("crossplatformid", new JSONString (kvp.Value.CrossPlatformId?.CombinedString ?? "")); 59 60 pJson.Add ("entityid", new JSONNumber (p.EntityID)); 60 61 pJson.Add ("ip", new JSONString (p.IP)); -
binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs
r420 r446 32 32 33 33 if (listOffline || p.IsOnline) { 34 if (bViewAll || p. PlatformId.Equals (userId)) {34 if (bViewAll || p.InternalId.Equals (userId)) { 35 35 JSONObject pos = new JSONObject (); 36 36 pos.Add ("x", new JSONNumber (p.LastPosition.x)); … … 39 39 40 40 JSONObject pJson = new JSONObject (); 41 pJson.Add ("steamid", new JSONString (kvp.Key.CombinedString)); 41 pJson.Add ("steamid", new JSONString (kvp.Value.PlatformId.CombinedString)); 42 pJson.Add ("crossplatformid", new JSONString (kvp.Value.CrossPlatformId?.CombinedString ?? "")); 42 43 43 44 // pJson.Add("entityid", new JSONNumber (p.EntityID)); -
binary-improvements/MapRendering/Web/API/GetPlayersOnline.cs
r371 r446 13 13 foreach (KeyValuePair<int, EntityPlayer> current in w.Players.dict) { 14 14 ClientInfo ci = ConnectionManager.Instance.Clients.ForEntityId (current.Key); 15 Player player = PersistentContainer.Instance.Players [ci.InternalId, false];15 Player player = PersistentContainer.Instance.Players.GetByInternalId (ci.InternalId); 16 16 17 17 JSONObject pos = new JSONObject (); … … 22 22 JSONObject p = new JSONObject (); 23 23 p.Add ("steamid", new JSONString (ci.PlatformId.CombinedString)); 24 p.Add ("crossplatformid", new JSONString (ci.CrossplatformId?.CombinedString ?? "")); 24 25 p.Add ("entityid", new JSONNumber (ci.entityId)); 25 26 p.Add ("ip", new JSONString (ci.ip)); -
binary-improvements/bin/Mods/Allocs_CommandExtensions/ModInfo.xml
r442 r446 5 5 <Description value="Additional commands for server operation" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 3" />7 <Version value="24" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/bin/Mods/Allocs_CommonFunc/ModInfo.xml
r443 r446 5 5 <Description value="Common functions" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 6" />7 <Version value="27" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/bin/Mods/Allocs_WebAndMapRendering/ModInfo.xml
r442 r446 5 5 <Description value="Render the game map to image map tiles as it is uncovered" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="4 0" />7 <Version value="41" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo>
Note:
See TracChangeset
for help on using the changeset viewer.