Skip to content

Commit

Permalink
[Feature] Add Support for Item Previews (#4599)
Browse files Browse the repository at this point in the history
* [Feature] Add Support for Item Previews

* Update client_packet.cpp
  • Loading branch information
Kinglykrab authored Jan 20, 2025
1 parent 37a7b7f commit 75698a8
Show file tree
Hide file tree
Showing 9 changed files with 1,269 additions and 1,204 deletions.
1 change: 1 addition & 0 deletions common/emu_oplist.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ N(OP_ItemLinkText),
N(OP_ItemName),
N(OP_ItemPacket),
N(OP_ItemPreview),
N(OP_ItemPreviewRequest),
N(OP_ItemRecastDelay),
N(OP_ItemVerifyReply),
N(OP_ItemVerifyRequest),
Expand Down
9 changes: 8 additions & 1 deletion common/patches/rof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5188,7 +5188,14 @@ namespace RoF

//sprintf(hdr.unknown000, "06e0002Y1W00");

snprintf(hdr.unknown000, sizeof(hdr.unknown000), "%016d", item->ID);
strn0cpy(
hdr.unknown000,
fmt::format(
"{:016}\0",
packet_type == ItemPacketInvalid ? 0 : inst->GetSerialNumber()
).c_str(),
sizeof(hdr.unknown000)
);

hdr.stacksize = (inst->IsStackable() ? ((inst->GetCharges() > 1000) ? 0xFFFFFFFF : inst->GetCharges()) : 1);
hdr.unknown004 = 0;
Expand Down
30 changes: 29 additions & 1 deletion common/patches/rof2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,33 @@ namespace RoF2
}
}

ENCODE(OP_ItemPreviewRequest)
{
EQApplicationPacket* in = *p;
*p = nullptr;

uchar* in_buf = in->pBuffer;

auto int_item = (EQ::InternalSerializedItem_Struct*) in_buf;

EQ::OutBuffer buf;
EQ::OutBuffer::pos_type last_pos = buf.tellp();

SerializeItem(buf, (const EQ::ItemInstance*) int_item->inst, int_item->slot_id, 0, ItemPacketInvalid);
if (buf.tellp() == last_pos) {
LogNetcode("RoF2::ENCODE(OP_ItemPreviewRequest) Serialization failed");
safe_delete_array(in_buf);
safe_delete(in);
return;
}

in->size = buf.size();
in->pBuffer = buf.detach();

safe_delete_array(in_buf);
dest->FastQueuePacket(&in, ack_req);
}

ENCODE(OP_ItemVerifyReply)
{
ENCODE_LENGTH_EXACT(ItemVerifyReply_Struct);
Expand Down Expand Up @@ -6857,12 +6884,13 @@ namespace RoF2
iqbs.Heirloom = 0;
iqbs.Placeable = 0;
iqbs.unknown28 = -1;
iqbs.unknown29 = packet_type == ItemPacketInvalid ? 0xFF : 0;
iqbs.unknown30 = -1;
iqbs.NoZone = 0;
iqbs.NoGround = 0;
iqbs.unknown37a = 0; // (guessed position) New to RoF2
iqbs.unknown38 = 0;
iqbs.unknown39 = 1;
iqbs.unknown39 = packet_type == ItemPacketInvalid ? 0 : 1;;

ob.write((const char*)&iqbs, sizeof(RoF2::structs::ItemQuaternaryBodyStruct));

Expand Down
3 changes: 2 additions & 1 deletion common/patches/rof2_ops.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -92,6 +92,7 @@ E(OP_InspectBuffs)
E(OP_InspectRequest)
E(OP_ItemLinkResponse)
E(OP_ItemPacket)
E(OP_ItemPreviewRequest)
E(OP_ItemVerifyReply)
E(OP_LeadershipExpUpdate)
E(OP_LogServer)
Expand Down
1 change: 1 addition & 0 deletions utils/patches/patch_RoF2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ OP_ItemPacket=0x368e
OP_ItemLinkResponse=0x70c0
OP_ItemLinkClick=0x4cef
OP_ItemPreview=0x6b5c
OP_ItemPreviewRequest=0x7f80
OP_NewSpawn=0x6097
OP_Track=0x17e5
OP_TrackTarget=0x695e
Expand Down
Loading

0 comments on commit 75698a8

Please sign in to comment.