Changeset 107 for binary-improvements/7dtd-server-fixes
- Timestamp:
- Jul 26, 2014, 4:41:11 PM (10 years ago)
- Location:
- binary-improvements/7dtd-server-fixes
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/7dtd-server-fixes.csproj
r103 r107 55 55 <Compile Include="src\CommandExtensions.cs" /> 56 56 <Compile Include="src\CommonMappingFunctions.cs" /> 57 <Compile Include="src\ConsoleOutputSeparator.cs" /> 57 58 </ItemGroup> 58 59 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
binary-improvements/7dtd-server-fixes/7dtd-server-fixes.userprefs
r99 r107 1 1 <Properties> 2 2 <MonoDevelop.Ide.Workspace ActiveConfiguration="Release" /> 3 <MonoDevelop.Ide.Workbench ActiveDocument="src/ PlayerDataStuff.cs">3 <MonoDevelop.Ide.Workbench ActiveDocument="src/AdminToolsStuff.cs"> 4 4 <Files> 5 5 <File FileName="src/AssemblyInfo.cs" Line="20" Column="40" /> 6 <File FileName="src/AllocsNetTelnetServer.cs" Line="136" Column="1" /> 7 <File FileName="src/AllocsTelnetConnection.cs" Line="44" Column="42" /> 8 <File FileName="src/AllocsLogFunctions.cs" Line="27" Column="42" /> 9 <File FileName="src/AdminToolsStuff.cs" Line="30" Column="54" /> 10 <File FileName="src/PlayerDataStuff.cs" Line="30" Column="27" /> 11 <File FileName="src/CommandExtensions.cs" Line="12" Column="73" /> 6 <File FileName="src/AllocsNetTelnetServer.cs" Line="155" Column="65" /> 7 <File FileName="src/AllocsTelnetConnection.cs" Line="50" Column="3" /> 8 <File FileName="src/AllocsLogFunctions.cs" Line="27" Column="43" /> 9 <File FileName="src/AdminToolsStuff.cs" Line="33" Column="1" /> 10 <File FileName="src/PlayerDataStuff.cs" Line="59" Column="40" /> 11 <File FileName="src/TelnetCommands/SayToPlayer.cs" Line="23" Column="49" /> 12 <File FileName="src/CommonMappingFunctions.cs" Line="149" Column="1" /> 13 <File FileName="src/CommandExtensions.cs" Line="34" Column="28" /> 12 14 </Files> 13 15 </MonoDevelop.Ide.Workbench> -
binary-improvements/7dtd-server-fixes/src/AdminToolsStuff.cs
r103 r107 25 25 } 26 26 } 27 28 if (tmpInfo.PermissionLevel <= 0) { 29 List<ConsoleCommand> commands = console.commands; 30 foreach (ConsoleCommand c in commands) { 31 if (!allowed.Contains (c.Names () [0])) { 32 if (!hasPermissionLevel (admTools, c.Names () [0])) { 33 addAllowed (console, allowed, c.Names () [0]); 34 } 35 } 36 } 37 } 27 38 } catch (Exception e) { 28 39 Log.Out ("Error in GetAllowedCommandsList: " + e); … … 33 44 } 34 45 46 private static bool hasPermissionLevel (AdminTools admTools, string cmd) 47 { 48 List<AdminToolsCommandPermissions> perms = admTools.commandPermissions; 49 50 foreach (AdminToolsCommandPermissions atcp in perms) { 51 foreach (string ccName in getAlternativeNames(cmd)) { 52 if (atcp.Command.ToLower ().Equals (ccName)) { 53 return true; 54 } 55 } 56 } 57 return false; 58 } 59 35 60 private static void addAllowed (ConsoleSdtd console, List<string> list, string cmd) 36 61 { 37 ConsoleCommand cc = console.getCommand (cmd); 62 foreach (string ccName in getAlternativeNames(cmd)) { 63 if (!list.Contains (ccName)) { 64 list.Add (ccName); 65 } 66 } 67 } 68 69 private static string[] getAlternativeNames (string cmd) 70 { 71 ConsoleCommand cc = CommonMappingFunctions.GetGameManager ().m_GUIConsole.getCommand (cmd); 38 72 if (cc != null) { 39 foreach (string ccName in cc.Names()) { 40 if (!list.Contains (ccName)) { 41 list.Add (ccName); 42 } 43 } 73 return cc.Names (); 44 74 } else { 45 list.Add (cmd);75 return new string[0]; 46 76 } 47 77 } -
binary-improvements/7dtd-server-fixes/src/AllocsLogFunctions.cs
r103 r107 28 28 } 29 29 } 30 31 public static void ExecuteCmdFromClient (ConsoleSdtd console, NetworkPlayer _networkPlayer, string _playerID, string _command)32 {33 Log.Out ("Executed command \"" + _command + "\" from player \"" + _playerID + "\"");34 }35 30 } -
binary-improvements/7dtd-server-fixes/src/AllocsNetTelnetServer.cs
r103 r107 78 78 } 79 79 Log.Out ("Telnet executed \"" + line + "\" from: " + c.GetEndPoint ()); 80 console.md000f (line);80 ConsoleOutputSeparator.QueueTelnetCommand (line, c); 81 81 } 82 82 } … … 168 168 } 169 169 } 170 171 public static void WriteToClient (string line, AllocsTelnetConnection client) 172 { 173 if (line == null) { 174 return; 175 } 176 RemoveClosedConnections (); 177 foreach (AllocsTelnetConnection c in connections) { 178 if (c.IsAuthenticated () && (c == client)) 179 c.WriteLine (line); 180 } 181 } 170 182 } -
binary-improvements/7dtd-server-fixes/src/CommandExtensions.cs
r96 r107 1 1 using System; 2 using System.Collections.Generic; 2 3 3 4 public class CommandExtensions … … 5 6 public static void InitCommandExtensions (GameManager manager) 6 7 { 7 manager.m_GUIConsole.AddCommand(new GetGamePrefs(manager.m_GUIConsole)); 8 manager.m_GUIConsole.AddCommand(new GetTime(manager.m_GUIConsole)); 9 manager.m_GUIConsole.AddCommand(new ListPlayersExtended(manager.m_GUIConsole)); 10 manager.m_GUIConsole.AddCommand(new SayToPlayer(manager.m_GUIConsole)); 11 manager.m_GUIConsole.AddCommand(new SetTimeReal(manager.m_GUIConsole)); 12 manager.m_GUIConsole.AddCommand(new ShowInventory(manager.m_GUIConsole)); 8 try { 9 manager.m_GUIConsole.AddCommand (new GetGamePrefs (manager.m_GUIConsole)); 10 manager.m_GUIConsole.AddCommand (new GetTime (manager.m_GUIConsole)); 11 manager.m_GUIConsole.AddCommand (new ListPlayersExtended (manager.m_GUIConsole)); 12 manager.m_GUIConsole.AddCommand (new SayToPlayer (manager.m_GUIConsole)); 13 manager.m_GUIConsole.AddCommand (new SetTimeReal (manager.m_GUIConsole)); 14 manager.m_GUIConsole.AddCommand (new ShowInventory (manager.m_GUIConsole)); 15 } catch (Exception e) { 16 Log.Out ("Error registering custom commands: " + e); 17 } 18 /* 19 try { 20 List<ConsoleCommand> commands = manager.m_GUIConsole.commands; 21 foreach (ConsoleCommand c in commands) { 22 string name = string.Empty; 23 foreach (string cname in c.Names()) { 24 if (cname.Length > 0) { 25 if (name.Length > 0) 26 name += ", "; 27 name += cname; 28 } 29 } 30 name += " => " + c.Description(); 31 Log.Out (name); 32 } 33 } catch (Exception e) { 34 Log.Out ("Error listing commands: " + e); 35 } 36 */ 13 37 } 14 38 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/GetGamePrefs.cs
r103 r107 65 65 } 66 66 foreach (string s in sortedList.Keys) { 67 m_Console. md000a(sortedList [s]);67 m_Console.SendResult (sortedList [s]); 68 68 } 69 69 } else { 70 70 if (prefAccessAllowed (enumGamePrefs)) 71 m_Console. md000a(string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs)));71 m_Console.SendResult (string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs))); 72 72 else 73 m_Console. md000a("Access to requested preference is forbidden");73 m_Console.SendResult ("Access to requested preference is forbidden"); 74 74 } 75 75 } catch (Exception e) { -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/GetTime.cs
r103 r107 28 28 } 29 29 int min = (int)(time % 1000) * 60 / 1000; 30 m_Console. md000a(String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min));30 m_Console.SendResult (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min)); 31 31 } catch (Exception e) { 32 32 Log.Out ("Error in GetTime.Run: " + e); -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/ListPlayersExtended.cs
r103 r107 29 29 ip = ci.networkPlayer.ipAddress; 30 30 } 31 m_Console. md000a(string.Concat (new object[]31 m_Console.SendResult (string.Concat (new object[] 32 32 { 33 33 string.Empty, … … 63 63 ); 64 64 } 65 m_Console. md000a("Total of " + w.playerEntities.list.Count + " in the game");65 m_Console.SendResult ("Total of " + w.playerEntities.list.Count + " in the game"); 66 66 } catch (Exception e) { 67 67 Log.Out ("Error in ListPlayersExtended.Run: " + e); -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/SayToPlayer.cs
r103 r107 23 23 new object[] { _message, -1, _sender + " (PM)", true }); 24 24 string receiverName = CommonMappingFunctions.GetPlayerName (_receiver); 25 m_Console. md000a("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + _sender + "\"");25 m_Console.SendResult ("Message to player " + (receiverName != null ? "\"" + receiverName + "\"" : "unknownName") + " sent with sender \"" + _sender + "\""); 26 26 } 27 27 … … 29 29 { 30 30 if (_params.Length < 2) { 31 m_Console. md000a("Usage: sayplayer <playername|entityid> <message>");31 m_Console.SendResult ("Usage: sayplayer <playername|entityid> <message>"); 32 32 return; 33 33 } … … 42 42 SendMessage (ci, _sender, message); 43 43 } else { 44 m_Console. md000a("Playername or entity ID not found.");44 m_Console.SendResult ("Playername or entity ID not found."); 45 45 } 46 46 } -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/SetTimeReal.cs
r103 r107 21 21 try { 22 22 if (_params.Length != 3) { 23 m_Console. md000a("Usage: settimereal <day> <hour> <min>");23 m_Console.SendResult ("Usage: settimereal <day> <hour> <min>"); 24 24 return; 25 25 } … … 27 27 int day, hour, min; 28 28 if (!int.TryParse (_params [0], out day)) { 29 m_Console. md000a("Could not parse day number \"" + _params [0] + "\"");29 m_Console.SendResult ("Could not parse day number \"" + _params [0] + "\""); 30 30 return; 31 31 } 32 32 if (day < 1) { 33 m_Console. md000a("Day must be >= 1");33 m_Console.SendResult ("Day must be >= 1"); 34 34 return; 35 35 } 36 36 if (!int.TryParse (_params [1], out hour)) { 37 m_Console. md000a("Could not parse hour \"" + _params [1] + "\"");37 m_Console.SendResult ("Could not parse hour \"" + _params [1] + "\""); 38 38 return; 39 39 } 40 40 if (hour > 23) { 41 m_Console. md000a("Hour must be <= 23");41 m_Console.SendResult ("Hour must be <= 23"); 42 42 return; 43 43 } 44 44 if (!int.TryParse (_params [2], out min)) { 45 m_Console. md000a("Could not parse minute \"" + _params [2] + "\"");45 m_Console.SendResult ("Could not parse minute \"" + _params [2] + "\""); 46 46 return; 47 47 } 48 48 if (min > 59) { 49 m_Console. md000a("Minute must be <= 59");49 m_Console.SendResult ("Minute must be <= 59"); 50 50 return; 51 51 } 52 52 if ((day < 1) || (hour < 8 && day < 1)) { 53 m_Console. md000a("Time may not be prior to day 1, 8:00");53 m_Console.SendResult ("Time may not be prior to day 1, 8:00"); 54 54 return; 55 55 } … … 57 57 ulong time = ((ulong)(day - 1) * 24000) + ((ulong)hour * 1000) + ((ulong)min * 1000 / 60) - 8000; 58 58 m_Console.gameManager.World.gameTime = time; 59 m_Console. md000a(String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time));59 m_Console.SendResult (String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time)); 60 60 } catch (Exception e) { 61 61 Log.Out ("Error in SetTimeReal.Run: " + e); -
binary-improvements/7dtd-server-fixes/src/TelnetCommands/ShowInventory.cs
r103 r107 25 25 try { 26 26 if (_params.Length < 1) { 27 m_Console. md000a("Usage: showinventory <playername|entityid>");27 m_Console.SendResult ("Usage: showinventory <playername|entityid>"); 28 28 return; 29 29 } … … 47 47 48 48 if (items == null) { 49 m_Console. md000a("Playername or entity id not found or no inventory saved (first saved after a player has been online for 30s).");49 m_Console.SendResult ("Playername or entity id not found or no inventory saved (first saved after a player has been online for 30s)."); 50 50 return; 51 51 } 52 52 53 m_Console. md000a("Belt of player:");53 m_Console.SendResult ("Belt of player:"); 54 54 foreach (KeyValuePair<string, int> kvp in items.belt) { 55 m_Console. md000a(string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));55 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key)); 56 56 } 57 m_Console. md000a(string.Empty);58 m_Console. md000a("Bagpack of player:");57 m_Console.SendResult (string.Empty); 58 m_Console.SendResult ("Bagpack of player:"); 59 59 foreach (KeyValuePair<string, int> kvp in items.bag) { 60 m_Console. md000a(string.Format (" {0:000} * {1}", kvp.Value, kvp.Key));60 m_Console.SendResult (string.Format (" {0:000} * {1}", kvp.Value, kvp.Key)); 61 61 } 62 m_Console. md000a(string.Empty);62 m_Console.SendResult (string.Empty); 63 63 } catch (Exception e) { 64 64 Log.Out ("Error in ShowInventory.Run: " + e);
Note:
See TracChangeset
for help on using the changeset viewer.