private void MoveItem(BaseEntity.RPCMessage msg)
    {
        uint id1        = msg.read.UInt32();
        uint id2        = msg.read.UInt32();
        int  iTargetPos = (int)msg.read.Int8();
        int  num        = (int)msg.read.UInt16();
        Item itemUid    = this.FindItemUID(id1);

        if (itemUid == null)
        {
            msg.player.ChatMessage("Invalid item (" + (object)id1 + ")");
        }
        else
        {
            if (Interface.CallHook("CanMoveItem", (object)itemUid, (object)this, (object)id2, (object)iTargetPos, (object)num) != null)
            {
                return;
            }
            if (!this.CanMoveItemsFrom(itemUid.parent.entityOwner, itemUid))
            {
                msg.player.ChatMessage("Cannot move item!");
            }
            else
            {
                if (num <= 0)
                {
                    num = itemUid.amount;
                }
                int split_Amount = Mathf.Clamp(num, 1, itemUid.info.stackable);
                if (id2 == 0U)
                {
                    if (this.GiveItem(itemUid, (ItemContainer)null))
                    {
                        return;
                    }
                    msg.player.ChatMessage("GiveItem failed!");
                }
                else
                {
                    ItemContainer container = this.FindContainer(id2);
                    if (container == null)
                    {
                        msg.player.ChatMessage("Invalid container (" + (object)id2 + ")");
                    }
                    else
                    {
                        ItemContainer parent = itemUid.parent;
                        if (parent != null && parent.IsLocked() || container.IsLocked())
                        {
                            msg.player.ChatMessage("Container is locked!");
                        }
                        else if (container.PlayerItemInputBlocked())
                        {
                            msg.player.ChatMessage("Container does not accept player items!");
                        }
                        else
                        {
                            using (TimeWarning.New("Split", 0.1f))
                            {
                                if (itemUid.amount > split_Amount)
                                {
                                    Item obj = itemUid.SplitItem(split_Amount);
                                    if (!obj.MoveToContainer(container, iTargetPos, true))
                                    {
                                        itemUid.amount += obj.amount;
                                        obj.Remove(0.0f);
                                    }
                                    ItemManager.DoRemoves();
                                    this.ServerUpdate(0.0f);
                                    return;
                                }
                            }
                            if (!itemUid.MoveToContainer(container, iTargetPos, true))
                            {
                                return;
                            }
                            ItemManager.DoRemoves();
                            this.ServerUpdate(0.0f);
                        }
                    }
                }
            }
        }
    }
Exemple #2
0
 private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus)
 {
     using (TimeWarning.New("AntiCheatKickPlayer", 10))
     {
         EasyAntiCheat.Server.Hydra.Client client = clientStatus.Client;
         Connection connection = GetConnection(client);
         if (connection == null)
         {
             Debug.LogError("EAC status update for invalid client: " + client.ClientID);
         }
         else
         {
             if (ShouldIgnore(connection))
             {
                 return;
             }
             if (clientStatus.RequiresKick)
             {
                 string text = clientStatus.Message;
                 if (string.IsNullOrEmpty(text))
                 {
                     text = clientStatus.Status.ToString();
                 }
                 Debug.Log($"[EAC] Kicking {connection.userid} / {connection.username} ({text})");
                 connection.authStatus = "eac";
                 Network.Net.sv.Kick(connection, "EAC: " + text);
                 Interface.CallHook("OnPlayerKicked", connection, text);
                 DateTime?timeBanExpires;
                 if (clientStatus.IsBanned(out timeBanExpires))
                 {
                     connection.authStatus = "eacbanned";
                     object[] args = new object[3]
                     {
                         2,
                         0,
                         "<color=#fff>SERVER</color> Kicking " + connection.username + " (banned by anticheat)"
                     };
                     Interface.CallHook("OnPlayerBanned", connection, text);
                     ConsoleNetwork.BroadcastToAllClients("chat.add", args);
                     if (!timeBanExpires.HasValue)
                     {
                         Entity.DeleteBy(connection.userid);
                     }
                 }
                 easyAntiCheat.UnregisterClient(client);
                 client2connection.Remove(client);
                 connection2client.Remove(connection);
                 connection2status.Remove(connection);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedLocal)
             {
                 OnAuthenticatedLocal(connection);
                 easyAntiCheat.SetClientNetworkState(client, false);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedRemote)
             {
                 OnAuthenticatedRemote(connection);
             }
             return;
         }
     }
 }
Exemple #3
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("ExcavatorArm.OnRpcMessage"))
     {
         RPCMessage rPCMessage;
         if (rpc == 2059417170 && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RPC_SetResourceTarget "));
             }
             using (TimeWarning.New("RPC_SetResourceTarget"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.MaxDistance.Test(2059417170u, "RPC_SetResourceTarget", this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         rPCMessage            = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage msg2 = rPCMessage;
                         RPC_SetResourceTarget(msg2);
                     }
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception);
                     player.Kick("RPC Error in RPC_SetResourceTarget");
                 }
             }
             return(true);
         }
         if (rpc == 2882020740u && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RPC_StopMining "));
             }
             using (TimeWarning.New("RPC_StopMining"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.MaxDistance.Test(2882020740u, "RPC_StopMining", this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         rPCMessage            = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage msg3 = rPCMessage;
                         RPC_StopMining(msg3);
                     }
                 }
                 catch (Exception exception2)
                 {
                     Debug.LogException(exception2);
                     player.Kick("RPC Error in RPC_StopMining");
                 }
             }
             return(true);
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemple #4
0
    public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
    {
        bool flag;

        BaseEntity.RPCMessage rPCMessage;
        using (TimeWarning timeWarning = TimeWarning.New("FogMachine.OnRpcMessage", 0.1f))
        {
            if (rpc == -1506851731 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SetFogOff "));
                }
                using (TimeWarning timeWarning1 = TimeWarning.New("SetFogOff", 0.1f))
                {
                    using (TimeWarning timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("SetFogOff", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.SetFogOff(rPCMessage);
                        }
                    }
                    catch (Exception exception)
                    {
                        player.Kick("RPC Error in SetFogOff");
                        Debug.LogException(exception);
                    }
                }
                flag = true;
            }
            else if (rpc == -389135368 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SetFogOn "));
                }
                using (timeWarning1 = TimeWarning.New("SetFogOn", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("SetFogOn", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.SetFogOn(rPCMessage);
                        }
                    }
                    catch (Exception exception1)
                    {
                        player.Kick("RPC Error in SetFogOn");
                        Debug.LogException(exception1);
                    }
                }
                flag = true;
            }
            else if (rpc != 1773639087 || !(player != null))
            {
                return(base.OnRpcMessage(player, rpc, msg));
            }
            else
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SetMotionDetection "));
                }
                using (timeWarning1 = TimeWarning.New("SetMotionDetection", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("SetMotionDetection", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.SetMotionDetection(rPCMessage);
                        }
                    }
                    catch (Exception exception2)
                    {
                        player.Kick("RPC Error in SetMotionDetection");
                        Debug.LogException(exception2);
                    }
                }
                flag = true;
            }
        }
        return(flag);
    }
 private void UpdateServerInformation()
 {
     if (Global.get_SteamServer() == null)
     {
         return;
     }
     using (TimeWarning.New(nameof(UpdateServerInformation), 0.1f))
     {
         Global.get_SteamServer().set_ServerName(ConVar.Server.hostname);
         Global.get_SteamServer().set_MaxPlayers(ConVar.Server.maxplayers);
         Global.get_SteamServer().set_Passworded(false);
         Global.get_SteamServer().set_MapName(World.Name);
         string str1 = "stok";
         if (this.Restarting)
         {
             str1 = "strst";
         }
         string str2 = string.Format("born{0}", (object)Epoch.FromDateTime(SaveRestore.SaveCreatedTime));
         string str3 = string.Format("mp{0},cp{1},qp{5},v{2}{3},h{4},{6},{7}", (object)ConVar.Server.maxplayers, (object)BasePlayer.activePlayerList.Count, (object)2161, ConVar.Server.pve ? (object)",pve" : (object)string.Empty, (object)this.AssemblyHash, (object)((ServerMgr)SingletonComponent <ServerMgr> .Instance).connectionQueue.Queued, (object)str1, (object)str2) + ",oxide";
         if (Interface.get_Oxide().get_Config().get_Options().Modded != null)
         {
             str3 += ",modded";
         }
         Global.get_SteamServer().set_GameTags(str3);
         if (ConVar.Server.description != null && ConVar.Server.description.Length > 100)
         {
             string[] array = StringEx.SplitToChunks(ConVar.Server.description, 100).ToArray <string>();
             for (int index = 0; index < 16; ++index)
             {
                 if (index < array.Length)
                 {
                     Global.get_SteamServer().SetKey(string.Format("description_{0:00}", (object)index), array[index]);
                 }
                 else
                 {
                     Global.get_SteamServer().SetKey(string.Format("description_{0:00}", (object)index), string.Empty);
                 }
             }
         }
         else
         {
             Global.get_SteamServer().SetKey("description_0", ConVar.Server.description);
             for (int index = 1; index < 16; ++index)
             {
                 Global.get_SteamServer().SetKey(string.Format("description_{0:00}", (object)index), string.Empty);
             }
         }
         Global.get_SteamServer().SetKey("hash", this.AssemblyHash);
         Facepunch.Steamworks.Server steamServer1 = Global.get_SteamServer();
         uint   num  = World.Seed;
         string str4 = num.ToString();
         steamServer1.SetKey("world.seed", str4);
         Facepunch.Steamworks.Server steamServer2 = Global.get_SteamServer();
         num = World.Size;
         string str5 = num.ToString();
         steamServer2.SetKey("world.size", str5);
         Global.get_SteamServer().SetKey("pve", ConVar.Server.pve.ToString());
         Global.get_SteamServer().SetKey("headerimage", ConVar.Server.headerimage);
         Global.get_SteamServer().SetKey("url", ConVar.Server.url);
         Global.get_SteamServer().SetKey("uptime", ((int)Time.get_realtimeSinceStartup()).ToString());
         Global.get_SteamServer().SetKey("gc_mb", Performance.report.memoryAllocations.ToString());
         Global.get_SteamServer().SetKey("gc_cl", Performance.report.memoryCollections.ToString());
         Global.get_SteamServer().SetKey("fps", Performance.report.frameRate.ToString());
         Global.get_SteamServer().SetKey("fps_avg", Performance.report.frameRateAverage.ToString("0.00"));
         Global.get_SteamServer().SetKey("ent_cnt", BaseNetworkable.serverEntities.Count.ToString());
         Global.get_SteamServer().SetKey("build", BuildInfo.get_Current().get_Scm().get_ChangeId());
     }
 }
