Changeset 332 for binary-improvements/MapRendering/Web/API/GetPlayerList.cs
- Timestamp:
- Nov 16, 2018, 10:38:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetPlayerList.cs
r326 r332 6 6 using AllocsFixes.JSON; 7 7 using AllocsFixes.PersistentData; 8 using UnityEngine.Profiling; 8 9 9 10 namespace AllocsFixes.NetConnections.Servers.Web.API { … … 12 13 new Regex (@"^(>=|=>|>|<=|=<|<|==|=)?\s*([0-9]+(\.[0-9]*)?)$"); 13 14 15 #if ENABLE_PROFILER 16 private static readonly CustomSampler jsonSerializeSampler = CustomSampler.Create ("JSON_Build"); 17 #endif 18 14 19 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, 15 20 int permissionLevel) { 16 21 AdminTools admTools = GameManager.Instance.adminTools; 17 user = user ?? new WebConnection ("", "", 0L);22 user = user ?? new WebConnection ("", IPAddress.None, 0L); 18 23 19 24 bool bViewAll = WebConnection.CanViewAllPlayers (permissionLevel); … … 35 40 Players playersList = PersistentContainer.Instance.Players; 36 41 42 37 43 List<JSONObject> playerList = new List<JSONObject> (); 38 44 39 foreach (string sid in playersList.SteamIDs) { 40 Player p = playersList [sid, false]; 45 #if ENABLE_PROFILER 46 jsonSerializeSampler.Begin (); 47 #endif 48 49 foreach (KeyValuePair<string, Player> kvp in playersList.Dict) { 50 Player p = kvp.Value; 41 51 42 52 ulong player_steam_ID; 43 if (!ulong.TryParse ( sid, out player_steam_ID)) {53 if (!ulong.TryParse (kvp.Key, out player_steam_ID)) { 44 54 player_steam_ID = 0L; 45 55 } … … 52 62 53 63 JSONObject pJson = new JSONObject (); 54 pJson.Add ("steamid", new JSONString ( sid));64 pJson.Add ("steamid", new JSONString (kvp.Key)); 55 65 pJson.Add ("entityid", new JSONNumber (p.EntityID)); 56 66 pJson.Add ("ip", new JSONString (p.IP)); … … 66 76 JSONBoolean banned; 67 77 if (admTools != null) { 68 banned = new JSONBoolean (admTools.IsBanned ( sid));78 banned = new JSONBoolean (admTools.IsBanned (kvp.Key)); 69 79 } else { 70 80 banned = new JSONBoolean (false); … … 76 86 } 77 87 } 88 89 #if ENABLE_PROFILER 90 jsonSerializeSampler.End (); 91 #endif 78 92 79 93 IEnumerable<JSONObject> list = playerList;
Note:
See TracChangeset
for help on using the changeset viewer.