Inheritance: Terraria.RemoteClient
Exemplo n.º 1
0
        public static void Init()
        {
            Terraria.Netplay.Clients = new ServerSlot[256];
            tdsm.api.Callbacks.NetplayCallback.CheckSectionMethod = CheckSection;
            for (int i = 0; i < 256; i++)
            {
                var slot = new ServerSlot()
                {
                    whoAmI = i
                };
                slot.Reset();
                Terraria.Netplay.Clients[i] = slot;
            }

            Ops            = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "ops.txt"));
            Bans           = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "bans.txt"));
            Whitelist      = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "whitelist.txt"));
            ItemRejections = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "itemrejection.txt"));
            IsInitialised  = true;
        }
        public static void OnPlayerLeft(Player player, ServerSlot slot, bool announced)
        {
            player.active = false;

            if (announced)
            {
                ProgramLog.Log("{0} @ {1}: LEAVE {2}", slot.remoteAddress, slot.Id, player.name);

                var msg = NewNetMessage.PrepareThreadInstance();

                msg.SynchBegin(player.whoAmI, 0 /*inactive*/);

                if (player.DisconnectReason != null)
                    msg.PlayerChat(255, string.Concat(player.Name, " disconnected (", player.DisconnectReason, ")."), 255, 165, 0);
                else
                    msg.PlayerChat(255, string.Concat(player.name, " has left."), 255, 240, 20);

                msg.BroadcastExcept(player.whoAmI);
            }

            var ctx = new HookContext
            {
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.PlayerLeftGame
            {
                Slot = slot.Id
            };

            HookPoints.PlayerLeftGame.Invoke(ref ctx, ref args);
        }
        public static void Init()
        {
            Terraria.Netplay.Clients = new ServerSlot[256];
            tdsm.api.Callbacks.NetplayCallback.CheckSectionMethod = CheckSection;
            for (int i = 0; i < 256; i++)
            {
                var slot = new ServerSlot()
                {
                    whoAmI = i
                };
                slot.Reset();
                Terraria.Netplay.Clients[i] = slot;
            }

            Ops = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "ops.txt"));
            Bans = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "bans.txt"));
            Whitelist = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "whitelist.txt"));
            ItemRejections = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "itemrejection.txt"));
            IsInitialised = true;
        }