mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-30 14:17:02 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -4,92 +4,73 @@
|
||||
#include "PacketListener.h"
|
||||
#include "AwardStatPacket.h"
|
||||
|
||||
|
||||
|
||||
AwardStatPacket::AwardStatPacket()
|
||||
{
|
||||
this->m_paramData.data = NULL;
|
||||
this->m_paramData.length = 0;
|
||||
AwardStatPacket::AwardStatPacket() {
|
||||
this->m_paramData.data = NULL;
|
||||
this->m_paramData.length = 0;
|
||||
}
|
||||
|
||||
AwardStatPacket::AwardStatPacket(int statId, int count)
|
||||
{
|
||||
this->statId = statId;
|
||||
AwardStatPacket::AwardStatPacket(int statId, int count) {
|
||||
this->statId = statId;
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
}
|
||||
|
||||
AwardStatPacket::AwardStatPacket(int statId, byteArray paramData)
|
||||
{
|
||||
this->statId = statId;
|
||||
this->m_paramData = paramData;
|
||||
AwardStatPacket::AwardStatPacket(int statId, byteArray paramData) {
|
||||
this->statId = statId;
|
||||
this->m_paramData = paramData;
|
||||
}
|
||||
|
||||
AwardStatPacket::~AwardStatPacket()
|
||||
{
|
||||
if (m_paramData.data != NULL)
|
||||
{
|
||||
delete[] m_paramData.data;
|
||||
m_paramData.data = NULL;
|
||||
}
|
||||
AwardStatPacket::~AwardStatPacket() {
|
||||
if (m_paramData.data != NULL) {
|
||||
delete[] m_paramData.data;
|
||||
m_paramData.data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void AwardStatPacket::handle(PacketListener *listener)
|
||||
{
|
||||
listener->handleAwardStat(shared_from_this());
|
||||
m_paramData.data = NULL;
|
||||
void AwardStatPacket::handle(PacketListener* listener) {
|
||||
listener->handleAwardStat(shared_from_this());
|
||||
m_paramData.data = NULL;
|
||||
}
|
||||
|
||||
void AwardStatPacket::read(DataInputStream *dis) //throws IOException
|
||||
void AwardStatPacket::read(DataInputStream* dis) // throws IOException
|
||||
{
|
||||
statId = dis->readInt();
|
||||
statId = dis->readInt();
|
||||
|
||||
// Read parameter blob.
|
||||
int length = dis->readInt();
|
||||
if(length > 0)
|
||||
{
|
||||
m_paramData = byteArray(length);
|
||||
dis->readFully(m_paramData);
|
||||
}
|
||||
// Read parameter blob.
|
||||
int length = dis->readInt();
|
||||
if (length > 0) {
|
||||
m_paramData = byteArray(length);
|
||||
dis->readFully(m_paramData);
|
||||
}
|
||||
}
|
||||
|
||||
void AwardStatPacket::write(DataOutputStream *dos) //throws IOException
|
||||
void AwardStatPacket::write(DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
dos->writeInt(statId);
|
||||
dos->writeInt(m_paramData.length);
|
||||
if(m_paramData.length > 0) dos->write(m_paramData);
|
||||
dos->writeInt(statId);
|
||||
dos->writeInt(m_paramData.length);
|
||||
if (m_paramData.length > 0) dos->write(m_paramData);
|
||||
}
|
||||
|
||||
int AwardStatPacket::getEstimatedSize()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
int AwardStatPacket::getEstimatedSize() { return 6; }
|
||||
|
||||
bool AwardStatPacket::isAync()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool AwardStatPacket::isAync() { return true; }
|
||||
|
||||
// On most platforms we only store 'count' in an AwardStatPacket.
|
||||
int AwardStatPacket::getCount()
|
||||
{
|
||||
int AwardStatPacket::getCount() {
|
||||
#ifdef _DURANGO
|
||||
assert(false); // Method not supported on Durango.
|
||||
return 0;
|
||||
assert(false); // Method not supported on Durango.
|
||||
return 0;
|
||||
#else
|
||||
return *((int*)this->m_paramData.data);
|
||||
return *((int*)this->m_paramData.data);
|
||||
#endif
|
||||
}
|
||||
|
||||
// On Durango we store 'Event' parameters here in a blob.
|
||||
byteArray AwardStatPacket::getParamData()
|
||||
{
|
||||
return m_paramData;
|
||||
}
|
||||
byteArray AwardStatPacket::getParamData() { return m_paramData; }
|
||||
|
||||
Reference in New Issue
Block a user