Exemple #6
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("BigWheelBettingTerminal.OnRpcMessage", 0.1f))
         ;
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemple #7
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("RepairBench.OnRpcMessage", 0.1f))
     {
         if (rpc == 1942825351U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - ChangeSkin "));
             }
             using (TimeWarning.New("ChangeSkin", 0.1f))
             {
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.ChangeSkin(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in ChangeSkin");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 1178348163U)
         {
             if (Object.op_Inequality((Object)player, (Object)null))
             {
                 Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                 if (Global.developer > 2)
                 {
                     Debug.Log((object)("SV_RPCMessage: " + (object)player + " - RepairItem "));
                 }
                 using (TimeWarning.New("RepairItem", 0.1f))
                 {
                     try
                     {
                         using (TimeWarning.New("Call", 0.1f))
                             this.RepairItem(new BaseEntity.RPCMessage()
                             {
                                 connection = (Connection)msg.connection,
                                 player     = player,
                                 read       = msg.get_read()
                             });
                     }
                     catch (Exception ex)
                     {
                         player.Kick("RPC Error in RepairItem");
                         Debug.LogException(ex);
                     }
                 }
                 return(true);
             }
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
    public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
    {
        bool flag;

        BaseEntity.RPCMessage rPCMessage;
        using (TimeWarning timeWarning = TimeWarning.New("AutoTurret.OnRpcMessage", 0.1f))
        {
            if (rpc == 1092560690 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - AddSelfAuthorize "));
                }
                using (TimeWarning timeWarning1 = TimeWarning.New("AddSelfAuthorize", 0.1f))
                {
                    using (TimeWarning timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("AddSelfAuthorize", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.AddSelfAuthorize(rPCMessage);
                        }
                    }
                    catch (Exception exception)
                    {
                        player.Kick("RPC Error in AddSelfAuthorize");
                        Debug.LogException(exception);
                    }
                }
                flag = true;
            }
            else if (rpc == 253307592 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - ClearList "));
                }
                using (timeWarning1 = TimeWarning.New("ClearList", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("ClearList", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.ClearList(rPCMessage);
                        }
                    }
                    catch (Exception exception1)
                    {
                        player.Kick("RPC Error in ClearList");
                        Debug.LogException(exception1);
                    }
                }
                flag = true;
            }
            else if (rpc == 1500257773 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - FlipAim "));
                }
                using (timeWarning1 = TimeWarning.New("FlipAim", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("FlipAim", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.FlipAim(rPCMessage);
                        }
                    }
                    catch (Exception exception2)
                    {
                        player.Kick("RPC Error in FlipAim");
                        Debug.LogException(exception2);
                    }
                }
                flag = true;
            }
            else if (rpc == -676981327 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RemoveSelfAuthorize "));
                }
                using (timeWarning1 = TimeWarning.New("RemoveSelfAuthorize", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("RemoveSelfAuthorize", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.RemoveSelfAuthorize(rPCMessage);
                        }
                    }
                    catch (Exception exception3)
                    {
                        player.Kick("RPC Error in RemoveSelfAuthorize");
                        Debug.LogException(exception3);
                    }
                }
                flag = true;
            }
            else if (rpc == 1770263114 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SERVER_AttackAll "));
                }
                using (timeWarning1 = TimeWarning.New("SERVER_AttackAll", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_AttackAll", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.SERVER_AttackAll(rPCMessage);
                        }
                    }
                    catch (Exception exception4)
                    {
                        player.Kick("RPC Error in SERVER_AttackAll");
                        Debug.LogException(exception4);
                    }
                }
                flag = true;
            }
            else if (rpc == -1029428465 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SERVER_Peacekeeper "));
                }
                using (timeWarning1 = TimeWarning.New("SERVER_Peacekeeper", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_Peacekeeper", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.SERVER_Peacekeeper(rPCMessage);
                        }
                    }
                    catch (Exception exception5)
                    {
                        player.Kick("RPC Error in SERVER_Peacekeeper");
                        Debug.LogException(exception5);
                    }
                }
                flag = true;
            }
            else if (rpc == 190717079 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SERVER_TurnOff "));
                }
                using (timeWarning1 = TimeWarning.New("SERVER_TurnOff", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_TurnOff", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.SERVER_TurnOff(rPCMessage);
                        }
                    }
                    catch (Exception exception6)
                    {
                        player.Kick("RPC Error in SERVER_TurnOff");
                        Debug.LogException(exception6);
                    }
                }
                flag = true;
            }
            else if (rpc != -1751444115 || !(player != null))
            {
                return(base.OnRpcMessage(player, rpc, msg));
            }
            else
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SERVER_TurnOn "));
                }
                using (timeWarning1 = TimeWarning.New("SERVER_TurnOn", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_TurnOn", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.SERVER_TurnOn(rPCMessage);
                        }
                    }
                    catch (Exception exception7)
                    {
                        player.Kick("RPC Error in SERVER_TurnOn");
                        Debug.LogException(exception7);
                    }
                }
                flag = true;
            }
        }
        return(flag);
    }
    public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
    {
        bool flag;

        BaseEntity.RPCMessage rPCMessage;
        using (TimeWarning timeWarning = TimeWarning.New("Door.OnRpcMessage", 0.1f))
        {
            if (rpc == -295458617 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RPC_CloseDoor "));
                }
                using (TimeWarning timeWarning1 = TimeWarning.New("RPC_CloseDoor", 0.1f))
                {
                    using (TimeWarning timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.MaxDistance.Test("RPC_CloseDoor", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.RPC_CloseDoor(rPCMessage);
                        }
                    }
                    catch (Exception exception)
                    {
                        player.Kick("RPC Error in RPC_CloseDoor");
                        Debug.LogException(exception);
                    }
                }
                flag = true;
            }
            else if (rpc == 1487779344 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RPC_KnockDoor "));
                }
                using (timeWarning1 = TimeWarning.New("RPC_KnockDoor", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.MaxDistance.Test("RPC_KnockDoor", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.RPC_KnockDoor(rPCMessage);
                        }
                    }
                    catch (Exception exception1)
                    {
                        player.Kick("RPC Error in RPC_KnockDoor");
                        Debug.LogException(exception1);
                    }
                }
                flag = true;
            }
            else if (rpc == -980606731 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RPC_OpenDoor "));
                }
                using (timeWarning1 = TimeWarning.New("RPC_OpenDoor", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.MaxDistance.Test("RPC_OpenDoor", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.RPC_OpenDoor(rPCMessage);
                        }
                    }
                    catch (Exception exception2)
                    {
                        player.Kick("RPC Error in RPC_OpenDoor");
                        Debug.LogException(exception2);
                    }
                }
                flag = true;
            }
            else if (rpc != -1294476695 || !(player != null))
            {
                return(base.OnRpcMessage(player, rpc, msg));
            }
            else
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RPC_ToggleHatch "));
                }
                using (timeWarning1 = TimeWarning.New("RPC_ToggleHatch", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.MaxDistance.Test("RPC_ToggleHatch", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.RPC_ToggleHatch(rPCMessage);
                        }
                    }
                    catch (Exception exception3)
                    {
                        player.Kick("RPC Error in RPC_ToggleHatch");
                        Debug.LogException(exception3);
                    }
                }
                flag = true;
            }
        }
        return(flag);
    }
