示例#1
0
        private static IEnumerator SendSceneLoad(int connectionId)
        {
            // wait until we've received the loadout
            while (!NetworkMatch.m_player_loadout_data.ContainsKey(connectionId))
            {
                if (!NetworkMatch.m_players.ContainsKey(connectionId)) // disconnected?
                {
                    yield break;
                }
                yield return(null);
            }

            StringMessage levelNameMsg = new StringMessage(MPJoinInProgress.NetworkMatchLevelName());

            NetworkServer.SendToClient(connectionId, CustomMsgType.SceneLoad, levelNameMsg);
            Debug.Log("JIP: sending scene load " + levelNameMsg.value);

            if (NetworkMatch.GetMatchState() == MatchState.LOBBY_LOADING_SCENE)
            {
                yield break;
            }

            StringMessage sceneNameMsg = new StringMessage(GameplayManager.m_level_info.SceneName);

            NetworkServer.SendToClient(connectionId, CustomMsgType.SceneLoaded, sceneNameMsg);
            Debug.Log("JIP: sending scene loaded " + sceneNameMsg.value);
        }
示例#2
0
 private static void Postfix(NetworkMessage msg)
 {
     if (!NetworkMatch.InLobby())
     {
         int           connectionId = msg.conn.connectionId;
         StringMessage levelNameMsg = new StringMessage(MPJoinInProgress.NetworkMatchLevelName());
         NetworkServer.SendToClient(connectionId, CustomMsgType.SceneLoad, levelNameMsg);
         StringMessage sceneNameMsg = new StringMessage(GameplayManager.m_level_info.SceneName);
         NetworkServer.SendToClient(connectionId, CustomMsgType.SceneLoaded, sceneNameMsg);
         Debug.Log("JIP: sending scene load " + levelNameMsg.value);
         Debug.Log("JIP: sending scene loaded " + sceneNameMsg.value);
     }
 }
        private static void Postfix(NetworkMessage msg)
        {
            MatchState match_state = NetworkMatch.GetMatchState();

            if (match_state != MatchState.LOBBY && match_state != MatchState.LOBBY_LOAD_COUNTDOWN)
            {
                GameManager.m_gm.StartCoroutine(SendSceneLoad(msg.conn.connectionId));
            }
            else
            {
                string level       = MPJoinInProgress.NetworkMatchLevelName();
                bool   customLevel = (level != null)? level.Contains(':') : false;
                GameManager.m_gm.StartCoroutine(InformClientAboutOlmod(msg.conn.connectionId, customLevel, 0));
            }
        }
示例#4
0
        private static void OnJIPJustJoinedMessage(NetworkMessage rawMsg)
        {
            if (Server.IsActive())
            {
                return;
            }

            var msg = rawMsg.ReadMessage <JIPJustJoinedMessage>();

            var player = Overload.NetworkManager.m_Players.Find(p => p.netId == msg.playerId);

            if (!player)
            {
                return;
            }

            MPJoinInProgress.SetReady(player, msg.ready);
        }
        private static IEnumerator SendSceneLoad(int connectionId)
        {
            // wait until we've received the loadout
            while (!NetworkMatch.m_player_loadout_data.ContainsKey(connectionId))
            {
                if (!NetworkMatch.m_players.ContainsKey(connectionId)) // disconnected?
                {
                    yield break;
                }
                yield return(null);
            }
            string level       = MPJoinInProgress.NetworkMatchLevelName();
            bool   customLevel = (level != null)? level.Contains(':') : false;

            if (customLevel && !MPTweaks.ClientHasMod(connectionId))
            {
                // client seems not to have olmod, warn it
                yield return(GameManager.m_gm.StartCoroutine(InformClientAboutOlmod(connectionId, customLevel, 8)));

                if (!NetworkMatch.m_players.ContainsKey(connectionId)) // disconnected?
                {
                    yield break;
                }
            }

            StringMessage levelNameMsg = new StringMessage(level);

            NetworkServer.SendToClient(connectionId, CustomMsgType.SceneLoad, levelNameMsg);
            Debug.Log("JIP: sending scene load " + levelNameMsg.value);

            if (NetworkMatch.GetMatchState() == MatchState.LOBBY_LOADING_SCENE)
            {
                yield break;
            }

            StringMessage sceneNameMsg = new StringMessage(GameplayManager.m_level_info.SceneName);

            NetworkServer.SendToClient(connectionId, CustomMsgType.SceneLoaded, sceneNameMsg);
            Debug.Log("JIP: sending scene loaded " + sceneNameMsg.value);
        }
        private static void OnJIPJustJoinedMessage(NetworkMessage rawMsg)
        {
            if (Server.IsActive())
            {
                return;
            }

            var msg = rawMsg.ReadMessage <JIPJustJoinedMessage>();

            var player = Overload.NetworkManager.m_Players.Find(p => p.netId == msg.playerId);

            if (!player)
            {
                return;
            }

            MPJoinInProgress.SetReady(player, msg.ready);

            // Check if we should be using 1v1 scoring
            if (NetworkMatch.GetMode() == MatchMode.ANARCHY)
            {
                NetworkMatch.m_head_to_head = (NetworkMatch.m_players.Count(x => !x.Value.m_name.StartsWith("OBSERVER")) < 3);
            }
        }
示例#7
0
        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)
        {
            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
        }