- Timestamp:
- Dec 12, 2015, 4:08:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs
r251 r253 11 11 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 12 12 { 13 AdminTools admTools = null; 13 AdminTools admTools = GameManager.Instance.adminTools; 14 user = user ?? new WebConnection ("", "", 0L); 14 15 15 try { admTools = GameManager.Instance.adminTools; } catch { } 16 try { user = user ?? new WebConnection ("", "", 0L); } catch { } // default user, cheap way to avoid 'null reference exception' 17 18 bool bViewAll = false; try { bViewAll = user.CanViewAllPlayers (permissionLevel); } catch { } 16 bool bViewAll = WebConnection.CanViewAllPlayers (permissionLevel); 19 17 20 18 JSONArray playersJsResult = new JSONArray (); … … 23 21 24 22 foreach (string sid in playersList.SteamIDs) { 25 try { 26 if ((admTools != null) && (PetesUtils.ValidText (sid))) 27 if (admTools.IsBanned (sid)) 28 continue; 23 if (admTools != null) 24 if (admTools.IsBanned (sid)) 25 continue; 26 27 Player p = playersList [sid, false]; 28 29 ulong player_steam_ID = 0L; 30 if (!ulong.TryParse (sid, out player_steam_ID)) 31 player_steam_ID = 0L; 32 33 if ((player_steam_ID == user.SteamID) || bViewAll) { 34 JSONObject pos = new JSONObject (); 35 pos.Add("x", new JSONNumber (p.LastPosition.x)); 36 pos.Add("y", new JSONNumber (p.LastPosition.y)); 37 pos.Add("z", new JSONNumber (p.LastPosition.z)); 38 39 JSONObject pJson = new JSONObject (); 40 pJson.Add("steamid", new JSONString (sid)); 41 pJson.Add("ip", new JSONString (p.IP)); 42 pJson.Add("name", new JSONString (p.Name)); 43 pJson.Add("online", new JSONBoolean (p.IsOnline)); 44 pJson.Add("position", pos); 45 46 playersJsResult.Add (pJson); 29 47 } 30 catch { }31 32 try33 {34 Player p = playersList [sid, false];35 36 ulong player_steam_ID = 0L;37 if (!ulong.TryParse (sid, out player_steam_ID))38 player_steam_ID = 0L;39 40 if ((player_steam_ID == user.SteamID) || bViewAll) {41 JSONObject pos = new JSONObject ();42 pos.Add("x", new JSONNumber (p.LastPosition.x));43 pos.Add("y", new JSONNumber (p.LastPosition.y));44 pos.Add("z", new JSONNumber (p.LastPosition.z));45 46 JSONObject pJson = new JSONObject ();47 pJson.Add("steamid", new JSONString (sid));48 pJson.Add("ip", new JSONString (p.IP));49 pJson.Add("name", new JSONString (p.Name));50 pJson.Add("online", new JSONBoolean (p.IsOnline));51 pJson.Add("position", pos);52 53 playersJsResult.Add (pJson);54 }55 }56 catch { }57 48 } 58 49
Note:
See TracChangeset
for help on using the changeset viewer.