Exemple #10
0
        public override BaseCorpse OnCreateCorpse(HTNPlayer target)
        {
            int        i;
            BaseCorpse baseCorpse;

            if (this.DeathEffect.isValid)
            {
                Effect.server.Run(this.DeathEffect.resourcePath, target, 0, Vector3.zero, Vector3.zero, null, false);
            }
            using (TimeWarning timeWarning = TimeWarning.New("Create corpse", 0.1f))
            {
                NPCPlayerCorpse navAgent = target.DropCorpse("assets/prefabs/npc/murderer/murderer_corpse.prefab") as NPCPlayerCorpse;
                if (navAgent)
                {
                    if (target.AiDomain != null && target.AiDomain.NavAgent != null && target.AiDomain.NavAgent.isOnNavMesh)
                    {
                        navAgent.transform.position = navAgent.transform.position + (Vector3.down * target.AiDomain.NavAgent.baseOffset);
                    }
                    navAgent.SetLootableIn(2f);
                    navAgent.SetFlag(BaseEntity.Flags.Reserved5, target.HasPlayerFlag(BasePlayer.PlayerFlags.DisplaySash), false, true);
                    navAgent.SetFlag(BaseEntity.Flags.Reserved2, true, false, true);
                    int num = 0;
                    while (num < target.inventory.containerWear.itemList.Count)
                    {
                        Item item = target.inventory.containerWear.itemList[num];
                        if (item == null || !(item.info.shortname == "gloweyes"))
                        {
                            num++;
                        }
                        else
                        {
                            target.inventory.containerWear.Remove(item);
                            break;
                        }
                    }
                    navAgent.TakeFrom(new ItemContainer[] { target.inventory.containerMain, target.inventory.containerWear, target.inventory.containerBelt });
                    navAgent.playerName    = target.displayName;
                    navAgent.playerSteamID = target.userID;
                    navAgent.Spawn();
                    navAgent.TakeChildren(target);
                    ItemContainer[] itemContainerArray = navAgent.containers;
                    for (i = 0; i < (int)itemContainerArray.Length; i++)
                    {
                        itemContainerArray[i].Clear();
                    }
                    if (this.Loot.Length != 0)
                    {
                        LootContainer.LootSpawnSlot[] loot = this.Loot;
                        for (i = 0; i < (int)loot.Length; i++)
                        {
                            LootContainer.LootSpawnSlot lootSpawnSlot = loot[i];
                            for (int j = 0; j < lootSpawnSlot.numberToSpawn; j++)
                            {
                                if (UnityEngine.Random.Range(0f, 1f) <= lootSpawnSlot.probability)
                                {
                                    lootSpawnSlot.definition.SpawnIntoContainer(navAgent.containers[0]);
                                }
                            }
                        }
                    }
                }
                baseCorpse = navAgent;
            }
            return(baseCorpse);
        }
