Ejemplo n.º 1
0
 private void CloseConnection()
 {
     if (this.persistance != null)
     {
         this.persistance.Dispose();
         this.persistance = null;
     }
     EACServer.DoShutdown();
     Network.Net.sv.callbackHandler = null;
     using (TimeWarning timeWarning = TimeWarning.New("sv.Stop", 0.1f))
     {
         Network.Net.sv.Stop("Shutting Down");
     }
     using (timeWarning = TimeWarning.New("RCon.Shutdown", 0.1f))
     {
         RCon.Shutdown();
     }
     using (timeWarning = TimeWarning.New("Steamworks.GameServer.Shutdown", 0.1f))
     {
         if (SteamServer.IsValid)
         {
             UnityEngine.Debug.Log("Steamworks Shutting Down");
             SteamServer.Shutdown();
             UnityEngine.Debug.Log("Okay");
         }
     }
 }
Ejemplo n.º 2
0
 private void CloseConnection()
 {
     if (this.persistance != null)
     {
         this.persistance.Dispose();
         this.persistance = (UserPersistance)null;
     }
     EACServer.DoShutdown();
     ((Network.Server)Network.Net.sv).callbackHandler = null;
     using (TimeWarning.New("sv.Stop", 0.1f))
         ((Network.Server)Network.Net.sv).Stop("Shutting Down");
     using (TimeWarning.New("RCon.Shutdown", 0.1f))
         RCon.Shutdown();
     using (TimeWarning.New("Steamworks.GameServer.Shutdown", 0.1f))
     {
         if (Global.get_SteamServer() == null)
         {
             return;
         }
         Debug.Log((object)"Steamworks Shutting Down");
         ((BaseSteamworks)Global.get_SteamServer()).Dispose();
         Global.set_SteamServer((Facepunch.Steamworks.Server)null);
         Debug.Log((object)"Okay");
     }
 }
Ejemplo n.º 3
0
    public static void InitializeEntitySupports()
    {
        if (!ConVar.Server.stability)
        {
            return;
        }
        StabilityEntity[] array = BaseNetworkable.serverEntities.Where <BaseNetworkable>((Func <BaseNetworkable, bool>)(x => x is StabilityEntity)).Select <BaseNetworkable, StabilityEntity>((Func <BaseNetworkable, StabilityEntity>)(x => x as StabilityEntity)).ToArray <StabilityEntity>();
        if (array.Length == 0)
        {
            return;
        }
        DebugEx.Log((object)("Initializing " + (object)array.Length + " stability supports"), (StackTraceLogType)0);
        Stopwatch stopwatch = Stopwatch.StartNew();

        for (int index = 0; index < array.Length; ++index)
        {
            RCon.Update();
            array[index].InitializeSupports();
            if (stopwatch.Elapsed.TotalMilliseconds > 2000.0)
            {
                stopwatch.Reset();
                stopwatch.Start();
                DebugEx.Log((object)("\t" + (object)(index + 1) + " / " + (object)array.Length), (StackTraceLogType)0);
            }
        }
        DebugEx.Log((object)"\tdone.", (StackTraceLogType)0);
    }
Ejemplo n.º 4
0
 private void DoTick()
 {
     if (SteamServer.IsValid)
     {
         Interface.CallHook("OnTick");
         SteamServer.RunCallbacks();
     }
     RCon.Update();
     for (int i = 0; i < Network.Net.sv.connections.Count; i++)
     {
         Network.Connection item = Network.Net.sv.connections[i];
         if (!item.isAuthenticated && item.GetSecondsConnected() >= (float)ConVar.Server.authtimeout)
         {
             Network.Net.sv.Kick(item, "Authentication Timed Out");
         }
     }
 }
Ejemplo n.º 5
0
 private void DoTick()
 {
     if (Global.get_SteamServer() != null)
     {
         Interface.CallHook("OnTick");
         ((BaseSteamworks)Global.get_SteamServer()).Update();
     }
     RCon.Update();
     for (int index = 0; index < ((List <Network.Connection>)((Network.Server)Network.Net.sv).connections).Count; ++index)
     {
         Network.Connection connection = ((List <Network.Connection>)((Network.Server)Network.Net.sv).connections)[index];
         if (!connection.get_isAuthenticated() && (double)connection.GetSecondsConnected() >= (double)ConVar.Server.authtimeout)
         {
             ((Network.Server)Network.Net.sv).Kick(connection, "Authentication Timed Out");
         }
     }
 }
Ejemplo n.º 6
0
 public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0uL)
 {
     if (Interface.CallHook("OnServerMessage", message, username, color, userid) == null)
     {
         string text = username.EscapeRichText();
         ConsoleNetwork.BroadcastToAllClients("chat.add", 2, 0, "<color=" + color + ">" + text + "</color> " + message);
         ChatEntry chatEntry = default(ChatEntry);
         chatEntry.Channel  = ChatChannel.Server;
         chatEntry.Message  = message;
         chatEntry.UserId   = userid.ToString();
         chatEntry.Username = username;
         chatEntry.Color    = color;
         chatEntry.Time     = Epoch.Current;
         ChatEntry chatEntry2 = chatEntry;
         History.Add(chatEntry2);
         RCon.Broadcast(RCon.LogType.Chat, chatEntry2);
     }
 }
Ejemplo n.º 7
0
        public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0)
        {
            if (Interface.CallHook("OnServerMessage", (object)message, (object)username, (object)color, (object)userid) != null)
            {
                return;
            }
            string str = StringEx.EscapeRichText(username);

            ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=" + color + ">" + str + "</color> " + message));
            Chat.ChatEntry chatEntry = new Chat.ChatEntry()
            {
                Message  = message,
                UserId   = userid,
                Username = username,
                Color    = color,
                Time     = Epoch.get_Current()
            };
            Chat.History.Add(chatEntry);
            RCon.Broadcast(RCon.LogType.Chat, (object)chatEntry);
        }
