public override void use(ClientPlayerInfo p, string message) { if (!GeneralUtilities.isOnGamemode()) { MessageUtilities.sendMessage(p, "Can't restart on lobby !"); return; } var serverLogic = G.Sys.GameManager_.GetComponent <ServerLogic>(); if (serverLogic == null) { MessageUtilities.sendMessage(p, "ServerLogic null !"); return; } var clients = (IEnumerable)PrivateUtilities.getPrivateField(serverLogic, "clientInfoList_"); foreach (var c in clients) { if (p.NetworkPlayer_ == (UnityEngine.NetworkPlayer)PrivateUtilities.getPrivateField(c, "networkPlayer_")) { exec(serverLogic, c); break; } } }
public ChatReplicationManager() { ChatLog chatLog = ChatLog.Instance_; bufferSize = (int)PrivateUtilities.getPrivateField(chatLog, "bufferSize_"); publicChatBuffer = new CircularBuffer <string>(bufferSize); personalChatBuffers = new Dictionary <string, CircularBuffer <string> >(); needsReplication = new List <string>(); }
public override void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { if (stream.isReading) { // Bypass SortedCircularBuffer logic. We assume that this is the newest CarDirectives data and update the main CarDirectives. // TODO: use SortedCircularBuffer. Find what index is the newest, streamed in data and call Serialize on it. // (We have to do this because Serialize is not called normally, which means that correct network data never gets turned into a non-zero CarDirectives) var newStream = ((Distance::BitStreamUnity)PrivateUtilities.getPrivateField(typeof(Distance::NetworkStateTransceiver), stateTransceiver, "stream_")); newStream.Encapsulate(stream); double timestamp = double.MinValue; newStream.Serialize(ref timestamp); CarLogicBridge.CarDirectives_.StreamIn(newStream); PrivateUtilities.callPrivateMethod(CarLogicBridge.CarDirectives_, "Serialize", new Distance::BitEncoder(CarLogicBridge.CarDirectives_.Bits_)); } else { stateTransceiver.OnSerializeNetworkView(stream, info); } }
public override void use(ClientPlayerInfo p, string message) { var gameMode = G.Sys.GameManager_.Mode_; if (gameMode == null) { MessageUtilities.sendMessage("Mode_ is null! Something is very wrong!"); Console.WriteLine("Mode_ is null! Something is very wrong!"); } else { MessageUtilities.sendMessage($"GameMode Name_: {gameMode.Name_}"); Console.WriteLine($"GameMode Name_: {gameMode.Name_}"); MessageUtilities.sendMessage($"IsStarted_: {gameMode.IsStarted_}"); Console.WriteLine($"IsStarted_: {gameMode.IsStarted_}"); } MessageUtilities.sendMessage("Connected players:"); MessageUtilities.sendMessage("gui : name : state : ready"); Console.WriteLine("guid : name : state : ready : levelVersion"); // more information is provided in the console. the message is meant to be sort-of compact. var serverLogic = G.Sys.GameManager_.GetComponent <ServerLogic>(); var clientInfoList = (System.Collections.IEnumerable)PrivateUtilities.getPrivateField(serverLogic, "clientInfoList_"); foreach (object clientInfo in clientInfoList) { // clientInfo is a private class so we can't actually use it :( // we can't even reference it for List<ClientInfo> // instead we have to use reflection to get the values of everything // (at least, i'm not aware of any other way to use it) var networkPlayer = (UnityEngine.NetworkPlayer)PrivateUtilities.getPrivateField(clientInfo, "networkPlayer_"); var client = GeneralUtilities.getClientFromNetworkPlayer(networkPlayer); string name = client == null ? "Unknown" : MessageUtilities.closeTags(client.GetChatName()); string rawName = client == null ? "Unknown" : client.Username_; var stateEnum = (Enum)PrivateUtilities.getPrivateField(clientInfo, "state_"); string state = stateEnum.ToString(); bool ready = (bool)PrivateUtilities.getPrivateProperty(clientInfo, "IsOkWithTheModeBeingStarted_"); string levelVersion = (string)PrivateUtilities.getPrivateField(clientInfo, "levelVersion_"); MessageUtilities.sendMessage($"{networkPlayer.guid} : {name} : {state} : {ready}"); Console.WriteLine($"{networkPlayer.guid} : {rawName} : {state} : {ready} : {levelVersion}"); } MessageUtilities.sendMessage("Try using !unstuck"); Console.WriteLine("Try using !unstuck"); }
public static System.Collections.IEnumerator StartGameAfterTimeout(int id, int timeout) { yield return(new UnityEngine.WaitForSeconds(timeout)); Console.WriteLine("InfinteLoadingTimeoutPatch Log:"); if (loadCounter != id) { Console.WriteLine("\tCancelled because: new level loaded"); yield break; } if (Utilities.GeneralUtilities.isOnLobby()) { Console.WriteLine("\tCancelled because: on lobby"); yield break; } var serverLogic = G.Sys.GameManager_.GetComponent <ServerLogic>(); if (serverLogic == null) { Console.WriteLine("\tCould not get ServerLogic! It does not exist!"); yield break; } var screens = PrivateUtilities.getComponents <OnlineMatchWaitingScreen>(); if (screens.Count == 0) { Console.WriteLine("\tNo loading screens. Game must be loaded."); yield break; } Console.WriteLine("\tLoading screen detected after timeout. Force-starting server."); var startPlayers = new List <UnityEngine.NetworkPlayer>(); var clientInfoList = (System.Collections.IEnumerable)PrivateUtilities.getPrivateField(serverLogic, "clientInfoList_"); foreach (object clientInfo in clientInfoList) { var networkPlayer = (UnityEngine.NetworkPlayer)PrivateUtilities.getPrivateField(clientInfo, "networkPlayer_"); startPlayers.Add(networkPlayer); } Events.Server.ReadyToStartGameMode.Broadcast(new Events.Server.ReadyToStartGameMode.Data(startPlayers.ToArray())); Utilities.MessageUtilities.sendMessage("Force-started match after timeout"); }
public static bool StartGameIfReady() { Console.WriteLine("InfinteLoadingPatch Log:"); if (!GeneralUtilities.isHost() || !GeneralUtilities.isOnline()) { Console.WriteLine("\tNot host"); return(false); } if (!all.getCommand <UnstuckCmd>().infiniteLoadingPatchEnabled) { Console.WriteLine("\tNot enabled"); return(false); } var serverLogic = G.Sys.GameManager_.GetComponent <ServerLogic>(); if (serverLogic == null) { Console.WriteLine("\tCould not get ServerLogic! It does not exist!"); return(false); } var hasStarted = (bool)PrivateUtilities.callPrivateMethod(serverLogic, "HasModeStarted"); if (!hasStarted) { Console.WriteLine("\tMatch has not started yet. Will wait for started event..."); return(false); } Console.WriteLine("\tMatch has already started. Firing ReadyToStartGameMode to simulate a proper start. This is the same as !unstuck 1 all."); var startPlayers = new List <UnityEngine.NetworkPlayer>(); var clientInfoList = (System.Collections.IEnumerable)PrivateUtilities.getPrivateField(serverLogic, "clientInfoList_"); foreach (object clientInfo in clientInfoList) { var networkPlayer = (UnityEngine.NetworkPlayer)PrivateUtilities.getPrivateField(clientInfo, "networkPlayer_"); startPlayers.Add(networkPlayer); } Events.Server.ReadyToStartGameMode.Broadcast(new Events.Server.ReadyToStartGameMode.Data(startPlayers.ToArray())); Utilities.MessageUtilities.sendMessage("Force-started match on load"); return(true); }
public override void use(ClientPlayerInfo p, string message) { if (GeneralUtilities.isOnLobby()) { MessageUtilities.sendMessage(p, "You can't do that on the lobby !"); return; } try { var playersInfos = (List <ModePlayerInfoBase>)PrivateUtilities.getPrivateField(G.Sys.GameManager_.Mode_, "modePlayerInfos_"); playersInfos.Sort((a, b) => { if (a.finishType_ == FinishType.Normal && b.finishType_ == FinishType.Normal) { double diff = a.modeData_ - b.modeData_; return(diff < 0 ? -1 : diff > 0 ? 1 : 0); } else if (a.finishType_ == FinishType.None && b.finishType_ == FinishType.None) { if (a is TimeBasedModePlayerInfo) { double diff = ((TimeBasedModePlayerInfo)a).distanceToFinish_ - ((TimeBasedModePlayerInfo)b).distanceToFinish_; return(diff < 0 ? -1 : diff > 0 ? 1 : 0); } else { double diff = a.modeData_ - b.modeData_; return(diff < 0 ? -1 : diff > 0 ? 1 : 0); } } else { return(Array.IndexOf(finishTypeValues, a.finishType_) - Array.IndexOf(finishTypeValues, b.finishType_)); } }); foreach (var pI in playersInfos) { string playerStr = pI.Name_ + " : "; switch (pI.finishType_) { case FinishType.None: playerStr += $"[FFFFFF]{textInfoOf(pI, false)}[-]"; break; case FinishType.DNF: playerStr += "[FF2222]DNF[-]"; break; case FinishType.JoinedLate: playerStr += "[FFFF22]Joined late[-]"; break; case FinishType.Normal: playerStr += $"[22FF22]Finished {textInfoOf(pI, true)}[-]"; break; case FinishType.Spectate: playerStr += "[88FF88]Spectator[-]"; break; default: playerStr += "None"; break; } MessageUtilities.sendMessage(p, playerStr); } } catch (Exception e) { MessageUtilities.sendMessage(p, "Error !"); Console.WriteLine(e); } }
public override void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { stateTransceiver.OnSerializeNetworkView(stream, info); var buffer = (Distance::SortedCircularBuffer <Distance::RigidbodyStateTransceiver.Snapshot>)PrivateUtilities.getPrivateField(stateTransceiver, "buffer_"); }
public override void OnDisable() { transceiver.StopCoroutine((IEnumerator)PrivateUtilities.getPrivateField(stateTransceiver, "coco_")); }
public override void use(ClientPlayerInfo p, string message) { var match = Regex.Match(message, @"^(\d*) ?(.*)$"); var mode = 1; var param = ""; if (match.Success) { if (match.Groups[1].Value != "") { mode = int.Parse(match.Groups[1].Value); } param = match.Groups[2].Value; } if (mode == 1 || mode == 2) { var isAll = param == "all"; var addon = isAll ? " on all" : "on loaded, submitted, and started"; if (mode == 1) { MessageUtilities.sendMessage("Trying mode 1 (ReadyToStartMode) " + addon); Console.WriteLine("Trying mode 1 (ReadyToStartMode) " + addon); } else { MessageUtilities.sendMessage("Trying mode 2 (StartMode) " + addon); Console.WriteLine("Trying mode 2 (StartMode) " + addon); } var startPlayers = new List <UnityEngine.NetworkPlayer>(); var failedAny = false; var serverLogic = G.Sys.GameManager_.GetComponent <ServerLogic>(); var clientInfoList = (System.Collections.IEnumerable)PrivateUtilities.getPrivateField(serverLogic, "clientInfoList_"); foreach (object clientInfo in clientInfoList) { // clientInfo is a private class so we can't actually use it :( // we can't even reference it for List<ClientInfo> // instead we have to use reflection to get the values of everything // (at least, i'm not aware of any other way to use it) var networkPlayer = (UnityEngine.NetworkPlayer)PrivateUtilities.getPrivateField(clientInfo, "networkPlayer_"); var client = GeneralUtilities.getClientFromNetworkPlayer(networkPlayer); string name = client == null ? "Unknown" : MessageUtilities.closeTags(client.GetChatName()); string rawName = client == null ? "Unknown" : client.Username_; var stateEnum = (Enum)PrivateUtilities.getPrivateField(clientInfo, "state_"); string state = stateEnum.ToString(); if (allowedStates.Contains(state) || isAll) { startPlayers.Add(networkPlayer); } else { failedAny = true; MessageUtilities.sendMessage($"Not starting {name} because their state is {state}"); Console.WriteLine($"Not starting {rawName} because their state is {state}"); } } if (failedAny) { MessageUtilities.sendMessage("You can force start all players using !unstuck all"); Console.WriteLine("You can force start all players using !unstuck all"); } if (mode == 1) { Events.Server.ReadyToStartGameMode.Broadcast(new Events.Server.ReadyToStartGameMode.Data(startPlayers.ToArray())); } else { var gameMode = G.Sys.GameManager_.Mode_; double startTime; if (gameMode == null) { MessageUtilities.sendMessage("Mode_ is null! Something is very wrong! Using 0 for start time."); Console.WriteLine("Mode_ is null! Something is very wrong! Using 0 for start time."); startTime = 0; } else { startTime = (double)PrivateUtilities.callPrivateMethod(typeof(GameMode), gameMode, "CalcStartTime"); } foreach (UnityEngine.NetworkPlayer player in startPlayers) { Events.ServerToClient.StartMode.Broadcast(player, new Events.ServerToClient.StartMode.Data(startTime, false)); } } MessageUtilities.sendMessage($"Tried to start {startPlayers.Count} players."); Console.WriteLine($"Tried to start {startPlayers.Count} players."); } else if (mode == 3) { MessageUtilities.sendMessage("Trying mode 3 (Destroy OnlineMatchWaitingScreen)"); Console.WriteLine("Trying mode 3 (Destroy OnlineMatchWaitingScreen)"); var screens = PrivateUtilities.getComponents <OnlineMatchWaitingScreen>(); MessageUtilities.sendMessage($"Found {screens.Count} screens."); Console.WriteLine($"Found {screens.Count} screens."); foreach (var screen in screens) { UnityEngine.Object.Destroy(screen.transform.root.gameObject); } MessageUtilities.sendMessage($"Destroyed {screens.Count} screens."); Console.WriteLine($"Destroyed {screens.Count} screens."); } else { MessageUtilities.sendMessage($"Unknown mode: {mode}"); Console.WriteLine($"Unknown mode: {mode}"); } }