- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetHostileLocation.cs
r313 r325 1 using AllocsFixes.JSON; 1 using System.Collections.Generic; 2 using System.Net; 3 using AllocsFixes.JSON; 2 4 using AllocsFixes.LiveData; 3 using System;4 using System.Collections.Generic;5 using System.Net;6 5 7 namespace AllocsFixes.NetConnections.Servers.Web.API 8 { 9 class GetHostileLocation : WebAPI 10 { 11 private List<EntityEnemy> enemies = new List<EntityEnemy> (); 6 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 internal class GetHostileLocation : WebAPI { 8 private readonly List<EntityEnemy> enemies = new List<EntityEnemy> (); 12 9 13 public override void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 14 15 JSONArray hostilesJsResult = new JSONArray();10 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, 11 int permissionLevel) { 12 JSONArray hostilesJsResult = new JSONArray (); 16 13 17 14 Hostiles.Instance.Get (enemies); 18 for (int i = 0; i < enemies.Count; i++) 19 { 15 for (int i = 0; i < enemies.Count; i++) { 20 16 EntityEnemy entity = enemies [i]; 21 Vector3i position = new Vector3i(entity.GetPosition());17 Vector3i position = new Vector3i (entity.GetPosition ()); 22 18 23 JSONObject jsonPOS = new JSONObject();24 jsonPOS.Add("x", new JSONNumber(position.x));25 jsonPOS.Add("y", new JSONNumber(position.y));26 jsonPOS.Add("z", new JSONNumber(position.z));19 JSONObject jsonPOS = new JSONObject (); 20 jsonPOS.Add ("x", new JSONNumber (position.x)); 21 jsonPOS.Add ("y", new JSONNumber (position.y)); 22 jsonPOS.Add ("z", new JSONNumber (position.z)); 27 23 28 JSONObject pJson = new JSONObject();29 pJson.Add("id", new JSONNumber(entity.entityId));24 JSONObject pJson = new JSONObject (); 25 pJson.Add ("id", new JSONNumber (entity.entityId)); 30 26 31 if (!string.IsNullOrEmpty(entity.EntityName)) 32 pJson.Add("name", new JSONString(entity.EntityName)); 33 else 34 pJson.Add("name", new JSONString("enemy class #" + entity.entityClass.ToString())); 27 if (!string.IsNullOrEmpty (entity.EntityName)) { 28 pJson.Add ("name", new JSONString (entity.EntityName)); 29 } else { 30 pJson.Add ("name", new JSONString ("enemy class #" + entity.entityClass)); 31 } 35 32 36 pJson.Add("position", jsonPOS);33 pJson.Add ("position", jsonPOS); 37 34 38 hostilesJsResult.Add(pJson);39 35 hostilesJsResult.Add (pJson); 36 } 40 37 41 WriteJSON(resp, hostilesJsResult);42 43 38 WriteJSON (resp, hostilesJsResult); 39 } 40 } 44 41 }
Note:
See TracChangeset
for help on using the changeset viewer.