From af16088015842705bddbab2366d67dbcd00ac5df Mon Sep 17 00:00:00 2001 From: Nikita Edel Date: Tue, 10 Mar 2026 20:13:01 +0100 Subject: [PATCH] improved a change --- Minecraft.World/Network/Packets/AwardStatPacket.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Minecraft.World/Network/Packets/AwardStatPacket.cpp b/Minecraft.World/Network/Packets/AwardStatPacket.cpp index 576cead1b..3ec3113a0 100644 --- a/Minecraft.World/Network/Packets/AwardStatPacket.cpp +++ b/Minecraft.World/Network/Packets/AwardStatPacket.cpp @@ -16,12 +16,13 @@ AwardStatPacket::AwardStatPacket(int statId, int count) { this->statId = statId; - // 4jcraft, changed from new int(count); to new int[1]; - // and initializing the array with count - // reason: .data needs to be delete with delete[] but its - // allocated with new, not new T[] - this->m_paramData.data = (uint8_t *) new int[1]; - ((int*)this->m_paramData.data)[0] = count; + // 4jcraft, changed from (uint8_t*) new int(count); to: + // new uint8_t[sizeof(int)]; + // and memcpy of the integer into the array + // reason: operator missmatch, array is deleted with delete[] + // and typesafety + this->m_paramData.data = new uint8_t[sizeof(int)]; + memcpy(this->m_paramData.data, &count, sizeof(int)); this->m_paramData.length = sizeof(int); }