Changeset 332 for binary-improvements/MapRendering/Web/API
- Timestamp:
- Nov 16, 2018, 10:38:46 PM (6 years ago)
- Location:
- binary-improvements/MapRendering/Web/API
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetLandClaims.cs
r326 r332 21 21 22 22 // default user, cheap way to avoid 'null reference exception' 23 user = user ?? new WebConnection ("", "", 0L);23 user = user ?? new WebConnection ("", IPAddress.None, 0L); 24 24 25 25 bool bViewAll = WebConnection.CanViewAllClaims (permissionLevel); -
binary-improvements/MapRendering/Web/API/GetPlayerInventories.cs
r325 r332 1 using System.Collections.Generic; 1 2 using System.Net; 2 3 using AllocsFixes.JSON; … … 9 10 JSONArray AllInventoriesResult = new JSONArray (); 10 11 11 foreach ( string sid in PersistentContainer.Instance.Players.SteamIDs) {12 Player p = PersistentContainer.Instance.Players [sid, false];12 foreach (KeyValuePair<string, Player> kvp in PersistentContainer.Instance.Players.Dict) { 13 Player p = kvp.Value; 13 14 14 15 if (p == null) { … … 23 24 JSONArray belt = new JSONArray (); 24 25 JSONObject equipment = new JSONObject (); 25 result.Add ("steamid", new JSONString ( sid));26 result.Add ("steamid", new JSONString (kvp.Key)); 26 27 result.Add ("entityid", new JSONNumber (p.EntityID)); 27 28 result.Add ("playername", new JSONString (p.Name)); -
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; -
binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs
r326 r332 1 using System.Collections.Generic; 1 2 using System.Net; 2 3 using AllocsFixes.JSON; … … 8 9 int permissionLevel) { 9 10 AdminTools admTools = GameManager.Instance.adminTools; 10 user = user ?? new WebConnection ("", "", 0L);11 user = user ?? new WebConnection ("", IPAddress.None, 0L); 11 12 12 13 bool listOffline = false; … … 21 22 Players playersList = PersistentContainer.Instance.Players; 22 23 23 foreach ( string sid in playersList.SteamIDs) {24 foreach (KeyValuePair<string, Player> kvp in playersList.Dict) { 24 25 if (admTools != null) { 25 if (admTools.IsBanned ( sid)) {26 if (admTools.IsBanned (kvp.Key)) { 26 27 continue; 27 28 } 28 29 } 29 30 30 Player p = playersList [sid, false];31 Player p = kvp.Value; 31 32 32 33 if (listOffline || p.IsOnline) { 33 34 ulong player_steam_ID; 34 if (!ulong.TryParse ( sid, out player_steam_ID)) {35 if (!ulong.TryParse (kvp.Key, out player_steam_ID)) { 35 36 player_steam_ID = 0L; 36 37 } … … 43 44 44 45 JSONObject pJson = new JSONObject (); 45 pJson.Add ("steamid", new JSONString ( sid));46 pJson.Add ("steamid", new JSONString (kvp.Key)); 46 47 47 48 // pJson.Add("entityid", new JSONNumber (p.EntityID)); -
binary-improvements/MapRendering/Web/API/WebAPI.cs
r326 r332 2 2 using System.Text; 3 3 using AllocsFixes.JSON; 4 using UnityEngine.Profiling; 4 5 5 6 namespace AllocsFixes.NetConnections.Servers.Web.API { … … 11 12 } 12 13 14 #if ENABLE_PROFILER 15 private static readonly CustomSampler jsonSerializeSampler = CustomSampler.Create ("JSON_Serialize"); 16 private static readonly CustomSampler netWriteSampler = CustomSampler.Create ("JSON_Write"); 17 #endif 18 13 19 public static void WriteJSON (HttpListenerResponse resp, JSONNode root) { 20 #if ENABLE_PROFILER 21 jsonSerializeSampler.Begin (); 22 #endif 14 23 StringBuilder sb = new StringBuilder (); 15 24 root.ToString (sb); 25 #if ENABLE_PROFILER 26 jsonSerializeSampler.End (); 27 netWriteSampler.Begin (); 28 #endif 16 29 byte[] buf = Encoding.UTF8.GetBytes (sb.ToString ()); 17 30 resp.ContentLength64 = buf.Length; … … 19 32 resp.ContentEncoding = Encoding.UTF8; 20 33 resp.OutputStream.Write (buf, 0, buf.Length); 34 #if ENABLE_PROFILER 35 netWriteSampler.End (); 36 #endif 21 37 } 22 38
Note:
See TracChangeset
for help on using the changeset viewer.