- Timestamp:
- Nov 9, 2021, 6:28:33 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs
r348 r369 8 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 9 9 int _permissionLevel) { 10 if (_req.QueryString [" steamid"] == null) {10 if (_req.QueryString ["userid"] == null) { 11 11 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 12 Web.SetResponseTextContent (_resp, "No SteamIDgiven");12 Web.SetResponseTextContent (_resp, "No user id given"); 13 13 return; 14 14 } 15 15 16 string steamId = _req.QueryString ["steamid"]; 17 18 Player p = PersistentContainer.Instance.Players [steamId, false]; 19 if (p == null) { 20 _resp.StatusCode = (int) HttpStatusCode.NotFound; 21 Web.SetResponseTextContent (_resp, "Invalid or unknown SteamID given"); 16 string userIdString = _req.QueryString ["userid"]; 17 if (!PlatformUserIdentifierAbs.TryFromCombinedString (userIdString, out PlatformUserIdentifierAbs userId)) { 18 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 19 Web.SetResponseTextContent (_resp, "Invalid user id given"); 22 20 return; 23 21 } 24 22 25 bool showIconColor, showIconName; 26 GetInventoryArguments (_req, out showIconColor, out showIconName); 23 Player p = PersistentContainer.Instance.Players [userId, false]; 24 if (p == null) { 25 _resp.StatusCode = (int) HttpStatusCode.NotFound; 26 Web.SetResponseTextContent (_resp, "Unknown user id given"); 27 return; 28 } 27 29 28 JSONObject result = DoPlayer (steamId, p, showIconColor, showIconName); 30 GetInventoryArguments (_req, out bool showIconColor, out bool showIconName); 31 32 JSONObject result = DoPlayer (userIdString, p, showIconColor, showIconName); 29 33 30 34 WriteJSON (_resp, result); … … 49 53 JSONArray belt = new JSONArray (); 50 54 JSONObject equipment = new JSONObject (); 51 result.Add (" steamid", new JSONString (_steamId));55 result.Add ("userid", new JSONString (_steamId)); 52 56 result.Add ("entityid", new JSONNumber (_player.EntityID)); 53 57 result.Add ("playername", new JSONString (_player.Name)); … … 86 90 87 91 for (int i = 0; i < slotindices.Length; i++) { 88 if (_items != null && _items[slotindices [i]] != null) {92 if (_items? [slotindices [i]] != null) { 89 93 InvItem item = _items [slotindices [i]]; 90 94 _eq.Add (_slotname, GetJsonForItem (item, _showIconColor, _showIconName));
Note:
See TracChangeset
for help on using the changeset viewer.