Beispiel #1
0
        public override MerchantManager GetMerchantData(NPCSpawnList npcsl)
        {
            List<EQApplicationPacket> PacketList = Packets.PacketList;

            UInt32 OP_ShopRequest = OpManager.OpCodeNameToNumber("OP_ShopRequest");

            UInt32 OP_ShopEnd = OpManager.OpCodeNameToNumber("OP_ShopEnd");

            UInt32 OP_ItemPacket = OpManager.OpCodeNameToNumber("OP_ItemPacket");

            MerchantManager mm = new MerchantManager();

            for (int i = 0; i < PacketList.Count; ++i)
            {
                EQApplicationPacket p = PacketList[i];

                if ((p.Direction == PacketDirection.ServerToClient) && (p.OpCode == OP_ShopRequest))
                {
                    ByteStream Buffer = new ByteStream(p.Buffer);

                    UInt32 MerchantSpawnID = Buffer.ReadUInt32();

                    NPCSpawn npc = npcsl.GetNPC(MerchantSpawnID);

                    UInt32 NPCTypeID;

                    if (npc != null)
                        NPCTypeID = npc.NPCTypeID;
                    else
                        NPCTypeID = 0;

                    mm.AddMerchant(MerchantSpawnID);

                    for (int j = i + 1; j < PacketList.Count; ++j)
                    {
                        p = PacketList[j];

                        if ((p.OpCode == OP_ShopEnd) || (p.OpCode == OP_ShopRequest))
                            break;

                        if (p.OpCode == OP_ItemPacket)
                        {
                            Item NewItem = DecodeItemPacket(p.Buffer);

                            mm.AddMerchantItem(MerchantSpawnID, NewItem.ID, NewItem.Name, NewItem.MerchantSlot, NewItem.Quantity);
                        }
                    }
                }
            }

            return mm;
        }
Beispiel #2
0
        public void GenerateMerchantSQL(NPCSpawnList NPCSL, UInt32 MerchantDBID, bool GenerateSpawns, Action <string> SQLOut)
        {
            MerchantManager mm = PatchDecoder.GetMerchantData(NPCSL);

            if (GenerateSpawns)
            {
                SQLOut("DELETE from merchantlist where merchantid >= @StartingMerchantID and merchantid <= @StartingMerchantID + 999;");
            }

            SQLOut("--");
            SQLOut("-- Merchant Lists");
            SQLOut("-- ");

            foreach (Merchant m in mm.MerchantList)
            {
                UInt32 MerchantSpawnID = m.SpawnID;

                NPCSpawn npc = NPCSL.GetNPC(MerchantSpawnID);

                if (npc == null)
                {
                    continue;
                }

                UInt32 MerchantNPCTypeID = npc.NPCTypeID;

                SQLOut("--");
                SQLOut("-- " + npc.Name);
                SQLOut("-- ");

                bool StartOfPlayerSoldItems = false;

                foreach (MerchantItem mi in m.Items)
                {
                    string Insert = "";

                    if (mi.Quantity >= 0)
                    {
                        if (!StartOfPlayerSoldItems)
                        {
                            StartOfPlayerSoldItems = true;
                            SQLOut("--");
                            SQLOut("-- The items below were more than likely sold to " + npc.Name + " by players. Uncomment them if you want.");
                            SQLOut("--");
                        }

                        Insert += "-- ";
                    }

                    Insert += "INSERT into merchantlist(`merchantid`, `slot`, `item`) VALUES(";

                    Insert += "@StartingMerchantID + " + MerchantDBID + ", " + mi.Slot + ", " + mi.ItemID + "); -- " + mi.Name;

                    SQLOut(Insert);
                }

                if (GenerateSpawns)
                {
                    SQLOut("UPDATE npc_types SET merchant_id = @StartingMerchantID + " + MerchantDBID + " WHERE id = @StartingNPCTypeID + " + MerchantNPCTypeID + ";");
                }

                ++MerchantDBID;
            }
        }
Beispiel #3
0
        public override MerchantManager GetMerchantData(NPCSpawnList npcsl)
        {
            List<EQApplicationPacket> PacketList = Packets.PacketList;

            UInt32 OP_ShopRequest = OpManager.OpCodeNameToNumber("OP_ShopRequest");

            UInt32 OP_ShopEnd = OpManager.OpCodeNameToNumber("OP_ShopEnd");

            UInt32 OP_ItemPacket = OpManager.OpCodeNameToNumber("OP_ItemPacket");

            MerchantManager mm = new MerchantManager();

            for (int i = 0; i < PacketList.Count; ++i)
            {
                EQApplicationPacket p = PacketList[i];

                if ((p.Direction == PacketDirection.ServerToClient) && (p.OpCode == OP_ShopRequest))
                {
                    ByteStream Buffer = new ByteStream(p.Buffer);

                    UInt32 MerchantSpawnID = Buffer.ReadUInt32();

                    NPCSpawn npc = npcsl.GetNPC(MerchantSpawnID);

                    UInt32 NPCTypeID;

                    if (npc != null)
                        NPCTypeID = npc.NPCTypeID;
                    else
                        NPCTypeID = 0;

                    mm.AddMerchant(MerchantSpawnID);

                    for (int j = i + 1; j < PacketList.Count; ++j)
                    {
                        p = PacketList[j];

                        if (p.OpCode == OP_ShopEnd)
                            break;

                        if (p.OpCode == OP_ItemPacket)
                        {
                            Buffer = new ByteStream(p.Buffer);

                            UInt32 StackSize = Buffer.ReadUInt32();

                            Buffer.SkipBytes(4);

                            UInt32 Slot = Buffer.ReadUInt32();

                            UInt32 MerchantSlot = Buffer.ReadUInt32();

                            UInt32 Price = Buffer.ReadUInt32();

                            Int32 Quantity = Buffer.ReadInt32();

                            Buffer.SetPosition(68); // Point to item name

                            string ItemName = Buffer.ReadString(true);

                            string Lore = Buffer.ReadString(true);

                            string IDFile = Buffer.ReadString(true);

                            UInt32 ItemID = Buffer.ReadUInt32();

                            //if (Quantity == -1)
                            mm.AddMerchantItem(MerchantSpawnID, ItemID, ItemName, MerchantSlot, Quantity);
                        }
                    }
                }
            }

            return mm;
        }