Ejemplo n.º 8
0
    public static void InitializeEntityConditionals()
    {
        BuildingBlock[] array = BaseNetworkable.serverEntities.Where <BaseNetworkable>((Func <BaseNetworkable, bool>)(x => x is BuildingBlock)).Select <BaseNetworkable, BuildingBlock>((Func <BaseNetworkable, BuildingBlock>)(x => x as BuildingBlock)).ToArray <BuildingBlock>();
        if (array.Length == 0)
        {
            return;
        }
        DebugEx.Log((object)("Initializing " + (object)array.Length + " conditional models"), (StackTraceLogType)0);
        Stopwatch stopwatch = Stopwatch.StartNew();

        for (int index = 0; index < array.Length; ++index)
        {
            RCon.Update();
            array[index].UpdateSkin(true);
            if (stopwatch.Elapsed.TotalMilliseconds > 2000.0)
            {
                stopwatch.Reset();
                stopwatch.Start();
                DebugEx.Log((object)("\t" + (object)(index + 1) + " / " + (object)array.Length), (StackTraceLogType)0);
            }
        }
        DebugEx.Log((object)"\tdone.", (StackTraceLogType)0);
    }
Ejemplo n.º 9
0
        public static void Broadcast(string message, string username = "******", string color = "#eee", ulong userid = 0L)
        {
            if (Interface.CallHook("OnServerMessage", message, username, color, userid) != null)
            {
                return;
            }
            string str = username.EscapeRichText();

            object[] objArray = new object[] { 0, null };
            objArray[1] = string.Concat(new string[] { "<color=", color, ">", str, "</color> ", message });
            ConsoleNetwork.BroadcastToAllClients("chat.add", objArray);
            Chat.ChatEntry chatEntry = new Chat.ChatEntry()
            {
                Message  = message,
                UserId   = userid,
                Username = username,
                Color    = color,
                Time     = Epoch.Current
            };
            Chat.ChatEntry chatEntry1 = chatEntry;
            Chat.History.Add(chatEntry1);
            RCon.Broadcast(RCon.LogType.Chat, chatEntry1);
        }
Ejemplo n.º 10
0
 public static void say(ConsoleSystem.Arg arg)
 {
     if (!Chat.enabled)
     {
         arg.ReplyWith("Chat is disabled.");
     }
     else
     {
         BasePlayer basePlayer = arg.Player();
         if (!Object.op_Implicit((Object)basePlayer) || basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute))
         {
             return;
         }
         if (!basePlayer.IsAdmin && !basePlayer.IsDeveloper)
         {
             if ((double)basePlayer.NextChatTime == 0.0)
             {
                 basePlayer.NextChatTime = Time.get_realtimeSinceStartup() - 30f;
             }
             if ((double)basePlayer.NextChatTime > (double)Time.get_realtimeSinceStartup())
             {
                 basePlayer.NextChatTime += 2f;
                 float num = basePlayer.NextChatTime - Time.get_realtimeSinceStartup();
                 ConsoleNetwork.SendClientCommand(basePlayer.net.get_connection(), "chat.add", (object)0, (object)("You're chatting too fast - try again in " + (num + 0.5f).ToString("0") + " seconds"));
                 if ((double)num <= 120.0)
                 {
                     return;
                 }
                 basePlayer.Kick("Chatting too fast");
                 return;
             }
         }
         string str1 = arg.GetString(0, "text").Trim();
         if (str1.Length > 128)
         {
             str1 = str1.Substring(0, 128);
         }
         if (str1.Length <= 0)
         {
             return;
         }
         if (str1.StartsWith("/") || str1.StartsWith("\\"))
         {
             if (Interface.CallHook("IOnPlayerCommand", (object)arg) != null)
             {
                 ;
             }
         }
         else
         {
             string str2 = StringEx.EscapeRichText(str1);
             if (Interface.CallHook("IOnPlayerChat", (object)arg) != null)
             {
                 return;
             }
             if (Chat.serverlog)
             {
                 ServerConsole.PrintColoured((object)ConsoleColor.DarkYellow, (object)(basePlayer.displayName + ": "), (object)ConsoleColor.DarkGreen, (object)str2);
                 DebugEx.Log((object)string.Format("[CHAT] {0} : {1}", (object)((object)basePlayer).ToString(), (object)str2), (StackTraceLogType)0);
             }
             string str3 = "#5af";
             if (basePlayer.IsAdmin)
             {
                 str3 = "#af5";
             }
             if (basePlayer.IsDeveloper)
             {
                 str3 = "#fa5";
             }
             string str4 = StringEx.EscapeRichText(basePlayer.displayName);
             basePlayer.NextChatTime = Time.get_realtimeSinceStartup() + 1.5f;
             Chat.ChatEntry chatEntry = new Chat.ChatEntry()
             {
                 Message  = str2,
                 UserId   = basePlayer.userID,
                 Username = basePlayer.displayName,
                 Color    = str3,
                 Time     = Epoch.get_Current()
             };
             Chat.History.Add(chatEntry);
             RCon.Broadcast(RCon.LogType.Chat, (object)chatEntry);
             if (Server.globalchat)
             {
                 ConsoleNetwork.BroadcastToAllClients("chat.add2", (object)basePlayer.userID, (object)str2, (object)str4, (object)str3, (object)1f);
                 arg.ReplyWith("");
             }
             else
             {
                 float num = 2500f;
                 foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
                 {
                     Vector3 vector3      = Vector3.op_Subtraction(((Component)activePlayer).get_transform().get_position(), ((Component)basePlayer).get_transform().get_position());
                     float   sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude();
                     if ((double)sqrMagnitude <= (double)num)
                     {
                         ConsoleNetwork.SendClientCommand(activePlayer.net.get_connection(), "chat.add2", (object)basePlayer.userID, (object)str2, (object)str4, (object)str3, (object)Mathf.Clamp01((float)((double)num - (double)sqrMagnitude + 0.200000002980232)));
                     }
                 }
                 arg.ReplyWith("");
             }
         }
     }
 }
