rodecomp/Source/Network/Packets/ShortcutPacket.h
ragnarok-clanker 63b1377599 Decompile 5 functions in Source/Client/ReplayPacketRecorder.h, Source/Contents/Emblems/EmblemUpload.h, ...
Batch #1488 by ragnarok-clanker: 0 byte-identical, 5 confirmed by peer review.

- fn_18386 PacketLengths::IsRecorded: logic confirmed by peer review
- fn_18387 PacketLengths::Initialize: logic confirmed by peer review
- fn_18388 PacketLengths::Lookup: logic confirmed by peer review
- fn_20391 PacketLengths::FixedLength: logic confirmed by peer review
- fn_18171 ResourceFailures::Report: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
2026-10-28 16:45:10 +00:00

51 lines
1.4 KiB
C++

#ifndef RAGNAROK_SOURCE_NETWORK_PACKETS_SHORTCUTPACKET_H
#define RAGNAROK_SOURCE_NETWORK_PACKETS_SHORTCUTPACKET_H
#include "Contents/UserData/NormalItemSlots.h"
#include "Network/Connection/Connection.h"
#include "Network/Packets/PacketLengths.h"
#include <cstdint>
#include <cstring>
struct NormalItemSlot;
class CConnection;
class PacketLengths;
void SendShortcutUpdate(
CConnection& connection, const PacketLengths& lengths, int index, int bank, const NormalItemSlot* bank0, const NormalItemSlot* bank1,
const NormalItemSlot* special
);
// INLINED
inline void SendShortcutUpdate(
CConnection& connection, const PacketLengths& lengths, int index, int bank, const NormalItemSlot* bank0, const NormalItemSlot* bank1,
const NormalItemSlot* special
) {
unsigned char packet[13];
const std::uint32_t header = 2849;
std::memcpy(packet, &header, sizeof(header));
const NormalItemSlot* slot = nullptr;
if (index >= 36) {
if (static_cast<unsigned>(index) - 36u <= 1) {
slot = &special[index - 36];
}
} else if (bank == 0) {
slot = &bank0[index];
} else if (bank == 1) {
slot = &bank1[index];
const std::uint16_t flag = 1;
std::memcpy(packet + 2, &flag, sizeof(flag));
}
if (slot) {
std::memcpy(packet + 6, slot, sizeof(*slot));
}
const auto position = static_cast<std::uint16_t>(index);
std::memcpy(packet + 4, &position, sizeof(position));
connection.Send(lengths.FixedLength(2849), packet);
}
#endif