the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include <iostream>
3#include "InputOutputStream.h"
4#include "PacketListener.h"
5#include "TexturePacket.h"
6
7
8
9TexturePacket::TexturePacket()
10{
11 this->textureName = L"";
12 this->dwBytes = 0;
13 this->pbData = NULL;
14}
15
16TexturePacket::~TexturePacket()
17{
18 // can't free this - it's used elsewhere
19// if(this->pbData!=NULL)
20// {
21// delete [] this->pbData;
22// }
23}
24
25TexturePacket::TexturePacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes)
26{
27 this->textureName = textureName;
28 this->pbData = pbData;
29 this->dwBytes = dwBytes;
30}
31
32void TexturePacket::handle(PacketListener *listener)
33{
34 listener->handleTexture(shared_from_this());
35}
36
37void TexturePacket::read(DataInputStream *dis) //throws IOException
38{
39 textureName = dis->readUTF();
40 dwBytes = (DWORD)dis->readShort();
41
42 if(dwBytes>0)
43 {
44 this->pbData= new BYTE [dwBytes];
45
46 for(DWORD i=0;i<dwBytes;i++)
47 {
48 this->pbData[i] = dis->readByte();
49 }
50 }
51}
52
53void TexturePacket::write(DataOutputStream *dos) //throws IOException
54{
55 dos->writeUTF(textureName);
56 dos->writeShort((short)dwBytes);
57 for(DWORD i=0;i<dwBytes;i++)
58 {
59 dos->writeByte(this->pbData[i]);
60 }
61}
62
63int TexturePacket::getEstimatedSize()
64{
65 return 4096;
66}