Ejemplo n.º 1
0
        public static void HandlePacket(BinaryReader reader, int playerWho)
        {
            var mymod = TheLunaticMod.Instance;
            NetProtocolTypes protocol = (NetProtocolTypes)reader.ReadByte();

            switch (protocol)
            {
            case NetProtocolTypes.RequestModData:
                if (mymod.Config.DebugModeNetInfo)
                {
                    LogHelpers.Log("Server RequestModData");
                }
                ServerPacketHandlers.ReceiveRequestModDataOnServer(reader, playerWho);
                break;

            case NetProtocolTypes.GiveMaskToServer:
                if (mymod.Config.DebugModeNetInfo)
                {
                    LogHelpers.Log("Server GiveMaskToServer");
                }
                ServerPacketHandlers.ReceiveGivenMaskOnServer(reader, playerWho);
                break;

            default:
                LogHelpers.Log("Invalid packet protocol: " + protocol);
                break;
            }
        }
Ejemplo n.º 2
0
        private static void ReceiveGivenMaskOnServer(BinaryReader reader, int playerWho)
        {
            // Server only
            if (Main.netMode != 2)
            {
                return;
            }

            var mymod   = TheLunaticMod.Instance;
            var myworld = ModContent.GetInstance <TheLunaticWorld>();

            if (myworld.MaskLogic == null)
            {
                throw new ModHelpersException("Mask logic not initialized.");
            }

            int  maskType = reader.ReadInt32();
            int  bossType = reader.ReadInt32();
            Item fakeMask = new Item();

            fakeMask.SetDefaults(maskType);
            if (maskType == ModContent.ItemType <CustomBossMaskItem>())
            {
                var moditem = (CustomBossMaskItem)fakeMask.modItem;
                moditem.SetBoss(bossType);
            }

            if (playerWho < 0 || playerWho >= Main.player.Length || Main.player[playerWho] == null)
            {
                LogHelpers.Log("TheLunaticNetProtocol.ReceiveGivenMaskOnServer - Invalid player id " + playerWho);
                return;
            }
            //if( !Main.player[player_who].active ) {
            //	DebugHelpers.Log( "TheLunaticNetProtocol.ReceiveGivenMaskOnServer - Inactive player " + Main.player[player_who].name );
            //	return;
            //}
            if (myworld.MaskLogic.DoesLoonyHaveThisMask(fakeMask))
            {
                LogHelpers.Log("TheLunaticNetProtocol.ReceiveGivenMaskOnServer - Invalid mask from player " + Main.player[playerWho].name + " of type " + maskType);
                return;
            }

            myworld.MaskLogic.RegisterReceiptOfMask(Main.player[playerWho], maskType, bossType);

            ServerPacketHandlers.BroadcastGivenMaskFromServer(playerWho, maskType, bossType);
        }
Ejemplo n.º 3
0
        ////////////////
        // Server Receivers
        ////////////////

        private static void ReceiveRequestModDataOnServer(BinaryReader reader, int playerWho)
        {
            // Server only
            if (Main.netMode != 2)
            {
                return;
            }

            if (playerWho < 0 || playerWho >= Main.player.Length || Main.player[playerWho] == null)
            {
                LogHelpers.Log("TheLunaticNetProtocol.ReceiveRequestModDataOnServer - Invalid player id " + playerWho);
                return;
            }
            //if( !Main.player[player_who].active ) {
            //	Debug.Log( "TheLunaticNetProtocol.ReceiveRequestModDataOnServer - Inactive player " + Main.player[playerWho].name );
            //	return;
            //}

            ServerPacketHandlers.SendModDataFromServer(Main.player[playerWho]);
        }