the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 89 lines 1.7 kB view raw
1#include "stdafx.h" 2#include <iostream> 3#include "InputOutputStream.h" 4#include "PacketListener.h" 5#include "AwardStatPacket.h" 6 7 8 9AwardStatPacket::AwardStatPacket() 10{ 11 this->m_paramData.data = NULL; 12 this->m_paramData.length = 0; 13} 14 15AwardStatPacket::AwardStatPacket(int statId, int count) 16{ 17 this->statId = statId; 18 19 this->m_paramData.data = (byte *) new int(count); 20 this->m_paramData.length = sizeof(int); 21} 22 23AwardStatPacket::AwardStatPacket(int statId, byteArray paramData) 24{ 25 this->statId = statId; 26 this->m_paramData = paramData; 27} 28 29AwardStatPacket::~AwardStatPacket() 30{ 31 if (m_paramData.data != NULL) 32 { 33 delete [] m_paramData.data; 34 m_paramData.data = NULL; 35 } 36} 37 38void AwardStatPacket::handle(PacketListener *listener) 39{ 40 listener->handleAwardStat(shared_from_this()); 41 m_paramData.data = NULL; 42} 43 44void AwardStatPacket::read(DataInputStream *dis) //throws IOException 45{ 46 statId = dis->readInt(); 47 48 // Read parameter blob. 49 int length = dis->readInt(); 50 if(length > 0) 51 { 52 m_paramData = byteArray(length); 53 dis->readFully(m_paramData); 54 } 55} 56 57void AwardStatPacket::write(DataOutputStream *dos) //throws IOException 58{ 59 dos->writeInt(statId); 60 dos->writeInt(m_paramData.length); 61 if(m_paramData.length > 0) dos->write(m_paramData); 62} 63 64int AwardStatPacket::getEstimatedSize() 65{ 66 return 6; 67} 68 69bool AwardStatPacket::isAync() 70{ 71 return true; 72} 73 74// On most platforms we only store 'count' in an AwardStatPacket. 75int AwardStatPacket::getCount() 76{ 77#ifdef _DURANGO 78 assert(false); // Method not supported on Durango. 79 return 0; 80#else 81 return *((int*)this->m_paramData.data); 82#endif 83} 84 85// On Durango we store 'Event' parameters here in a blob. 86byteArray AwardStatPacket::getParamData() 87{ 88 return m_paramData; 89}