Exemple #11
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("HBHFSensor.OnRpcMessage", 0.1f))
     {
         if (rpc == 3206885720U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - SetIncludeAuth "));
             }
             using (TimeWarning.New("SetIncludeAuth", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("SetIncludeAuth", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.SetIncludeAuth(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in SetIncludeAuth");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 2223203375U)
         {
             if (Object.op_Inequality((Object)player, (Object)null))
             {
                 Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                 if (Global.developer > 2)
                 {
                     Debug.Log((object)("SV_RPCMessage: " + (object)player + " - SetIncludeOthers "));
                 }
                 using (TimeWarning.New("SetIncludeOthers", 0.1f))
                 {
                     using (TimeWarning.New("Conditions", 0.1f))
                     {
                         if (!BaseEntity.RPC_Server.IsVisible.Test("SetIncludeOthers", (BaseEntity)this, player, 3f))
                         {
                             return(true);
                         }
                     }
                     try
                     {
                         using (TimeWarning.New("Call", 0.1f))
                             this.SetIncludeOthers(new BaseEntity.RPCMessage()
                             {
                                 connection = (Connection)msg.connection,
                                 player     = player,
                                 read       = msg.get_read()
                             });
                     }
                     catch (Exception ex)
                     {
                         player.Kick("RPC Error in SetIncludeOthers");
                         Debug.LogException(ex);
                     }
                 }
                 return(true);
             }
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("SpinnerWheel.OnRpcMessage", 0.1f))
     {
         if (rpc == 3019675107U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - RPC_AnyoneSpin "));
             }
             using (TimeWarning.New("RPC_AnyoneSpin", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.MaxDistance.Test("RPC_AnyoneSpin", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.RPC_AnyoneSpin(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in RPC_AnyoneSpin");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 1455840454U)
         {
             if (Object.op_Inequality((Object)player, (Object)null))
             {
                 Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                 if (Global.developer > 2)
                 {
                     Debug.Log((object)("SV_RPCMessage: " + (object)player + " - RPC_Spin "));
                 }
                 using (TimeWarning.New("RPC_Spin", 0.1f))
                 {
                     using (TimeWarning.New("Conditions", 0.1f))
                     {
                         if (!BaseEntity.RPC_Server.MaxDistance.Test("RPC_Spin", (BaseEntity)this, player, 3f))
                         {
                             return(true);
                         }
                     }
                     try
                     {
                         using (TimeWarning.New("Call", 0.1f))
                             this.RPC_Spin(new BaseEntity.RPCMessage()
                             {
                                 connection = (Connection)msg.connection,
                                 player     = player,
                                 read       = msg.get_read()
                             });
                     }
                     catch (Exception ex)
                     {
                         player.Kick("RPC Error in RPC_Spin");
                         Debug.LogException(ex);
                     }
                 }
                 return(true);
             }
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("AutoTurret.OnRpcMessage", 0.1f))
     {
         if (rpc == 1092560690U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - AddSelfAuthorize "));
             }
             using (TimeWarning.New("AddSelfAuthorize", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("AddSelfAuthorize", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.AddSelfAuthorize(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in AddSelfAuthorize");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 253307592U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - ClearList "));
             }
             using (TimeWarning.New("ClearList", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("ClearList", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.ClearList(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in ClearList");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 1500257773U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - FlipAim "));
             }
             using (TimeWarning.New("FlipAim", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("FlipAim", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.FlipAim(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in FlipAim");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 3617985969U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - RemoveSelfAuthorize "));
             }
             using (TimeWarning.New("RemoveSelfAuthorize", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("RemoveSelfAuthorize", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.RemoveSelfAuthorize(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in RemoveSelfAuthorize");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 1770263114U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - SERVER_AttackAll "));
             }
             using (TimeWarning.New("SERVER_AttackAll", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_AttackAll", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.SERVER_AttackAll(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in SERVER_AttackAll");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 3265538831U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - SERVER_Peacekeeper "));
             }
             using (TimeWarning.New("SERVER_Peacekeeper", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_Peacekeeper", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.SERVER_Peacekeeper(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in SERVER_Peacekeeper");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 190717079U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - SERVER_TurnOff "));
             }
             using (TimeWarning.New("SERVER_TurnOff", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_TurnOff", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.SERVER_TurnOff(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in SERVER_TurnOff");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 2543523181U)
         {
             if (Object.op_Inequality((Object)player, (Object)null))
             {
                 Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                 if (Global.developer > 2)
                 {
                     Debug.Log((object)("SV_RPCMessage: " + (object)player + " - SERVER_TurnOn "));
                 }
                 using (TimeWarning.New("SERVER_TurnOn", 0.1f))
                 {
                     using (TimeWarning.New("Conditions", 0.1f))
                     {
                         if (!BaseEntity.RPC_Server.IsVisible.Test("SERVER_TurnOn", (BaseEntity)this, player, 3f))
                         {
                             return(true);
                         }
                     }
                     try
                     {
                         using (TimeWarning.New("Call", 0.1f))
                             this.SERVER_TurnOn(new BaseEntity.RPCMessage()
                             {
                                 connection = (Connection)msg.connection,
                                 player     = player,
                                 read       = msg.get_read()
                             });
                     }
                     catch (Exception ex)
                     {
                         player.Kick("RPC Error in SERVER_TurnOn");
                         Debug.LogException(ex);
                     }
                 }
                 return(true);
             }
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
 public ItemContainer FindContainer(uint id)
 {
     using (TimeWarning.New(nameof(FindContainer), 0.1f))
         return(this.containerMain.FindContainer(id) ?? this.containerBelt.FindContainer(id) ?? this.containerWear.FindContainer(id) ?? this.loot.FindContainer(id));
 }
Exemple #15
0
    public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
    {
        bool flag;

        BaseEntity.RPCMessage rPCMessage;
        using (TimeWarning timeWarning = TimeWarning.New("PlayerInventory.OnRpcMessage", 0.1f))
        {
            if (rpc == -812517836 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - ItemCmd "));
                }
                using (TimeWarning timeWarning1 = TimeWarning.New("ItemCmd", 0.1f))
                {
                    using (TimeWarning timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.FromOwner.Test("ItemCmd", this.GetBaseEntity(), player))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.ItemCmd(rPCMessage);
                        }
                    }
                    catch (Exception exception)
                    {
                        player.Kick("RPC Error in ItemCmd");
                        Debug.LogException(exception);
                    }
                }
                flag = true;
            }
            else if (rpc != -1253874771 || !(player != null))
            {
                return(base.OnRpcMessage(player, rpc, msg));
            }
            else
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (ConVar.Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - MoveItem "));
                }
                using (timeWarning1 = TimeWarning.New("MoveItem", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.FromOwner.Test("MoveItem", this.GetBaseEntity(), player))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.MoveItem(rPCMessage);
                        }
                    }
                    catch (Exception exception1)
                    {
                        player.Kick("RPC Error in MoveItem");
                        Debug.LogException(exception1);
                    }
                }
                flag = true;
            }
        }
        return(flag);
    }
Exemple #16
0
    public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
    {
        bool flag;

        BaseEntity.RPCMessage rPCMessage;
        using (TimeWarning timeWarning = TimeWarning.New("WheelSwitch.OnRpcMessage", 0.1f))
        {
            if (rpc == -2071363974 && player != null)
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - BeginRotate "));
                }
                using (TimeWarning timeWarning1 = TimeWarning.New("BeginRotate", 0.1f))
                {
                    using (TimeWarning timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("BeginRotate", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.BeginRotate(rPCMessage);
                        }
                    }
                    catch (Exception exception)
                    {
                        player.Kick("RPC Error in BeginRotate");
                        Debug.LogException(exception);
                    }
                }
                flag = true;
            }
            else if (rpc != 434251040 || !(player != null))
            {
                return(base.OnRpcMessage(player, rpc, msg));
            }
            else
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - CancelRotate "));
                }
                using (timeWarning1 = TimeWarning.New("CancelRotate", 0.1f))
                {
                    using (timeWarning2 = TimeWarning.New("Conditions", 0.1f))
                    {
                        if (!BaseEntity.RPC_Server.IsVisible.Test("CancelRotate", this, player, 3f))
                        {
                            flag = true;
                            return(flag);
                        }
                    }
                    try
                    {
                        using (timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.CancelRotate(rPCMessage);
                        }
                    }
                    catch (Exception exception1)
                    {
                        player.Kick("RPC Error in CancelRotate");
                        Debug.LogException(exception1);
                    }
                }
                flag = true;
            }
        }
        return(flag);
    }
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("CustomDoorManipulator.OnRpcMessage"))
     {
         RPCMessage rPCMessage;
         if (rpc == 1224330484 && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - DoPair "));
             }
             using (TimeWarning.New("DoPair"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.IsVisible.Test(1224330484u, "DoPair", this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         rPCMessage            = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage msg2 = rPCMessage;
                         DoPair(msg2);
                     }
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception);
                     player.Kick("RPC Error in DoPair");
                 }
             }
             return(true);
         }
         if (rpc == 3800726972u && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - ServerActionChange "));
             }
             using (TimeWarning.New("ServerActionChange"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.IsVisible.Test(3800726972u, "ServerActionChange", this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         rPCMessage            = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage msg3 = rPCMessage;
                         ServerActionChange(msg3);
                     }
                 }
                 catch (Exception exception2)
                 {
                     Debug.LogException(exception2);
                     player.Kick("RPC Error in ServerActionChange");
                 }
             }
             return(true);
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("CustomDoorManipulator.OnRpcMessage", 0.1f))
     {
         if (rpc == 1224330484U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - DoPair "));
             }
             using (TimeWarning.New("DoPair", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("DoPair", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.DoPair(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in DoPair");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 3800726972U)
         {
             if (Object.op_Inequality((Object)player, (Object)null))
             {
                 Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                 if (Global.developer > 2)
                 {
                     Debug.Log((object)("SV_RPCMessage: " + (object)player + " - ServerActionChange "));
                 }
                 using (TimeWarning.New("ServerActionChange", 0.1f))
                 {
                     using (TimeWarning.New("Conditions", 0.1f))
                     {
                         if (!BaseEntity.RPC_Server.IsVisible.Test("ServerActionChange", (BaseEntity)this, player, 3f))
                         {
                             return(true);
                         }
                     }
                     try
                     {
                         using (TimeWarning.New("Call", 0.1f))
                             this.ServerActionChange(new BaseEntity.RPCMessage()
                             {
                                 connection = (Connection)msg.connection,
                                 player     = player,
                                 read       = msg.get_read()
                             });
                     }
                     catch (Exception ex)
                     {
                         player.Kick("RPC Error in ServerActionChange");
                         Debug.LogException(ex);
                     }
                 }
                 return(true);
             }
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemple #19
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("MapMarkerGenericRadius.OnRpcMessage", 0.1f))
         ;
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemple #20
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("OreResourceEntity.OnRpcMessage", 0.1f))
         ;
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemple #21
0
 public bool MoveToContainer(ItemContainer newcontainer, int iTargetPos = -1, bool allowStack = true)
 {
     using (TimeWarning.New(nameof(MoveToContainer), 0.1f))
     {
         ItemContainer parent1 = this.parent;
         if (!this.CanMoveTo(newcontainer, iTargetPos, allowStack))
         {
             return(false);
         }
         if (iTargetPos >= 0 && newcontainer.SlotTaken(iTargetPos))
         {
             Item slot = newcontainer.GetSlot(iTargetPos);
             if (allowStack)
             {
                 int num = slot.MaxStackable();
                 if (slot.CanStack(this))
                 {
                     if (slot.amount >= num)
                     {
                         return(false);
                     }
                     slot.amount += this.amount;
                     slot.MarkDirty();
                     this.RemoveFromWorld();
                     this.RemoveFromContainer();
                     this.Remove(0.0f);
                     int split_Amount = slot.amount - num;
                     if (split_Amount > 0)
                     {
                         Item obj = slot.SplitItem(split_Amount);
                         if (obj != null && !obj.MoveToContainer(newcontainer, -1, false) && (parent1 == null || !obj.MoveToContainer(parent1, -1, true)))
                         {
                             obj.Drop(newcontainer.dropPosition, newcontainer.dropVelocity, (Quaternion)null);
                         }
                         slot.amount = num;
                     }
                     return(true);
                 }
             }
             if (this.parent == null)
             {
                 return(false);
             }
             ItemContainer parent2  = this.parent;
             int           position = this.position;
             if (!slot.CanMoveTo(parent2, position, true))
             {
                 return(false);
             }
             this.RemoveFromContainer();
             slot.RemoveFromContainer();
             slot.MoveToContainer(parent2, position, true);
             return(this.MoveToContainer(newcontainer, iTargetPos, true));
         }
         if (this.parent == newcontainer)
         {
             if (iTargetPos < 0 || iTargetPos == this.position || this.parent.SlotTaken(iTargetPos))
             {
                 return(false);
             }
             this.position = iTargetPos;
             this.MarkDirty();
             return(true);
         }
         if (iTargetPos == -1 & allowStack && this.info.stackable > 1)
         {
             Item obj = newcontainer.FindItemsByItemID(this.info.itemid).OrderBy <Item, int>((Func <Item, int>)(x => x.amount)).FirstOrDefault <Item>();
             if (obj != null && obj.CanStack(this))
             {
                 int num1 = obj.MaxStackable();
                 if (obj.amount < num1)
                 {
                     obj.amount += this.amount;
                     obj.MarkDirty();
                     int num2 = obj.amount - num1;
                     if (num2 <= 0)
                     {
                         this.RemoveFromWorld();
                         this.RemoveFromContainer();
                         this.Remove(0.0f);
                         return(true);
                     }
                     this.amount = num2;
                     this.MarkDirty();
                     obj.amount = num1;
                     return(this.MoveToContainer(newcontainer, iTargetPos, allowStack));
                 }
             }
         }
         if (newcontainer.maxStackSize > 0 && newcontainer.maxStackSize < this.amount)
         {
             Item obj = this.SplitItem(newcontainer.maxStackSize);
             if (obj != null && !obj.MoveToContainer(newcontainer, iTargetPos, false) && (parent1 == null || !obj.MoveToContainer(parent1, -1, true)))
             {
                 obj.Drop(newcontainer.dropPosition, newcontainer.dropVelocity, (Quaternion)null);
             }
             return(true);
         }
         if (!newcontainer.CanTake(this))
         {
             return(false);
         }
         this.RemoveFromContainer();
         this.RemoveFromWorld();
         this.position = iTargetPos;
         this.SetParent(newcontainer);
         return(true);
     }
 }
Exemple #22
0
        void cmdPersonnalMap(BasePlayer player, string command, string[] args)
        {
            using (TimeWarning.New("Personnal Map Command", 0.01f))
            {
                string    reason  = string.Empty;
                MapEntity map     = null;
                var       steamid = player.userID.ToString();

                if (!hasPermission(player, cfg_map_user_permission))
                {
                    SendReply(player, GetMsg("You are not allowed to use this command.", steamid));
                    return;
                }

                if (args.Length == 0)
                {
                    SendReply(player, GetHelp(player));
                    return;
                }

                var name = args.Length > 1 ? args[1].ToLower() : string.Empty;

                var PlayerData = new Dictionary <string, PaperMap>();

                var success = PlayerDatabase.Call("GetPlayerDataRaw", steamid, "PersonnalMap");
                if (success is string)
                {
                    PlayerData = JsonConvert.DeserializeObject <Dictionary <string, PaperMap> >((string)success);
                }

                switch (args[0].ToLower())
                {
                case "admin":
                    if (!hasPermission(player, cfg_map_admin_permission))
                    {
                        SendReply(player, GetMsg("You are not allowed to use this command.", steamid));
                        return;
                    }
                    if (args.Length == 1)
                    {
                        SendReply(player, GetHelp(player));
                        return;
                    }
                    switch (args[1].ToLower())
                    {
                    case "reset":
                        var knownPlayers = (HashSet <string>)PlayerDatabase.Call("GetAllKnownPlayers");
                        if (knownPlayers == null)
                        {
                            SendReply(player, "Couldn't get all known players out of PlayerDatabase."); return;
                        }
                        foreach (var userid in knownPlayers)
                        {
                            PlayerDatabase?.Call("SetPlayerData", userid, "PersonnalMap", new Dictionary <string, PaperMap>());
                        }
                        cfg_default_map = string.Empty;
                        Config["Default - Map (DO NOT EDIT HERE)"] = cfg_default_map;
                        default_map = null;
                        SaveConfig();
                        SendReply(player, "All personnal map data has been reset.");
                        return;

                        break;

                    case "default":
                        if (args.Length > 2 && (args[2].ToLower() == "false" || args[2].ToLower() == "null"))
                        {
                            cfg_default_map = string.Empty;
                            Config["Default - Map (DO NOT EDIT HERE)"] = cfg_default_map;
                            default_map = cfg_default_map == string.Empty ? null : JsonConvert.DeserializeObject <PaperMap>(cfg_default_map);
                            SaveConfig();
                            SendReply(player, "You've removed the default map.");
                            return;
                        }

                        break;

                    default:
                        SendReply(player, GetHelp(player));
                        return;

                        break;
                    }
                    break;

                case "save":
                case "load":

                    break;

                case "list":
                    string l = GetMsg("List of saved maps:\n", steamid);
                    foreach (var n in PlayerData.Keys)
                    {
                        l += n + "\n";
                    }
                    SendReply(player, l);
                    return;

                    break;

                case "remove":
                    if (name == string.Empty)
                    {
                        SendReply(player, GetMsg("usage: /pmap remove mapname.", steamid));
                        return;
                    }
                    if (!PlayerData.ContainsKey(name))
                    {
                        SendReply(player, GetMsg("You don't have any map named like that.", steamid));
                        return;
                    }

                    PlayerData.Remove(name);
                    PlayerDatabase?.Call("SetPlayerData", steamid, "PersonnalMap", PlayerData);
                    SendReply(player, string.Format(GetMsg("You have successfully removed your map: {0}.", steamid), name));
                    return;

                    break;

                default:
                    SendReply(player, GetHelp(player));
                    return;

                    break;
                }

                var inv = player.inventory;
                if (inv == null)
                {
                    SendReply(player, GetMsg("Couldn't find your inventory.", steamid));
                    return;
                }

                var target = inv.containerBelt.FindItemByItemID(papermapdef.itemid);

                if (target == null)
                {
                    SendReply(player, GetMsg("You need to place the Paper Map in your Belt.", steamid));
                    return;
                }

                reason = GetMapEntity(target, out map);
                if (reason != string.Empty)
                {
                    SendReply(player, reason);
                    return;
                }


                switch (args[0].ToLower())
                {
                case "admin":

                    switch (args[1].ToLower())
                    {
                    case "default":
                        var d = new PaperMap(map.fogImages, map.paintImages);
                        cfg_default_map = JsonConvert.SerializeObject(d);
                        Config["Default - Map (DO NOT EDIT HERE)"] = cfg_default_map;
                        default_map = cfg_default_map == string.Empty ? null : JsonConvert.DeserializeObject <PaperMap>(cfg_default_map);
                        SaveConfig();
                        SendReply(player, "You have set your current map as the default crafting map.");
                        return;

                        break;

                    default:
                        break;
                    }
                    break;

                case "save":
                    if (name == string.Empty)
                    {
                        SendReply(player, GetMsg("usage: /pmap save mapname.", steamid));
                        return;
                    }
                    if (!PlayerData.ContainsKey(name) && PlayerData.Count >= cfg_map_user_max)
                    {
                        SendReply(player, "You have reached the limit of maps your can save.");
                        return;
                    }
                    if (PlayerData.ContainsKey(name))
                    {
                        PlayerData.Remove(name);
                    }
                    PlayerData.Add(name, new PaperMap(map.fogImages, map.paintImages));

                    PlayerDatabase?.Call("SetPlayerData", steamid, "PersonnalMap", PlayerData);
                    SendReply(player, string.Format(GetMsg("Your map has been saved to: {0}", steamid), name));
                    return;

                    break;

                case "load":
                    if (name == string.Empty)
                    {
                        SendReply(player, GetMsg("usage: /pmap load mapname.", steamid));
                        return;
                    }
                    if (!PlayerData.ContainsKey(name))
                    {
                        SendReply(player, GetMsg("You don't have any map named like that.", steamid));
                        return;
                    }

                    map.fogImages   = PlayerData[name].ImageFog;
                    map.paintImages = PlayerData[name].ImagePaint;

                    target.RemoveFromContainer();
                    target.MoveToContainer(inv.containerBelt, -1, false);
                    SendReply(player, string.Format(GetMsg("You have successfully loaded your map: {0}", steamid), name));
                    return;

                    break;

                default:
                    break;
                }
            }
        }
 private void Update()
 {
     if (!this.runFrameUpdate)
     {
         return;
     }
     using (TimeWarning.New("ServerMgr.Update", 500L))
     {
         if (EACServer.playerTracker != null)
         {
             EACServer.playerTracker.BeginFrame();
         }
         try
         {
             using (TimeWarning.New("Net.sv.Cycle", 100L))
                 ((Network.Server)Network.Net.sv).Cycle();
         }
         catch (Exception ex)
         {
             Debug.LogWarning((object)"Server Exception: Network Cycle");
             Debug.LogException(ex, (Object)this);
         }
         try
         {
             using (TimeWarning.New("ServerBuildingManager.Cycle", 0.1f))
                 BuildingManager.server.Cycle();
         }
         catch (Exception ex)
         {
             Debug.LogWarning((object)"Server Exception: Building Manager");
             Debug.LogException(ex, (Object)this);
         }
         try
         {
             using (TimeWarning.New("BasePlayer.ServerCycle", 0.1f))
                 BasePlayer.ServerCycle(Time.get_deltaTime());
         }
         catch (Exception ex)
         {
             Debug.LogWarning((object)"Server Exception: Player Update");
             Debug.LogException(ex, (Object)this);
         }
         try
         {
             using (TimeWarning.New("SteamQueryResponse", 0.1f))
                 this.SteamQueryResponse();
         }
         catch (Exception ex)
         {
             Debug.LogWarning((object)"Server Exception: Steam Query");
             Debug.LogException(ex, (Object)this);
         }
         try
         {
             using (TimeWarning.New("connectionQueue.Cycle", 0.1f))
                 this.connectionQueue.Cycle(ServerMgr.AvailableSlots);
         }
         catch (Exception ex)
         {
             Debug.LogWarning((object)"Server Exception: Connection Queue");
             Debug.LogException(ex, (Object)this);
         }
         try
         {
             using (TimeWarning.New("IOEntity.ProcessQueue", 0.1f))
                 IOEntity.ProcessQueue();
         }
         catch (Exception ex)
         {
             Debug.LogWarning((object)"Server Exception: IOEntity.ProcessQueue");
             Debug.LogException(ex, (Object)this);
         }
         try
         {
             using (TimeWarning.New("AIThinkManager.ProcessQueue", 0.1f))
                 AIThinkManager.ProcessQueue();
         }
         catch (Exception ex)
         {
             Debug.LogWarning((object)"Server Exception: AIThinkManager.ProcessQueue");
             Debug.LogException(ex, (Object)this);
         }
         if (EACServer.playerTracker == null)
         {
             return;
         }
         EACServer.playerTracker.EndFrame();
     }
 }
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("BuildingPrivlidge.OnRpcMessage", 0.1f))
     {
         if (rpc == 1092560690U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - AddSelfAuthorize "));
             }
             using (TimeWarning.New("AddSelfAuthorize", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("AddSelfAuthorize", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.AddSelfAuthorize(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in AddSelfAuthorize");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 253307592U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - ClearList "));
             }
             using (TimeWarning.New("ClearList", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("ClearList", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.ClearList(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in ClearList");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 3617985969U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - RemoveSelfAuthorize "));
             }
             using (TimeWarning.New("RemoveSelfAuthorize", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.IsVisible.Test("RemoveSelfAuthorize", (BaseEntity)this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.RemoveSelfAuthorize(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in RemoveSelfAuthorize");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 2051750736U)
         {
             if (Object.op_Inequality((Object)player, (Object)null))
             {
                 Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                 if (Global.developer > 2)
                 {
                     Debug.Log((object)("SV_RPCMessage: " + (object)player + " - RPC_Rotate "));
                 }
                 using (TimeWarning.New("RPC_Rotate", 0.1f))
                 {
                     using (TimeWarning.New("Conditions", 0.1f))
                     {
                         if (!BaseEntity.RPC_Server.IsVisible.Test("RPC_Rotate", (BaseEntity)this, player, 3f))
                         {
                             return(true);
                         }
                     }
                     try
                     {
                         using (TimeWarning.New("Call", 0.1f))
                             this.RPC_Rotate(new BaseEntity.RPCMessage()
                             {
                                 connection = (Connection)msg.connection,
                                 player     = player,
                                 read       = msg.get_read()
                             });
                     }
                     catch (Exception ex)
                     {
                         player.Kick("RPC Error in RPC_Rotate");
                         Debug.LogException(ex);
                     }
                 }
                 return(true);
             }
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
    public void OnNetworkMessage(Message packet)
    {
        Message.Type type = (Message.Type)packet.type;
        if (type != 4)
        {
            switch (type - 9)
            {
            case 0:
                if (!((Network.Connection)packet.connection).get_isAuthenticated())
                {
                    break;
                }
                if (((Network.Connection)packet.connection).GetPacketsPerSecond((Message.Type)packet.type) > (ulong)ConVar.Server.maxrpcspersecond)
                {
                    ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Paket Flooding: RPC Message");
                    break;
                }
                using (TimeWarning.New("OnRPCMessage", 20L))
                {
                    try
                    {
                        this.OnRPCMessage(packet);
                    }
                    catch (Exception ex)
                    {
                        this.Log(ex);
                        ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: RPC Message");
                    }
                }
                ((Network.Connection)packet.connection).AddPacketsPerSecond((Message.Type)packet.type);
                break;

            case 1:
            case 2:
            case 4:
label_84:
                this.ProcessUnhandledPacket(packet);
                break;

            case 3:
                if (!((Network.Connection)packet.connection).get_isAuthenticated())
                {
                    break;
                }
                if (((Network.Connection)packet.connection).GetPacketsPerSecond((Message.Type)packet.type) > (ulong)ConVar.Server.maxcommandspersecond)
                {
                    ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Packet Flooding: Client Command");
                    break;
                }
                using (TimeWarning.New("OnClientCommand", 20L))
                {
                    try
                    {
                        ConsoleNetwork.OnClientCommand(packet);
                    }
                    catch (Exception ex)
                    {
                        this.Log(ex);
                        ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: Client Command");
                    }
                }
                ((Network.Connection)packet.connection).AddPacketsPerSecond((Message.Type)packet.type);
                break;

            case 5:
                if (!((Network.Connection)packet.connection).get_isAuthenticated())
                {
                    break;
                }
                if (((Network.Connection)packet.connection).GetPacketsPerSecond((Message.Type)packet.type) > 1UL)
                {
                    ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Packet Flooding: Disconnect Reason");
                    break;
                }
                using (TimeWarning.New("ReadDisconnectReason", 20L))
                {
                    try
                    {
                        this.ReadDisconnectReason(packet);
                    }
                    catch (Exception ex)
                    {
                        this.Log(ex);
                        ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: Disconnect Reason");
                    }
                }
                ((Network.Connection)packet.connection).AddPacketsPerSecond((Message.Type)packet.type);
                break;

            case 6:
                if (!((Network.Connection)packet.connection).get_isAuthenticated())
                {
                    break;
                }
                if (((Network.Connection)packet.connection).GetPacketsPerSecond((Message.Type)packet.type) > (ulong)ConVar.Server.maxtickspersecond)
                {
                    ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Packet Flooding: Player Tick");
                    break;
                }
                using (TimeWarning.New("OnPlayerTick", 20L))
                {
                    try
                    {
                        this.OnPlayerTick(packet);
                    }
                    catch (Exception ex)
                    {
                        this.Log(ex);
                        ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: Player Tick");
                    }
                }
                ((Network.Connection)packet.connection).AddPacketsPerSecond((Message.Type)packet.type);
                break;

            default:
                switch (type - 18)
                {
                case 0:
                    if (((Network.Connection)packet.connection).GetPacketsPerSecond((Message.Type)packet.type) > 1UL)
                    {
                        ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Packet Flooding: User Information");
                        return;
                    }
                    using (TimeWarning.New("GiveUserInformation", 20L))
                    {
                        try
                        {
                            this.OnGiveUserInformation(packet);
                        }
                        catch (Exception ex)
                        {
                            this.Log(ex);
                            ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: User Information");
                        }
                    }
                    ((Network.Connection)packet.connection).AddPacketsPerSecond((Message.Type)packet.type);
                    return;

                case 3:
                    if (!((Network.Connection)packet.connection).get_isAuthenticated())
                    {
                        return;
                    }
                    if (((Network.Connection)packet.connection).GetPacketsPerSecond((Message.Type)packet.type) > 100UL)
                    {
                        ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Packet Flooding: Disconnect Reason");
                        return;
                    }
                    using (TimeWarning.New("OnPlayerVoice", 20L))
                    {
                        try
                        {
                            this.OnPlayerVoice(packet);
                        }
                        catch (Exception ex)
                        {
                            this.Log(ex);
                            ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: Player Voice");
                        }
                    }
                    ((Network.Connection)packet.connection).AddPacketsPerSecond((Message.Type)packet.type);
                    return;

                case 4:
                    using (TimeWarning.New("OnEACMessage", 20L))
                    {
                        try
                        {
                            EACServer.OnMessageReceived(packet);
                            return;
                        }
                        catch (Exception ex)
                        {
                            this.Log(ex);
                            ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: EAC");
                            return;
                        }
                    }

                default:
                    goto label_84;
                }
            }
        }
        else
        {
            if (!((Network.Connection)packet.connection).get_isAuthenticated())
            {
                return;
            }
            if (((Network.Connection)packet.connection).GetPacketsPerSecond((Message.Type)packet.type) > 1UL)
            {
                ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Packet Flooding: Client Ready");
            }
            else
            {
                using (TimeWarning.New("ClientReady", 20L))
                {
                    try
                    {
                        this.ClientReady(packet);
                    }
                    catch (Exception ex)
                    {
                        this.Log(ex);
                        ((Network.Server)Network.Net.sv).Kick((Network.Connection)packet.connection, "Invalid Packet: Client Ready");
                    }
                }
                ((Network.Connection)packet.connection).AddPacketsPerSecond((Message.Type)packet.type);
            }
        }
    }
Exemple #26
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("GunTrap.OnRpcMessage", 0.1f))
         ;
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemple #27
0
    public virtual void DecayTick()
    {
        if (decay == null)
        {
            return;
        }
        float num = UnityEngine.Time.time - lastDecayTick;

        if (num < ConVar.Decay.tick)
        {
            return;
        }
        lastDecayTick = UnityEngine.Time.time;
        if (!decay.ShouldDecay(this))
        {
            return;
        }
        float num2 = num * ConVar.Decay.scale;

        if (ConVar.Decay.upkeep)
        {
            upkeepTimer += num2;
            if (upkeepTimer > 0f)
            {
                BuildingPrivlidge buildingPrivilege = GetBuildingPrivilege();
                if (buildingPrivilege != null)
                {
                    upkeepTimer -= buildingPrivilege.PurchaseUpkeepTime(this, Mathf.Max(upkeepTimer, 600f));
                }
            }
            if (upkeepTimer < 1f)
            {
                if (base.healthFraction < 1f && ConVar.Decay.upkeep_heal_scale > 0f && base.SecondsSinceAttacked > 600f)
                {
                    float num3 = num / decay.GetDecayDuration(this) * ConVar.Decay.upkeep_heal_scale;
                    Heal(MaxHealth() * num3);
                }
                return;
            }
            upkeepTimer = 1f;
        }
        decayTimer += num2;
        if (decayTimer < decay.GetDecayDelay(this))
        {
            return;
        }
        using (TimeWarning.New("DecayTick"))
        {
            float num4 = 1f;
            if (ConVar.Decay.upkeep)
            {
                if (!IsOutside())
                {
                    num4 *= ConVar.Decay.upkeep_inside_decay_scale;
                }
            }
            else
            {
                for (int i = 0; i < decayPoints.Length; i++)
                {
                    DecayPoint decayPoint = decayPoints[i];
                    if (decayPoint.IsOccupied(this))
                    {
                        num4 -= decayPoint.protection;
                    }
                }
            }
            if (num4 > 0f)
            {
                float num5 = num2 / decay.GetDecayDuration(this) * MaxHealth();
                Hurt(num5 * num4 * decayVariance, DamageType.Decay);
            }
        }
    }
Exemple #28
0
    private void MoveItem(BaseEntity.RPCMessage msg)
    {
        uint num  = msg.read.UInt32();
        uint num1 = msg.read.UInt32();
        int  num2 = msg.read.Int8();
        int  num3 = msg.read.UInt16();
        Item item = this.FindItemUID(num);

        if (item == null)
        {
            msg.player.ChatMessage(string.Concat("Invalid item (", num, ")"));
            return;
        }
        if (Interface.CallHook("CanMoveItem", item, this, num1, num2, num3) != null)
        {
            return;
        }
        if (!this.CanMoveItemsFrom(item.parent.entityOwner, item))
        {
            msg.player.ChatMessage("Cannot move item!");
            return;
        }
        if (num3 <= 0)
        {
            num3 = item.amount;
        }
        num3 = Mathf.Clamp(num3, 1, item.MaxStackable());
        if (num1 == 0)
        {
            if (!this.GiveItem(item, null))
            {
                msg.player.ChatMessage("GiveItem failed!");
            }
            return;
        }
        ItemContainer itemContainer = this.FindContainer(num1);

        if (itemContainer == null)
        {
            msg.player.ChatMessage(string.Concat("Invalid container (", num1, ")"));
            return;
        }
        ItemContainer itemContainer1 = item.parent;

        if (itemContainer1 != null && itemContainer1.IsLocked() || itemContainer.IsLocked())
        {
            msg.player.ChatMessage("Container is locked!");
            return;
        }
        if (itemContainer.PlayerItemInputBlocked())
        {
            msg.player.ChatMessage("Container does not accept player items!");
            return;
        }
        using (TimeWarning timeWarning = TimeWarning.New("Split", 0.1f))
        {
            if (item.amount > num3)
            {
                Item item1 = item.SplitItem(num3);
                if (!item1.MoveToContainer(itemContainer, num2, true))
                {
                    item.amount += item1.amount;
                    item1.Remove(0f);
                }
                ItemManager.DoRemoves();
                this.ServerUpdate(0f);
                return;
            }
        }
        if (!item.MoveToContainer(itemContainer, num2, true))
        {
            return;
        }
        ItemManager.DoRemoves();
        this.ServerUpdate(0f);
    }
Exemple #29
0
 static bool Prefix(ServerMgr serverMgr)
 {
     if (!SteamServer.IsValid)
     {
         return(false);
     }
     using (TimeWarning.New("UpdateServerInformation", 0))
     {
         SteamServer.ServerName = ConVar.Server.hostname;
         SteamServer.MaxPlayers = ConVar.Server.maxplayers;
         SteamServer.Passworded = false;
         SteamServer.MapName    = global::World.Name;
         string text = "stok";
         if (serverMgr.Restarting)
         {
             text = "strst";
         }
         string text2 = string.Format("born{0}", Epoch.FromDateTime(global::SaveRestore.SaveCreatedTime));
         string text3 = string.Format("gm{0}", global::ServerMgr.GamemodeName());
         SteamServer.GameTags = string.Format("mp{0},cp{1},qp{5},v{2}{3},h{4},{6},{7},{8}", new object[]
         {
             ConVar.Server.maxplayers,
             global::BasePlayer.activePlayerList.Count,
             typeof(Protocol).GetFields().Single(x => x.Name == "network").GetRawConstantValue(),
             ConVar.Server.pve ? ",pve" : string.Empty,
             AssemblyHash,
             SingletonComponent <global::ServerMgr> .Instance.connectionQueue.Queued,
             text,
             text2,
             text3
         });
         Interface.CallHook("IOnUpdateServerInformation");
         if (ConVar.Server.description != null && ConVar.Server.description.Length > 100)
         {
             string[] array = ConVar.Server.description.SplitToChunks(100).ToArray <string>();
             Interface.CallHook("IOnUpdateServerDescription");
             for (int i = 0; i < 16; i++)
             {
                 if (i < array.Length)
                 {
                     SteamServer.SetKey(string.Format("description_{0:00}", i), array[i]);
                 }
                 else
                 {
                     SteamServer.SetKey(string.Format("description_{0:00}", i), string.Empty);
                 }
             }
         }
         else
         {
             SteamServer.SetKey("description_0", ConVar.Server.description);
             for (int j = 1; j < 16; j++)
             {
                 SteamServer.SetKey(string.Format("description_{0:00}", j), string.Empty);
             }
         }
         SteamServer.SetKey("hash", AssemblyHash);
         SteamServer.SetKey("world.seed", global::World.Seed.ToString());
         SteamServer.SetKey("world.size", global::World.Size.ToString());
         SteamServer.SetKey("pve", ConVar.Server.pve.ToString());
         SteamServer.SetKey("headerimage", ConVar.Server.headerimage);
         SteamServer.SetKey("url", ConVar.Server.url);
         SteamServer.SetKey("gmn", global::ServerMgr.GamemodeName());
         SteamServer.SetKey("gmt", global::ServerMgr.GamemodeTitle());
         SteamServer.SetKey("gmd", global::ServerMgr.GamemodeDesc());
         SteamServer.SetKey("gmu", global::ServerMgr.GamemodeUrl());
         SteamServer.SetKey("uptime", ((int)UnityEngine.Time.realtimeSinceStartup).ToString());
         SteamServer.SetKey("gc_mb", global::Performance.report.memoryAllocations.ToString());
         SteamServer.SetKey("gc_cl", global::Performance.report.memoryCollections.ToString());
         SteamServer.SetKey("fps", global::Performance.report.frameRate.ToString());
         SteamServer.SetKey("fps_avg", global::Performance.report.frameRateAverage.ToString("0.00"));
         SteamServer.SetKey("ent_cnt", global::BaseNetworkable.serverEntities.Count.ToString());
         SteamServer.SetKey("build", BuildInfo.Current.Scm.ChangeId);
     }
     return(false);
 }
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("PlayerInventory.OnRpcMessage", 0.1f))
     {
         if (rpc == 3482449460U && Object.op_Inequality((Object)player, (Object)null))
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log((object)("SV_RPCMessage: " + (object)player + " - ItemCmd "));
             }
             using (TimeWarning.New("ItemCmd", 0.1f))
             {
                 using (TimeWarning.New("Conditions", 0.1f))
                 {
                     if (!BaseEntity.RPC_Server.FromOwner.Test("ItemCmd", this.GetBaseEntity(), player))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call", 0.1f))
                         this.ItemCmd(new BaseEntity.RPCMessage()
                         {
                             connection = (Connection)msg.connection,
                             player     = player,
                             read       = msg.get_read()
                         });
                 }
                 catch (Exception ex)
                 {
                     player.Kick("RPC Error in ItemCmd");
                     Debug.LogException(ex);
                 }
             }
             return(true);
         }
         if (rpc == 3041092525U)
         {
             if (Object.op_Inequality((Object)player, (Object)null))
             {
                 Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                 if (Global.developer > 2)
                 {
                     Debug.Log((object)("SV_RPCMessage: " + (object)player + " - MoveItem "));
                 }
                 using (TimeWarning.New("MoveItem", 0.1f))
                 {
                     using (TimeWarning.New("Conditions", 0.1f))
                     {
                         if (!BaseEntity.RPC_Server.FromOwner.Test("MoveItem", this.GetBaseEntity(), player))
                         {
                             return(true);
                         }
                     }
                     try
                     {
                         using (TimeWarning.New("Call", 0.1f))
                             this.MoveItem(new BaseEntity.RPCMessage()
                             {
                                 connection = (Connection)msg.connection,
                                 player     = player,
                                 read       = msg.get_read()
                             });
                     }
                     catch (Exception ex)
                     {
                         player.Kick("RPC Error in MoveItem");
                         Debug.LogException(ex);
                     }
                 }
                 return(true);
             }
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }