mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-20 01:18:21 +00:00
More numeric to constant conversions..should be most of them... Please report any inventory abnormalities.
This commit is contained in:
+98
-88
@@ -107,70 +107,72 @@ const EQClientVersion Strategy::ClientVersion() const
|
||||
#include "SSDefine.h"
|
||||
|
||||
|
||||
// Converts Titanium Slot IDs to SoF Slot IDs for use in Encodes
|
||||
static inline uint32 TitaniumToSoFSlot(uint32 TitaniumSlot) {
|
||||
// Converts Server Slot IDs to SoF Slot IDs for use in Encodes
|
||||
static inline uint32 ServerToSoFSlot(uint32 ServerSlot) {
|
||||
uint32 SoFSlot = 0;
|
||||
|
||||
if(TitaniumSlot >= 21 && TitaniumSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
{
|
||||
SoFSlot = TitaniumSlot + 1;
|
||||
}
|
||||
else if(TitaniumSlot >= 251 && TitaniumSlot <= 340) // Bag Slots for Normal Inventory and Cursor
|
||||
{
|
||||
SoFSlot = TitaniumSlot + 11;
|
||||
}
|
||||
else if(TitaniumSlot >= 2031 && TitaniumSlot <= 2270) // Bank Bag Slots
|
||||
{
|
||||
SoFSlot = TitaniumSlot + 1;
|
||||
}
|
||||
else if(TitaniumSlot >= 2531 && TitaniumSlot <= 2550) // Shared Bank Bag Slots
|
||||
{
|
||||
SoFSlot = TitaniumSlot + 1;
|
||||
}
|
||||
else if(TitaniumSlot == 9999) //Unused slot ID to give a place to save Power Slot
|
||||
{
|
||||
SoFSlot = 21;
|
||||
}
|
||||
if (ServerSlot >= MainAmmo && ServerSlot <= 53) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
SoFSlot = ServerSlot + 1;
|
||||
|
||||
else if (ServerSlot >= EmuConstants::GENERAL_BAGS_BEGIN && ServerSlot <= EmuConstants::CURSOR_BAG_END)
|
||||
SoFSlot = ServerSlot + 11;
|
||||
|
||||
else if (ServerSlot >= EmuConstants::BANK_BAGS_BEGIN && ServerSlot <= EmuConstants::BANK_BAGS_END)
|
||||
SoFSlot = ServerSlot + 1;
|
||||
|
||||
else if (ServerSlot >= EmuConstants::SHARED_BANK_BAGS_BEGIN && ServerSlot <= EmuConstants::SHARED_BANK_BAGS_END)
|
||||
SoFSlot = ServerSlot + 1;
|
||||
|
||||
else if (ServerSlot == MainPowerSource)
|
||||
SoFSlot = slots::MainPowerSource;
|
||||
|
||||
else
|
||||
{
|
||||
SoFSlot = TitaniumSlot;
|
||||
}
|
||||
SoFSlot = ServerSlot;
|
||||
|
||||
return SoFSlot;
|
||||
}
|
||||
|
||||
// Converts Sof Slot IDs to Titanium Slot IDs for use in Decodes
|
||||
static inline uint32 SoFToTitaniumSlot(uint32 SoFSlot) {
|
||||
uint32 TitaniumSlot = 0;
|
||||
// Converts SoF Slot IDs to Server Slot IDs for use in Decodes
|
||||
static inline uint32 SoFToServerSlot(uint32 SoFSlot) {
|
||||
uint32 ServerSlot = 0;
|
||||
|
||||
if(SoFSlot >= 22 && SoFSlot <= 54) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
{
|
||||
TitaniumSlot = SoFSlot - 1;
|
||||
}
|
||||
else if(SoFSlot >= 262 && SoFSlot <= 351) // Bag Slots for Normal Inventory and Cursor
|
||||
{
|
||||
TitaniumSlot = SoFSlot - 11;
|
||||
}
|
||||
else if(SoFSlot >= 2032 && SoFSlot <= 2271) // Bank Bag Slots
|
||||
{
|
||||
TitaniumSlot = SoFSlot - 1;
|
||||
}
|
||||
else if(SoFSlot >= 2532 && SoFSlot <= 2551) // Shared Bank Bag Slots
|
||||
{
|
||||
TitaniumSlot = SoFSlot - 1;
|
||||
}
|
||||
else if(SoFSlot == 21)
|
||||
{
|
||||
TitaniumSlot = 9999; //Unused slot ID to give a place to save Power Slot
|
||||
}
|
||||
if(SoFSlot >= slots::MainAmmo && SoFSlot <= consts::CORPSE_END) // Cursor/Ammo/Power Source and Normal Inventory Slots
|
||||
ServerSlot = SoFSlot - 1;
|
||||
|
||||
else if(SoFSlot >= consts::GENERAL_BAGS_BEGIN && SoFSlot <= consts::CURSOR_BAG_END)
|
||||
ServerSlot = SoFSlot - 11;
|
||||
|
||||
else if(SoFSlot >= consts::BANK_BAGS_BEGIN && SoFSlot <= consts::BANK_BAGS_END)
|
||||
ServerSlot = SoFSlot - 1;
|
||||
|
||||
else if(SoFSlot >= consts::SHARED_BANK_BAGS_BEGIN && SoFSlot <= consts::SHARED_BANK_BAGS_END)
|
||||
ServerSlot = SoFSlot - 1;
|
||||
|
||||
else if(SoFSlot == slots::MainPowerSource)
|
||||
ServerSlot = MainPowerSource;
|
||||
|
||||
else
|
||||
{
|
||||
TitaniumSlot = SoFSlot;
|
||||
}
|
||||
ServerSlot = SoFSlot;
|
||||
|
||||
|
||||
return TitaniumSlot;
|
||||
return ServerSlot;
|
||||
}
|
||||
|
||||
/*
|
||||
// Converts Server Corpse Slot IDs to SoF Corpse Slot IDs for use in Encodes
|
||||
static inline uint32 ServerToSoFCorpseSlot(uint32 ServerCorpse) {
|
||||
uint32 SoFCorpse;
|
||||
// reserved
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Converts SoF Corpse Slot IDs to Server Corpse Slot IDs for use in Decodes
|
||||
static inline uint32 SoFToServerCorpseSlot(uint32 SoFCorpse) {
|
||||
uint32 ServerCorpse;
|
||||
// reserved
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
ENCODE(OP_OpenNewTasksWindow) {
|
||||
|
||||
@@ -1421,7 +1423,7 @@ ENCODE(OP_ShopPlayerSell) {
|
||||
ENCODE_LENGTH_EXACT(Merchant_Purchase_Struct);
|
||||
SETUP_DIRECT_ENCODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
|
||||
OUT(npcid);
|
||||
eq->itemslot = TitaniumToSoFSlot(emu->itemslot);
|
||||
eq->itemslot = ServerToSoFSlot(emu->itemslot);
|
||||
OUT(quantity);
|
||||
OUT(price);
|
||||
FINISH_ENCODE();
|
||||
@@ -1430,7 +1432,7 @@ ENCODE(OP_ShopPlayerSell) {
|
||||
ENCODE(OP_ApplyPoison) {
|
||||
ENCODE_LENGTH_EXACT(ApplyPoison_Struct);
|
||||
SETUP_DIRECT_ENCODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
|
||||
eq->inventorySlot = TitaniumToSoFSlot(emu->inventorySlot);
|
||||
eq->inventorySlot = ServerToSoFSlot(emu->inventorySlot);
|
||||
OUT(success);
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
@@ -1439,8 +1441,8 @@ ENCODE(OP_DeleteItem) {
|
||||
ENCODE_LENGTH_EXACT(DeleteItem_Struct);
|
||||
SETUP_DIRECT_ENCODE(DeleteItem_Struct, structs::DeleteItem_Struct);
|
||||
|
||||
eq->from_slot = TitaniumToSoFSlot(emu->from_slot);
|
||||
eq->to_slot = TitaniumToSoFSlot(emu->to_slot);
|
||||
eq->from_slot = ServerToSoFSlot(emu->from_slot);
|
||||
eq->to_slot = ServerToSoFSlot(emu->to_slot);
|
||||
OUT(number_in_stack);
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -1451,8 +1453,8 @@ ENCODE(OP_MoveItem) {
|
||||
ENCODE_LENGTH_EXACT(MoveItem_Struct);
|
||||
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
eq->from_slot = TitaniumToSoFSlot(emu->from_slot);
|
||||
eq->to_slot = TitaniumToSoFSlot(emu->to_slot);
|
||||
eq->from_slot = ServerToSoFSlot(emu->from_slot);
|
||||
eq->to_slot = ServerToSoFSlot(emu->to_slot);
|
||||
OUT(number_in_stack);
|
||||
|
||||
FINISH_ENCODE();
|
||||
@@ -1462,7 +1464,7 @@ ENCODE(OP_ItemVerifyReply) {
|
||||
ENCODE_LENGTH_EXACT(ItemVerifyReply_Struct);
|
||||
SETUP_DIRECT_ENCODE(ItemVerifyReply_Struct, structs::ItemVerifyReply_Struct);
|
||||
|
||||
eq->slot = TitaniumToSoFSlot(emu->slot);
|
||||
eq->slot = ServerToSoFSlot(emu->slot);
|
||||
OUT(spell);
|
||||
OUT(target);
|
||||
|
||||
@@ -1566,7 +1568,7 @@ ENCODE(OP_TributeItem) {
|
||||
ENCODE_LENGTH_EXACT(TributeItem_Struct);
|
||||
SETUP_DIRECT_ENCODE(TributeItem_Struct, structs::TributeItem_Struct);
|
||||
|
||||
eq->slot = TitaniumToSoFSlot(emu->slot);
|
||||
eq->slot = ServerToSoFSlot(emu->slot);
|
||||
OUT(quantity);
|
||||
OUT(tribute_master_id);
|
||||
OUT(tribute_points);
|
||||
@@ -1613,7 +1615,7 @@ ENCODE(OP_ReadBook) {
|
||||
else
|
||||
eq->window = emu->window;
|
||||
OUT(type);
|
||||
eq->invslot = TitaniumToSoFSlot(emu->invslot);
|
||||
eq->invslot = ServerToSoFSlot(emu->invslot);
|
||||
strn0cpy(eq->txtfile, emu->booktext, sizeof(eq->txtfile));
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
@@ -1674,7 +1676,7 @@ ENCODE(OP_AdventureMerchantSell) {
|
||||
|
||||
eq->unknown000 = 1;
|
||||
OUT(npcid);
|
||||
eq->slot = TitaniumToSoFSlot(emu->slot);
|
||||
eq->slot = ServerToSoFSlot(emu->slot);
|
||||
OUT(charges);
|
||||
OUT(sell_price);
|
||||
|
||||
@@ -1959,7 +1961,7 @@ ENCODE(OP_AltCurrencySell)
|
||||
SETUP_DIRECT_ENCODE(AltCurrencySellItem_Struct, structs::AltCurrencySellItem_Struct);
|
||||
|
||||
OUT(merchant_entity_id);
|
||||
eq->slot_id = TitaniumToSoFSlot(emu->slot_id);
|
||||
eq->slot_id = ServerToSoFSlot(emu->slot_id);
|
||||
OUT(charges);
|
||||
OUT(cost);
|
||||
FINISH_ENCODE();
|
||||
@@ -2011,7 +2013,7 @@ DECODE(OP_AdventureMerchantSell) {
|
||||
SETUP_DIRECT_DECODE(Adventure_Sell_Struct, structs::Adventure_Sell_Struct);
|
||||
|
||||
IN(npcid);
|
||||
emu->slot = SoFToTitaniumSlot(eq->slot);
|
||||
emu->slot = SoFToServerSlot(eq->slot);
|
||||
IN(charges);
|
||||
IN(sell_price);
|
||||
|
||||
@@ -2022,7 +2024,7 @@ DECODE(OP_ApplyPoison) {
|
||||
DECODE_LENGTH_EXACT(structs::ApplyPoison_Struct);
|
||||
SETUP_DIRECT_DECODE(ApplyPoison_Struct, structs::ApplyPoison_Struct);
|
||||
|
||||
emu->inventorySlot = SoFToTitaniumSlot(eq->inventorySlot);
|
||||
emu->inventorySlot = SoFToServerSlot(eq->inventorySlot);
|
||||
IN(success);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2032,7 +2034,7 @@ DECODE(OP_ItemVerifyRequest) {
|
||||
DECODE_LENGTH_EXACT(structs::ItemVerifyRequest_Struct);
|
||||
SETUP_DIRECT_DECODE(ItemVerifyRequest_Struct, structs::ItemVerifyRequest_Struct);
|
||||
|
||||
emu->slot = SoFToTitaniumSlot(eq->slot);
|
||||
emu->slot = SoFToServerSlot(eq->slot);
|
||||
IN(target);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2042,7 +2044,7 @@ DECODE(OP_Consume) {
|
||||
DECODE_LENGTH_EXACT(structs::Consume_Struct);
|
||||
SETUP_DIRECT_DECODE(Consume_Struct, structs::Consume_Struct);
|
||||
|
||||
emu->slot = SoFToTitaniumSlot(eq->slot);
|
||||
emu->slot = SoFToServerSlot(eq->slot);
|
||||
IN(auto_consumed);
|
||||
IN(type);
|
||||
|
||||
@@ -2055,7 +2057,7 @@ DECODE(OP_CastSpell) {
|
||||
|
||||
IN(slot);
|
||||
IN(spell_id);
|
||||
emu->inventoryslot = SoFToTitaniumSlot(eq->inventoryslot);
|
||||
emu->inventoryslot = SoFToServerSlot(eq->inventoryslot);
|
||||
IN(target_id);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2066,8 +2068,8 @@ DECODE(OP_DeleteItem)
|
||||
DECODE_LENGTH_EXACT(structs::DeleteItem_Struct);
|
||||
SETUP_DIRECT_DECODE(DeleteItem_Struct, structs::DeleteItem_Struct);
|
||||
|
||||
emu->from_slot = SoFToTitaniumSlot(eq->from_slot);
|
||||
emu->to_slot = SoFToTitaniumSlot(eq->to_slot);
|
||||
emu->from_slot = SoFToServerSlot(eq->from_slot);
|
||||
emu->to_slot = SoFToServerSlot(eq->to_slot);
|
||||
IN(number_in_stack);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2080,8 +2082,8 @@ DECODE(OP_MoveItem)
|
||||
|
||||
_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot, eq->to_slot);
|
||||
|
||||
emu->from_slot = SoFToTitaniumSlot(eq->from_slot);
|
||||
emu->to_slot = SoFToTitaniumSlot(eq->to_slot);
|
||||
emu->from_slot = SoFToServerSlot(eq->from_slot);
|
||||
emu->to_slot = SoFToServerSlot(eq->to_slot);
|
||||
IN(number_in_stack);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2230,7 +2232,7 @@ DECODE(OP_ShopPlayerSell) {
|
||||
SETUP_DIRECT_DECODE(Merchant_Purchase_Struct, structs::Merchant_Purchase_Struct);
|
||||
|
||||
IN(npcid);
|
||||
emu->itemslot = SoFToTitaniumSlot(eq->itemslot);
|
||||
emu->itemslot = SoFToServerSlot(eq->itemslot);
|
||||
IN(quantity);
|
||||
IN(price);
|
||||
|
||||
@@ -2298,7 +2300,7 @@ DECODE(OP_TributeItem) {
|
||||
DECODE_LENGTH_EXACT(structs::TributeItem_Struct);
|
||||
SETUP_DIRECT_DECODE(TributeItem_Struct, structs::TributeItem_Struct);
|
||||
|
||||
emu->slot = SoFToTitaniumSlot(eq->slot);
|
||||
emu->slot = SoFToServerSlot(eq->slot);
|
||||
IN(quantity);
|
||||
IN(tribute_master_id);
|
||||
IN(tribute_points);
|
||||
@@ -2311,7 +2313,7 @@ DECODE(OP_ReadBook) {
|
||||
SETUP_DIRECT_DECODE(BookRequest_Struct, structs::BookRequest_Struct);
|
||||
|
||||
IN(type);
|
||||
emu->invslot = SoFToTitaniumSlot(eq->invslot);
|
||||
emu->invslot = SoFToServerSlot(eq->invslot);
|
||||
emu->window = (uint8) eq->window;
|
||||
strn0cpy(emu->txtfile, eq->txtfile, sizeof(emu->txtfile));
|
||||
|
||||
@@ -2322,7 +2324,7 @@ DECODE(OP_TradeSkillCombine) {
|
||||
DECODE_LENGTH_EXACT(structs::NewCombine_Struct);
|
||||
SETUP_DIRECT_DECODE(NewCombine_Struct, structs::NewCombine_Struct);
|
||||
|
||||
emu->container_slot = SoFToTitaniumSlot(eq->container_slot);
|
||||
emu->container_slot = SoFToServerSlot(eq->container_slot);
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
}
|
||||
@@ -2331,7 +2333,7 @@ DECODE(OP_AugmentItem) {
|
||||
DECODE_LENGTH_EXACT(structs::AugmentItem_Struct);
|
||||
SETUP_DIRECT_DECODE(AugmentItem_Struct, structs::AugmentItem_Struct);
|
||||
|
||||
emu->container_slot = SoFToTitaniumSlot(eq->container_slot);
|
||||
emu->container_slot = SoFToServerSlot(eq->container_slot);
|
||||
emu->augment_slot = eq->augment_slot;
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
@@ -2396,7 +2398,7 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
|
||||
hdr.stacksize = stackable ? charges : 1;
|
||||
hdr.unknown004 = 0;
|
||||
|
||||
int32 slot_id = TitaniumToSoFSlot(slot_id_in);
|
||||
int32 slot_id = ServerToSoFSlot(slot_id_in);
|
||||
|
||||
hdr.slot = (merchant_slot == 0) ? slot_id : merchant_slot;
|
||||
hdr.price = inst->GetPrice();
|
||||
@@ -2778,11 +2780,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;
|
||||
|
||||
@@ -2794,15 +2796,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);
|
||||
}
|
||||
}
|
||||
@@ -2834,7 +2844,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 = SoFToTitaniumSlot(eq->slot_id);
|
||||
emu->slot_id = SoFToServerSlot(eq->slot_id);
|
||||
FINISH_DIRECT_DECODE();
|
||||
}
|
||||
|
||||
@@ -2843,7 +2853,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 = SoFToTitaniumSlot(eq->slot_id);
|
||||
emu->slot_id = SoFToServerSlot(eq->slot_id);
|
||||
IN(charges);
|
||||
IN(cost);
|
||||
FINISH_DIRECT_DECODE();
|
||||
|
||||
Reference in New Issue
Block a user