Changeset 325 for binary-improvements/MapRendering/Commands
- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- Location:
- binary-improvements/MapRendering/Commands
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Commands/EnableOpenIDDebug.cs
r318 r325 1 1 using System; 2 2 using System.Collections.Generic; 3 using AllocsFixes.NetConnections.Servers.Web; 3 4 4 namespace AllocsFixes.CustomCommands 5 { 6 public class EnableOpenIDDebug : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 5 namespace AllocsFixes.CustomCommands { 6 public class EnableOpenIDDebug : ConsoleCmdAbstract { 7 public override string GetDescription () { 10 8 return "enable/disable OpenID debugging"; 11 9 } 12 10 13 public override string[] GetCommands () 14 { 15 return new string[] { "openiddebug" }; 11 public override string[] GetCommands () { 12 return new[] {"openiddebug"}; 16 13 } 17 14 18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 19 { 15 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 20 16 try { 21 17 if (_params.Count != 1) { 22 SdtdConsole.Instance.Output ("Current state: " + AllocsFixes.NetConnections.Servers.Web.OpenID.debugOpenId);18 SdtdConsole.Instance.Output ("Current state: " + OpenID.debugOpenId); 23 19 return; 24 20 } 25 21 26 AllocsFixes.NetConnections.Servers.Web.OpenID.debugOpenId = _params[0].Equals("1");22 OpenID.debugOpenId = _params [0].Equals ("1"); 27 23 SdtdConsole.Instance.Output ("Set OpenID debugging to " + _params [0].Equals ("1")); 28 24 } catch (Exception e) { -
binary-improvements/MapRendering/Commands/EnableRendering.cs
r230 r325 2 2 using System.Collections.Generic; 3 3 4 namespace AllocsFixes.CustomCommands 5 { 6 public class EnableRendering : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 4 namespace AllocsFixes.CustomCommands { 5 public class EnableRendering : ConsoleCmdAbstract { 6 public override string GetDescription () { 10 7 return "enable/disable live map rendering"; 11 8 } 12 9 13 public override string[] GetCommands () 14 { 15 return new string[] { "enablerendering" }; 10 public override string[] GetCommands () { 11 return new[] {"enablerendering"}; 16 12 } 17 13 18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 19 { 14 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 20 15 try { 21 16 if (_params.Count != 1) { 22 SdtdConsole.Instance.Output ("Current state: " + AllocsFixes.MapRendering.MapRendering.renderingEnabled);17 SdtdConsole.Instance.Output ("Current state: " + MapRendering.MapRendering.renderingEnabled); 23 18 return; 24 19 } 25 20 26 AllocsFixes.MapRendering.MapRendering.renderingEnabled = _params[0].Equals("1");21 MapRendering.MapRendering.renderingEnabled = _params [0].Equals ("1"); 27 22 SdtdConsole.Instance.Output ("Set live map rendering to " + _params [0].Equals ("1")); 28 23 } catch (Exception e) { -
binary-improvements/MapRendering/Commands/ReloadWebPermissions.cs
r244 r325 1 1 using System; 2 2 using System.Collections.Generic; 3 using AllocsFixes.NetConnections.Servers.Web; 3 4 4 namespace AllocsFixes.CustomCommands 5 { 6 public class ReloadWebPermissions : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 5 namespace AllocsFixes.CustomCommands { 6 public class ReloadWebPermissions : ConsoleCmdAbstract { 7 public override string GetDescription () { 10 8 return "force reload of web permissions file"; 11 9 } 12 10 13 public override string[] GetCommands () 14 { 15 return new string[] { "reloadwebpermissions" }; 11 public override string[] GetCommands () { 12 return new[] {"reloadwebpermissions"}; 16 13 } 17 14 18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 19 { 15 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 20 16 try { 21 AllocsFixes.NetConnections.Servers.Web.WebPermissions.Instance.Load ();17 WebPermissions.Instance.Load (); 22 18 SdtdConsole.Instance.Output ("Web permissions file reloaded"); 23 19 } catch (Exception e) { -
binary-improvements/MapRendering/Commands/RenderMap.cs
r230 r325 1 using AllocsFixes.MapRendering;2 1 using System; 3 using System.IO;4 2 using System.Collections.Generic; 5 3 6 namespace AllocsFixes.CustomCommands 7 { 8 public class RenderMap : ConsoleCmdAbstract 9 { 10 public override string GetDescription () 11 { 4 namespace AllocsFixes.CustomCommands { 5 public class RenderMap : ConsoleCmdAbstract { 6 public override string GetDescription () { 12 7 return "render the current map to a file"; 13 8 } 14 9 15 public override string[] GetCommands () 16 { 17 return new string[] { "rendermap" }; 10 public override string[] GetCommands () { 11 return new[] {"rendermap"}; 18 12 } 19 13 20 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 21 { 14 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 22 15 try { 23 AllocsFixes.MapRendering.MapRendering.Instance.RenderFullMap ();16 MapRendering.MapRendering.Instance.RenderFullMap (); 24 17 25 18 SdtdConsole.Instance.Output ("Render map done"); -
binary-improvements/MapRendering/Commands/WebPermissionsCmd.cs
r244 r325 1 using System;2 1 using System.Collections.Generic; 3 using System.IO;2 using AllocsFixes.NetConnections.Servers.Web; 4 3 5 using AllocsFixes.NetConnections.Servers.Web; 6 using UnityEngine; 7 8 namespace AllocsFixes.CustomCommands 9 { 4 namespace AllocsFixes.CustomCommands { 10 5 public class WebPermissionsCmd : ConsoleCmdAbstract { 11 6 public override string[] GetCommands () { 12 return new string[] { "webpermission"};7 return new[] {"webpermission"}; 13 8 } 14 15 public override string GetDescription () { 9 10 public override string GetDescription () { 16 11 return "Manage web permission levels"; 17 12 } 18 13 19 14 public override string GetHelp () { 20 15 return "Set/get permission levels required to access a given web functionality. Default\n" + 21 22 23 24 25 16 "level required for functions that are not explicitly specified is 0.\n" + 17 "Usage:\n" + 18 " webpermission add <webfunction> <level>\n" + 19 " webpermission remove <webfunction>\n" + 20 " webpermission list"; 26 21 } 27 22 28 23 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 29 24 if (_params.Count >= 1) { … … 46 41 } 47 42 } 48 43 49 44 private void ExecuteAdd (List<string> _params) { 50 45 if (_params.Count != 3) { … … 52 47 return; 53 48 } 54 49 55 50 if (!WebPermissions.Instance.IsKnownModule (_params [1])) { 56 51 SdtdConsole.Instance.Output ("\"" + _params [1] + "\" is not a valid web function."); 57 52 return; 58 53 } 59 54 60 55 int level; 61 56 if (!int.TryParse (_params [2], out level)) { … … 63 58 return; 64 59 } 65 60 66 61 WebPermissions.Instance.AddModulePermission (_params [1], level); 67 62 SdtdConsole.Instance.Output (string.Format ("{0} added with permission level of {1}.", _params [1], level)); 68 63 } 69 64 70 65 private void ExecuteRemove (List<string> _params) { 71 66 if (_params.Count != 2) { … … 73 68 return; 74 69 } 75 70 76 71 if (!WebPermissions.Instance.IsKnownModule (_params [1])) { 77 72 SdtdConsole.Instance.Output ("\"" + _params [1] + "\" is not a valid web function."); 78 73 return; 79 74 } 80 75 81 76 WebPermissions.Instance.RemoveModulePermission (_params [1]); 82 77 SdtdConsole.Instance.Output (string.Format ("{0} removed from permissions list.", _params [1])); 83 78 } 84 79 85 80 private void ExecuteList () { 86 81 SdtdConsole.Instance.Output ("Defined web function permissions:"); … … 90 85 } 91 86 } 92 93 87 } 94 88 } -
binary-improvements/MapRendering/Commands/WebTokens.cs
r244 r325 1 using System;2 1 using System.Collections.Generic; 3 using System.IO;4 2 using System.Text.RegularExpressions; 3 using AllocsFixes.NetConnections.Servers.Web; 5 4 6 using AllocsFixes.NetConnections.Servers.Web; 7 using UnityEngine; 8 9 namespace AllocsFixes.CustomCommands 10 { 5 namespace AllocsFixes.CustomCommands { 11 6 public class WebTokens : ConsoleCmdAbstract { 12 private static Regex validNameTokenMatcher = new Regex (@"^\w+$");7 private static readonly Regex validNameTokenMatcher = new Regex (@"^\w+$"); 13 8 14 9 public override string[] GetCommands () { 15 return new string[] { "webtokens"};10 return new[] {"webtokens"}; 16 11 } 17 18 public override string GetDescription () { 12 13 public override string GetDescription () { 19 14 return "Manage web tokens"; 20 15 } … … 22 17 public override string GetHelp () { 23 18 return "Set/get webtoken permission levels. A level of 0 is maximum permission.\n" + 24 25 26 27 19 "Usage:\n" + 20 " webtokens add <username> <usertoken> <level>\n" + 21 " webtokens remove <username>\n" + 22 " webtokens list"; 28 23 } 29 24 30 25 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 31 26 if (_params.Count >= 1) { … … 61 56 62 57 if (!validNameTokenMatcher.IsMatch (_params [1])) { 63 SdtdConsole.Instance.Output ("Argument 'username' may only contain characters (A-Z, a-z), digits (0-9) and underscores (_)."); 58 SdtdConsole.Instance.Output ( 59 "Argument 'username' may only contain characters (A-Z, a-z), digits (0-9) and underscores (_)."); 64 60 return; 65 61 } … … 71 67 72 68 if (!validNameTokenMatcher.IsMatch (_params [2])) { 73 SdtdConsole.Instance.Output ("Argument 'usertoken' may only contain characters (A-Z, a-z), digits (0-9) and underscores (_)."); 69 SdtdConsole.Instance.Output ( 70 "Argument 'usertoken' may only contain characters (A-Z, a-z), digits (0-9) and underscores (_)."); 74 71 return; 75 72 } … … 82 79 83 80 WebPermissions.Instance.AddAdmin (_params [1], _params [2], level); 84 SdtdConsole.Instance.Output (string.Format ("Web user with name={0} and password={1} added with permission level of {2}.", _params [1], _params [2], level)); 81 SdtdConsole.Instance.Output (string.Format ( 82 "Web user with name={0} and password={1} added with permission level of {2}.", _params [1], _params [2], 83 level)); 85 84 } 86 85 87 86 private void ExecuteRemove (List<string> _params) { 88 87 if (_params.Count != 2) { … … 90 89 return; 91 90 } 92 91 93 92 if (string.IsNullOrEmpty (_params [1])) { 94 93 SdtdConsole.Instance.Output ("Argument 'username' is empty."); … … 97 96 98 97 if (!validNameTokenMatcher.IsMatch (_params [1])) { 99 SdtdConsole.Instance.Output ("Argument 'username' may only contain characters (A-Z, a-z), digits (0-9) and underscores (_)."); 98 SdtdConsole.Instance.Output ( 99 "Argument 'username' may only contain characters (A-Z, a-z), digits (0-9) and underscores (_)."); 100 100 return; 101 101 } … … 104 104 SdtdConsole.Instance.Output (string.Format ("{0} removed from web user permissions list.", _params [1])); 105 105 } 106 106 107 107 private void ExecuteList () { 108 108 SdtdConsole.Instance.Output ("Defined webuser permissions:"); 109 109 SdtdConsole.Instance.Output (" Level: Name / Token"); 110 110 foreach (WebPermissions.AdminToken at in WebPermissions.Instance.GetAdmins ()) { 111 SdtdConsole.Instance.Output (string.Format (" {0,5}: {1} / {2}", at.permissionLevel, at.name, at.token)); 111 SdtdConsole.Instance.Output ( 112 string.Format (" {0,5}: {1} / {2}", at.permissionLevel, at.name, at.token)); 112 113 } 113 114 } 114 115 115 } 116 116 } -
binary-improvements/MapRendering/Commands/webstat.cs
r279 r325 1 1 using System; 2 2 using System.Collections.Generic; 3 using AllocsFixes.NetConnections.Servers.Web; 3 4 4 namespace AllocsFixes.CustomCommands 5 { 6 public class webstat : ConsoleCmdAbstract 7 { 8 public override string GetDescription () 9 { 5 namespace AllocsFixes.CustomCommands { 6 public class webstat : ConsoleCmdAbstract { 7 public override string GetDescription () { 10 8 return "DEBUG PURPOSES ONLY"; 11 9 } 12 10 13 public override string[] GetCommands () 14 { 15 return new string[] { "webstat" }; 11 public override string[] GetCommands () { 12 return new[] {"webstat"}; 16 13 } 17 14 18 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) 19 { 15 public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) { 20 16 try { 21 int curHandlers = AllocsFixes.NetConnections.Servers.Web.Web.currentHandlers;22 int totalHandlers = AllocsFixes.NetConnections.Servers.Web.Web.handlingCount;23 long totalTime = AllocsFixes.NetConnections.Servers.Web.Web.totalHandlingTime;17 int curHandlers = Web.currentHandlers; 18 int totalHandlers = Web.handlingCount; 19 long totalTime = Web.totalHandlingTime; 24 20 SdtdConsole.Instance.Output ("Current Web handlers: " + curHandlers + " - total: " + totalHandlers); 25 SdtdConsole.Instance.Output (" - Total time: " + totalTime + " µs - average time: " + (totalTime / totalHandlers) + " µs"); 21 SdtdConsole.Instance.Output (" - Total time: " + totalTime + " µs - average time: " + 22 totalTime / totalHandlers + " µs"); 26 23 27 curHandlers = AllocsFixes.NetConnections.Servers.Web.WebCommandResult.currentHandlers; 28 totalHandlers = AllocsFixes.NetConnections.Servers.Web.WebCommandResult.handlingCount; 29 totalTime = AllocsFixes.NetConnections.Servers.Web.WebCommandResult.totalHandlingTime; 30 SdtdConsole.Instance.Output ("Current Web command handlers: " + curHandlers + " - total: " + totalHandlers); 31 SdtdConsole.Instance.Output (" - Total time: " + totalTime + " µs" + (totalHandlers > 0 ? " - average time: " + (totalTime / totalHandlers) + " µs" : "")); 24 curHandlers = WebCommandResult.currentHandlers; 25 totalHandlers = WebCommandResult.handlingCount; 26 totalTime = WebCommandResult.totalHandlingTime; 27 SdtdConsole.Instance.Output ("Current Web command handlers: " + curHandlers + " - total: " + 28 totalHandlers); 29 SdtdConsole.Instance.Output (" - Total time: " + totalTime + " µs" + 30 (totalHandlers > 0 31 ? " - average time: " + totalTime / totalHandlers + " µs" 32 : "")); 32 33 } catch (Exception e) { 33 34 Log.Out ("Error in webstat.Run: " + e);
Note:
See TracChangeset
for help on using the changeset viewer.