Changeset 326 for binary-improvements/MapRendering/Web/API
- Timestamp:
- Sep 4, 2018, 2:33:52 PM (6 years ago)
- Location:
- binary-improvements/MapRendering/Web/API
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetLandClaims.cs
r325 r326 50 50 51 51 foreach (KeyValuePair<Player, List<Vector3i>> kvp in claims) { 52 try {52 // try { 53 53 JSONObject owner = new JSONObject (); 54 54 claimOwners.Add (owner); … … 74 74 claimsJson.Add (claim); 75 75 } 76 } catch {77 }76 // } catch { 77 // } 78 78 } 79 79 -
binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs
r325 r326 75 75 76 76 internal static JSONNode GetJsonForItem (InvItem _item) { 77 if (_item != null) { 78 JSONObject jsonItem = new JSONObject (); 79 jsonItem.Add ("count", new JSONNumber (_item.count)); 80 jsonItem.Add ("name", new JSONString (_item.itemName)); 81 jsonItem.Add ("icon", new JSONString (_item.icon)); 82 jsonItem.Add ("iconcolor", new JSONString (_item.iconcolor)); 83 jsonItem.Add ("quality", new JSONNumber (_item.quality)); 84 if (_item.quality >= 0) { 85 jsonItem.Add ("qualitycolor", new JSONString (QualityInfo.GetQualityColorHex (_item.quality))); 86 } 87 88 return jsonItem; 77 if (_item == null) { 78 return new JSONNull (); 89 79 } 90 80 91 return new JSONNull (); 81 JSONObject jsonItem = new JSONObject (); 82 jsonItem.Add ("count", new JSONNumber (_item.count)); 83 jsonItem.Add ("name", new JSONString (_item.itemName)); 84 jsonItem.Add ("icon", new JSONString (_item.icon)); 85 jsonItem.Add ("iconcolor", new JSONString (_item.iconcolor)); 86 jsonItem.Add ("quality", new JSONNumber (_item.quality)); 87 if (_item.quality >= 0) { 88 jsonItem.Add ("qualitycolor", new JSONString (QualityInfo.GetQualityColorHex (_item.quality))); 89 } 90 91 return jsonItem; 92 92 93 } 93 94 } -
binary-improvements/MapRendering/Web/API/GetPlayerList.cs
r325 r326 40 40 Player p = playersList [sid, false]; 41 41 42 ulong player_steam_ID = 0L;42 ulong player_steam_ID; 43 43 if (!ulong.TryParse (sid, out player_steam_ID)) { 44 44 player_steam_ID = 0L; … … 64 64 pJson.Add ("ping", new JSONNumber (p.IsOnline ? p.ClientInfo.ping : -1)); 65 65 66 JSONBoolean banned = null;66 JSONBoolean banned; 67 67 if (admTools != null) { 68 68 banned = new JSONBoolean (admTools.IsBanned (sid)); … … 132 132 133 133 if (colType == typeof (JSONBoolean)) { 134 bool value = _filterVal.Trim ().ToLower () == "true";135 return _list.Where (line => ( line [_filterCol] as JSONBoolean).GetBool () == value);134 bool value = StringParsers.ParseBool (_filterVal); 135 return _list.Where (line => ((JSONBoolean) line [_filterCol]).GetBool () == value); 136 136 } 137 137 … … 143 143 //Log.Out ("GetPlayerList: Filter on String with Regex '" + _filterVal + "'"); 144 144 Regex matcher = new Regex (_filterVal, RegexOptions.IgnoreCase); 145 return _list.Where (line => matcher.IsMatch (( line [_filterCol] as JSONString).GetString ()));145 return _list.Where (line => matcher.IsMatch (((JSONString) line [_filterCol]).GetString ())); 146 146 } 147 147 } … … 185 185 186 186 return _list.Where (delegate (JSONObject line) { 187 double objVal = ( line [_filterCol] as JSONNumber).GetDouble ();187 double objVal = ((JSONNumber) line [_filterCol]).GetDouble (); 188 188 switch (matchType) { 189 189 case NumberMatchType.Greater: … … 216 216 if (colType == typeof (JSONNumber)) { 217 217 if (_ascending) { 218 return _list.OrderBy (line => ( line [_sortCol] as JSONNumber).GetDouble ());219 } 220 221 return _list.OrderByDescending (line => ( line [_sortCol] as JSONNumber).GetDouble ());218 return _list.OrderBy (line => ((JSONNumber) line [_sortCol]).GetDouble ()); 219 } 220 221 return _list.OrderByDescending (line => ((JSONNumber) line [_sortCol]).GetDouble ()); 222 222 } 223 223 224 224 if (colType == typeof (JSONBoolean)) { 225 225 if (_ascending) { 226 return _list.OrderBy (line => ( line [_sortCol] as JSONBoolean).GetBool ());227 } 228 229 return _list.OrderByDescending (line => ( line [_sortCol] as JSONBoolean).GetBool ());226 return _list.OrderBy (line => ((JSONBoolean) line [_sortCol]).GetBool ()); 227 } 228 229 return _list.OrderByDescending (line => ((JSONBoolean) line [_sortCol]).GetBool ()); 230 230 } 231 231 -
binary-improvements/MapRendering/Web/API/GetPlayersLocation.cs
r325 r326 31 31 32 32 if (listOffline || p.IsOnline) { 33 ulong player_steam_ID = 0L;33 ulong player_steam_ID; 34 34 if (!ulong.TryParse (sid, out player_steam_ID)) { 35 35 player_steam_ID = 0L; -
binary-improvements/MapRendering/Web/API/GetPlayersOnline.cs
r325 r326 41 41 p.Add ("totalplaytime", new JSONNumber (player != null ? player.TotalPlayTime : -1)); 42 42 p.Add ("lastonline", new JSONString (player != null ? player.LastOnline.ToString ("s") : string.Empty)); 43 p.Add ("ping", new JSONNumber (ci != null ? ci.ping : -1));43 p.Add ("ping", new JSONNumber (ci.ping)); 44 44 45 45 players.Add (p); -
binary-improvements/MapRendering/Web/API/WebAPI.cs
r325 r326 5 5 namespace AllocsFixes.NetConnections.Servers.Web.API { 6 6 public abstract class WebAPI { 7 public readonly string Name; 8 9 protected WebAPI () { 10 Name = GetType ().Name; 11 } 12 7 13 public static void WriteJSON (HttpListenerResponse resp, JSONNode root) { 8 14 StringBuilder sb = new StringBuilder ();
Note:
See TracChangeset
for help on using the changeset viewer.