Changeset 202 for binary-improvements
- Timestamp:
- Oct 23, 2014, 3:09:29 PM (10 years ago)
- Location:
- binary-improvements
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/7dtd-server-fixes.csproj
r199 r202 10 10 <AssemblyName>7dtd-server-fixes</AssemblyName> 11 11 <RootNamespace>AllocsFixes</RootNamespace> 12 <TargetFrameworkVersion>v 2.0</TargetFrameworkVersion>12 <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> 13 13 </PropertyGroup> 14 14 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> … … 129 129 <Compile Include="src\FileCache\SimpleCache.cs" /> 130 130 <Compile Include="src\FileCache\MapTileCache.cs" /> 131 <Compile Include="src\CustomCommands\webstat.cs" /> 131 132 </ItemGroup> 132 133 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
binary-improvements/7dtd-server-fixes/src/CustomCommands/ListLandProtection.cs
r146 r202 20 20 } 21 21 22 public override void ExecuteRemote (string _sender, string[] _params) 23 { 24 try { 25 if (_params.Length >= 1 && _params [0].ToLower ().Equals ("nearby")) { 26 string[] params2 = new string[_params.Length + 1]; 27 for (int i = 0; i < _params.Length; i++) 28 params2 [i] = _params [i]; 29 params2 [_params.Length] = _sender; 30 _params = params2; 31 } 32 Run (_params); 33 } catch (Exception e) { 34 Log.Out ("Error in ListLandProtection.ExecuteRemote: " + e); 35 } 36 } 37 22 38 public override void Run (string[] _params) 23 39 { … … 28 44 bool summaryOnly = false; 29 45 string steamIdFilter = string.Empty; 46 Vector3i closeTo = default(Vector3i); 47 bool onlyCloseToPlayer = false; 48 int closeToDistance = 32; 30 49 31 50 if (_params.Length == 1) { … … 45 64 } 46 65 } 66 } else if (_params.Length >= 2) { 67 if (_params [0].ToLower ().Equals ("nearby")) { 68 try { 69 if (_params.Length == 3) { 70 if (!int.TryParse (_params[1], out closeToDistance)) { 71 m_Console.SendResult ("Given radius is not an integer!"); 72 } 73 } 74 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromSteamID (_params [_params.Length - 1]); 75 EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci); 76 closeTo = new Vector3i (ep.GetPosition ()); 77 onlyCloseToPlayer = true; 78 } catch (Exception e) { 79 m_Console.SendResult ("Error getting current player's position"); 80 Log.Out ("Error in ListLandProtection.Run: " + e); 81 } 82 } else { 83 m_Console.SendResult ("Illegal parameter list"); 84 return; 85 } 47 86 } 48 87 … … 51 90 Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>> (); 52 91 foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) { 53 if (!owners.ContainsKey (kvp.Value)) { 54 owners.Add (kvp.Value, new List<Vector3i> ()); 92 if (!onlyCloseToPlayer || (Math.Abs (kvp.Key.x - closeTo.x) <= closeToDistance && Math.Abs (kvp.Key.z - closeTo.z) <= closeToDistance)) { 93 if (!owners.ContainsKey (kvp.Value)) { 94 owners.Add (kvp.Value, new List<Vector3i> ()); 95 } 96 owners [kvp.Value].Add (kvp.Key); 55 97 } 56 owners [kvp.Value].Add (kvp.Key);57 98 } 58 99 59 100 foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) { 60 101 if (steamIdFilter.Length == 0 || kvp.Key.PlayerId.Equals (steamIdFilter)) { 61 string name = PersistentData.PersistentContainer.Instance.Players [kvp.Key.PlayerId].Name;102 string name = PersistentData.PersistentContainer.Instance.Players [kvp.Key.PlayerId].Name; 62 103 name += " (" + kvp.Key.PlayerId + ")"; 63 104 -
binary-improvements/7dtd-server-fixes/src/CustomCommands/RemoveLandProtection.cs
r130 r202 41 41 CommonMappingFunctions.GetGameManager ().SetBlocksRPC (changes); 42 42 43 m_Console.SendResult ("#" + changes.Count + " Land protection blocks for player \"" + _id + "\" removed"); 43 m_Console.SendResult ("Tried to remove #" + changes.Count + " land protection blocks for player \"" + _id + "\". Note "+ 44 "that only blocks in chunks that are currently loaded (close to any player) could be removed. "+ 45 "Please check for remaining blocks by running:"); 46 m_Console.SendResult(" listlandprotection " + _id); 44 47 } catch (Exception e) { 45 48 Log.Out ("Error in RemoveLandProtection.removeById: " + e); -
binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Telnet/TelnetConnection.cs
r190 r202 59 59 { 60 60 toClientQueue.Enqueue ("*** Connected with 7DTD server."); 61 toClientQueue.Enqueue ("*** Server version: " + GamePrefs.GetString(EnumGamePrefs.GameVersion)); 61 62 toClientQueue.Enqueue ("*** Dedicated server only build"); 62 63 toClientQueue.Enqueue ("*** Allocs server fixes loaded"); -
binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/StaticHandler.cs
r199 r202 24 24 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, HttpListenerBasicIdentity user) 25 25 { 26 try { 27 string fn = req.Url.AbsolutePath.Remove (0, staticPart.Length); 26 string fn = req.Url.AbsolutePath.Remove (0, staticPart.Length); 28 27 29 byte[] content = cache.GetFileContent (datapath + "/" + fn); 30 if (content != null) { 31 resp.ContentType = MimeType.GetMimeType (Path.GetExtension (fn)); 32 resp.ContentLength64 = content.Length; 33 resp.OutputStream.Write (content, 0, content.Length); 34 } else { 35 resp.StatusCode = (int)HttpStatusCode.NotFound; 36 if (logMissingFiles) 37 Log.Out ("Web:Static:FileNotFound: \"" + req.Url.AbsolutePath + "\" @ \"" + datapath + "/" + req.Url.AbsolutePath.Remove (0, staticPart.Length) + "\""); 38 return; 39 } 40 } catch (Exception e) { 41 Log.Out ("Error in StaticHandler.HandleRequest: " + e); 28 byte[] content = cache.GetFileContent (datapath + "/" + fn); 29 if (content != null) { 30 resp.ContentType = MimeType.GetMimeType (Path.GetExtension (fn)); 31 resp.ContentLength64 = content.Length; 32 resp.OutputStream.Write (content, 0, content.Length); 33 } else { 34 resp.StatusCode = (int)HttpStatusCode.NotFound; 35 if (logMissingFiles) 36 Log.Out ("Web:Static:FileNotFound: \"" + req.Url.AbsolutePath + "\" @ \"" + datapath + "/" + req.Url.AbsolutePath.Remove (0, staticPart.Length) + "\""); 37 return; 42 38 } 43 39 } -
binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/Web.cs
r199 r202 3 3 using System.IO; 4 4 using System.Net; 5 using System.Net.Sockets; 5 6 using System.Text; 6 7 using System.Threading; … … 15 16 private bool authEnabled = false; 16 17 private string realm = "7dtd Admin Panel"; 18 public static int handlingCount = 0; 19 public static int currentHandlers = 0; 17 20 18 21 public Web () … … 62 65 _listener.Realm = realm; 63 66 64 ThreadPool.QueueUserWorkItem ((o) =>65 {66 try {67 while (_listener.IsListening) {68 ThreadPool.QueueUserWorkItem ((c) =>69 {70 HttpListenerContext ctx = c as HttpListenerContext;71 HandleRequest (ctx);72 }, _listener.GetContext ());73 }74 } catch {75 }76 }77 );78 79 67 NetTelnetServer.RegisterServer (this); 80 68 69 _listener.BeginGetContext (new AsyncCallback (HandleRequest), _listener); 81 70 82 71 Log.Out ("Started Webserver on " + (webPort + 2) + " (authentication " + (authEnabled ? "enabled" : "disabled") + ")"); … … 86 75 } 87 76 88 private void HandleRequest ( HttpListenerContext ctx)77 private void HandleRequest (IAsyncResult result) 89 78 { 90 try { 91 ctx.Response.ProtocolVersion = new Version ("1.1"); 79 if (_listener.IsListening) { 80 Interlocked.Increment(ref handlingCount); 81 Interlocked.Increment(ref currentHandlers); 82 HttpListenerContext ctx = _listener.EndGetContext (result); 83 _listener.BeginGetContext (new AsyncCallback (HandleRequest), _listener); 84 try { 85 ctx.Response.ProtocolVersion = new Version ("1.1"); 92 86 93 HttpListenerBasicIdentity user = Authorize (ctx);87 HttpListenerBasicIdentity user = Authorize (ctx); 94 88 95 if (!authEnabled || (user.Name.ToLower ().Equals ("admin") && user.Password.Equals (GamePrefs.GetString (EnumGamePrefs.ControlPanelPassword)))) { 96 if (ctx.Request.Url.AbsolutePath.Length < 2) { 97 handlers ["/index.htm"].HandleRequest (ctx.Request, ctx.Response, user); 98 return; 99 } else { 100 foreach (KeyValuePair<string, PathHandler> kvp in handlers) { 101 if (ctx.Request.Url.AbsolutePath.StartsWith (kvp.Key)) { 102 kvp.Value.HandleRequest (ctx.Request, ctx.Response, user); 103 return; 89 if (!authEnabled || (user.Name.ToLower ().Equals ("admin") && user.Password.Equals (GamePrefs.GetString (EnumGamePrefs.ControlPanelPassword)))) { 90 if (ctx.Request.Url.AbsolutePath.Length < 2) { 91 handlers ["/index.htm"].HandleRequest (ctx.Request, ctx.Response, user); 92 return; 93 } else { 94 foreach (KeyValuePair<string, PathHandler> kvp in handlers) { 95 if (ctx.Request.Url.AbsolutePath.StartsWith (kvp.Key)) { 96 kvp.Value.HandleRequest (ctx.Request, ctx.Response, user); 97 return; 98 } 104 99 } 105 100 } 101 102 Log.Out ("Error in Web.HandleRequest(): No handler found for path \"" + ctx.Request.Url.AbsolutePath + "\""); 103 ctx.Response.StatusCode = (int)HttpStatusCode.NotFound; 104 } else { 105 ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized; 106 ctx.Response.Headers ["WWW-Authenticate"] = "Basic realm=\"" + realm + "\""; 106 107 } 107 108 Log.Out ("Error in Web.HandleRequest(): No handler found for path \"" + ctx.Request.Url.AbsolutePath + "\""); 109 ctx.Response.StatusCode = (int)HttpStatusCode.NotFound; 110 } else { 111 ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized; 112 ctx.Response.Headers ["WWW-Authenticate"] = "Basic realm=\"" + realm + "\""; 108 } catch (IOException e) { 109 if (e.InnerException is SocketException) { 110 if (e.InnerException.Message.Contains ("forcibly closed") || e.InnerException.Message.Contains ("socket has been shut down")) 111 Log.Out ("Error in Web.HandleRequest(): Remote host closed connection"); 112 else 113 Log.Out ("Error (IO->Socket) in Web.HandleRequest(): " + e); 114 } else { 115 Log.Out ("Error (IO) in Web.HandleRequest(): " + e); 116 } 117 } catch (Exception e) { 118 Log.Out ("Error in Web.HandleRequest(): " + e); 119 } finally { 120 if (ctx != null) 121 ctx.Response.OutputStream.Close (); 122 Interlocked.Decrement(ref currentHandlers); 113 123 } 114 115 // byte[] buf = Encoding.UTF8.GetBytes ("Hello World");116 // resp.ContentLength64 = buf.Length;117 // resp.ContentType = "text/html";118 // resp.ContentEncoding = Encoding.UTF8;119 // resp.OutputStream.Write (buf, 0, buf.Length);120 } catch (Exception e) {121 Log.Out ("Error in Web.HandleRequest(): " + e);122 } finally {123 ctx.Response.Close ();124 124 } 125 125 } -
binary-improvements/7dtd-server-fixes/src/PersistentData/Players.cs
r189 r202 47 47 public Player GetPlayerByNameOrId (string _nameOrId, bool _ignoreColorCodes) 48 48 { 49 string sid = GetSteamID (_nameOrId, _ignoreColorCodes);49 string sid = GetSteamID (_nameOrId, _ignoreColorCodes); 50 50 if (sid != null) 51 return this [sid];51 return this [sid]; 52 52 else 53 53 return null; -
binary-improvements/bin/Release/7dtd-server-fixes_version.txt
r199 r202 1 Version: 0.93.5 378.417311 Version: 0.93.5409.27239 -
binary-improvements/server-fixes.userprefs
r148 r202 1 1 <Properties> 2 2 <MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Version" /> 3 <MonoDevelop.Ide.Workbench ActiveDocument="7dtd-server-fixes/src/ CustomCommands/ListPlayersExtended.cs">3 <MonoDevelop.Ide.Workbench ActiveDocument="7dtd-server-fixes/src/PersistentData/Players.cs"> 4 4 <Files> 5 <File FileName="assembly-patcher/Main.cs" Line="86" Column="25" /> 6 <File FileName="7dtd-server-fixes/src/PlayerDataStuff.cs" Line="16" Column="1" /> 7 <File FileName="7dtd-server-fixes/src/PersistentData/PersistentContainer.cs" Line="56" Column="70" /> 8 <File FileName="7dtd-server-fixes/src/PersistentData/Players.cs" Line="34" Column="33" /> 9 <File FileName="7dtd-server-fixes/src/PersistentData/Player.cs" Line="22" Column="3" /> 10 <File FileName="7dtd-server-fixes/src/PersistentData/Inventory.cs" Line="33" Column="1" /> 11 <File FileName="7dtd-server-fixes/src/PersistentData/InvItem.cs" Line="15" Column="23" /> 12 <File FileName="7dtd-server-fixes/src/StateManager.cs" Line="21" Column="5" /> 13 <File FileName="7dtd-server-fixes/src/CustomCommands/ListLandProtection.cs" Line="48" Column="1" /> 14 <File FileName="7dtd-server-fixes/src/AllocsLogFunctions.cs" Line="45" Column="57" /> 15 <File FileName="7dtd-server-fixes/src/CustomCommands/ListKnownPlayers.cs" Line="41" Column="5" /> 16 <File FileName="7dtd-server-fixes/src/CommandExtensions.cs" Line="19" Column="81" /> 17 <File FileName="7dtd-server-fixes/src/CustomCommands/ListPlayersExtended.cs" Line="70" Column="5" /> 5 <File FileName="7dtd-server-fixes/src/PersistentData/Players.cs" Line="43" Column="5" /> 6 <File FileName="7dtd-server-fixes/src/NetConnections/NetTelnetServer.cs" Line="34" Column="1" /> 7 <File FileName="7dtd-server-fixes/src/NetConnections/Servers/Web/Web.cs" Line="89" Column="1" /> 8 <File FileName="7dtd-server-fixes/src/NetConnections/Servers/Telnet/Telnet.cs" Line="67" Column="34" /> 9 <File FileName="7dtd-server-fixes/src/NetConnections/Servers/Telnet/TelnetConnection.cs" Line="65" Column="45" /> 10 <File FileName="7dtd-server-fixes/src/MapRendering/MapRenderBlockBuffer.cs" Line="91" Column="37" /> 11 <File FileName="7dtd-server-fixes/src/MapRendering/MapRendering.cs" Line="11" Column="27" /> 12 <File FileName="7dtd-server-fixes/src/CustomCommands/webstat.cs" Line="25" Column="1" /> 13 <File FileName="7dtd-server-fixes/src/CommonMappingFunctions.cs" Line="135" Column="36" /> 18 14 </Files> 19 15 <Pads>
Note:
See TracChangeset
for help on using the changeset viewer.