- Timestamp:
- Aug 26, 2014, 4:41:47 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/ConsoleOutputSeparator.cs
r115 r130 4 4 using UnityEngine; 5 5 6 public class ConsoleOutputSeparator 6 namespace AllocsFixes 7 7 { 8 public struct AllocsTelnetCommand8 public class ConsoleOutputSeparator 9 9 { 10 public string command; 11 public AllocsTelnetConnection client; 10 public struct AllocsTelnetCommand 11 { 12 public string command; 13 public AllocsTelnetConnection client; 12 14 13 public AllocsTelnetCommand (string _cmd, AllocsTelnetConnection _client) 14 { 15 command = _cmd; 16 client = _client; 17 } 18 } 19 20 private static List<AllocsTelnetCommand> telnetCommandQueue = new List<AllocsTelnetCommand> (); 21 private static bool isCurrentCommandFromClient = false; 22 private static AllocsTelnetConnection issuerOfCurrentTelnetCommand; 23 24 public static void C_ExecuteCmdFromClient (ConsoleSdtd console, NetworkPlayer _networkPlayer, string _playerID, string _command) 25 { 26 Log.Out ("Executed command \"" + _command + "\" from player \"" + _playerID + "\""); 27 28 object obj = telnetCommandQueue; 29 Monitor.Enter (obj); 30 try { 31 isCurrentCommandFromClient = true; 32 console.issuerOfCurrentClientCommand = _networkPlayer; 33 console.ExecuteClientCmdInternal (_playerID, _command); 34 isCurrentCommandFromClient = false; 35 } finally { 36 Monitor.Exit (obj); 15 public AllocsTelnetCommand (string _cmd, AllocsTelnetConnection _client) 16 { 17 command = _cmd; 18 client = _client; 19 } 37 20 } 38 21 39 } 22 private static List<AllocsTelnetCommand> telnetCommandQueue = new List<AllocsTelnetCommand> (); 23 private static bool isCurrentCommandFromClient = false; 24 private static AllocsTelnetConnection issuerOfCurrentTelnetCommand; 40 25 41 public static void C_SendResult (ConsoleSdtd console, string _line) 42 { 43 if (isCurrentCommandFromClient) { 44 console.gameManager.GetRPCNetworkView ().RPC ("RPC_Console", console.issuerOfCurrentClientCommand, new object[] 26 public static void C_ExecuteCmdFromClient (ConsoleSdtd console, NetworkPlayer _networkPlayer, string _playerID, string _command) 27 { 28 Log.Out ("Executed command \"" + _command + "\" from player \"" + _playerID + "\""); 29 30 object obj = telnetCommandQueue; 31 Monitor.Enter (obj); 32 try { 33 isCurrentCommandFromClient = true; 34 console.issuerOfCurrentClientCommand = _networkPlayer; 35 console.ExecuteClientCmdInternal (_playerID, _command); 36 isCurrentCommandFromClient = false; 37 } finally { 38 Monitor.Exit (obj); 39 } 40 41 } 42 43 public static void C_SendResult (ConsoleSdtd console, string _line) 44 { 45 if (isCurrentCommandFromClient) { 46 console.gameManager.GetRPCNetworkView ().RPC ("RPC_Console", console.issuerOfCurrentClientCommand, new object[] 45 47 { 46 48 _line, 47 49 false 48 50 } 49 ); 50 } else { 51 if (console.telnetServer != null && issuerOfCurrentTelnetCommand != null) 52 AllocsNetTelnetServer.WriteToClient_Single (_line, issuerOfCurrentTelnetCommand); 53 else if (ControlPanel.IsStarted ()) 54 ControlPanel.AddTextToOutputBuffer (_line); 51 ); 52 } else { 53 if (console.telnetServer != null && issuerOfCurrentTelnetCommand != null) 54 AllocsNetTelnetServer.WriteToClient_Single (_line, issuerOfCurrentTelnetCommand); 55 else if (ControlPanel.IsStarted ()) 56 ControlPanel.AddTextToOutputBuffer (_line); 57 } 55 58 } 56 }57 59 58 public static void C_Run (ConsoleSdtd console) 59 { 60 if (telnetCommandQueue.Count > 0) { 60 public static void C_Run (ConsoleSdtd console) 61 { 62 if (telnetCommandQueue.Count > 0) { 63 object obj = telnetCommandQueue; 64 Monitor.Enter (obj); 65 try { 66 issuerOfCurrentTelnetCommand = telnetCommandQueue [0].client; 67 console.ExecuteRemoteCmdInternal (telnetCommandQueue [0].command, false); 68 telnetCommandQueue.RemoveAt (0); 69 issuerOfCurrentTelnetCommand = null; 70 } finally { 71 Monitor.Exit (obj); 72 } 73 } 74 } 75 76 public static void QueueTelnetCommand (string _line, AllocsTelnetConnection _con) 77 { 61 78 object obj = telnetCommandQueue; 62 79 Monitor.Enter (obj); 63 80 try { 64 issuerOfCurrentTelnetCommand = telnetCommandQueue [0].client; 65 console.ExecuteRemoteCmdInternal (telnetCommandQueue [0].command, false); 66 telnetCommandQueue.RemoveAt (0); 67 issuerOfCurrentTelnetCommand = null; 81 telnetCommandQueue.Add (new AllocsTelnetCommand (_line, _con)); 68 82 } finally { 69 83 Monitor.Exit (obj); … … 71 85 } 72 86 } 73 74 public static void QueueTelnetCommand (string _line, AllocsTelnetConnection _con)75 {76 object obj = telnetCommandQueue;77 Monitor.Enter (obj);78 try {79 telnetCommandQueue.Add (new AllocsTelnetCommand (_line, _con));80 } finally {81 Monitor.Exit (obj);82 }83 }84 87 } 85
Note:
See TracChangeset
for help on using the changeset viewer.