Ejemplo n.º 11
0
        private bool OnPlayerChat(ConsoleSystem.Arg arg, Chat.ChatChannel channel)
        {
            var player = arg.Player();
            var text   = arg.GetString(0, "text").Replace("\n", "").Replace("\r", "").Trim().EscapeRichText();

            if (Chat.serverlog)
            {
                ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", channel.ToString(), "] ", player.displayName, ": "), ConsoleColor.DarkGreen, text);
                DebugEx.Log(channel == Chat.ChatChannel.Team
                    ? $"[TEAM CHAT] {player} : {text}"
                    : $"[CHAT] {player} : {text}");
            }

            var color       = "#5af";
            var displayName = player.displayName.EscapeRichText();

            player.NextChatTime = Time.realtimeSinceStartup + 1.5f;

            var chatEntry = new Chat.ChatEntry
            {
                Channel  = channel,
                Message  = text,
                UserId   = player.UserIDString,
                Username = player.displayName,
                Color    = color,
                Time     = Epoch.Current
            };

            RCon.Broadcast(RCon.LogType.Chat, chatEntry);

            if (channel != Chat.ChatChannel.Global)
            {
                if (channel == Chat.ChatChannel.Team)
                {
                    var team = arg.Player().Team;
                    var list = team?.GetOnlineMemberConnections();
                    if (list == null)
                    {
                        return(false);
                    }

                    ConsoleNetwork.SendClientCommand(list, "chat.add2", new object[]
                    {
                        1,
                        player.userID,
                        text,
                        displayName,
                        color,
                        1f
                    });

                    return(false);
                }
            }
            else if (ConVar.Server.globalchat)
            {
                ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, player.userID, text, displayName, color, 1f);
                return(false);
            }

            var radius = 2500f;

            foreach (var basePlayer2 in BasePlayer.activePlayerList)
            {
                var sqrMagnitude = (basePlayer2.transform.position - player.transform.position).sqrMagnitude;
                if (sqrMagnitude <= radius)
                {
                    ConsoleNetwork.SendClientCommand(basePlayer2.net.connection, "chat.add2", 0, player.userID, text, displayName, color, Mathf.Clamp01(radius - sqrMagnitude + 0.2f));
                }
            }

            return(false);
        }
