Changeset 369 for binary-improvements/MapRendering/Web/API/GetLandClaims.cs
- Timestamp:
- Nov 9, 2021, 6:28:33 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetLandClaims.cs
r351 r369 8 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 9 9 int _permissionLevel) { 10 string requestedSteamID = string.Empty; 11 12 if (_req.QueryString ["steamid"] != null) { 13 ulong lViewersSteamID; 14 requestedSteamID = _req.QueryString ["steamid"]; 15 if (requestedSteamID.Length != 17 || !ulong.TryParse (requestedSteamID, out lViewersSteamID)) { 10 PlatformUserIdentifierAbs requestedUserId = null; 11 if (_req.QueryString ["userid"] != null) { 12 if (!PlatformUserIdentifierAbs.TryFromCombinedString (_req.QueryString ["userid"], out requestedUserId)) { 16 13 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 17 Web.SetResponseTextContent (_resp, "Invalid SteamIDgiven");14 Web.SetResponseTextContent (_resp, "Invalid user id given"); 18 15 return; 19 16 } … … 21 18 22 19 // default user, cheap way to avoid 'null reference exception' 23 _user = _user ?? new WebConnection ("", IPAddress.None, 0L);20 PlatformUserIdentifierAbs userId = _user?.UserId; 24 21 25 22 bool bViewAll = WebConnection.CanViewAllClaims (_permissionLevel); … … 32 29 33 30 LandClaimList.OwnerFilter[] ownerFilters = null; 34 if ( !string.IsNullOrEmpty (requestedSteamID)|| !bViewAll) {35 if ( !string.IsNullOrEmpty (requestedSteamID)&& !bViewAll) {31 if (requestedUserId != null || !bViewAll) { 32 if (requestedUserId != null && !bViewAll) { 36 33 ownerFilters = new[] { 37 LandClaimList. SteamIdFilter (_user.SteamID.ToString ()),38 LandClaimList. SteamIdFilter (requestedSteamID)34 LandClaimList.UserIdFilter (userId), 35 LandClaimList.UserIdFilter (requestedUserId) 39 36 }; 40 37 } else if (!bViewAll) { 41 ownerFilters = new[] {LandClaimList. SteamIdFilter (_user.SteamID.ToString ())};38 ownerFilters = new[] {LandClaimList.UserIdFilter (userId)}; 42 39 } else { 43 ownerFilters = new[] {LandClaimList. SteamIdFilter (requestedSteamID)};40 ownerFilters = new[] {LandClaimList.UserIdFilter (requestedUserId)}; 44 41 } 45 42 } … … 50 47 51 48 foreach (KeyValuePair<Player, List<Vector3i>> kvp in claims) { 52 // try { 53 JSONObject owner = new JSONObject (); 54 claimOwners.Add (owner); 49 JSONObject owner = new JSONObject (); 50 claimOwners.Add (owner); 55 51 56 owner.Add ("steamid", new JSONString (kvp.Key.SteamID));57 52 owner.Add ("steamid", new JSONString (kvp.Key.PlatformId.CombinedString)); 53 owner.Add ("claimactive", new JSONBoolean (kvp.Key.LandProtectionActive)); 58 54 59 60 61 62 63 55 if (kvp.Key.Name.Length > 0) { 56 owner.Add ("playername", new JSONString (kvp.Key.Name)); 57 } else { 58 owner.Add ("playername", new JSONNull ()); 59 } 64 60 65 66 61 JSONArray claimsJson = new JSONArray (); 62 owner.Add ("claims", claimsJson); 67 63 68 69 70 71 72 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)); 73 69 74 claimsJson.Add (claim); 75 } 76 // } catch { 77 // } 70 claimsJson.Add (claim); 71 } 78 72 } 79 73
Note:
See TracChangeset
for help on using the changeset viewer.