Changeset 306
- Timestamp:
- Aug 2, 2017, 6:46:15 PM (7 years ago)
- Location:
- binary-improvements
- Files:
-
- 1 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/7dtd-server-fixes.csproj
r279 r306 83 83 <Compile Include="src\JSON\JSONNull.cs" /> 84 84 <Compile Include="src\JSON\MalformedJSONException.cs" /> 85 <Compile Include="src\ItemList.cs" />86 85 <Compile Include="src\FileCache\AbstractCache.cs" /> 87 86 <Compile Include="src\FileCache\DirectAccess.cs" /> -
binary-improvements/7dtd-server-fixes/ModInfo.xml
r300 r306 5 5 <Description value="Common functions" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="1 4" />7 <Version value="15" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/7dtd-server-fixes/src/JSON/JSONString.cs
r279 r306 33 33 case '\\': 34 34 case '"': 35 case '/':35 // case '/': 36 36 sb.Append ('\\'); 37 37 sb.Append (c); -
binary-improvements/7dtd-server-fixes/src/LiveData/Animals.cs
r252 r306 6 6 public class Animals 7 7 { 8 public static List<EntityAnimal> List { 9 get { 10 List<EntityAnimal> lst = new List<EntityAnimal> (); 8 public static void Get (List<EntityAnimal> _list) { 9 _list.Clear (); 10 try { 11 List<Entity> entities = GameManager.Instance.World.Entities.list; 12 for (int i = 0; i < entities.Count; i++) { 13 Entity entity = entities [i]; 11 14 12 try { 13 foreach (object base_entity in GameManager.Instance.World.Entities.list) { 14 try { 15 Entity entity = (Entity)base_entity; 15 // Kind of hack-ish, but the game is legitimately setting the base type of animals ('entityType') to enum 0 ('EntityType.Unknown'). 16 if ((entity.entityType == EntityType.Animal) || (entity is EntityAnimal)) { 17 EntityAnimal ea = (EntityAnimal)entity; 16 18 17 // Kind of hack-ish, but the game is legitimately setting the base type of animals ('entityType') to enum 0 ('EntityType.Unknown'). 18 if ((entity.entityType == EntityType.Animal) || (base_entity.GetType ().ToString ().ToLower ().Contains ("animal"))) { 19 EntityAnimal ea = (EntityAnimal)entity; 19 if (ea.IsAlive ()) 20 _list.Add (ea); 21 } 22 } 23 } 24 catch (Exception e) { 25 Log.Exception (e); 26 } 27 } 20 28 21 if (ea.IsAlive ()) 22 lst.Add (ea); 23 } 24 } 25 catch { } 26 } 27 } 28 catch { } 29 public static int GetCount () { 30 int count = 0; 31 try { 32 List<Entity> entities = GameManager.Instance.World.Entities.list; 33 for (int i = 0; i < entities.Count; i++) { 34 Entity entity = entities [i]; 29 35 30 return lst; 31 } 32 } 36 // Kind of hack-ish, but the game is legitimately setting the base type of animals ('entityType') to enum 0 ('EntityType.Unknown'). 37 if ((entity.entityType == EntityType.Animal) || (entity is EntityAnimal)) { 38 EntityAnimal ea = (EntityAnimal)entity; 33 39 40 if (ea.IsAlive ()) 41 count++; 42 } 43 } 44 } 45 catch (Exception e) { 46 Log.Exception (e); 47 } 48 return count; 49 } 34 50 35 public static int Count {36 get { return List.Count; }37 }38 51 } 39 52 } -
binary-improvements/7dtd-server-fixes/src/LiveData/Hostiles.cs
r252 r306 4 4 namespace AllocsFixes.LiveData 5 5 { 6 public class Hostiles 7 { 8 public static List<EntityEnemy> List { 9 get { 10 List<EntityEnemy> lst = new List<EntityEnemy> (); 6 public class Hostiles 7 { 8 public static void Get (List<EntityEnemy> _list) { 9 _list.Clear (); 10 try { 11 List<Entity> entities = GameManager.Instance.World.Entities.list; 12 for (int i = 0; i < entities.Count; i++) { 13 Entity entity = entities [i]; 11 14 12 try { 13 foreach (int ent_id in GameManager.Instance.World.Entities.dict.Keys) { 14 try { 15 Entity entity = GameManager.Instance.World.Entities.dict [ent_id]; 15 if (entity is EntityEnemy) { 16 if (entity.IsAlive ()) 17 _list.Add (entity as EntityEnemy); 18 } 19 } 20 } 21 catch (Exception e) { 22 Log.Exception (e); 23 } 24 } 16 25 17 if (entity.entityType == EntityType.Zombie) { 18 EntityEnemy ee = (EntityEnemy)entity; 26 public static int GetCount () { 27 int count = 0; 28 try { 29 List<Entity> entities = GameManager.Instance.World.Entities.list; 30 for (int i = 0; i < entities.Count; i++) { 31 Entity entity = entities [i]; 19 32 20 if (ee.IsAlive ()) 21 lst.Add (ee); 22 } 23 } 24 catch { } 25 } 26 } 27 catch { } 33 if (entity.entityType == EntityType.Zombie) { 34 EntityEnemy ee = (EntityEnemy)entity; 28 35 29 return lst; 30 } 31 } 32 33 public static int Count { 34 get { return List.Count; } 35 } 36 } 36 if (ee.IsAlive ()) 37 count++; 38 } 39 } 40 } 41 catch (Exception e) { 42 Log.Exception (e); 43 } 44 return count; 45 } 46 } 37 47 } 38 48 -
binary-improvements/7dtd-server-fixes/src/StateManager.cs
r232 r306 9 9 { 10 10 try { 11 ItemList.Instance.Init ();12 13 11 PersistentData.PersistentContainer.Load (); 14 12 } catch (Exception e) { -
binary-improvements/AllocsCommands/Commands/Give.cs
r299 r306 39 39 } 40 40 41 ItemValue iv = Item List.Instance.GetItemValue (_params [1]);42 if (iv == null) {41 ItemValue iv = ItemClass.GetItem (_params [1], true); 42 if (iv.type == ItemValue.None.type) { 43 43 SdtdConsole.Instance.Output ("Item not found."); 44 44 return; 45 45 } 46 47 iv = new ItemValue (iv.type, true); 46 48 47 49 int n = int.MinValue; … … 88 90 ItemStack invField = new ItemStack (iv, n); 89 91 90 GameManager.Instance.ItemDropServer (invField, p.GetPosition (), Vector3.zero , -1, 50);92 GameManager.Instance.ItemDropServer (invField, p.GetPosition (), Vector3.zero); 91 93 92 94 SdtdConsole.Instance.Output ("Dropped item"); -
binary-improvements/AllocsCommands/Commands/ListItems.cs
r273 r306 16 16 } 17 17 18 public override string GetHelp () { 19 return "List all available item names\n" + 20 "Usage:\n" + 21 " 1. listitems <searchString>\n" + 22 " 2. listitems *\n" + 23 "1. List only names that contain the given string.\n" + 24 "2. List all names."; 25 } 26 18 27 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 19 28 { … … 24 33 } 25 34 26 int n = 0; 27 foreach (string s in ItemList.Instance.ItemNames) { 28 if (s.ToLower ().Contains (_params [0].ToLower ()) || _params[0].Trim().Equals("*")) { 35 int count = ItemClass.ItemNames.Count; 36 bool showAll = _params[0].Trim().Equals("*"); 37 38 int listed = 0; 39 for (int i = 0; i < count; i++) { 40 string s = ItemClass.ItemNames [i]; 41 if (showAll || s.IndexOf (_params [0], StringComparison.OrdinalIgnoreCase) >= 0) { 29 42 SdtdConsole.Instance.Output (" " + s); 30 n++;43 listed++; 31 44 } 32 45 } 33 46 34 SdtdConsole.Instance.Output ("Listed " + n+ " matching items.");47 SdtdConsole.Instance.Output ("Listed " + listed + " matching items."); 35 48 } catch (Exception e) { 36 49 Log.Out ("Error in ListItems.Run: " + e); -
binary-improvements/AllocsCommands/Commands/RemoveLandProtection.cs
r266 r306 15 15 " 1. removelandprotection <steamid>\n" + 16 16 " 2. removelandprotection <x> <y> <z>\n" + 17 " 3. removelandprotection nearby [length]\n" + 17 18 "1. Remove all land claims owned by the user with the given SteamID\n" + 18 "2. Remove only the claim block on the exactly given block position"; 19 "2. Remove only the claim block on the exactly given block position\n" + 20 "3. Remove all claims in a square with edge length of 64 (or the optionally specified size) around the executing player"; 19 21 } 20 22 … … 95 97 { 96 98 try { 97 if (_params.Count == 1) { 99 if (_senderInfo.RemoteClientInfo != null) { 100 if (_params.Count >= 1 && _params [0].EqualsCaseInsensitive ("nearby")) { 101 _params.Add (_senderInfo.RemoteClientInfo.playerId); 102 } 103 } 104 105 if (_params.Count > 0 && _params [0].EqualsCaseInsensitive ("nearby")) { 106 try { 107 int closeToDistance = 32; 108 if (_params.Count == 3) { 109 if (!int.TryParse (_params[1], out closeToDistance)) { 110 SdtdConsole.Instance.Output ("Given length is not an integer!"); 111 return; 112 } 113 closeToDistance /= 2; 114 } 115 ClientInfo ci = ConsoleHelper.ParseParamSteamIdOnline (_params [_params.Count - 1]); 116 EntityPlayer ep = GameManager.Instance.World.Players.dict [ci.entityId]; 117 Vector3i closeTo = new Vector3i (ep.GetPosition ()); 118 LandClaimList.PositionFilter[] posFilters = new LandClaimList.PositionFilter[] { LandClaimList.CloseToFilter2dRect (closeTo, closeToDistance) }; 119 Dictionary<PersistentData.Player, List<Vector3i>> claims = LandClaimList.GetLandClaims (null, posFilters); 120 121 try { 122 List<BlockChangeInfo> changes = new List<BlockChangeInfo> (); 123 foreach (KeyValuePair<PersistentData.Player, List<Vector3i>> kvp in claims) { 124 foreach (Vector3i v in kvp.Value) { 125 BlockChangeInfo bci = new BlockChangeInfo (v, new BlockValue (0), true, false); 126 changes.Add (bci); 127 } 128 } 129 GameManager.Instance.SetBlocksRPC (changes); 130 } catch (Exception e) { 131 SdtdConsole.Instance.Output ("Error removing claims"); 132 Log.Out ("Error in RemoveLandProtection.Run: " + e); 133 return; 134 } 135 } catch (Exception e) { 136 SdtdConsole.Instance.Output ("Error getting current player's position"); 137 Log.Out ("Error in RemoveLandProtection.Run: " + e); 138 return; 139 } 140 } else if (_params.Count == 1) { 98 141 removeById (_params [0]); 99 142 } else if (_params.Count == 3) { 100 143 removeByPosition (_params); 101 144 } else { 102 SdtdConsole.Instance.Output (" Usage: removelandprotection <x> <y> <z> OR removelandprotection <steamid>");145 SdtdConsole.Instance.Output ("Illegal parameters"); 103 146 } 104 147 } catch (Exception e) { -
binary-improvements/AllocsCommands/ModInfo.xml
r299 r306 5 5 <Description value="Additional commands for server operation" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="1 2" />7 <Version value="13" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/ModInfo.xml
r299 r306 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=" 19" />7 <Version value="20" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/Web/API/ExecuteConsoleCommand.cs
r279 r306 15 15 return; 16 16 } 17 18 WebCommandResult.ResultType responseType = 19 req.QueryString ["raw"] != null ? WebCommandResult.ResultType.Raw : 20 (req.QueryString ["simple"] != null ? WebCommandResult.ResultType.ResultOnly : 21 WebCommandResult.ResultType.Full); 17 22 18 23 string commandline = req.QueryString ["command"]; … … 36 41 } 37 42 38 // TODO: Execute command (store resp as IConsoleConnection instance to deliver response to the single client?)39 40 43 resp.SendChunked = true; 41 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, resp );44 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, resp); 42 45 SdtdConsole.Instance.ExecuteAsync (commandline, wcr); 43 46 } -
binary-improvements/MapRendering/Web/API/GetAnimalsLocation.cs
r251 r306 9 9 class GetAnimalsLocation : WebAPI 10 10 { 11 private List<EntityAnimal> animals = new List<EntityAnimal> (); 12 11 13 public override void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 12 14 { 13 15 JSONArray animalsJsResult = new JSONArray(); 14 16 15 foreach (EntityAnimal entity in Animals.List) 16 { 17 Animals.Get (animals); 18 for (int i = 0; i < animals.Count; i++) 19 { 20 EntityAnimal entity = animals [i]; 17 21 Vector3i position = new Vector3i(entity.GetPosition()); 18 22 -
binary-improvements/MapRendering/Web/API/GetHostileLocation.cs
r251 r306 9 9 class GetHostileLocation : WebAPI 10 10 { 11 private List<EntityEnemy> enemies = new List<EntityEnemy> (); 12 11 13 public override void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 12 14 { 13 15 JSONArray hostilesJsResult = new JSONArray(); 14 16 15 foreach (EntityEnemy entity in Hostiles.List) 17 Hostiles.Get (enemies); 18 for (int i = 0; i < enemies.Count; i++) 16 19 { 20 EntityEnemy entity = enemies [i]; 17 21 Vector3i position = new Vector3i(entity.GetPosition()); 18 22 -
binary-improvements/MapRendering/Web/API/GetStats.cs
r279 r306 21 21 22 22 result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count)); 23 result.Add ("hostiles", new JSONNumber (Hostiles.Count));24 result.Add ("animals", new JSONNumber (Animals.Count));23 result.Add ("hostiles", new JSONNumber (Hostiles.GetCount ())); 24 result.Add ("animals", new JSONNumber (Animals.GetCount ())); 25 25 26 26 WriteJSON (resp, result); -
binary-improvements/MapRendering/Web/API/GetWebUIUpdates.cs
r279 r306 24 24 25 25 result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count)); 26 result.Add ("hostiles", new JSONNumber (Hostiles.Count));27 result.Add ("animals", new JSONNumber (Animals.Count));26 result.Add ("hostiles", new JSONNumber (Hostiles.GetCount ())); 27 result.Add ("animals", new JSONNumber (Animals.GetCount ())); 28 28 29 29 result.Add ("newlogs", new JSONNumber (LogBuffer.Instance.LatestLine - latestLine)); -
binary-improvements/MapRendering/Web/API/WebAPI.cs
r279 r306 7 7 public abstract class WebAPI 8 8 { 9 public void WriteJSON (HttpListenerResponse resp, JSON.JSONNode root)9 public static void WriteJSON (HttpListenerResponse resp, JSON.JSONNode root) 10 10 { 11 11 byte[] buf = Encoding.UTF8.GetBytes (root.ToString()); … … 14 14 resp.ContentEncoding = Encoding.UTF8; 15 15 resp.OutputStream.Write (buf, 0, buf.Length); 16 } 17 18 public static void WriteText (HttpListenerResponse _resp, string _text) 19 { 20 byte[] buf = Encoding.UTF8.GetBytes (_text); 21 _resp.ContentLength64 = buf.Length; 22 _resp.ContentType = "text/plain"; 23 _resp.ContentEncoding = Encoding.UTF8; 24 _resp.OutputStream.Write (buf, 0, buf.Length); 16 25 } 17 26 -
binary-improvements/MapRendering/Web/Handlers/ItemIconHandler.cs
r292 r306 152 152 153 153 private void AddIcon (string _name, Texture2D _tex, Dictionary<string, List<Color>> _tintedIcons) { 154 icons .Add (_name + "__FFFFFF", _tex.EncodeToPNG ());154 icons [_name + "__FFFFFF"] = _tex.EncodeToPNG (); 155 155 156 156 if (_tintedIcons.ContainsKey (_name)) { … … 166 166 } 167 167 168 icons .Add (tintedName, tintedTex.EncodeToPNG ());168 icons [tintedName] = tintedTex.EncodeToPNG (); 169 169 170 170 UnityEngine.Object.Destroy (tintedTex); -
binary-improvements/MapRendering/Web/WebCommandResult.cs
r279 r306 8 8 using System.Net.Sockets; 9 9 using System.Threading; 10 using AllocsFixes.NetConnections.Servers.Web.API; 10 11 11 12 namespace AllocsFixes.NetConnections.Servers.Web … … 13 14 public class WebCommandResult : IConsoleConnection 14 15 { 16 public enum ResultType { 17 Full, 18 ResultOnly, 19 Raw 20 } 21 15 22 public static int handlingCount = 0; 16 23 public static int currentHandlers = 0; … … 20 27 private string command; 21 28 private string parameters; 29 private ResultType responseType; 22 30 23 public WebCommandResult (string _command, string _parameters, HttpListenerResponse _response) {31 public WebCommandResult (string _command, string _parameters, ResultType _responseType, HttpListenerResponse _response) { 24 32 Interlocked.Increment (ref handlingCount); 25 33 Interlocked.Increment (ref currentHandlers); … … 28 36 command = _command; 29 37 parameters = _parameters; 38 responseType = _responseType; 30 39 } 31 40 … … 38 47 } 39 48 40 JSONObject result = new JSONObject ();41 42 result.Add ("command", new JSONString (command));43 result.Add ("parameters", new JSONString (parameters));44 result.Add ("result", new JSONString (sb.ToString ()));45 46 49 response.SendChunked = false; 47 50 48 51 try { 49 WriteJSON (response, result); 52 if (responseType == ResultType.Raw) { 53 WebAPI.WriteText (response, sb.ToString ()); 54 } else { 55 JSONNode result; 56 if (responseType == ResultType.ResultOnly) { 57 result = new JSONString (sb.ToString ()); 58 } else { 59 JSONObject resultObj = new JSONObject (); 60 61 resultObj.Add ("command", new JSONString (command)); 62 resultObj.Add ("parameters", new JSONString (parameters)); 63 resultObj.Add ("result", new JSONString (sb.ToString ())); 64 65 result = resultObj; 66 } 67 WebAPI.WriteJSON (response, result); 68 } 50 69 } catch (IOException e) { 51 70 if (e.InnerException is SocketException) { … … 62 81 63 82 msw.Stop (); 64 totalHandlingTime += msw.ElapsedMicroseconds; 65 Log.Out ("WebCommandResult.SendLines(): Took {0} µs", msw.ElapsedMicroseconds); 83 if (GamePrefs.GetInt (EnumGamePrefs.HideCommandExecutionLog) < 1) { 84 totalHandlingTime += msw.ElapsedMicroseconds; 85 Log.Out ("WebCommandResult.SendLines(): Took {0} µs", msw.ElapsedMicroseconds); 86 } 66 87 Interlocked.Decrement (ref currentHandlers); 67 88 } 68 }69 70 public void WriteJSON (HttpListenerResponse resp, JSON.JSONNode root)71 {72 byte[] buf = Encoding.UTF8.GetBytes (root.ToString());73 resp.ContentLength64 = buf.Length;74 resp.ContentType = "application/json";75 resp.ContentEncoding = Encoding.UTF8;76 resp.OutputStream.Write (buf, 0, buf.Length);77 89 } 78 90 -
binary-improvements/server-fixes.userprefs
r299 r306 1 1 <Properties> 2 2 <MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Version" /> 3 <MonoDevelop.Ide.Workbench ActiveDocument=" 7dtd-server-fixes/src/ItemList.cs">3 <MonoDevelop.Ide.Workbench ActiveDocument="MapRendering/Web/API/WebAPI.cs"> 4 4 <Files> 5 5 <File FileName="7dtd-server-fixes/ModInfo.xml" Line="1" Column="1" /> 6 <File FileName="AllocsCommands/ModInfo.xml" Line=" 21" Column="21" />7 <File FileName="MapRendering/ModInfo.xml" Line=" 7" Column="7" />8 <File FileName="MapRendering/Web/Web.cs" Line="1 " Column="1" />9 <File FileName="MapRendering/Web/API/ExecuteConsoleCommand.cs" Line=" 1" Column="1" />6 <File FileName="AllocsCommands/ModInfo.xml" Line="1" Column="1" /> 7 <File FileName="MapRendering/ModInfo.xml" Line="1" Column="1" /> 8 <File FileName="MapRendering/Web/Web.cs" Line="10" Column="10" /> 9 <File FileName="MapRendering/Web/API/ExecuteConsoleCommand.cs" Line="41" Column="41" /> 10 10 <File FileName="MapRendering/Commands/WebTokens.cs" Line="1" Column="1" /> 11 <File FileName="MapRendering/API.cs" Line=" 1" Column="1" />11 <File FileName="MapRendering/API.cs" Line="48" Column="48" /> 12 12 <File FileName="MapRendering/Web/API/GetAllowedCommands.cs" Line="1" Column="1" /> 13 13 <File FileName="MapRendering/Web/API/GetPlayerList.cs" Line="1" Column="1" /> 14 <File FileName="AllocsCommands/Commands/ListKnownPlayers.cs" Line="1" Column="1" /> 15 <File FileName="MapRendering/Web/API/GetHostileLocation.cs" Line="1" Column="1" /> 16 <File FileName="7dtd-server-fixes/src/LiveData/Hostiles.cs" Line="1" Column="1" /> 14 <File FileName="MapRendering/Web/API/GetHostileLocation.cs" Line="54" Column="54" /> 17 15 <File FileName="7dtd-server-fixes/src/PersistentData/Player.cs" Line="1" Column="1" /> 18 <File FileName="MapRendering/Web/API/GetPlayersOnline.cs" Line=" 1" Column="1" />16 <File FileName="MapRendering/Web/API/GetPlayersOnline.cs" Line="57" Column="57" /> 19 17 <File FileName="AllocsCommands/Commands/Give.cs" Line="1" Column="1" /> 20 <File FileName="MapRendering/Web/Handlers/ItemIconHandler.cs" Line="1" Column="1" /> 21 <File FileName="AllocsCommands/Commands/ShowInventory.cs" Line="107" Column="107" /> 22 <File FileName="7dtd-server-fixes/src/ItemList.cs" Line="17" Column="17" /> 23 <File FileName="7dtd-server-fixes/src/API.cs" Line="17" Column="17" /> 18 <File FileName="MapRendering/Web/Handlers/ItemIconHandler.cs" Line="4" Column="4" /> 19 <File FileName="AllocsCommands/Commands/ShowInventory.cs" Line="1" Column="1" /> 20 <File FileName="7dtd-server-fixes/src/ItemList.cs" Line="25" Column="25" /> 21 <File FileName="7dtd-server-fixes/src/PersistentData/Inventory.cs" Line="1" Column="1" /> 22 <File FileName="7dtd-server-fixes/src/AllocsLogFunctions.cs" Line="1" Column="1" /> 23 <File FileName="7dtd-server-fixes/src/PersistentData/PersistentContainer.cs" Line="1" Column="1" /> 24 <File FileName="7dtd-server-fixes/src/ChatHookExample.cs" Line="1" Column="1" /> 25 <File FileName="MapRendering/Commands/WebPermissionsCmd.cs" Line="1" Column="1" /> 26 <File FileName="MapRendering/Web/WebPermissions.cs" Line="1" Column="1" /> 27 <File FileName="MapRendering/Web/Handlers/ApiHandler.cs" Line="28" Column="28" /> 28 <File FileName="MapRendering/Web/WebCommandResult.cs" Line="18" Column="18" /> 29 <File FileName="7dtd-server-fixes/src/LiveData/Hostiles.cs" Line="51" Column="51" /> 30 <File FileName="MapRendering/Web/API/WebAPI.cs" Line="34" Column="34" /> 24 31 </Files> 25 32 </MonoDevelop.Ide.Workbench> -
binary-improvements/webserver/js/map.js
r253 r306 93 93 }); 94 94 95 var densityMismatchMarkerGroupAir = L.markerClusterGroup({ 96 maxClusterRadius: function(zoom) { return zoom == mapinfo.maxzoom ? 10 : 50; } 97 }); 98 var densityMismatchMarkerGroupTerrain = L.markerClusterGroup({ 99 maxClusterRadius: function(zoom) { return zoom == mapinfo.maxzoom ? 10 : 50; } 100 }); 101 var densityMismatchMarkerGroupNonTerrain = L.markerClusterGroup({ 102 maxClusterRadius: function(zoom) { return zoom == mapinfo.maxzoom ? 10 : 50; } 103 }); 104 95 105 96 106 var layerControl = L.control.layers({ … … 117 127 118 128 layerControl.addOverlay (GetRegionLayer (mapinfo), "Region files"); 129 layerCount++; 119 130 120 131 var miniMap = new L.Control.MiniMap(tileLayerMiniMap, { … … 166 177 layerCount++; 167 178 } 168 179 169 180 if (layerCount > 0) { 170 181 layerControl.addTo(map); … … 430 441 } 431 442 443 444 445 446 447 448 449 450 451 // =============================================================================================== 452 // Density markers 453 454 var setDensityMarkers = function(data) { 455 var densityCountAir = 0; 456 var densityCountTerrain = 0; 457 var densityCountNonTerrain = 0; 458 459 densityMismatchMarkerGroupAir.clearLayers(); 460 densityMismatchMarkerGroupTerrain.clearLayers(); 461 densityMismatchMarkerGroupNonTerrain.clearLayers(); 462 463 464 var downloadCsv = true; 465 var downloadJson = false; 466 467 if (downloadJson) { 468 var jsonAir = []; 469 var jsonTerrain = []; 470 var jsonNonTerrain = []; 471 } 472 if (downloadCsv) { 473 var csvAir = "x;y;z;Density;IsTerrain;BvType\r\n"; 474 var csvTerrain = "x;y;z;Density;IsTerrain;BvType\r\n"; 475 var csvNonTerrain = "x;y;z;Density;IsTerrain;BvType\r\n"; 476 } 477 478 $.each( data, function( key, val ) { 479 if (val.bvtype == 0) { 480 marker = L.marker([val.x, val.z]).bindPopup( 481 "Density Mismatch: <br>Position: " + val.x + " " + val.y + " " + val.z + "<br>Density: " + val.density + "<br>isTerrain: " + val.terrain + "<br>bv.type: " + val.bvtype 482 ); 483 densityMismatchMarkerGroupAir.addLayer(marker); 484 densityCountAir++; 485 if (downloadJson) { 486 jsonAir.push (val); 487 } 488 if (downloadCsv) { 489 csvAir += val.x + ";" + val.y + ";" + val.z + ";" + val.density + ";" + val.terrain + ";" + val.bvtype + "\r\n"; 490 } 491 } else if (val.terrain) { 492 marker = L.marker([val.x, val.z]).bindPopup( 493 "Density Mismatch: <br>Position: " + val.x + " " + val.y + " " + val.z + "<br>Density: " + val.density + "<br>isTerrain: " + val.terrain + "<br>bv.type: " + val.bvtype 494 ); 495 densityMismatchMarkerGroupTerrain.addLayer(marker); 496 densityCountTerrain++; 497 if (downloadJson) { 498 jsonTerrain.push (val); 499 } 500 if (downloadCsv) { 501 csvTerrain += val.x + ";" + val.y + ";" + val.z + ";" + val.density + ";" + val.terrain + ";" + val.bvtype + "\r\n"; 502 } 503 } else { 504 marker = L.marker([val.x, val.z]).bindPopup( 505 "Density Mismatch: <br>Position: " + val.x + " " + val.y + " " + val.z + "<br>Density: " + val.density + "<br>isTerrain: " + val.terrain + "<br>bv.type: " + val.bvtype 506 ); 507 densityMismatchMarkerGroupNonTerrain.addLayer(marker); 508 densityCountNonTerrain++; 509 if (downloadJson) { 510 jsonNonTerrain.push (val); 511 } 512 if (downloadCsv) { 513 csvNonTerrain += val.x + ";" + val.y + ";" + val.z + ";" + val.density + ";" + val.terrain + ";" + val.bvtype + "\r\n"; 514 } 515 } 516 }); 517 518 layerControl.addOverlay (densityMismatchMarkerGroupAir, "Density Mismatches Air (<span id='mapControlDensityCountAir'>0</span>)"); 519 layerControl.addOverlay (densityMismatchMarkerGroupTerrain, "Density Mismatches Terrain (<span id='mapControlDensityCountTerrain'>0</span>)"); 520 layerControl.addOverlay (densityMismatchMarkerGroupNonTerrain, "Density Mismatches NonTerrain (<span id='mapControlDensityCountNonTerrain'>0</span>)"); 521 522 $( "#mapControlDensityCountAir" ).text( densityCountAir ); 523 $( "#mapControlDensityCountTerrain" ).text( densityCountTerrain ); 524 $( "#mapControlDensityCountNonTerrain" ).text( densityCountNonTerrain ); 525 526 if (downloadJson) { 527 download ("air-negative-density.json", JSON.stringify(jsonAir, null, '\t')); 528 download ("terrain-positive-density.json", JSON.stringify(jsonTerrain, null, '\t')); 529 download ("nonterrain-negative-density.json", JSON.stringify(jsonNonTerrain, null, '\t')); 530 } 531 if (downloadCsv) { 532 download ("air-negative-density.csv", csvAir); 533 download ("terrain-positive-density.csv", csvTerrain); 534 download ("nonterrain-negative-density.csv", csvNonTerrain); 535 } 536 537 function download(filename, text) { 538 var element = document.createElement('a'); 539 var file = new Blob([text], {type: 'text/plain'}); 540 element.href = URL.createObjectURL(file); 541 element.download = filename; 542 543 element.style.display = 'none'; 544 document.body.appendChild(element); 545 546 element.click(); 547 548 document.body.removeChild(element); 549 } 550 } 551 552 $.getJSON("densitymismatch.json") 553 .done(setDensityMarkers) 554 .fail(function(jqxhr, textStatus, error) { 555 console.log("Error fetching density mismatch list"); 556 }); 557 432 558 } 433 559
Note:
See TracChangeset
for help on using the changeset viewer.