Ejemplo n.º 12
0
        internal static bool sayAs(ChatChannel targetChannel, ulong userId, string username, string message, BasePlayer player = null)
        {
            if (!player)
            {
                player = null;
            }
            if (!enabled)
            {
                return(false);
            }
            if (player != null && player.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute))
            {
                return(false);
            }
            ServerUsers.UserGroup userGroup = ServerUsers.Get(userId)?.group ?? ServerUsers.UserGroup.None;
            if (userGroup == ServerUsers.UserGroup.Banned)
            {
                return(false);
            }
            string text = message.Replace("\n", "").Replace("\r", "").Trim();

            if (text.Length > 128)
            {
                text = text.Substring(0, 128);
            }
            if (text.Length <= 0)
            {
                return(false);
            }
            if (text.StartsWith("/") || text.StartsWith("\\"))
            {
                Interface.CallHook("IOnPlayerCommand", player, message);
                return(false);
            }
            text = text.EscapeRichText();
            object obj = Interface.CallHook("IOnPlayerChat", userId, username, text, targetChannel, player);

            if (obj is bool)
            {
                return((bool)obj);
            }
            if (serverlog)
            {
                ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", targetChannel, "] ", username, ": "), ConsoleColor.DarkGreen, text);
                string text2 = player?.ToString() ?? $"{username}[{userId}]";
                switch (targetChannel)
                {
                case ChatChannel.Team:
                    DebugEx.Log("[TEAM CHAT] " + text2 + " : " + text);
                    break;

                case ChatChannel.Cards:
                    DebugEx.Log("[CARDS CHAT] " + text2 + " : " + text);
                    break;

                default:
                    DebugEx.Log("[CHAT] " + text2 + " : " + text);
                    break;
                }
            }
            bool   flag  = userGroup == ServerUsers.UserGroup.Owner || userGroup == ServerUsers.UserGroup.Moderator;
            bool   num   = ((player != null) ? player.IsDeveloper : DeveloperList.Contains(userId));
            string text3 = "#5af";

            if (flag)
            {
                text3 = "#af5";
            }
            if (num)
            {
                text3 = "#fa5";
            }
            string    text4     = username.EscapeRichText();
            ChatEntry chatEntry = default(ChatEntry);

            chatEntry.Channel  = targetChannel;
            chatEntry.Message  = text;
            chatEntry.UserId   = ((player != null) ? player.UserIDString : userId.ToString());
            chatEntry.Username = username;
            chatEntry.Color    = text3;
            chatEntry.Time     = Epoch.Current;
            ChatEntry chatEntry2 = chatEntry;

            History.Add(chatEntry2);
            RCon.Broadcast(RCon.LogType.Chat, chatEntry2);
            switch (targetChannel)
            {
            case ChatChannel.Cards:
            {
                if (player == null)
                {
                    return(false);
                }
                if (!player.isMounted)
                {
                    return(false);
                }
                CardTable cardTable = player.GetMountedVehicle() as CardTable;
                if (cardTable == null || !cardTable.GameController.PlayerIsInGame(player))
                {
                    return(false);
                }
                List <Network.Connection> obj2 = Facepunch.Pool.GetList <Network.Connection>();
                cardTable.GameController.GetConnectionsInGame(obj2);
                if (obj2.Count > 0)
                {
                    ConsoleNetwork.SendClientCommand(obj2, "chat.add2", 3, userId, text, text4, text3, 1f);
                }
                Facepunch.Pool.FreeList(ref obj2);
                return(true);
            }

            case ChatChannel.Global:
                if (Server.globalchat)
                {
                    ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, userId, text, text4, text3, 1f);
                    return(true);
                }
                break;

            case ChatChannel.Team:
            {
                RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(userId);
                if (playerTeam == null)
                {
                    return(false);
                }
                List <Network.Connection> onlineMemberConnections = playerTeam.GetOnlineMemberConnections();
                if (onlineMemberConnections != null)
                {
                    ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add2", 1, userId, text, text4, text3, 1f);
                }
                Util.BroadcastTeamChat(playerTeam, userId, text4, text, text3);
                return(true);
            }
            }
            if (player != null)
            {
                float num2 = 2500f;
                foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
                {
                    float sqrMagnitude = (activePlayer.transform.position - player.transform.position).sqrMagnitude;
                    if (!(sqrMagnitude > num2))
                    {
                        ConsoleNetwork.SendClientCommand(activePlayer.net.connection, "chat.add2", 0, userId, text, text4, text3, Mathf.Clamp01(num2 - sqrMagnitude + 0.2f));
                    }
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 13
0
        private BetterChatMessage.CancelOptions SendBetterChatMessage(BetterChatMessage chatMessage)
#endif
        {
            Dictionary <string, object> chatMessageDict = chatMessage.ToDictionary();

#if RUST
            chatMessageDict.Add("ChatChannel", chatchannel);
#endif
            foreach (Plugin plugin in plugins.GetAll())
            {
                object hookResult = plugin.CallHook("OnBetterChat", chatMessageDict);

                if (hookResult is Dictionary <string, object> )
                {
                    try
                    {
                        chatMessageDict = hookResult as Dictionary <string, object>;
                    }
                    catch (Exception e)
                    {
                        PrintError($"Failed to load modified OnBetterChat hook data from plugin '{plugin.Title} ({plugin.Version})':{Environment.NewLine}{e}");
                        continue;
                    }
                }
                else if (hookResult != null)
                {
                    return(BetterChatMessage.CancelOptions.BetterChatOnly);
                }
            }

            chatMessage = BetterChatMessage.FromDictionary(chatMessageDict);

            if (chatMessage.CancelOption != BetterChatMessage.CancelOptions.None)
            {
                return(chatMessage.CancelOption);
            }

            var output = chatMessage.GetOutput();

#if RUST
            BasePlayer basePlayer = chatMessage.Player.Object as BasePlayer;

            switch (chatchannel)
            {
            case Chat.ChatChannel.Team:
                RelationshipManager.PlayerTeam team = basePlayer.Team;
                if (team == null || team.members.Count == 0)
                {
                    throw new InvalidOperationException("Chat channel is set to Team, however the player is not in a team.");
                }

                team.BroadcastTeamChat(basePlayer.userID, chatMessage.Player.Name, chatMessage.Message, chatMessage.UsernameSettings.Color);

                List <Network.Connection> onlineMemberConnections = team.GetOnlineMemberConnections();
                if (onlineMemberConnections != null)
                {
                    ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add", (int)chatchannel, chatMessage.Player.Id, output.Chat);
                }
                break;

            case Chat.ChatChannel.Cards:
                CardTable cardTable = basePlayer.GetMountedVehicle() as CardTable;

                if (cardTable == null /* || !cardTable.GameController.PlayerIsInGame(basePlayer) */)
                {
                    throw new InvalidOperationException("Chat channel is set to Cards, however the player is not in a participating in a card game.");
                }

                List <Network.Connection> list = Facepunch.Pool.GetList <Network.Connection>();

                foreach (CardPlayerData playerData in cardTable.GameController.playerData)
                {
                    if (playerData.HasUser)
                    {
                        list.Add(BasePlayer.FindByID(playerData.UserID).net.connection);
                    }
                }

                if (list.Count > 0)
                {
                    ConsoleNetwork.SendClientCommand(list, "chat.add", (int)chatchannel, chatMessage.Player.Id, output.Chat);
                }

                Facepunch.Pool.FreeList(ref list);
                break;

            default:
                foreach (BasePlayer p in BasePlayer.activePlayerList.Where(p => !chatMessage.BlockedReceivers.Contains(p.UserIDString)))
                {
                    p.SendConsoleCommand("chat.add", (int)chatchannel, chatMessage.Player.Id, output.Chat);
                }
                break;
            }
#else
            foreach (IPlayer p in players.Connected.Where(p => !chatMessage.BlockedReceivers.Contains(p.Id)))
            {
                p.Message(output.Chat);
            }
#endif

#if RUST
            Puts($"[{chatchannel}] {output.Console}");

            var chatEntry = new Chat.ChatEntry
            {
                Channel  = chatchannel,
                Message  = output.Console,
                UserId   = chatMessage.Player.Id,
                Username = chatMessage.Player.Name,
                Color    = chatMessage.UsernameSettings.Color,
                Time     = Epoch.Current
            };

            Chat.Record(chatEntry);
            RCon.Broadcast(RCon.LogType.Chat, chatEntry);
#else
            Puts(output.Console);
#endif

            return(chatMessage.CancelOption);
        }
Ejemplo n.º 14
0
        private bool OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel)
        {
            if (Chat.serverlog)
            {
                ServerConsole.PrintColoured(ConsoleColor.DarkYellow,
                                            string.Concat("[", channel, "] ", player.displayName, ": "), ConsoleColor.DarkGreen, message);

                var str = (player != null ? player.ToString() : null) ??
                          $"{player.displayName}[{player.userID}]";

                if (channel == Chat.ChatChannel.Team)
                {
                    DebugEx.Log("[TEAM CHAT] " + str + " : " + message);
                }
                else
                {
                    DebugEx.Log("[CHAT] " + str + " : " + message);
                }
            }

            var color       = "#5af";
            var displayName = player.displayName.EscapeRichText();
            var chatEntry   = new Chat.ChatEntry
            {
                Channel  = channel,
                Message  = message,
                UserId   = player.UserIDString,
                Username = displayName,
                Color    = color,
                Time     = Epoch.Current
            };

            RCon.Broadcast(RCon.LogType.Chat, chatEntry);
            if (channel != Chat.ChatChannel.Global)
            {
                if (channel == Chat.ChatChannel.Team)
                {
                    var playerTeam = RelationshipManager.Instance.FindPlayersTeam(player.userID);
                    if (playerTeam == null)
                    {
                        return(false);
                    }

                    var onlineMemberConnections = playerTeam.GetOnlineMemberConnections();
                    if (onlineMemberConnections != null)
                    {
                        ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add2", 1, player.userID,
                                                         message, displayName, color, 1f);
                    }

                    playerTeam.BroadcastTeamChat(player.userID, displayName, message, color);
                    return(true);
                }
            }
            else if (ConVar.Server.globalchat)
            {
                ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, player.userID, message, displayName, color, 1f);
                return(true);
            }

            if (player == null)
            {
                return(true);
            }

            var radius = 2500f;

            foreach (var basePlayer in BasePlayer.activePlayerList)
            {
                var sqrMagnitude = (basePlayer.transform.position - player.transform.position).sqrMagnitude;
                if (sqrMagnitude <= radius)
                {
                    ConsoleNetwork.SendClientCommand(basePlayer.net.connection, "chat.add2", 0, player.userID,
                                                     message,
                                                     displayName, color, Mathf.Clamp01(radius - sqrMagnitude + 0.2f));
                }
            }

            return(true);
        }
