Ignore:
Timestamp:
Oct 28, 2015, 7:51:20 PM (9 years ago)
Author:
peter.souza
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/MapRendering/Web/API/GetLandClaims.cs

    r245 r251  
    1111                public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel)
    1212                {
    13                         string steamid = string.Empty;
     13                        string ViewersSteamID = string.Empty;
     14            ulong lViewersSteamID = 0L;
    1415
    1516                        if (req.QueryString ["steamid"] != null) {
    16                                 long tempLong;
    17                                 steamid = req.QueryString ["steamid"];
    18                                 if (steamid.Length != 17 || !long.TryParse (steamid, out tempLong)) {
     17                                ViewersSteamID = req.QueryString ["steamid"];
     18                if (ViewersSteamID.Length != 17 || !ulong.TryParse (ViewersSteamID, out lViewersSteamID)) {
    1919                                        resp.StatusCode = (int)HttpStatusCode.BadRequest;
    2020                                        Web.SetResponseTextContent (resp, "Invalid SteamID given");
     
    2323                        }
    2424
     25            // default user, cheap way to avoid 'null reference exception'
     26            try { user = user ?? new WebConnection ("", "", 0L); } catch { }
     27
     28            bool bViewAll = false; try { bViewAll = user.CanViewAllClaims (permissionLevel); } catch { }
     29           
    2530                        JSONObject result = new JSONObject ();
    2631                        result.Add ("claimsize", new JSONNumber (GamePrefs.GetInt (EnumGamePrefs.LandClaimSize)));
     
    3338                                World w = GameManager.Instance.World;
    3439                                Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>> ();
     40
     41                // Add all owners to this temporary list regardless of permissions
    3542                                foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) {
    36                                         if (steamid.Length == 0 || kvp.Value.PlayerId.Equals (steamid)) {
     43                                        if (kvp.Value.PlayerId.Equals (ViewersSteamID)) {
    3744                                                if (!owners.ContainsKey (kvp.Value)) {
    3845                                                        owners.Add (kvp.Value, new List<Vector3i> ());
     
    4249                                }
    4350
     51                // Loop through all claim owners...
    4452                                foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) {
    45                                         if (steamid.Length == 0 || kvp.Key.PlayerId.Equals (steamid)) {
    46                                                 string curID = kvp.Key.PlayerId;
    47                                                 bool isActive = w.IsLandProtectionValidForPlayer (kvp.Key);
     53                    try
     54                    {
     55                        // ... but only show us claims that are from the current web user or if the current web user can see all claims regardless of ownership
     56                        if (kvp.Key.PlayerId.Equals (ViewersSteamID) || bViewAll)
     57                        {
     58                            string currentSteamID = kvp.Key.PlayerId;
     59                            bool isActive = w.IsLandProtectionValidForPlayer (kvp.Key);
    4860
    49                                                 JSONObject owner = new JSONObject ();
    50                                                 claimOwners.Add (owner);
     61                            JSONObject owner = new JSONObject ();
     62                            claimOwners.Add (owner);
    5163
    52                                                 owner.Add ("steamid", new JSONString (curID));
    53                                                 owner.Add ("claimactive", new JSONBoolean (isActive));
     64                            owner.Add("steamid", new JSONString (currentSteamID));
     65                            owner.Add("claimactive", new JSONBoolean (isActive));
    5466
    55                                                 if (PersistentContainer.Instance.Players [curID, false] != null) {
    56                                                         owner.Add ("playername", new JSONString (PersistentContainer.Instance.Players [curID, false].Name));
    57                                                 } else {
    58                                                         owner.Add ("playername", new JSONNull ());
    59                                                 }
     67                            if (PersistentContainer.Instance.Players [currentSteamID, false] != null) {
     68                                owner.Add("playername", new JSONString (PersistentContainer.Instance.Players [currentSteamID, false].Name));
     69                            } else {
     70                                owner.Add("playername", new JSONNull ());
     71                            }
    6072
    61                                                 JSONArray claims = new JSONArray ();
    62                                                 owner.Add ("claims", claims);
     73                            JSONArray claims = new JSONArray ();
     74                            owner.Add ("claims", claims);
    6375
    64                                                 foreach (Vector3i v in kvp.Value) {
    65                                                         JSONObject claim = new JSONObject ();
    66                                                         claim.Add ("x", new JSONNumber (v.x));
    67                                                         claim.Add ("y", new JSONNumber (v.y));
    68                                                         claim.Add ("z", new JSONNumber (v.z));
     76                            foreach (Vector3i v in kvp.Value) {
     77                                JSONObject claim = new JSONObject ();
     78                                claim.Add ("x", new JSONNumber (v.x));
     79                                claim.Add ("y", new JSONNumber (v.y));
     80                                claim.Add ("z", new JSONNumber (v.z));
    6981
    70                                                         claims.Add (claim);
    71                                                 }
    72                                         }
     82                                claims.Add (claim);
     83                            }
     84                        }
     85                    }
     86                    catch { }
    7387                                }
    7488                        }
Note: See TracChangeset for help on using the changeset viewer.