mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-21 10:38:20 +00:00
More numeric to constant conversions..should be most of them... Please report any inventory abnormalities.
This commit is contained in:
@@ -109,70 +109,71 @@ const EQClientVersion Strategy::ClientVersion() const
|
||||
#include "SSDefine.h"
|
||||
|
||||
|
||||
// Converts Titanium Slot IDs to Underfoot Slot IDs for use in Encodes
|
||||
static inline uint32 TitaniumToUnderfootSlot(uint32 TitaniumSlot) {
|
||||
// Converts Server Slot IDs to Underfoot Slot IDs for use in Encodes
|
||||
static inline uint32 ServerToUnderfootSlot(uint32 ServerSlot) {
|
||||
uint32 UnderfootSlot = 0;
|
||||
|
||||
if(TitaniumSlot >= 21 && TitaniumSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
{
|
||||
UnderfootSlot = TitaniumSlot + 1;
|
||||
}
|
||||
else if(TitaniumSlot >= 251 && TitaniumSlot <= 340) // Bag Slots for Normal Inventory and Cursor
|
||||
{
|
||||
UnderfootSlot = TitaniumSlot + 11;
|
||||
}
|
||||
else if(TitaniumSlot >= 2031 && TitaniumSlot <= 2270) // Bank Bag Slots
|
||||
{
|
||||
UnderfootSlot = TitaniumSlot + 1;
|
||||
}
|
||||
else if(TitaniumSlot >= 2531 && TitaniumSlot <= 2550) // Shared Bank Bag Slots
|
||||
{
|
||||
UnderfootSlot = TitaniumSlot + 1;
|
||||
}
|
||||
else if(TitaniumSlot == 9999) //Unused slot ID to give a place to save Power Slot
|
||||
{
|
||||
UnderfootSlot = 21;
|
||||
}
|
||||
if (ServerSlot >= MainAmmo && ServerSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
UnderfootSlot = ServerSlot + 1;
|
||||
|
||||
else if (ServerSlot >= EmuConstants::GENERAL_BAGS_BEGIN && ServerSlot <= EmuConstants::CURSOR_BAG_END)
|
||||
UnderfootSlot = ServerSlot + 11;
|
||||
|
||||
else if (ServerSlot >= EmuConstants::BANK_BAGS_BEGIN && ServerSlot <= EmuConstants::BANK_BAGS_END)
|
||||
UnderfootSlot = ServerSlot + 1;
|
||||
|
||||
else if (ServerSlot >= EmuConstants::SHARED_BANK_BAGS_BEGIN && ServerSlot <= EmuConstants::SHARED_BANK_BAGS_END)
|
||||
UnderfootSlot = ServerSlot + 1;
|
||||
|
||||
else if (ServerSlot == MainPowerSource)
|
||||
UnderfootSlot = slots::MainPowerSource;
|
||||
|
||||
else
|
||||
{
|
||||
UnderfootSlot = TitaniumSlot;
|
||||
}
|
||||
UnderfootSlot = ServerSlot;
|
||||
|
||||
return UnderfootSlot;
|
||||
}
|
||||
|
||||
// Converts Underfoot Slot IDs to Titanium Slot IDs for use in Decodes
|
||||
static inline uint32 UnderfootToTitaniumSlot(uint32 UnderfootSlot) {
|
||||
uint32 TitaniumSlot = 0;
|
||||
// Converts Underfoot Slot IDs to Server Slot IDs for use in Decodes
|
||||
static inline uint32 UnderfootToServerSlot(uint32 UnderfootSlot) {
|
||||
uint32 ServerSlot = 0;
|
||||
|
||||
if(UnderfootSlot >= 22 && UnderfootSlot <= 54) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
{
|
||||
TitaniumSlot = UnderfootSlot - 1;
|
||||
}
|
||||
else if(UnderfootSlot >= 262 && UnderfootSlot <= 351) // Bag Slots for Normal Inventory and Cursor
|
||||
{
|
||||
TitaniumSlot = UnderfootSlot - 11;
|
||||
}
|
||||
else if(UnderfootSlot >= 2032 && UnderfootSlot <= 2271) // Bank Bag Slots
|
||||
{
|
||||
TitaniumSlot = UnderfootSlot - 1;
|
||||
}
|
||||
else if(UnderfootSlot >= 2532 && UnderfootSlot <= 2551) // Shared Bank Bag Slots
|
||||
{
|
||||
TitaniumSlot = UnderfootSlot - 1;
|
||||
}
|
||||
else if(UnderfootSlot == 21)
|
||||
{
|
||||
TitaniumSlot = 9999; //Unused slot ID to give a place to save Power Slot
|
||||
}
|
||||
if(UnderfootSlot >= slots::MainAmmo && UnderfootSlot <= consts::CORPSE_END) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
ServerSlot = UnderfootSlot - 1;
|
||||
|
||||
else if(UnderfootSlot >= consts::GENERAL_BAGS_BEGIN && UnderfootSlot <= consts::CURSOR_BAG_END)
|
||||
ServerSlot = UnderfootSlot - 11;
|
||||
|
||||
else if(UnderfootSlot >= consts::BANK_BAGS_BEGIN && UnderfootSlot <= consts::BANK_BAGS_END)
|
||||
ServerSlot = UnderfootSlot - 1;
|
||||
|
||||
else if(UnderfootSlot >= consts::SHARED_BANK_BAGS_BEGIN && UnderfootSlot <= consts::SHARED_BANK_BAGS_END)
|
||||
ServerSlot = UnderfootSlot - 1;
|
||||
|
||||
else if(UnderfootSlot == slots::MainPowerSource)
|
||||
ServerSlot = MainPowerSource;
|
||||
|
||||
else
|
||||
{
|
||||
TitaniumSlot = UnderfootSlot;
|
||||
}
|
||||
ServerSlot = UnderfootSlot;
|
||||
|
||||
return TitaniumSlot;
|
||||
return ServerSlot;
|
||||
}
|
||||
|
||||
/*
|
||||
// Converts Server Corpse Slot IDs to Underfoot Corpse Slot IDs for use in Encodes
|
||||
static inline uint32 ServerToUnderFootCorpseSlot(uint32 ServerCorpse) {
|
||||
uint32 UnderfootCorpse;
|
||||
// reserved
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Converts Underfoot Corpse Slot IDs to Server Corpse Slot IDs for use in Decodes
|
||||
static inline uint32 UnderfootToServerCorpseSlot(uint32 UnderfootCorpse) {
|
||||
uint32 ServerCorpse;
|
||||
// reserved
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
ENCODE(OP_OpenNewTasksWindow) {
|
||||
|
||||
@@ -1898,7 +1899,7 @@ ENCODE(OP_ShopPlayerSell) {
|
||||
ENCODE_LENGTH_EXACT(Merchant_Purchase_Struct);
|
||||
SETUP_DIRECT_ENCODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
|
||||
OUT(npcid);
|
||||
eq->itemslot = TitaniumToUnderfootSlot(emu->itemslot);
|
||||
eq->itemslot = ServerToUnderfootSlot(emu->itemslot);
|
||||
OUT(quantity);
|
||||
OUT(price);
|
||||
FINISH_ENCODE();
|
||||
@@ -1907,7 +1908,7 @@ ENCODE(OP_ShopPlayerSell) {
|
||||
ENCODE(OP_ApplyPoison) {
|
||||
ENCODE_LENGTH_EXACT(ApplyPoison_Struct);
|
||||
SETUP_DIRECT_ENCODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
|
||||
eq->inventorySlot = TitaniumToUnderfootSlot(emu->inventorySlot);
|
||||
eq->inventorySlot = ServerToUnderfootSlot(emu->inventorySlot);
|
||||
OUT(success);
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
@@ -1916,8 +1917,8 @@ ENCODE(OP_DeleteItem) {
|
||||
ENCODE_LENGTH_EXACT(DeleteItem_Struct);
|
||||
SETUP_DIRECT_ENCODE(DeleteItem_Struct, structs::DeleteItem_Struct);
|
||||
|
||||
eq->from_slot = TitaniumToUnderfootSlot(emu->from_slot);
|
||||
eq->to_slot = TitaniumToUnderfootSlot(emu->to_slot);
|
||||
eq->from_slot = ServerToUnderfootSlot(emu->from_slot);
|
||||
eq->to_slot = ServerToUnderfootSlot(emu->to_slot);
|
||||
OUT(number_in_stack);
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -1928,8 +1929,8 @@ ENCODE(OP_MoveItem) {
|
||||
ENCODE_LENGTH_EXACT(MoveItem_Struct);
|
||||
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
eq->from_slot = TitaniumToUnderfootSlot(emu->from_slot);
|
||||
eq->to_slot = TitaniumToUnderfootSlot(emu->to_slot);
|
||||
eq->from_slot = ServerToUnderfootSlot(emu->from_slot);
|
||||
eq->to_slot = ServerToUnderfootSlot(emu->to_slot);
|
||||
OUT(number_in_stack);
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -1939,7 +1940,7 @@ ENCODE(OP_ItemVerifyReply) {
|
||||
ENCODE_LENGTH_EXACT(ItemVerifyReply_Struct);
|
||||
SETUP_DIRECT_ENCODE(ItemVerifyReply_Struct, structs::ItemVerifyReply_Struct);
|
||||
|
||||
eq->slot = TitaniumToUnderfootSlot(emu->slot);
|
||||
eq->slot = ServerToUnderfootSlot(emu->slot);
|
||||
OUT(spell);
|
||||
OUT(target);
|
||||
|
||||
@@ -1989,7 +1990,7 @@ ENCODE(OP_TributeItem) {
|
||||
ENCODE_LENGTH_EXACT(TributeItem_Struct);
|
||||
SETUP_DIRECT_ENCODE(TributeItem_Struct, structs::TributeItem_Struct);
|
||||
|
||||
eq->slot = TitaniumToUnderfootSlot(emu->slot);
|
||||
eq->slot = ServerToUnderfootSlot(emu->slot);
|
||||
OUT(quantity);
|
||||
OUT(tribute_master_id);
|
||||
OUT(tribute_points);
|
||||
@@ -2036,7 +2037,7 @@ ENCODE(OP_ReadBook) {
|
||||
else
|
||||
eq->window = emu->window;
|
||||
OUT(type);
|
||||
eq->invslot = TitaniumToUnderfootSlot(emu->invslot);
|
||||
eq->invslot = ServerToUnderfootSlot(emu->invslot);
|
||||
strn0cpy(eq->txtfile, emu->booktext, sizeof(eq->txtfile));
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
@@ -2097,7 +2098,7 @@ ENCODE(OP_AdventureMerchantSell) {
|
||||
|
||||
eq->unknown000 = 1;
|
||||
OUT(npcid);
|
||||
eq->slot = TitaniumToUnderfootSlot(emu->slot);
|
||||
eq->slot = ServerToUnderfootSlot(emu->slot);
|
||||
OUT(charges);
|
||||
OUT(sell_price);
|
||||
|
||||
@@ -2798,7 +2799,7 @@ ENCODE(OP_AltCurrencySell)
|
||||
SETUP_DIRECT_ENCODE(AltCurrencySellItem_Struct, structs::AltCurrencySellItem_Struct);
|
||||
|
||||
OUT(merchant_entity_id);
|
||||
eq->slot_id = TitaniumToUnderfootSlot(emu->slot_id);
|
||||
eq->slot_id = ServerToUnderfootSlot(emu->slot_id);
|
||||
OUT(charges);
|
||||
OUT(cost);
|
||||
FINISH_ENCODE();
|
||||
@@ -2892,7 +2893,7 @@ DECODE(OP_AdventureMerchantSell) {
|
||||
SETUP_DIRECT_DECODE(Adventure_Sell_Struct, structs::Adventure_Sell_Struct);
|
||||
|
||||
IN(npcid);
|
||||
emu->slot = UnderfootToTitaniumSlot(eq->slot);
|
||||
emu->slot = UnderfootToServerSlot(eq->slot);
|
||||
IN(charges);
|
||||
IN(sell_price);
|
||||
|
||||
@@ -2904,7 +2905,7 @@ DECODE(OP_ApplyPoison) {
|
||||
DECODE_LENGTH_EXACT(structs::ApplyPoison_Struct);
|
||||
SETUP_DIRECT_DECODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
|
||||
|
||||
emu->inventorySlot = UnderfootToTitaniumSlot(eq->inventorySlot);
|
||||
emu->inventorySlot = UnderfootToServerSlot(eq->inventorySlot);
|
||||
IN(success);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2914,7 +2915,7 @@ DECODE(OP_ItemVerifyRequest) {
|
||||
DECODE_LENGTH_EXACT(structs::ItemVerifyRequest_Struct);
|
||||
SETUP_DIRECT_DECODE(ItemVerifyRequest_Struct, structs::ItemVerifyRequest_Struct);
|
||||
|
||||
emu->slot = UnderfootToTitaniumSlot(eq->slot);
|
||||
emu->slot = UnderfootToServerSlot(eq->slot);
|
||||
IN(target);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2924,7 +2925,7 @@ DECODE(OP_Consume) {
|
||||
DECODE_LENGTH_EXACT(structs::Consume_Struct);
|
||||
SETUP_DIRECT_DECODE(Consume_Struct, structs::Consume_Struct);
|
||||
|
||||
emu->slot = UnderfootToTitaniumSlot(eq->slot);
|
||||
emu->slot = UnderfootToServerSlot(eq->slot);
|
||||
IN(auto_consumed);
|
||||
IN(type);
|
||||
|
||||
@@ -2944,7 +2945,7 @@ DECODE(OP_CastSpell) {
|
||||
IN(slot);
|
||||
}
|
||||
IN(spell_id);
|
||||
emu->inventoryslot = UnderfootToTitaniumSlot(eq->inventoryslot);
|
||||
emu->inventoryslot = UnderfootToServerSlot(eq->inventoryslot);
|
||||
IN(target_id);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2955,8 +2956,8 @@ DECODE(OP_DeleteItem)
|
||||
DECODE_LENGTH_EXACT(structs::DeleteItem_Struct);
|
||||
SETUP_DIRECT_DECODE(DeleteItem_Struct, structs::DeleteItem_Struct);
|
||||
|
||||
emu->from_slot = UnderfootToTitaniumSlot(eq->from_slot);
|
||||
emu->to_slot = UnderfootToTitaniumSlot(eq->to_slot);
|
||||
emu->from_slot = UnderfootToServerSlot(eq->from_slot);
|
||||
emu->to_slot = UnderfootToServerSlot(eq->to_slot);
|
||||
IN(number_in_stack);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2969,8 +2970,8 @@ DECODE(OP_MoveItem)
|
||||
|
||||
_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot, eq->to_slot);
|
||||
|
||||
emu->from_slot = UnderfootToTitaniumSlot(eq->from_slot);
|
||||
emu->to_slot = UnderfootToTitaniumSlot(eq->to_slot);
|
||||
emu->from_slot = UnderfootToServerSlot(eq->from_slot);
|
||||
emu->to_slot = UnderfootToServerSlot(eq->to_slot);
|
||||
IN(number_in_stack);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -3177,7 +3178,7 @@ DECODE(OP_ShopPlayerSell) {
|
||||
SETUP_DIRECT_DECODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
|
||||
|
||||
IN(npcid);
|
||||
emu->itemslot = UnderfootToTitaniumSlot(eq->itemslot);
|
||||
emu->itemslot = UnderfootToServerSlot(eq->itemslot);
|
||||
IN(quantity);
|
||||
IN(price);
|
||||
|
||||
@@ -3246,7 +3247,7 @@ DECODE(OP_TributeItem) {
|
||||
DECODE_LENGTH_EXACT(structs::TributeItem_Struct);
|
||||
SETUP_DIRECT_DECODE(TributeItem_Struct, structs::TributeItem_Struct);
|
||||
|
||||
emu->slot = UnderfootToTitaniumSlot(eq->slot);
|
||||
emu->slot = UnderfootToServerSlot(eq->slot);
|
||||
IN(quantity);
|
||||
IN(tribute_master_id);
|
||||
IN(tribute_points);
|
||||
@@ -3259,7 +3260,7 @@ DECODE(OP_ReadBook) {
|
||||
SETUP_DIRECT_DECODE(BookRequest_Struct, structs::BookRequest_Struct);
|
||||
|
||||
IN(type);
|
||||
emu->invslot = UnderfootToTitaniumSlot(eq->invslot);
|
||||
emu->invslot = UnderfootToServerSlot(eq->invslot);
|
||||
emu->window = (uint8) eq->window;
|
||||
strn0cpy(emu->txtfile, eq->txtfile, sizeof(emu->txtfile));
|
||||
|
||||
@@ -3270,7 +3271,7 @@ DECODE(OP_TradeSkillCombine) {
|
||||
DECODE_LENGTH_EXACT(structs::NewCombine_Struct);
|
||||
SETUP_DIRECT_DECODE(NewCombine_Struct, structs::NewCombine_Struct);
|
||||
|
||||
emu->container_slot = UnderfootToTitaniumSlot(eq->container_slot);
|
||||
emu->container_slot = UnderfootToServerSlot(eq->container_slot);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
}
|
||||
@@ -3279,7 +3280,7 @@ DECODE(OP_AugmentItem) {
|
||||
DECODE_LENGTH_EXACT(structs::AugmentItem_Struct);
|
||||
SETUP_DIRECT_DECODE(AugmentItem_Struct, structs::AugmentItem_Struct);
|
||||
|
||||
emu->container_slot = UnderfootToTitaniumSlot(eq->container_slot);
|
||||
emu->container_slot = UnderfootToServerSlot(eq->container_slot);
|
||||
emu->augment_slot = eq->augment_slot;
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -3488,7 +3489,7 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
|
||||
hdr.stacksize = stackable ? charges : 1;
|
||||
hdr.unknown004 = 0;
|
||||
|
||||
int32 slot_id = TitaniumToUnderfootSlot(slot_id_in);
|
||||
int32 slot_id = ServerToUnderfootSlot(slot_id_in);
|
||||
|
||||
hdr.slot = (merchant_slot == 0) ? slot_id : merchant_slot;
|
||||
hdr.price = inst->GetPrice();
|
||||
@@ -3894,11 +3895,11 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
|
||||
|
||||
iqbs.subitem_count = 0;
|
||||
|
||||
char *SubSerializations[10];
|
||||
char *SubSerializations[10]; // <watch>
|
||||
|
||||
uint32 SubLengths[10];
|
||||
|
||||
for(int x = 0; x < 10; ++x) {
|
||||
for(int x = SUB_BEGIN; x < EmuConstants::ITEM_CONTAINER_SIZE; ++x) {
|
||||
|
||||
SubSerializations[x] = nullptr;
|
||||
|
||||
@@ -3910,15 +3911,23 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
|
||||
|
||||
iqbs.subitem_count++;
|
||||
|
||||
if(slot_id_in >= 22 && slot_id_in < 30)
|
||||
SubSlotNumber = (((slot_id_in + 3) * 10) + x + 1);
|
||||
else if(slot_id_in >= 2000 && slot_id_in <= 2023)
|
||||
SubSlotNumber = (((slot_id_in - 2000) * 10) + 2030 + x + 1);
|
||||
else if(slot_id_in >= 2500 && slot_id_in <= 2501)
|
||||
SubSlotNumber = (((slot_id_in - 2500) * 10) + 2530 + x + 1);
|
||||
if (slot_id_in >= EmuConstants::GENERAL_BEGIN && slot_id_in <= EmuConstants::GENERAL_END) // (< 30) - no cursor?
|
||||
//SubSlotNumber = (((slot_id_in + 3) * 10) + x + 1);
|
||||
SubSlotNumber = (((slot_id_in + 3) * EmuConstants::ITEM_CONTAINER_SIZE) + x + 1);
|
||||
else if (slot_id_in >= EmuConstants::BANK_BEGIN && slot_id_in <= EmuConstants::BANK_END)
|
||||
//SubSlotNumber = (((slot_id_in - 2000) * 10) + 2030 + x + 1);
|
||||
SubSlotNumber = (((slot_id_in - EmuConstants::BANK_BEGIN) * EmuConstants::ITEM_CONTAINER_SIZE) + EmuConstants::BANK_BAGS_BEGIN + x);
|
||||
else if (slot_id_in >= EmuConstants::SHARED_BANK_BEGIN && slot_id_in <= EmuConstants::SHARED_BANK_END)
|
||||
//SubSlotNumber = (((slot_id_in - 2500) * 10) + 2530 + x + 1);
|
||||
SubSlotNumber = (((slot_id_in - EmuConstants::SHARED_BANK_BEGIN) * EmuConstants::ITEM_CONTAINER_SIZE) + EmuConstants::SHARED_BANK_BAGS_BEGIN + x);
|
||||
else
|
||||
SubSlotNumber = slot_id_in; // ???????
|
||||
|
||||
/*
|
||||
// TEST CODE: <watch>
|
||||
SubSlotNumber = Inventory::CalcSlotID(slot_id_in, x);
|
||||
*/
|
||||
|
||||
SubSerializations[x] = SerializeItem(subitem, SubSlotNumber, &SubLengths[x], depth + 1);
|
||||
}
|
||||
}
|
||||
@@ -3950,7 +3959,7 @@ DECODE(OP_AltCurrencySellSelection)
|
||||
DECODE_LENGTH_EXACT(structs::AltCurrencySelectItem_Struct);
|
||||
SETUP_DIRECT_DECODE(AltCurrencySelectItem_Struct, structs::AltCurrencySelectItem_Struct);
|
||||
IN(merchant_entity_id);
|
||||
emu->slot_id = UnderfootToTitaniumSlot(eq->slot_id);
|
||||
emu->slot_id = UnderfootToServerSlot(eq->slot_id);
|
||||
FINISH_DIRECT_DECODE();
|
||||
}
|
||||
|
||||
@@ -3959,7 +3968,7 @@ DECODE(OP_AltCurrencySell)
|
||||
DECODE_LENGTH_EXACT(structs::AltCurrencySellItem_Struct);
|
||||
SETUP_DIRECT_DECODE(AltCurrencySellItem_Struct, structs::AltCurrencySellItem_Struct);
|
||||
IN(merchant_entity_id);
|
||||
emu->slot_id = UnderfootToTitaniumSlot(eq->slot_id);
|
||||
emu->slot_id = UnderfootToServerSlot(eq->slot_id);
|
||||
IN(charges);
|
||||
IN(cost);
|
||||
FINISH_DIRECT_DECODE();
|
||||
|
||||
Reference in New Issue
Block a user