Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add Support for Item Previews #4599

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/emu_oplist.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,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 @@ -2053,6 +2053,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 @@ -6803,12 +6830,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 @@ -91,6 +91,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