source: binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs@ 251

Last change on this file since 251 was 251, checked in by peter.souza, 9 years ago

Enemies (zombies and hostile animal entities) are now shown on the map as Hostiles and require permission level 'webapi.gethostilelocation' for web viewers to see.

Animals (non-hostile entities) are now shown on the map as Animals and require permission level 'webapi.getanimalslocation' for web viewers to see.

Permission level for 'webapi.viewallclaims' is now required for a viewer to see all claims, otherwise the permission level for 'webapi.getlandclaims' will only show viewer-owned claims. A viewer requires both 'webapi.getlandclaims' and 'webapi.viewallclaims' to be set for all claims to show (you can't just set 'webapi.viewallclaims').
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317405&viewfull=1#post317405

Permission level for 'webapi.viewallplayers' is now required for a viewer to see all players, otherwise the permission level for 'webapi.getplayerslocation' will only show the player for the currently-authenticated viewer. A viewer requires both 'webapi.getplayerslocation' and 'webapi.viewallplayers' to be set for all players to show (you can't just set 'webapi.viewallplayers').
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317405&viewfull=1#post317405

Banned players are now hidden from the web map.
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=320702&viewfull=1#post320702

Items using 'CustomIcon' and 'CustomIconTint' are now supported (although the exact tinting may not be perfectly the same as the game).
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317117&viewfull=1#post317117
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317679&viewfull=1#post317679

Map marker icons for players, hostiles, and animals have been updated.

File size: 2.3 KB
Line 
1using AllocsFixes.JSON;
2using AllocsFixes.PersistentData;
3using System;
4using System.Collections.Generic;
5using System.Net;
6
7namespace 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 = null;
14
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 { }
19
20 JSONArray playersJsResult = new JSONArray ();
21
22 Players playersList = PersistentContainer.Instance.Players;
23
24 foreach (string sid in playersList.SteamIDs) {
25 try {
26 if ((admTools != null) && (PetesUtils.ValidText (sid)))
27 if (admTools.IsBanned (sid))
28 continue;
29 }
30 catch { }
31
32 try
33 {
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 }
58
59 WriteJSON (resp, playersJsResult);
60 }
61 }
62}
63
Note: See TracBrowser for help on using the repository browser.