Ejemplo n.º 15
0
        public static void say(ConsoleSystem.Arg arg)
        {
            if (!Chat.enabled)
            {
                arg.ReplyWith("Chat is disabled.");
                return;
            }
            BasePlayer basePlayer = arg.Player();

            if (!basePlayer)
            {
                return;
            }
            if (basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute))
            {
                return;
            }
            if (!basePlayer.IsAdmin && !basePlayer.IsDeveloper)
            {
                if (basePlayer.NextChatTime == 0f)
                {
                    basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup - 30f;
                }
                if (basePlayer.NextChatTime > UnityEngine.Time.realtimeSinceStartup)
                {
                    basePlayer.NextChatTime += 2f;
                    float      nextChatTime = basePlayer.NextChatTime - UnityEngine.Time.realtimeSinceStartup;
                    Connection connection   = basePlayer.net.connection;
                    object[]   objArray     = new object[] { 0, null };
                    float      single       = nextChatTime + 0.5f;
                    objArray[1] = string.Concat("You're chatting too fast - try again in ", single.ToString("0"), " seconds");
                    ConsoleNetwork.SendClientCommand(connection, "chat.add", objArray);
                    if (nextChatTime > 120f)
                    {
                        basePlayer.Kick("Chatting too fast");
                    }
                    return;
                }
            }
            string str = arg.GetString(0, "text").Trim();

            if (str.Length > 128)
            {
                str = str.Substring(0, 128);
            }
            if (str.Length <= 0)
            {
                return;
            }
            if (str.StartsWith("/") || str.StartsWith("\\"))
            {
                if (Interface.CallHook("IOnPlayerCommand", arg) != null)
                {
                    return;
                }
                return;
            }
            str = str.EscapeRichText();
            if (Interface.CallHook("IOnPlayerChat", arg, str) != null)
            {
                return;
            }
            if (Chat.serverlog)
            {
                ServerConsole.PrintColoured(new object[] { ConsoleColor.DarkYellow, string.Concat(basePlayer.displayName, ": "), ConsoleColor.DarkGreen, str });
                DebugEx.Log(string.Format("[CHAT] {0} : {1}", basePlayer.ToString(), str), StackTraceLogType.None);
            }
            string str1 = "#5af";

            if (basePlayer.IsAdmin)
            {
                str1 = "#af5";
            }
            if (basePlayer.IsDeveloper)
            {
                str1 = "#fa5";
            }
            string str2 = basePlayer.displayName.EscapeRichText();

            basePlayer.NextChatTime = UnityEngine.Time.realtimeSinceStartup + 1.5f;
            Chat.ChatEntry chatEntry = new Chat.ChatEntry()
            {
                Message  = str,
                UserId   = basePlayer.userID,
                Username = basePlayer.displayName,
                Color    = str1,
                Time     = Epoch.Current
            };
            Chat.ChatEntry chatEntry1 = chatEntry;
            Chat.History.Add(chatEntry1);
            RCon.Broadcast(RCon.LogType.Chat, chatEntry1);
            if (ConVar.Server.globalchat)
            {
                ConsoleNetwork.BroadcastToAllClients("chat.add2", new object[] { basePlayer.userID, str, str2, str1, 1f });
                arg.ReplyWith("");
                return;
            }
            float single1 = 2500f;

            foreach (BasePlayer basePlayer1 in BasePlayer.activePlayerList)
            {
                Vector3 vector3 = basePlayer1.transform.position - basePlayer.transform.position;
                float   single2 = vector3.sqrMagnitude;
                if (single2 > single1)
                {
                    continue;
                }
                ConsoleNetwork.SendClientCommand(basePlayer1.net.connection, "chat.add2", new object[] { basePlayer.userID, str, str2, str1, Mathf.Clamp01(single1 - single2 + 0.2f) });
            }
            arg.ReplyWith("");
        }
