mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-07-07 06:17:03 +00:00
Remove Win32 byte types from texture packets
This commit is contained in:
parent
6026f078ac
commit
474d8b2896
|
|
@ -2235,7 +2235,7 @@ void ClientConnection::handleTexture(std::shared_ptr<TexturePacket> packet)
|
|||
// Server side also needs to store a list of those clients waiting to get a texture the server doesn't have yet
|
||||
// so that it can send it out to them when it comes in
|
||||
|
||||
if(packet->dwBytes==0)
|
||||
if(packet->dataBytes==0)
|
||||
{
|
||||
// Request for texture
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
|
|
@ -2256,7 +2256,7 @@ void ClientConnection::handleTexture(std::shared_ptr<TexturePacket> packet)
|
|||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(L"Client received custom texture %ls\n",packet->textureName.c_str());
|
||||
#endif
|
||||
app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dwBytes);
|
||||
app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dataBytes);
|
||||
Minecraft::GetInstance()->handleClientTextureReceived(packet->textureName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -796,7 +796,7 @@ void PlayerConnection::handleTexture(std::shared_ptr<TexturePacket> packet)
|
|||
{
|
||||
// Both PlayerConnection and ClientConnection should handle this mostly the same way
|
||||
|
||||
if(packet->dwBytes==0)
|
||||
if(packet->dataBytes==0)
|
||||
{
|
||||
// Request for texture
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
|
|
@ -821,7 +821,7 @@ void PlayerConnection::handleTexture(std::shared_ptr<TexturePacket> packet)
|
|||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(L"Server received custom texture %ls\n",packet->textureName.c_str());
|
||||
#endif
|
||||
app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dwBytes);
|
||||
app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dataBytes);
|
||||
server->connection->handleTextureReceived(packet->textureName);
|
||||
}
|
||||
}
|
||||
|
|
@ -1714,4 +1714,4 @@ bool PlayerConnection::isGuest()
|
|||
}
|
||||
return isGuest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
TexturePacket::TexturePacket()
|
||||
{
|
||||
this->textureName = L"";
|
||||
this->dwBytes = 0;
|
||||
this->dataBytes = 0;
|
||||
this->pbData = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -22,11 +22,11 @@ TexturePacket::~TexturePacket()
|
|||
// }
|
||||
}
|
||||
|
||||
TexturePacket::TexturePacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes)
|
||||
TexturePacket::TexturePacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes)
|
||||
{
|
||||
this->textureName = textureName;
|
||||
this->pbData = pbData;
|
||||
this->dwBytes = dwBytes;
|
||||
this->dataBytes = dataBytes;
|
||||
}
|
||||
|
||||
void TexturePacket::handle(PacketListener *listener)
|
||||
|
|
@ -37,13 +37,13 @@ void TexturePacket::handle(PacketListener *listener)
|
|||
void TexturePacket::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
textureName = dis->readUTF();
|
||||
dwBytes = (DWORD)dis->readShort();
|
||||
dataBytes = (std::uint32_t)dis->readShort();
|
||||
|
||||
if(dwBytes>0)
|
||||
if(dataBytes>0)
|
||||
{
|
||||
this->pbData= new BYTE [dwBytes];
|
||||
this->pbData= new std::uint8_t [dataBytes];
|
||||
|
||||
for(DWORD i=0;i<dwBytes;i++)
|
||||
for(std::uint32_t i=0;i<dataBytes;i++)
|
||||
{
|
||||
this->pbData[i] = dis->readByte();
|
||||
}
|
||||
|
|
@ -53,8 +53,8 @@ void TexturePacket::read(DataInputStream *dis) //throws IOException
|
|||
void TexturePacket::write(DataOutputStream *dos) //throws IOException
|
||||
{
|
||||
dos->writeUTF(textureName);
|
||||
dos->writeShort((short)dwBytes);
|
||||
for(DWORD i=0;i<dwBytes;i++)
|
||||
dos->writeShort((short)dataBytes);
|
||||
for(std::uint32_t i=0;i<dataBytes;i++)
|
||||
{
|
||||
dos->writeByte(this->pbData[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "Packet.h"
|
||||
|
||||
|
|
@ -7,12 +7,12 @@ class TexturePacket : public Packet, public std::enable_shared_from_this<Texture
|
|||
{
|
||||
public:
|
||||
std::wstring textureName;
|
||||
PBYTE pbData;
|
||||
DWORD dwBytes;
|
||||
std::uint8_t *pbData;
|
||||
std::uint32_t dataBytes;
|
||||
|
||||
TexturePacket();
|
||||
~TexturePacket();
|
||||
TexturePacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes);
|
||||
TexturePacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes);
|
||||
|
||||
virtual void handle(PacketListener *listener);
|
||||
virtual void read(DataInputStream *dis);
|
||||
|
|
@ -22,4 +22,4 @@ public:
|
|||
public:
|
||||
static std::shared_ptr<Packet> create() { return std::shared_ptr<Packet>(new TexturePacket()); }
|
||||
virtual int getId() { return 154; }
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue