Changeset 250 for binary-improvements/MapRendering
- Timestamp:
- Aug 12, 2015, 6:10:28 PM (9 years ago)
- Location:
- binary-improvements/MapRendering
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/API.cs
r230 r250 7 7 public override void GameAwake () { 8 8 new AllocsFixes.NetConnections.Servers.Web.Web (); 9 AllocsFixes.NetConnections.Servers.Web.LogBuffer.Instance.GetType (); 9 10 } 10 11 -
binary-improvements/MapRendering/ModInfo.xml
r249 r250 5 5 <Description value="Render the game map to image map tiles as it is uncovered" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value=" 8" />7 <Version value="9" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/Web/API/GetPlayerInventory.cs
r245 r250 35 35 result.Add ("equipment", equipment); 36 36 37 for (int i = 0; i < inv.belt.Count; i++) { 38 JSONObject item = new JSONObject (); 39 if (inv.belt [i] != null) { 40 item.Add ("count", new JSONNumber (inv.belt [i].count)); 41 item.Add ("name", new JSONString (inv.belt [i].itemName)); 42 } else { 43 item.Add ("count", new JSONNumber (0)); 44 item.Add ("name", new JSONString (string.Empty)); 45 } 46 belt.Add (item); 47 } 48 for (int i = 0; i < inv.bag.Count; i++) { 49 JSONObject item = new JSONObject (); 50 if (inv.bag [i] != null) { 51 item.Add ("count", new JSONNumber (inv.bag [i].count)); 52 item.Add ("name", new JSONString (inv.bag [i].itemName)); 53 } else { 54 item.Add ("count", new JSONNumber (0)); 55 item.Add ("name", new JSONString (string.Empty)); 56 } 57 bag.Add (item); 58 } 37 DoInventory (belt, inv.belt); 38 DoInventory (bag, inv.bag); 59 39 60 40 AddEquipment (equipment, "head", inv.equipment, XMLData.Item.EnumEquipmentSlot.Head, NGuiInvGridEquipment.EnumClothingLayer.Middle); … … 76 56 } 77 57 58 private void DoInventory (JSONArray _jsonRes, List<InvItem> _inv) { 59 for (int i = 0; i < _inv.Count; i++) { 60 _jsonRes.Add (GetJsonForItem (_inv [i])); 61 } 62 } 63 78 64 private void AddEquipment (JSONObject _eq, string _slotname, InvItem[] _items, XMLData.Item.EnumEquipmentSlot _slot, NGuiInvGridEquipment.EnumClothingLayer _layer) { 79 65 int index = (int)_slot + (int)_layer * (int)XMLData.Item.EnumEquipmentSlot.Count; 80 if (_items != null && _items [index] != null) {81 _eq.Add (_slotname, new JSONString (_items [index].itemName));66 if (_items != null) { 67 _eq.Add (_slotname, GetJsonForItem (_items [index])); 82 68 } else { 83 _eq.Add (_slotname, new JSONBoolean (false)); 69 _eq.Add (_slotname, new JSONNull ()); 70 } 71 } 72 73 private JSONNode GetJsonForItem (InvItem _item) { 74 if (_item != null) { 75 JSONObject jsonItem = new JSONObject (); 76 jsonItem.Add ("count", new JSONNumber (_item.count)); 77 jsonItem.Add ("name", new JSONString (_item.itemName)); 78 jsonItem.Add ("quality", new JSONNumber (_item.quality)); 79 if (_item.quality >= 0) { 80 jsonItem.Add ("qualitycolor", new JSONString (QualityInfo.GetQualityColorHex (_item.quality))); 81 } 82 return jsonItem; 83 } else { 84 return new JSONNull (); 84 85 } 85 86 } -
binary-improvements/MapRendering/Web/ConnectionHandler.cs
r244 r250 50 50 } 51 51 52 public void SendLog (string text, string trace, UnityEngine.LogType type) {53 foreach (WebConnection wc in connections.Values) {54 wc.SendLog (text, trace, type);55 }56 }57 58 52 } 59 53 } -
binary-improvements/MapRendering/Web/Handlers/ApiHandler.cs
r247 r250 4 4 using System.IO; 5 5 using System.Net; 6 using System.Reflection; 6 7 using System.Threading; 7 8 … … 14 15 public ApiHandler (string staticPart, string moduleName = null) : base(moduleName) { 15 16 this.staticPart = staticPart; 16 addApi ("getlandclaims", new GetLandClaims ()); 17 addApi ("getplayersonline", new GetPlayersOnline ()); 18 addApi ("getplayerslocation", new GetPlayersLocation ()); 19 addApi ("getplayerinventory", new GetPlayerInventory ()); 20 addApi ("getstats", new GetStats ()); 17 18 foreach (Type t in Assembly.GetExecutingAssembly ().GetTypes ()) { 19 if (!t.IsAbstract && t.IsSubclassOf (typeof(WebAPI))) { 20 ConstructorInfo ctor = t.GetConstructor (new Type[0]); 21 if (ctor != null) { 22 WebAPI apiInstance = (WebAPI)ctor.Invoke (new object[0]); 23 addApi (t.Name.ToLower (), apiInstance); 24 } 25 } 26 } 21 27 } 22 28 … … 38 44 } else { 39 45 foreach (KeyValuePair<string, WebAPI> kvp in apis) { 40 try{41 if (apiName.StartsWith (kvp.Key)){46 if (apiName.StartsWith (kvp.Key)) { 47 try { 42 48 kvp.Value.HandleRequest (req, resp, user, permissionLevel); 43 49 return; 50 } catch (Exception e) { 51 Log.Error ("Error in ApiHandler.HandleRequest(): Handler {0} threw an exception:", kvp.Key); 52 Log.Exception (e); 53 resp.StatusCode = (int)HttpStatusCode.InternalServerError; 54 return; 44 55 } 45 } catch (Exception e) {46 Log.Out ("Error in ApiHandler.HandleRequest(): Handler threw an exception: " + e);47 resp.StatusCode = (int)HttpStatusCode.InternalServerError;48 return;49 56 } 50 57 } -
binary-improvements/MapRendering/Web/Web.cs
r249 r250 250 250 251 251 public void SendLog (string text, string trace, UnityEngine.LogType type) { 252 connectionHandler.SendLog (text, trace, type);252 // Do nothing, handled by LogBuffer internally 253 253 } 254 254 -
binary-improvements/MapRendering/Web/WebConnection.cs
r244 r250 12 12 private DateTime login; 13 13 private DateTime lastAction; 14 15 14 private List<string> outputLines = new List<string> (); 16 private List<LogLine> logLines = new List<LogLine> ();17 15 18 16 public string SessionID { … … 57 55 58 56 public override void SendLog (string _msg, string _trace, LogType _type) { 59 LogLine ll = new LogLine (); 60 ll.message = _msg; 61 ll.trace = _trace; 62 ll.type = _type; 63 logLines.Add (ll); 57 // Do nothing, handled by LogBuffer 64 58 } 65 59 66 private struct LogLine {67 public string message;68 public string trace;69 public LogType type;70 }71 60 } 72 61 } -
binary-improvements/MapRendering/WebAndMapRendering.csproj
r244 r250 75 75 <Compile Include="Commands\WebTokens.cs" /> 76 76 <Compile Include="Commands\WebPermissionsCmd.cs" /> 77 <Compile Include="Web\LogBuffer.cs" /> 78 <Compile Include="Web\API\GetLog.cs" /> 79 <Compile Include="Web\API\GetWebUIUpdates.cs" /> 77 80 </ItemGroup> 78 81 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Note:
See TracChangeset
for help on using the changeset viewer.