Ejemplo n.º 16
0
        private object OnUserChat(IPlayer player, string message)
        {
#endif
            if (message.Length > _instance._config.MaxMessageLength)
            {
                message = message.Substring(0, _instance._config.MaxMessageLength);
            }

            BetterChatMessage chatMessage = ChatGroup.FormatMessage(player, message);

            if (chatMessage == null)
            {
                return(null);
            }

            Dictionary <string, object> chatMessageDict = chatMessage.ToDictionary();

#if RUST
            chatMessageDict.Add("ChatChannel", chatchannel);
#endif
            foreach (Plugin plugin in plugins.GetAll())
            {
                object hookResult = plugin.CallHook("OnBetterChat", chatMessageDict);

                if (hookResult is Dictionary <string, object> )
                {
                    try
                    {
                        chatMessageDict = hookResult as Dictionary <string, object>;
                    }
                    catch (Exception e)
                    {
                        PrintError($"Failed to load modified OnBetterChat hook data from plugin '{plugin.Title} ({plugin.Version})':{Environment.NewLine}{e}");
                        continue;
                    }
                }
                else if (hookResult != null)
                {
                    return(null);
                }
            }

            chatMessage = BetterChatMessage.FromDictionary(chatMessageDict);

            switch (chatMessage.CancelOption)
            {
            case BetterChatMessage.CancelOptions.BetterChatOnly:
                return(null);

            case BetterChatMessage.CancelOptions.BetterChatAndDefault:
                return(true);
            }

            var output = chatMessage.GetOutput();

#if RUST
            switch (chatchannel)
            {
            case Chat.ChatChannel.Team:
                RelationshipManager.PlayerTeam team = BasePlayer.Find(player.Id).Team;
                if (team == null || team.members.Count == 0)
                {
                    return(true);
                }

                team.BroadcastTeamChat(Convert.ToUInt64(player.Id), player.Name, chatMessage.Message, chatMessage.UsernameSettings.Color);

                List <Network.Connection> onlineMemberConnections = team.GetOnlineMemberConnections();
                if (onlineMemberConnections != null)
                {
                    ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add", new object[] { (int)chatchannel, player.Id, output.Chat });
                }
                break;

            default:
                foreach (BasePlayer p in BasePlayer.activePlayerList.Where(p => !chatMessage.BlockedReceivers.Contains(p.UserIDString)))
                {
                    p.SendConsoleCommand("chat.add", new object[] { (int)chatchannel, player.Id, output.Chat });
                }
                break;
            }
#else
            foreach (IPlayer p in players.Connected.Where(p => !chatMessage.BlockedReceivers.Contains(p.Id)))
            {
                p.Message(output.Chat);
            }
#endif



#if RUST
            Puts($"[{chatchannel}] {output.Console}");

            RCon.Broadcast(RCon.LogType.Chat, new Chat.ChatEntry
            {
                Channel  = chatchannel,
                Message  = output.Console,
                UserId   = player.Id,
                Username = player.Name,
                Color    = chatMessage.UsernameSettings.Color,
                Time     = Epoch.Current
            });
#else
            Puts(output.Console);
#endif

            return(true);
        }
Ejemplo n.º 17
0
        object OnUserChat(IPlayer player, string message)
        {
            if (message.Length > Configuration.MaxMessageLength)
            {
                message = message.Substring(0, Configuration.MaxMessageLength);
            }

            BetterChatMessage chatMessage = ChatGroup.FormatMessage(player, message);

            if (chatMessage == null)
            {
                return(null);
            }

            Dictionary <string, object> chatMessageDict = chatMessage.ToDictionary();

            foreach (Plugin plugin in plugins.GetAll())
            {
                object hookResult = plugin.CallHook("OnBetterChat", chatMessageDict);

                if (hookResult is Dictionary <string, object> )
                {
                    try
                    {
                        chatMessageDict = (Dictionary <string, object>)hookResult;
                    }
                    catch (Exception e)
                    {
                        PrintError($"Failed to load modified OnBetterChat data from plugin '{plugin.Title} ({plugin.Version})':{Environment.NewLine}{e}");
                        continue;
                    }
                }
                else if (hookResult != null)
                {
                    return(null);
                }
            }

            chatMessage = BetterChatMessage.FromDictionary(chatMessageDict);
            var output = chatMessage.GetOutput();

            List <string> blockedReceivers = (List <string>)chatMessageDict["BlockedReceivers"];

#if RUST
            foreach (BasePlayer p in BasePlayer.activePlayerList.Where(p => !blockedReceivers.Contains(p.UserIDString)))
            {
                p.SendConsoleCommand("chat.add", new object[] { player.Id, output.Chat });
            }
#else
            foreach (IPlayer p in players.Connected.Where(p => !blockedReceivers.Contains(p.Id)))
            {
                p.Message(output.Chat);
            }
#endif

            Puts(output.Console);

#if RUST
            Chat.ChatEntry chatEntry = new Chat.ChatEntry
            {
                Message  = output.Console,
                UserId   = Convert.ToUInt64(player.Id),
                Username = player.Name,
                Time     = Epoch.Current
            };

            RCon.Broadcast(RCon.LogType.Chat, chatEntry);
#endif

            return(true);
        }
