Example #1
0
        private void OpenWindow(GameClient client, House house, eMerchantWindowType type)
        {
            switch (type)
            {
            case eMerchantWindowType.HousingOutsideShop:
            case eMerchantWindowType.HousingOutsideMenu:
                if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                {
                    return;
                }
                HouseMgr.SendHousingMerchantWindow(client.Player, type);
                break;

            case eMerchantWindowType.HousingDeedMenu:
            case eMerchantWindowType.HousingVaultHookpoint:
            case eMerchantWindowType.HousingCraftingHookpoint:
            case eMerchantWindowType.HousingBindstoneHookpoint:
            case eMerchantWindowType.HousingNPCHookpoint:
            case eMerchantWindowType.HousingInsideShop:
            case eMerchantWindowType.HousingInsideMenu:
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }
                HouseMgr.SendHousingMerchantWindow(client.Player, type);
                break;

            case (eMerchantWindowType)0xFF:
                house.SendHouseInfo(client.Player);
                break;
            }
        }
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int housenumber = packet.ReadShort();
            int menuid      = packet.ReadByte();
            int flag        = packet.ReadByte();

            var house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber);

            if (house == null)
            {
                return;
            }

            if (client.Player == null)
            {
                return;
            }

            client.Player.CurrentHouse = house;

            switch (menuid)
            {
            case 0:                     // Exterior decoration (Garden)
            {
                if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingOutsideShop);
                break;
            }

            case 1:                     // Interior decoration
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingInsideShop);
                break;
            }

            case 2:                     // Exterior menu
            {
                if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                client.Player.Out.SendMerchantWindow(HouseTemplateMgr.OutdoorMenuItems, eMerchantWindowType.HousingOutsideMenu);
                break;
            }

            case 3:                     // interior npc
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingNPCHookpoint);
                break;
            }

            case 4:                     // vault shop
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingVaultHookpoint);
                break;
            }

            case 5:                     // craft shop
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingCraftingHookpoint);
                break;
            }

            case 6:                     // bindstone shop
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingBindstoneHookpoint);
                break;
            }

            case 7:
                house.SendHouseInfo(client.Player);
                break;

            case 8:                     // Interior menu (flag = 0x00 - roof, 0xFF - floor or wall)
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                client.Player.Out.SendMerchantWindow(HouseTemplateMgr.IndoorMenuItems, eMerchantWindowType.HousingInsideMenu);
                break;

            default:
                client.Out.SendMessage("Invalid menu id " + menuid + " (hookpoint?).", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                break;
            }
        }