private static IEnumerator MatchStart(int connectionId) { var newPlayer = Server.FindPlayerByConnectionId(connectionId); MPBanEntry newPlayerEntry = new MPBanEntry(newPlayer); // prevent banned players from JIP into our match // there is already a delayed Disconnect going on, just // prevent this player from entering the JIP code if (MPBanPlayers.IsBanned(newPlayerEntry)) { yield break; } float pregameWait = 3f; if (!newPlayer.m_mp_name.StartsWith("OBSERVER")) { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = false }); } } MPJoinInProgress.SetReady(newPlayer, false, true); // special case: do not disable the player completely, as this would prevent this player to be sent to new clients joining before we finally switch to ready } pregameWait = SendPreGame(connectionId, pregameWait); yield return(new WaitForSeconds(pregameWait)); Server.SendLoadoutDataToClients(); if (newPlayer.m_mp_name.StartsWith("OBSERVER")) { Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name); newPlayer.Networkm_spectator = true; Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name); yield return(null); // make sure spectator change is received before sending MatchStart } else { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = true }); } } MPJoinInProgress.SetReady(newPlayer, true); } if (NetworkMatch.GetMatchState() != MatchState.PLAYING) { yield break; } IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode()); NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg); SendMatchState(connectionId); NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship); MPTweaks.Send(connectionId); //if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled) // newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true); CTF.SendJoinUpdate(newPlayer); Race.SendJoinUpdate(newPlayer); foreach (Player player in Overload.NetworkManager.m_Players) { if (player.connectionToClient.connectionId == connectionId) { continue; } // Resend mode for existing player to move h2h -> anarchy NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg); if (!newPlayer.m_spectator) { player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true); } //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId); NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage { m_net_id = player.netId, lobby_id = player.connectionToClient.connectionId, m_pos = player.transform.position, m_rotation = player.transform.rotation, use_loadout1 = player.m_use_loadout1 }); } ServerStatLog.Connected(newPlayer.m_mp_name); MPBanPlayers.ApplyAllBans(); // make sure the newly connected player gets proper treatment if he is BANNED }
private static IEnumerator MatchStart(int connectionId) { var newPlayer = Server.FindPlayerByConnectionId(connectionId); float pregameWait = 3f; if (!newPlayer.m_mp_name.StartsWith("OBSERVER")) { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = false }); } } MPJoinInProgress.SetReady(newPlayer, false); } pregameWait = SendPreGame(connectionId, pregameWait); yield return(new WaitForSeconds(pregameWait)); Server.SendLoadoutDataToClients(); if (newPlayer.m_mp_name.StartsWith("OBSERVER")) { Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name); newPlayer.Networkm_spectator = true; Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name); yield return(null); // make sure spectator change is received before sending MatchStart } else { foreach (Player player in Overload.NetworkManager.m_Players) { if (MPTweaks.ClientHasTweak(player.connectionToClient.connectionId, "jip")) { NetworkServer.SendToClient(player.connectionToClient.connectionId, MessageTypes.MsgJIPJustJoined, new JIPJustJoinedMessage { playerId = newPlayer.netId, ready = true }); } } MPJoinInProgress.SetReady(newPlayer, true); } if (NetworkMatch.GetMatchState() != MatchState.PLAYING) { yield break; } IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode()); NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg); SendMatchState(connectionId); NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship); MPTweaks.Send(connectionId); //if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled) // newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true); CTF.SendJoinUpdate(newPlayer); Race.SendJoinUpdate(newPlayer); foreach (Player player in Overload.NetworkManager.m_Players) { if (player.connectionToClient.connectionId == connectionId) { continue; } // Resend mode for existing player to move h2h -> anarchy NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg); if (!newPlayer.m_spectator) { player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true); } //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId); NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage { m_net_id = player.netId, lobby_id = player.connectionToClient.connectionId, m_pos = player.transform.position, m_rotation = player.transform.rotation, use_loadout1 = player.m_use_loadout1 }); } ServerStatLog.Connected(newPlayer.m_mp_name); }
private static IEnumerator MatchStart(int connectionId) { if (!MPTweaks.ClientHasMod(connectionId) && MPTweaks.MatchNeedsMod()) { yield break; } var newPlayer = Server.FindPlayerByConnectionId(connectionId); if (newPlayer.m_mp_name.StartsWith("OBSERVER")) { Debug.LogFormat("Enabling spectator for {0}", newPlayer.m_mp_name); newPlayer.Networkm_spectator = true; Debug.LogFormat("Enabled spectator for {0}", newPlayer.m_mp_name); } int pregameWait = newPlayer.Networkm_spectator ? 0 : 3; //Debug.Log("SendLoadoutDataToClients: " + NetworkMatch.m_player_loadout_data.Join()); // restore lobby_id which got wiped out in Client.OnSetLoadout foreach (var idData in NetworkMatch.m_player_loadout_data) { idData.Value.lobby_id = idData.Key; } Server.SendLoadoutDataToClients(); IntegerMessage durationMsg = new IntegerMessage(pregameWait * 1000); NetworkServer.SendToClient(connectionId, CustomMsgType.StartPregameCountdown, durationMsg); Debug.Log("JIP: sending start pregame countdown"); yield return(new WaitForSeconds(pregameWait)); IntegerMessage modeMsg = new IntegerMessage((int)NetworkMatch.GetMode()); NetworkServer.SendToClient(connectionId, CustomMsgType.MatchStart, modeMsg); SendMatchState(connectionId); NetworkSpawnPlayer.Respawn(newPlayer.c_player_ship); MPTweaks.Send(connectionId); if (!newPlayer.m_spectator && RearView.MPNetworkMatchEnabled) { newPlayer.CallTargetAddHUDMessage(newPlayer.connectionToClient, "REARVIEW ENABLED", -1, true); } CTF.SendJoinUpdate(newPlayer); Race.SendJoinUpdate(newPlayer); foreach (Player player in Overload.NetworkManager.m_Players) { if (player.connectionToClient.connectionId == connectionId) { continue; } // Resend mode for existing player to move h2h -> anarchy NetworkServer.SendToClient(player.connectionToClient.connectionId, CustomMsgType.MatchStart, modeMsg); if (!newPlayer.m_spectator) { player.CallTargetAddHUDMessage(player.connectionToClient, String.Format(Loc.LS("{0} JOINED MATCH"), newPlayer.m_mp_name), -1, true); } //Debug.Log("JIP: spawning on new client net " + player.netId + " lobby " + player.connectionToClient.connectionId); NetworkServer.SendToClient(connectionId, CustomMsgType.Respawn, new RespawnMessage { m_net_id = player.netId, lobby_id = player.connectionToClient.connectionId, m_pos = player.transform.position, m_rotation = player.transform.rotation, use_loadout1 = player.m_use_loadout1 }); } ServerStatLog.Connected(newPlayer.m_mp_name); }