Ejemplo n.º 18
0
    public static IEnumerator StartServer(bool doLoad, string saveFileOverride, bool allowOutOfDateSaves)
    {
        float timeScale = UnityEngine.Time.timeScale;

        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = 0f;
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if ((bool)SingletonComponent <WorldSetup> .Instance)
        {
            yield return(SingletonComponent <WorldSetup> .Instance.StartCoroutine(SingletonComponent <WorldSetup> .Instance.InitCoroutine()));
        }
        if ((bool)SingletonComponent <DynamicNavMesh> .Instance && SingletonComponent <DynamicNavMesh> .Instance.enabled && !AiManager.nav_disable)
        {
            yield return(SingletonComponent <DynamicNavMesh> .Instance.StartCoroutine(SingletonComponent <DynamicNavMesh> .Instance.UpdateNavMeshAndWait()));
        }
        if ((bool)SingletonComponent <AiManager> .Instance && SingletonComponent <AiManager> .Instance.enabled)
        {
            SingletonComponent <AiManager> .Instance.Initialize();

            if (!AiManager.nav_disable && AI.npc_enable && TerrainMeta.Path != null)
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (monument.HasNavmesh)
                    {
                        yield return(monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                    }
                }
                if ((bool)TerrainMeta.Path && (bool)TerrainMeta.Path.DungeonRoot)
                {
                    DungeonNavmesh dungeonNavmesh = TerrainMeta.Path.DungeonRoot.AddComponent <DungeonNavmesh>();
                    dungeonNavmesh.NavMeshCollectGeometry = NavMeshCollectGeometry.PhysicsColliders;
                    dungeonNavmesh.LayerMask = 65537;
                    yield return(dungeonNavmesh.StartCoroutine(dungeonNavmesh.UpdateNavMeshAndWait()));
                }
                else
                {
                    Debug.LogError("Failed to find DungeonRoot, NOT generating Dungeon navmesh");
                }
            }
        }
        GameObject gameObject = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab");

        Object.DontDestroyOnLoad(gameObject);
        ServerMgr serverMgr = gameObject.GetComponent <ServerMgr>();

        serverMgr.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves);
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        BaseGameMode.CreateGameMode();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        serverMgr.OpenConnection();
        CompanionServer.Server.Initialize();
        using (BenchmarkTimer.New("Boombox.LoadStations"))
        {
            BoomBox.LoadStations();
        }
        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = timeScale;
        }
        WriteToLog("Server startup complete");
    }
Ejemplo n.º 19
0
    public static IEnumerator StartServer(bool doLoad, string saveFileOverride, bool allowOutOfDateSaves)
    {
        float single = UnityEngine.Time.timeScale;

        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = 0f;
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if (SingletonComponent <WorldSetup> .Instance)
        {
            yield return(SingletonComponent <WorldSetup> .Instance.StartCoroutine(SingletonComponent <WorldSetup> .Instance.InitCoroutine()));
        }
        if (SingletonComponent <DynamicNavMesh> .Instance && SingletonComponent <DynamicNavMesh> .Instance.enabled && !AiManager.nav_disable)
        {
            yield return(SingletonComponent <DynamicNavMesh> .Instance.StartCoroutine(SingletonComponent <DynamicNavMesh> .Instance.UpdateNavMeshAndWait()));
        }
        if (SingletonComponent <AiManager> .Instance && SingletonComponent <AiManager> .Instance.enabled)
        {
            SingletonComponent <AiManager> .Instance.Initialize();

            if (!AiManager.nav_disable && AI.npc_enable && TerrainMeta.Path != null)
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (!monument.HasNavmesh)
                    {
                        continue;
                    }
                    yield return(monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                }
            }
        }
        GameObject gameObject = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab", true);

        UnityEngine.Object.DontDestroyOnLoad(gameObject);
        ServerMgr component = gameObject.GetComponent <ServerMgr>();

        component.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves, false);
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        component.OpenConnection();
        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = single;
        }
        Bootstrap.WriteToLog("Server startup complete");
    }
