Validating packets (starting with loot) (#5079)

This commit is contained in:
dannuic
2026-05-07 21:56:10 -06:00
committed by GitHub
parent 99f99c8b8e
commit 65330af50e
6 changed files with 128 additions and 61 deletions
+1
View File
@@ -81,6 +81,7 @@ public:
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
void ReadString(std::string &str) { str = reinterpret_cast<char *>(pBuffer + _rpos); _rpos += str.length() + 1; }
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
void ReadLengthString(std::string& str) { uint32 len = *(uint32*)(pBuffer + _rpos); _rpos += sizeof(uint32); str.resize(len); memcpy(&str[0], pBuffer + _rpos, len); _rpos += len; }
uint32 GetWritePosition() { return _wpos; }
uint32 GetReadPosition() { return _rpos; }
+51 -4
View File
@@ -238,6 +238,22 @@ namespace TOB
FINISH_ENCODE();
}
ENCODE(OP_Begging)
{
ENCODE_LENGTH_EXACT(BeggingResponse_Struct);
SETUP_DIRECT_ENCODE(BeggingResponse_Struct, structs::BeggingResponse_Struct);
OUT(Unknown00);
OUT(Unknown04);
OUT(Unknown08);
eq->Result = static_cast<uint8>(emu->Result);
OUT(Amount);
eq->StringSize = 0; // set this to 0, but it's a string size
eq->Lucky = 0; // set to 1 to message a lucky beg
FINISH_ENCODE();
}
ENCODE(OP_BeginCast)
{
ENCODE_LENGTH_EXACT(BeginCast_Struct);
@@ -597,8 +613,8 @@ namespace TOB
OUT(skills[i]);
}
eq->unknown408[0] = 1;
eq->unknown408[1] = 0xC9;
eq->unknown408[0] = 1; // this tells the client to update the GM window
eq->unknown408[1] = 0xC9; // these appear to be languages, but it's only testing if this is non-zero
eq->unknown408[2] = 0xC9;
eq->unknown408[3] = 0xC9;
eq->unknown408[4] = 0xC9;
@@ -698,8 +714,6 @@ namespace TOB
OUT(spawnid);
OUT_str(charname);
OUT(race);
eq->unknown006[0] = 0;
eq->unknown006[1] = 0;
OUT(gender);
OUT(texture);
OUT(helmtexture);
@@ -893,6 +907,7 @@ namespace TOB
ENCODE_LENGTH_EXACT(moneyOnCorpseStruct);
SETUP_DIRECT_ENCODE(moneyOnCorpseStruct, structs::moneyOnCorpseStruct);
// TODO: The type has changed to accomodate all kinds of loot options and actions, including advloot
eq->type = emu->response;
OUT(platinum);
OUT(gold);
@@ -3693,6 +3708,23 @@ namespace TOB
DECODE(OP_ConsiderCorpse) { DECODE_FORWARD(OP_Consider); }
DECODE(OP_CorpseDrag)
{
std::string CorpseName;
__packet->ReadLengthString(CorpseName);
std::string DraggerName;
__packet->ReadLengthString(DraggerName);
__packet->SetReadPosition(0);
__packet->size = sizeof(CorpseDrag_Struct);
__packet->pBuffer = new unsigned char[__packet->size]{};
auto* emu = reinterpret_cast<CorpseDrag_Struct*>(__packet->pBuffer);
strncpy(emu->CorpseName, CorpseName.c_str(), 64);
strncpy(emu->DraggerName, DraggerName.c_str(), 64);
}
DECODE(OP_DeleteItem)
{
DECODE_LENGTH_EXACT(structs::DeleteItem_Struct);
@@ -3759,6 +3791,21 @@ namespace TOB
DECODE_FORWARD(OP_GroupInvite);
}
DECODE(OP_LootItem)
{
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Detail, Logs::Netcode, "TOB::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
emu->slot_id = TOBToServerCorpseMainSlot(eq->slot_id);
IN(auto_loot);
FINISH_DIRECT_DECODE();
}
DECODE(OP_MemorizeSpell) {
DECODE_LENGTH_EXACT(structs::MemorizeSpell_Struct);
SETUP_DIRECT_DECODE(MemorizeSpell_Struct, structs::MemorizeSpell_Struct);
+3
View File
@@ -4,6 +4,7 @@ E(OP_Action)
E(OP_Animation)
E(OP_ApplyPoison)
E(OP_AugmentInfo)
E(OP_Begging)
E(OP_BeginCast)
E(OP_BlockedBuffs)
E(OP_CancelTrade)
@@ -77,12 +78,14 @@ D(OP_ClientUpdate)
D(OP_ClickDoor)
D(OP_Consider)
D(OP_ConsiderCorpse)
D(OP_CorpseDrag)
D(OP_DeleteItem)
D(OP_EnterWorld)
D(OP_GMTraining)
D(OP_GroupDisband)
D(OP_GroupInvite)
D(OP_GroupInvite2)
D(OP_LootItem)
D(OP_MemorizeSpell)
D(OP_MoveItem)
D(OP_RemoveBlockedBuffs)
+44 -28
View File
@@ -645,7 +645,7 @@ namespace TOB {
{
/*000*/ uint32 spawn_id;
/*004*/ uint32 killer_id;
/*008*/ uint32 corpseid; //not read by client
/*008*/ uint32 corpseid;
/*012*/ uint32 unknown1; //not read by client
/*016*/ int32 spell_id;
/*020*/ uint32 attack_skill;
@@ -790,7 +790,7 @@ namespace TOB {
//This is what we call OP_Action
//To the client though this is basically a missile hit though
//OP_Action is basically "instant missile hit" to the client
//@0x1401f0970 MissileHitInfo::Deserialize(CUnSerializeBuffer *buffer);
//@0x1402024C0 MissileHitInfo::Deserialize(CUnSerializeBuffer *buffer);
struct MissileHitInfo
{
uint16 target;
@@ -896,38 +896,34 @@ namespace TOB {
struct Illusion_Struct {
/*000*/ uint32 spawnid;
/*004*/ char charname[64];
/*068*/ uint16 race; //according to eqlib this is s32
/*070*/ char unknown006[2];
/*072*/ uint8 gender;
/*073*/ uint8 texture;
/*074*/ uint8 armorVariation;
/*075*/ uint8 armorMaterial;
/*076*/ uint8 helmtexture;
/*077*/ uint8 unknown077; //padding from this being a pack(4) struct actually
/*078*/ uint8 unknown078;
/*079*/ uint8 unknown079;
/*068*/ int32 race;
/*072*/ int32 class_;
/*076*/ float size;
/*080*/ uint32 face;
/*084*/ uint8 hairstyle;
/*085*/ uint8 haircolor;
/*086*/ uint8 beard;
/*087*/ uint8 beardcolor;
/*088*/ float size;
/*092*/ uint32_t npc_tint;
/*096*/ bool keep_armor_properties;
/*097*/ uint8 unknown097[3]; //padding from this being a pack(4) struct actually
/*100*/ ArmorPropertyStruct armorProperties[9];
/*280*/ uint32_t armorTints[9];
/*316*/ int32 class_;
/*320*/ uint32 drakkin_heritage;
/*324*/ uint32 drakkin_tattoo;
/*328*/ uint32 drakkin_details;
/*084*/ uint32 npc_tint;
/*088*/ uint32 keep_armor_properties;
/*092*/ uint32 drakkin_heritage;
/*096*/ uint32 drakkin_tattoo;
/*100*/ uint32 drakkin_details;
/*104*/ uint8 gender;
/*105*/ uint8 texture;
/*106*/ uint8 helmtexture;
/*107*/ uint8 armorVariation;
/*108*/ uint8 armorMaterial;
/*109*/ uint8 hairstyle;
/*110*/ uint8 haircolor;
/*111*/ uint8 beard;
/*112*/ uint8 beardcolor;
/*113*/ uint8 padding[3];
/*116*/ ArmorPropertyStruct armorProperties[9];
/*296*/ uint32 armorTints[9];
/*332*/
};
struct moneyOnCorpseStruct {
/*000*/ uint8 type;
/*000*/ uint8 type; // 0 = someone is already looting, 1 = OK, 2 = cannot access at this time, 3 = OK, 4 = cannot loot while hostile nearby, 5 = too far away to loot, 6 = loot all, 7 = cancel loot, 8 = add access, 9 = using advloot (when right clicking), 10 = show advloot
/*001*/ uint8 padding1[3];
/*004*/ uint32 flags;
/*004*/ uint32 flags; // 1 = extra lucky bonus, 2 = lucky bonus, 4 = bonus
/*008*/ uint32 platinum;
/*012*/ uint32 gold;
/*016*/ uint32 silver;
@@ -935,6 +931,15 @@ namespace TOB {
/*024*/
};
struct LootingItem_Struct {
/*000*/ uint32 lootee;
/*004*/ uint32 looter;
/*008*/ uint32 slot_id;
/*012*/ int32 auto_loot;
/*016*/ uint32 unknown16;
/*020*/
};
struct GroupGeneric_Struct {
/*0000*/ char name1[64];
/*0064*/ char name2[64];
@@ -1102,6 +1107,17 @@ namespace TOB {
uint32 Zone;
};
struct BeggingResponse_Struct
{
/*00*/ uint32 Unknown00;
/*04*/ uint32 Unknown04;
/*08*/ uint32 Unknown08;
/*12*/ uint8 Result; // 0 = Fail, 1 = Plat, 2 = Gold, 3 = Silver, 4 = Copper
/*13*/ uint32 Amount;
/*17*/ uint32 StringSize; // set this to 0, but it's a string size
/*21*/ uint8 Lucky; // set to 1 to message a lucky beg
};
#pragma pack()
}; //end namespace structs