- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs
r315 r325 1 using System.Net; 1 2 using AllocsFixes.JSON; 2 3 using AllocsFixes.PersistentData; 3 using System;4 using System.Collections.Generic;5 using System.Net;6 4 7 namespace AllocsFixes.NetConnections.Servers.Web.API 8 { 9 public class GetPlayersLocation : WebAPI 10 { 11 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 12 { 13 AdminTools admTools = GameManager.Instance.adminTools; 14 user = user ?? new WebConnection ("", "", 0L); 5 namespace AllocsFixes.NetConnections.Servers.Web.API { 6 public class GetPlayersLocation : WebAPI { 7 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, 8 int permissionLevel) { 9 AdminTools admTools = GameManager.Instance.adminTools; 10 user = user ?? new WebConnection ("", "", 0L); 15 11 16 12 bool listOffline = false; … … 19 15 } 20 16 21 17 bool bViewAll = WebConnection.CanViewAllPlayers (permissionLevel); 22 18 23 19 JSONArray playersJsResult = new JSONArray (); 24 20 25 21 Players playersList = PersistentContainer.Instance.Players; 26 22 27 23 foreach (string sid in playersList.SteamIDs) { 28 if (admTools != null) 29 if (admTools.IsBanned (sid)) 30 continue; 24 if (admTools != null) { 25 if (admTools.IsBanned (sid)) { 26 continue; 27 } 28 } 31 29 32 30 Player p = playersList [sid, false]; 33 31 34 32 if (listOffline || p.IsOnline) { 35 ulong player_steam_ID = 0L; 36 if (!ulong.TryParse (sid, out player_steam_ID)) 37 player_steam_ID = 0L; 33 ulong player_steam_ID = 0L; 34 if (!ulong.TryParse (sid, out player_steam_ID)) { 35 player_steam_ID = 0L; 36 } 38 37 39 if ((player_steam_ID == user.SteamID)|| bViewAll) {40 41 pos.Add("x", new JSONNumber (p.LastPosition.x));42 pos.Add("y", new JSONNumber (p.LastPosition.y));43 pos.Add("z", new JSONNumber (p.LastPosition.z));38 if (player_steam_ID == user.SteamID || bViewAll) { 39 JSONObject pos = new JSONObject (); 40 pos.Add ("x", new JSONNumber (p.LastPosition.x)); 41 pos.Add ("y", new JSONNumber (p.LastPosition.y)); 42 pos.Add ("z", new JSONNumber (p.LastPosition.z)); 44 43 45 JSONObject pJson = new JSONObject (); 46 pJson.Add("steamid", new JSONString (sid)); 47 // pJson.Add("entityid", new JSONNumber (p.EntityID)); 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); 44 JSONObject pJson = new JSONObject (); 45 pJson.Add ("steamid", new JSONString (sid)); 52 46 53 // pJson.Add ("totalplaytime", new JSONNumber (p.TotalPlayTime)); 54 // pJson.Add ("lastonline", new JSONString (p.LastOnline.ToString ("s"))); 55 // pJson.Add ("ping", new JSONNumber (p.IsOnline ? p.ClientInfo.ping : -1)); 47 // pJson.Add("entityid", new JSONNumber (p.EntityID)); 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 // pJson.Add ("totalplaytime", new JSONNumber (p.TotalPlayTime)); 54 // pJson.Add ("lastonline", new JSONString (p.LastOnline.ToString ("s"))); 55 // pJson.Add ("ping", new JSONNumber (p.IsOnline ? p.ClientInfo.ping : -1)); 56 56 57 57 playersJsResult.Add (pJson); 58 58 } 59 59 } 60 60 } 61 61 62 62 WriteJSON (resp, playersJsResult); … … 64 64 } 65 65 } 66
Note:
See TracChangeset
for help on using the changeset viewer.