Ejemplo n.º 20
0
    public static IEnumerator StartServer(
        bool doLoad,
        string saveFileOverride,
        bool allowOutOfDateSaves)
    {
        float timeScale = Time.get_timeScale();

        if (Time.pausewhileloading)
        {
            Time.set_timeScale(0.0f);
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if (Object.op_Implicit((Object)SingletonComponent <WorldSetup> .Instance))
        {
            yield return((object)((MonoBehaviour)SingletonComponent <WorldSetup> .Instance).StartCoroutine(((WorldSetup)SingletonComponent <WorldSetup> .Instance).InitCoroutine()));
        }
        if (Object.op_Implicit((Object)SingletonComponent <DynamicNavMesh> .Instance) && ((Behaviour)SingletonComponent <DynamicNavMesh> .Instance).get_enabled() && !AiManager.nav_disable)
        {
            yield return((object)((MonoBehaviour)SingletonComponent <DynamicNavMesh> .Instance).StartCoroutine(((DynamicNavMesh)SingletonComponent <DynamicNavMesh> .Instance).UpdateNavMeshAndWait()));
        }
        if (Object.op_Implicit((Object)SingletonComponent <AiManager> .Instance) && ((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled())
        {
            ((AiManager)SingletonComponent <AiManager> .Instance).Initialize();
            if (!AiManager.nav_disable && AI.npc_enable && Object.op_Inequality((Object)TerrainMeta.Path, (Object)null))
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (monument.HasNavmesh)
                    {
                        yield return((object)monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                    }
                }
            }
        }
        GameObject prefab = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab", true);

        Object.DontDestroyOnLoad((Object)prefab);
        ServerMgr serverMgr = (ServerMgr)prefab.GetComponent <ServerMgr>();

        serverMgr.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves, false);
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        serverMgr.OpenConnection();
        if (Time.pausewhileloading)
        {
            Time.set_timeScale(timeScale);
        }
        Bootstrap.WriteToLog("Server startup complete");
    }
Ejemplo n.º 21
0
 public static bool Load(string strFilename = "", bool allowOutOfDateSaves = false)
 {
     SaveRestore.SaveCreatedTime = DateTime.UtcNow;
     try
     {
         if (strFilename == "")
         {
             strFilename = World.SaveFolderName + "/" + World.SaveFileName;
         }
         if (!File.Exists(strFilename))
         {
             if (File.Exists("TestSaves/" + strFilename))
             {
                 strFilename = "TestSaves/" + strFilename;
             }
             else
             {
                 Debug.LogWarning((object)("Couldn't load " + strFilename + " - file doesn't exist"));
                 Interface.CallHook("OnNewSave", (object)strFilename);
                 return(false);
             }
         }
         Dictionary <BaseEntity, Entity> dictionary = new Dictionary <BaseEntity, Entity>();
         using (FileStream fileStream = File.OpenRead(strFilename))
         {
             using (BinaryReader binaryReader = new BinaryReader((Stream)fileStream))
             {
                 SaveRestore.SaveCreatedTime = File.GetCreationTime(strFilename);
                 if (binaryReader.ReadSByte() != (sbyte)83 || binaryReader.ReadSByte() != (sbyte)65 || (binaryReader.ReadSByte() != (sbyte)86 || binaryReader.ReadSByte() != (sbyte)82))
                 {
                     Debug.LogWarning((object)"Invalid save (missing header)");
                     return(false);
                 }
                 if (binaryReader.PeekChar() == 68)
                 {
                     int num = (int)binaryReader.ReadChar();
                     SaveRestore.SaveCreatedTime = Epoch.ToDateTime((Decimal)binaryReader.ReadInt32());
                 }
                 if (binaryReader.ReadUInt32() != 177U)
                 {
                     if (allowOutOfDateSaves)
                     {
                         Debug.LogWarning((object)"This save is from an older (possibly incompatible) version!");
                     }
                     else
                     {
                         Debug.LogWarning((object)"This save is from an older version. It might not load properly.");
                     }
                 }
                 SaveRestore.ClearMapEntities();
                 Assert.IsTrue(BaseEntity.saveList.Count == 0, "BaseEntity.saveList isn't empty!");
                 ((Network.Server)Net.sv).Reset();
                 Application.isLoadingSave = (__Null)1;
                 HashSet <uint> uintSet = new HashSet <uint>();
                 while (fileStream.Position < fileStream.Length)
                 {
                     RCon.Update();
                     uint   num     = binaryReader.ReadUInt32();
                     Entity entData = Entity.DeserializeLength((Stream)fileStream, (int)num);
                     if (entData.basePlayer != null && ((IEnumerable <KeyValuePair <BaseEntity, Entity> >)dictionary).Any <KeyValuePair <BaseEntity, Entity> >((Func <KeyValuePair <BaseEntity, Entity>, bool>)(x =>
                     {
                         if (x.Value.basePlayer != null)
                         {
                             return(((BasePlayer)x.Value.basePlayer).userid == ((BasePlayer)entData.basePlayer).userid);
                         }
                         return(false);
                     })))
                     {
                         Debug.LogWarning((object)("Skipping entity " + (object)(uint)((BaseNetworkable)entData.baseNetworkable).uid + " - it's a player " + (object)(ulong)((BasePlayer)entData.basePlayer).userid + " who is in the save multiple times"));
                     }
                     else if (((BaseNetworkable)entData.baseNetworkable).uid > 0 && uintSet.Contains((uint)((BaseNetworkable)entData.baseNetworkable).uid))
                     {
                         Debug.LogWarning((object)("Skipping entity " + (object)(uint)((BaseNetworkable)entData.baseNetworkable).uid + " " + StringPool.Get((uint)((BaseNetworkable)entData.baseNetworkable).prefabID) + " - uid is used multiple times"));
                     }
                     else
                     {
                         if (((BaseNetworkable)entData.baseNetworkable).uid > 0)
                         {
                             uintSet.Add((uint)((BaseNetworkable)entData.baseNetworkable).uid);
                         }
                         BaseEntity entity = GameManager.server.CreateEntity(StringPool.Get((uint)((BaseNetworkable)entData.baseNetworkable).prefabID), (Vector3)((BaseEntity)entData.baseEntity).pos, Quaternion.Euler((Vector3)((BaseEntity)entData.baseEntity).rot), true);
                         if (Object.op_Implicit((Object)entity))
                         {
                             entity.InitLoad((uint)((BaseNetworkable)entData.baseNetworkable).uid);
                             dictionary.Add(entity, entData);
                         }
                     }
                 }
             }
         }
         DebugEx.Log((object)("Spawning " + (object)dictionary.Count + " entities"), (StackTraceLogType)0);
         object obj = Interface.CallHook("OnSaveLoad", (object)dictionary);
         if (obj is bool)
         {
             return((bool)obj);
         }
         BaseNetworkable.LoadInfo info = new BaseNetworkable.LoadInfo();
         info.fromDisk = true;
         Stopwatch stopwatch = Stopwatch.StartNew();
         int       num1      = 0;
         using (Dictionary <BaseEntity, Entity> .Enumerator enumerator = dictionary.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 KeyValuePair <BaseEntity, Entity> current = enumerator.Current;
                 BaseEntity key = current.Key;
                 if (!Object.op_Equality((Object)key, (Object)null))
                 {
                     RCon.Update();
                     info.msg = current.Value;
                     key.Spawn();
                     key.Load(info);
                     if (key.IsValid())
                     {
                         ++num1;
                         if (stopwatch.Elapsed.TotalMilliseconds > 2000.0)
                         {
                             stopwatch.Reset();
                             stopwatch.Start();
                             DebugEx.Log((object)("\t" + (object)num1 + " / " + (object)dictionary.Count), (StackTraceLogType)0);
                         }
                     }
                 }
             }
         }
         using (Dictionary <BaseEntity, Entity> .Enumerator enumerator = dictionary.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 BaseEntity key = enumerator.Current.Key;
                 if (!Object.op_Equality((Object)key, (Object)null))
                 {
                     RCon.Update();
                     if (key.IsValid())
                     {
                         key.PostServerLoad();
                     }
                 }
             }
         }
         DebugEx.Log((object)"\tdone.", (StackTraceLogType)0);
         if (Object.op_Implicit((Object)SingletonComponent <SpawnHandler> .Instance))
         {
             DebugEx.Log((object)"Enforcing SpawnPopulation Limits", (StackTraceLogType)0);
             ((SpawnHandler)SingletonComponent <SpawnHandler> .Instance).EnforceLimits(false);
             DebugEx.Log((object)"\tdone.", (StackTraceLogType)0);
         }
         Application.isLoadingSave = (__Null)0;
         return(true);
     }
     catch (Exception ex)
     {
         Debug.LogWarning((object)("Error loading save (" + strFilename + ")"));
         Debug.LogException(ex);
         return(false);
     }
 }