diff --git a/Minecraft.World/AddEntityPacket.cpp b/Minecraft.World/AddEntityPacket.cpp index ae330fd1..df03e103 100644 --- a/Minecraft.World/AddEntityPacket.cpp +++ b/Minecraft.World/AddEntityPacket.cpp @@ -5,7 +5,7 @@ #include "net.minecraft.world.entity.h" #include "PacketListener.h" #include "AddEntityPacket.h" - +#include void AddEntityPacket::_init(shared_ptr e, int type, int data, int xp, int yp, int zp, int yRotp, int xRotp) @@ -16,8 +16,15 @@ void AddEntityPacket::_init(shared_ptr e, int type, int data, int xp, in x = xp;//(int) floor(e->x * 32); y = yp;//(int) floor(e->y * 32); z = zp;//(int) floor(e->z * 32); - yRot = yRotp; + +#ifdef _WIN32 + yRot = yRotp; xRot = xRotp; +#else + yRot = static_cast(yRotp); + xRot = static_cast(xRotp); +#endif + this->type = type; this->data = data; if (data > -1) // 4J - changed "no data" value to be -1, we can have a valid entity id of 0 @@ -38,7 +45,7 @@ void AddEntityPacket::_init(shared_ptr e, int type, int data, int xp, in } } -AddEntityPacket::AddEntityPacket() +AddEntityPacket::AddEntityPacket() { } @@ -47,7 +54,7 @@ AddEntityPacket::AddEntityPacket(shared_ptr e, int type, int yRotp, int _init(e, type, -1, xp, yp, zp, yRotp, xRotp); // 4J - changed "no data" value to be -1, we can have a valid entity id of 0 } -AddEntityPacket::AddEntityPacket(shared_ptr e, int type, int data, int yRotp, int xRotp, int xp, int yp, int zp ) +AddEntityPacket::AddEntityPacket(shared_ptr e, int type, int data, int yRotp, int xRotp, int xp, int yp, int zp ) { _init(e, type, data, xp, yp, zp, yRotp, xRotp); } @@ -55,7 +62,13 @@ AddEntityPacket::AddEntityPacket(shared_ptr e, int type, int data, int y void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J JEV add throws statement { id = dis->readInt(); - type = dis->readByte(); + +#ifdef _WIN32 + type = dis->readByte(); +#else + type = std::to_integer(dis->readByte()); +#endif + #ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readInt(); @@ -79,7 +92,12 @@ void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J JEV add throws statement { dos->writeInt(id); - dos->writeByte(type); +#ifdef _WIN32 + dos->writeByte(type); +#else + dos->writeByte(static_cast(type)); +#endif + #ifdef _LARGE_WORLDS dos->writeInt(x); dos->writeInt(y); @@ -100,12 +118,12 @@ void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J } } -void AddEntityPacket::handle(PacketListener *listener) +void AddEntityPacket::handle(PacketListener *listener) { listener->handleAddEntity(shared_from_this()); } -int AddEntityPacket::getEstimatedSize() +int AddEntityPacket::getEstimatedSize() { #ifdef _LARGE_WORLDS int posSize = 4 + 4 + 4; diff --git a/Minecraft.World/AddGlobalEntityPacket.cpp b/Minecraft.World/AddGlobalEntityPacket.cpp index 9d688f74..b596b061 100644 --- a/Minecraft.World/AddGlobalEntityPacket.cpp +++ b/Minecraft.World/AddGlobalEntityPacket.cpp @@ -7,7 +7,9 @@ #include "PacketListener.h" #include "AddGlobalEntityPacket.h" - +#if defined(__linux__) +#include +#endif const int AddGlobalEntityPacket::LIGHTNING = 1; @@ -20,13 +22,13 @@ AddGlobalEntityPacket::AddGlobalEntityPacket() type = 0; } -AddGlobalEntityPacket::AddGlobalEntityPacket(shared_ptr e) +AddGlobalEntityPacket::AddGlobalEntityPacket(shared_ptr e) { id = e->entityId; x = Mth::floor(e->x * 32); y = Mth::floor(e->y * 32); z = Mth::floor(e->z * 32); - if ( e->instanceof(eTYPE_LIGHTNINGBOLT) ) + if ( e->instanceof(eTYPE_LIGHTNINGBOLT) ) { type = LIGHTNING; } @@ -39,16 +41,28 @@ AddGlobalEntityPacket::AddGlobalEntityPacket(shared_ptr e) void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException { id = dis->readInt(); + +#ifdef _WIN32 type = dis->readByte(); +#else + type = std::to_integer(dis->readByte()); +#endif + x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); } -void AddGlobalEntityPacket::write(DataOutputStream *dos) // throws IOException +void AddGlobalEntityPacket::write(DataOutputStream *dos) // throws IOException { dos->writeInt(id); + +#ifdef _WIN32 dos->writeByte(type); +#else + dos->writeByte(static_cast(type)); +#endif + dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); diff --git a/Minecraft.World/AddMobPacket.cpp b/Minecraft.World/AddMobPacket.cpp index 8aca1055..fec9a7ea 100644 --- a/Minecraft.World/AddMobPacket.cpp +++ b/Minecraft.World/AddMobPacket.cpp @@ -14,8 +14,16 @@ AddMobPacket::AddMobPacket() x = 0; y = 0; z = 0; - yRot = 0; + +#ifdef _WIN32 + yRot = 0; xRot = 0; +#else + yRot = static_cast(0); + xRot = static_cast(0); +#endif + + entityData = nullptr; unpack = nullptr; } @@ -29,16 +37,29 @@ AddMobPacket::AddMobPacket(shared_ptr mob, int yRotp, int xRotp, i { id = mob->entityId; - type = static_cast(EntityIO::getId(mob)); +#ifdef _WIN32 + type = static_cast(EntityIO::getId(mob)); +#else + type = static_cast(EntityIO::getId(mob)); +#endif + // 4J Stu - We should add entities at their "last sent" position so that the relative update packets // put them in the correct place x = xp;//Mth::floor(mob->x * 32); y = yp;//Mth::floor(mob->y * 32); z = zp;//Mth::floor(mob->z * 32); // 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients - yRot = yRotp; + +#ifdef _WIN32 + yRot = yRotp; xRot = xRotp; yHeadRot = yHeadRotp; +#else + yRot = static_cast(yRotp); + xRot = static_cast(xRotp); + yHeadRot = static_cast(yHeadRotp); +#endif + // yRot = (byte) (mob->yRot * 256 / 360); // xRot = (byte) (mob->xRot * 256 / 360); // yHeadRot = (byte) (mob->yHeadRot * 256 / 360); @@ -67,7 +88,12 @@ AddMobPacket::AddMobPacket(shared_ptr mob, int yRotp, int xRotp, i void AddMobPacket::read(DataInputStream *dis) //throws IOException { id = dis->readInt(); - type = dis->readByte() & 0xff; +#ifdef _WIN32 + type = dis->readByte() & 0xff; +#else + type = std::to_integer(dis->readByte()) & 0xff; +#endif + #ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readInt(); @@ -91,7 +117,13 @@ void AddMobPacket::read(DataInputStream *dis) //throws IOException void AddMobPacket::write(DataOutputStream *dos) //throws IOException { dos->writeInt(id); - dos->writeByte(type & 0xff); + +#ifdef _WIN32 + dos->writeByte(type & 0xff); +#else + dos->writeByte(static_cast(type & 0xff)); +#endif + #ifdef _LARGE_WORLDS dos->writeInt(x); dos->writeInt(y); @@ -115,7 +147,7 @@ void AddMobPacket::handle(PacketListener *listener) listener->handleAddMob(shared_from_this()); } -int AddMobPacket::getEstimatedSize() +int AddMobPacket::getEstimatedSize() { int size = 11; if( entityData != nullptr ) @@ -130,7 +162,7 @@ int AddMobPacket::getEstimatedSize() return size + 2; } -vector > *AddMobPacket::getUnpackedData() +vector > *AddMobPacket::getUnpackedData() { if (unpack == nullptr) { diff --git a/Minecraft.World/AddPlayerPacket.cpp b/Minecraft.World/AddPlayerPacket.cpp index fbee1fc5..6cb954c1 100644 --- a/Minecraft.World/AddPlayerPacket.cpp +++ b/Minecraft.World/AddPlayerPacket.cpp @@ -32,7 +32,7 @@ AddPlayerPacket::~AddPlayerPacket() if(unpack != nullptr) delete unpack; } -AddPlayerPacket::AddPlayerPacket(shared_ptr player, PlayerUID xuid, PlayerUID OnlineXuid,int xp, int yp, int zp, int yRotp, int xRotp, int yHeadRotp) +AddPlayerPacket::AddPlayerPacket(shared_ptr player, PlayerUID xuid, PlayerUID OnlineXuid,int xp, int yp, int zp, int yRotp, int xRotp, int yHeadRotp) { id = player->entityId; name = player->getName(); @@ -44,11 +44,12 @@ AddPlayerPacket::AddPlayerPacket(shared_ptr player, PlayerUID xuid, Play // 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients yRot = yRotp; xRot = xRotp; - yHeadRot = yHeadRotp; // 4J Added - // yRot = (byte) (player->yRot * 256 / 360); - // xRot = (byte) (player->xRot * 256 / 360); - //printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot); +#ifdef _WIN32 + yHeadRot = yHeadRotp; +#else + yHeadRot = static_cast(yHeadRotp); +#endif shared_ptr itemInstance = player->inventory->getSelected(); carriedItem = itemInstance == nullptr ? 0 : itemInstance->id; @@ -71,15 +72,25 @@ void AddPlayerPacket::read(DataInputStream *dis) //throws IOException x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); - yRot = dis->readByte(); - xRot = dis->readByte(); +#ifdef _WIN32 + yRot = dis->readByte(); + xRot = dis->readByte(); +#else + yRot = static_cast(dis->readByte()); + xRot = static_cast(dis->readByte()); +#endif + yHeadRot = dis->readByte(); // 4J Added carriedItem = dis->readShort(); xuid = dis->readPlayerUID(); OnlineXuid = dis->readPlayerUID(); - m_playerIndex = dis->readByte(); +#ifdef _WIN32 + m_playerIndex = dis->readByte(); +#else + m_playerIndex = static_cast(dis->readByte()); +#endif INT skinId = dis->readInt(); - m_skinId = *(DWORD *)&skinId; + m_skinId = *(DWORD *)&skinId; INT capeId = dis->readInt(); m_capeId = *(DWORD *)&capeId; INT privileges = dis->readInt(); @@ -96,13 +107,27 @@ void AddPlayerPacket::write(DataOutputStream *dos) //throws IOException dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); - dos->writeByte(yRot); + +#ifdef _WIN32 + dos->writeByte(yRot); dos->writeByte(xRot); - dos->writeByte(yHeadRot); // 4J Added + dos->writeByte(yHeadRot); +#else + dos->writeByte(static_cast(yRot)); + dos->writeByte(static_cast(xRot)); + dos->writeByte(static_cast(m_playerIndex)); +#endif + + dos->writeShort(carriedItem); dos->writePlayerUID(xuid); dos->writePlayerUID(OnlineXuid); - dos->writeByte(m_playerIndex); + +#ifdef _WIN32 + dos->writeByte(m_playerIndex); +#else + dos->writeByte(static_cast(m_playerIndex)); +#endif dos->writeInt(m_skinId); dos->writeInt(m_capeId); dos->writeInt(m_uiGamePrivileges); @@ -132,7 +157,7 @@ int AddPlayerPacket::getEstimatedSize() return iSize; } -vector > *AddPlayerPacket::getUnpackedData() +vector > *AddPlayerPacket::getUnpackedData() { if (unpack == nullptr) { diff --git a/Minecraft.World/Command.cpp b/Minecraft.World/Command.cpp index 3816d69e..e91bd0df 100644 --- a/Minecraft.World/Command.cpp +++ b/Minecraft.World/Command.cpp @@ -47,4 +47,4 @@ shared_ptr Command::getPlayer(PlayerUID playerId) { return player; } -} \ No newline at end of file +} diff --git a/Minecraft.World/CommandDispatcher.cpp b/Minecraft.World/CommandDispatcher.cpp index 45b3f5fe..1e6cba90 100644 --- a/Minecraft.World/CommandDispatcher.cpp +++ b/Minecraft.World/CommandDispatcher.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "net.minecraft.commands.h" #include "CommandDispatcher.h" +#include "../Minecraft.Client/Windows64/Windows64_App.h" int CommandDispatcher::performCommand(shared_ptr sender, EGameCommand command, byteArray commandData) { @@ -33,4 +34,4 @@ Command *CommandDispatcher::addCommand(Command *command) commandsById[command->getId()] = command; commands.insert(command); return command; -} \ No newline at end of file +} diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index 0fd66688..f0dcf795 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -19,14 +19,20 @@ int Connection::writeThreads = 0; int Connection::readSizes[256]; int Connection::writeSizes[256]; - +#if defined(__linux__) +#define INFINITE 999999999 +#define WAIT_TIMEOUT 258 +#include +#endif //__linux__ void Connection::_init() { // printf("Con:0x%x init\n",this); +#if !defined(__linux__) InitializeCriticalSection(&writeLock); InitializeCriticalSection(&threadCounterLock); InitializeCriticalSection(&incoming_cs); +#endif running = true; quitting = false; @@ -54,11 +60,11 @@ Connection::~Connection() // may get stuck whilst blocking waiting on a read readThread->WaitForCompletion(INFINITE); writeThread->WaitForCompletion(INFINITE); - +#if defined(__linux__) DeleteCriticalSection(&writeLock); DeleteCriticalSection(&threadCounterLock); DeleteCriticalSection(&incoming_cs); - +#endif // __linux__ delete m_hWakeReadThread; delete m_hWakeWriteThread; @@ -99,7 +105,7 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet }*/ dis = new DataInputStream(socket->getInputStream(packetListener->isServerPacketListener())); - + sos = socket->getOutputStream(packetListener->isServerPacketListener()); bufferedDos = new DataOutputStream(new BufferedOutputStream(sos, SEND_BUFFER_SIZE)); baos = new ByteArrayOutputStream( SEND_BUFFER_SIZE ); @@ -127,7 +133,7 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet writeThread->Run(); - /* 4J JEV, java: + /* 4J JEV, java: new Thread(wstring(id).append(L" read thread")) { }; @@ -183,7 +189,7 @@ void Connection::send(shared_ptr packet) message.createTime = packet->createTime; message.isRaw = false; message.isSlow = packet->shouldDelay; - if (packet->shouldDelay) + if (packet->shouldDelay) { // 4J We have delayed it enough by putting it in the slow queue, so don't delay when we actually send it packet->shouldDelay = false; @@ -326,7 +332,7 @@ bool Connection::readTick() } LeaveCriticalSection(&incoming_cs); didSomething = true; - } + } else { // printf("Con:0x%x readTick close EOS\n",this); @@ -386,7 +392,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) // int count = 0, sum = 0, i = first; // va_list marker; - // + // // va_start( marker, first ); // while( i != -1 ) // { @@ -629,13 +635,13 @@ int Connection::runWrite(void* lpParam) // Otherwise there is a race between the calling thread setting the running flag and this loop checking the condition DWORD waitResult = WAIT_TIMEOUT; - while ((con->running || waitResult == WAIT_OBJECT_0 ) && ShutdownManager::ShouldRun(ShutdownManager::eConnectionWriteThreads)) + while ((con->running || waitResult == 0 ) && ShutdownManager::ShouldRun(ShutdownManager::eConnectionWriteThreads)) { while (con->writeTick()) ; - //Sleep(100L); - // TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well + //Sleep(100L); + // TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well waitResult = con->m_hWakeWriteThread->WaitForSignal(100L); if (con->bufferedDos != nullptr) con->bufferedDos->flush(); @@ -660,7 +666,12 @@ int Connection::runClose(void* lpParam) //try { - Sleep(2000); +#ifdef _WIN32 + Sleep(2000); +#else + sleep(2000); +#endif + if (con->running) { // 4J TODO writeThread.interrupt(); @@ -683,8 +694,12 @@ int Connection::runSendAndQuit(void* lpParam) if (con == nullptr) return 0; //try { - +#ifdef _WIN32 Sleep(2000); +#else + sleep(2000); +#endif + if (con->running) { // 4J TODO writeThread.interrupt(); diff --git a/Minecraft.World/EnchantItemCommand.cpp b/Minecraft.World/EnchantItemCommand.cpp index 9c0efbb9..de234629 100644 --- a/Minecraft.World/EnchantItemCommand.cpp +++ b/Minecraft.World/EnchantItemCommand.cpp @@ -82,4 +82,4 @@ shared_ptr EnchantItemCommand::preparePacket(shared_ptr(eGameCommand_EnchantItem, baos.toByteArray()); -} \ No newline at end of file +} diff --git a/Minecraft.World/ExperienceCommand.cpp b/Minecraft.World/ExperienceCommand.cpp index 94200d34..4e8b5880 100644 --- a/Minecraft.World/ExperienceCommand.cpp +++ b/Minecraft.World/ExperienceCommand.cpp @@ -56,4 +56,4 @@ void ExperienceCommand::execute(shared_ptr source, byteArray comm // } // // throw new UsageException("commands.xp.usage"); -} \ No newline at end of file +} diff --git a/Minecraft.World/FileOutputStream.cpp b/Minecraft.World/FileOutputStream.cpp index 58a0ecd9..3dec4267 100644 --- a/Minecraft.World/FileOutputStream.cpp +++ b/Minecraft.World/FileOutputStream.cpp @@ -1,6 +1,16 @@ #include "stdafx.h" #include "File.h" #include "FileOutputStream.h" +#include +#include +#include +#include +#include +#include + +#if defined(__linux__) +#include +#endif //Creates a file output stream to write to the file represented by the specified File object. A new FileDescriptor object is //created to represent this file connection. @@ -29,6 +39,13 @@ FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HAN FILE_ATTRIBUTE_NORMAL , // file attributes nullptr // Unsupported ); +#elif defined(__linux__) + std::wstring path = file.getPath(); + char* convertedPath = new char[path.size() + 1]; + std::wcstombs(convertedPath, path.c_str(), path.size() + 1); + + m_fileHandle = open(convertedPath, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); + delete[] convertedPath; #else m_fileHandle = CreateFile( wstringtofilename(file.getPath()) , // file name @@ -43,26 +60,33 @@ FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HAN if( m_fileHandle == INVALID_HANDLE_VALUE ) { - DWORD error = GetLastError(); // TODO 4J Stu - Any form of error/exception handling +#ifndef __linux__ + DWORD error = GetLastError(); +#endif // __linux__ } } FileOutputStream::~FileOutputStream() { +#ifdef _WIN32 if( m_fileHandle != INVALID_HANDLE_VALUE ) CloseHandle( m_fileHandle ); +#else + if( m_fileHandle != INVALID_HANDLE_VALUE ) + ::close( m_fileHandle ); +#endif } //Writes the specified byte to this file output stream. Implements the write method of OutputStream. //Parameters: //b - the byte to be written. void FileOutputStream::write(unsigned int b) -{ - DWORD numberOfBytesWritten; - +{ byte value = static_cast(b); +#if defined(_WIN32) + DWORD numberOfBytesWritten; BOOL result = WriteFile( m_fileHandle, // handle to file &value, // data buffer @@ -70,6 +94,11 @@ void FileOutputStream::write(unsigned int b) &numberOfBytesWritten, // number of bytes written nullptr // overlapped buffer ); +#else // LINUX + int fileDescriptor = reinterpret_cast(m_fileHandle); + ssize_t numberOfBytesWritten = ::write(fileDescriptor, NULL, 1); + int result = static_cast(numberOfBytesWritten); +#endif // _WIN32 if( result == 0 ) { @@ -86,8 +115,8 @@ void FileOutputStream::write(unsigned int b) //b - the data. void FileOutputStream::write(byteArray b) { - DWORD numberOfBytesWritten; - +#if defined(_WIN32) + DWORD numberOfBytesWritten; BOOL result = WriteFile( m_fileHandle, // handle to file &b.data, // data buffer @@ -95,6 +124,11 @@ void FileOutputStream::write(byteArray b) &numberOfBytesWritten, // number of bytes written nullptr // overlapped buffer ); +#else // Linux + int fileDescriptor = reinterpret_cast(m_fileHandle); + ssize_t numberOfBytesWritten = ::write(fileDescriptor, NULL, 1); + int result = static_cast(numberOfBytesWritten); +#endif // _WIN32 if( result == 0 ) { @@ -116,6 +150,7 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng // 4J Stu - We don't want to write any more than the array buffer holds assert( length <= ( b.length - offset ) ); +#if defined(_WIN32) DWORD numberOfBytesWritten; BOOL result = WriteFile( @@ -125,6 +160,11 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng &numberOfBytesWritten, // number of bytes written nullptr // overlapped buffer ); +#else + int fileDescriptor = reinterpret_cast(m_fileHandle); + ssize_t numberOfBytesWritten = ::write(fileDescriptor, static_cast(&b[offset]), length); + int result = static_cast(numberOfBytesWritten); +#endif // _WIN32 if( result == 0 ) { @@ -141,8 +181,11 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng //If this stream has an associated channel then the channel is closed as well. void FileOutputStream::close() { +#ifdef _WIN32 BOOL result = CloseHandle( m_fileHandle ); - +#else // __linux__ + int result = ::close( m_fileHandle ); +#endif // _WIN32 if( result == 0 ) { // TODO 4J Stu - Some kind of error handling diff --git a/Minecraft.World/Minecraft.World.cpp b/Minecraft.World/Minecraft.World.cpp index 3e9cb16d..09dd25d3 100644 --- a/Minecraft.World/Minecraft.World.cpp +++ b/Minecraft.World/Minecraft.World.cpp @@ -18,6 +18,11 @@ #include "../Minecraft.Client/ServerLevel.h" #include "LootTableManager.h" +#include "SparseLightStorage.h" +#include "SparseDataStorage.h" +#include "McRegionChunkStorage.h" +#include "Villager.h" +#include "LevelSettings.h" #ifdef _DURANGO #include "DurangoStats.h" @@ -50,7 +55,7 @@ void MinecraftWorld_RunStaticCtors() MobEffect::staticCtor(); Item::staticCtor(); FurnaceRecipes::staticCtor(); - Recipes::staticCtor(); + Recipes::staticCtor(); #ifdef _DURANGO GenericStats::setInstance(new DurangoStats()); #else diff --git a/Minecraft.World/Stat.h b/Minecraft.World/Stat.h index 3c2ab071..e4690077 100644 --- a/Minecraft.World/Stat.h +++ b/Minecraft.World/Stat.h @@ -4,6 +4,8 @@ using namespace std; #include "StatFormatter.h" #include "GenericStats.h" +#include "../Minecraft.Client/Windows64/Windows64_App.h" + class DecimalFormat; class Stat diff --git a/Minecraft.World/Tag.cpp b/Minecraft.World/Tag.cpp index 30273537..63944ac4 100644 --- a/Minecraft.World/Tag.cpp +++ b/Minecraft.World/Tag.cpp @@ -11,6 +11,7 @@ #include "StringTag.h" #include "ListTag.h" #include "CompoundTag.h" +#include "../Minecraft.Client/Windows64/Windows64_App.h" Tag::Tag(const wstring &name) { @@ -109,13 +110,13 @@ Tag *Tag::readNamedTag(DataInput *dis, int tagDepth) } byte type = dis->readByte(); - if (type == 0) { - depth--; - return new EndTag(); + if (static_cast(type) == 0) { + depth--; + return new EndTag(); } // 4J Stu - readByte can return -1, so if it's that then also mark as the end tag - if(type == 255) + if(static_cast(type) == 255) { depth--; return new EndTag(); @@ -124,8 +125,8 @@ Tag *Tag::readNamedTag(DataInput *dis, int tagDepth) wstring name = dis->readUTF();//new String(bytes, "UTF-8"); Tag *tag = newTag(type, name); - if (tag == nullptr) { - depth--; + if (tag == nullptr) { + depth--; return new EndTag(); } // short length = dis.readShort(); @@ -212,4 +213,4 @@ const wchar_t *Tag::getTagName(byte type) return L"TAG_Compound"; } return L"UNKNOWN"; -} \ No newline at end of file +} diff --git a/Minecraft.World/TextureAndGeometryPacket.h b/Minecraft.World/TextureAndGeometryPacket.h index 245edd2a..bcbd6bd0 100644 --- a/Minecraft.World/TextureAndGeometryPacket.h +++ b/Minecraft.World/TextureAndGeometryPacket.h @@ -23,9 +23,9 @@ public: TextureAndGeometryPacket(); ~TextureAndGeometryPacket(); - TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes); - TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, DLCSkinFile *pDLCSkinFile); - TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, vector *pvSkinOffsets, unsigned int uiAnimOverrideBitmask); + TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes); + TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, DLCSkinFile *pDLCSkinFile); + TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector *pvSkinBoxes, vector *pvSkinOffsets, unsigned int uiAnimOverrideBitmask); virtual void handle(PacketListener *listener); virtual void read(DataInputStream *dis); @@ -35,4 +35,4 @@ public: public: static shared_ptr create() { return shared_ptr(new TextureAndGeometryPacket()); } virtual int getId() { return 160; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/TileEntity.h b/Minecraft.World/TileEntity.h index f71f8b7f..a4e8efd7 100644 --- a/Minecraft.World/TileEntity.h +++ b/Minecraft.World/TileEntity.h @@ -73,4 +73,4 @@ public: virtual shared_ptr clone() = 0; protected: void clone(shared_ptr tileEntity); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/ToggleDownfallCommand.cpp b/Minecraft.World/ToggleDownfallCommand.cpp index f90b145a..d709b2b4 100644 --- a/Minecraft.World/ToggleDownfallCommand.cpp +++ b/Minecraft.World/ToggleDownfallCommand.cpp @@ -32,4 +32,4 @@ void ToggleDownfallCommand::doToggleDownfall() shared_ptr ToggleDownfallCommand::preparePacket() { return std::make_shared(eGameCommand_ToggleDownfall, byteArray()); -} \ No newline at end of file +} diff --git a/Minecraft.World/compression.cpp b/Minecraft.World/compression.cpp index 1a6dbd16..6cd59776 100644 --- a/Minecraft.World/compression.cpp +++ b/Minecraft.World/compression.cpp @@ -4,12 +4,20 @@ #include "../Minecraft.Client/Common/zlib/zlib.h" #endif +#if defined(__linux__) +#include "../Minecraft.Client/Common/zlib/zlib.h" +#include // TLS shit +#endif // __linux__ + #if defined __PSVITA__ #include "../Minecraft.Client/PSVita/PSVitaExtras/zlib.h" #elif defined __PS3__ #include "../Minecraft.Client/PS3/PS3Extras/EdgeZLib.h" #endif //__PS3__ +#if defined(__linux__) +#define S_OK 0 +#endif // __linux__ DWORD Compression::tlsIdx = 0; Compression::ThreadStorage *Compression::tlsDefault = nullptr; @@ -27,22 +35,40 @@ Compression::ThreadStorage::~ThreadStorage() void Compression::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == nullptr ) + if (tlsDefault == nullptr) { - tlsIdx = TlsAlloc(); +#ifdef _WIN32 + tlsIdx = TlsAlloc(); tlsDefault = tls; +#else + pthread_key_create(&tlsIdx, nullptr); + tlsDefault = tls; +#endif } +#ifdef _WIN32 TlsSetValue(tlsIdx, tls); +#else + pthread_setspecific(tlsIdx, tls); +#endif } void Compression::UseDefaultThreadStorage() { - TlsSetValue(tlsIdx, tlsDefault); +#ifdef _WIN32 + TlsSetValue(tlsIdx, tlsDefault); +#else + pthread_setspecific(tlsIdx, tlsDefault); +#endif } void Compression::ReleaseThreadStorage() { + #ifdef _WIN32 const ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); + #else // Linux + const ThreadStorage *tls = static_cast(pthread_getspecific(tlsIdx)); + #endif // _WIN32 + if( tls == tlsDefault ) return; delete tls; @@ -50,7 +76,12 @@ void Compression::ReleaseThreadStorage() Compression *Compression::getCompression() { + #ifdef _WIN32 const ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); + #else // Linux + const ThreadStorage *tls = static_cast(pthread_getspecific(tlsIdx)); + #endif // _WIN32 + if (!tls) { return nullptr; } @@ -333,7 +364,7 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) { EnterCriticalSection(&rleDecompressLock); - + //unsigned char *pucIn = (unsigned char *)rleDecompressBuf; unsigned char *pucIn = static_cast(pSource); const unsigned char *pucEnd = pucIn + SrcSize; @@ -507,7 +538,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS #endif case eCompressionType_PS3ZLIB: #if (defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WIN64) - // Note that we're missing the normal zlib header and footer so we'll use inflate to + // Note that we're missing the normal zlib header and footer so we'll use inflate to // decompress the payload and skip all the CRC checking, etc if (pDestination != nullptr) { @@ -559,12 +590,12 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS return S_OK; } else break; // Cannot decompress when destination is nullptr -#else +#else assert(0); #endif } - assert(false); + assert(false); return -1; } @@ -594,8 +625,10 @@ Compression::Compression() #endif m_decompressType = m_localDecompressType; +#ifndef __linux__ InitializeCriticalSection(&rleCompressLock); InitializeCriticalSection(&rleDecompressLock); +#endif // __linux__ } Compression::~Compression() @@ -634,5 +667,3 @@ void Compression::SetDecompressionType(ESavePlatform platform) } /*Compression gCompression;*/ - - diff --git a/Minecraft.World/net.minecraft.world.item.h b/Minecraft.World/net.minecraft.world.item.h index 5ad6efff..8d0462f1 100644 --- a/Minecraft.World/net.minecraft.world.item.h +++ b/Minecraft.World/net.minecraft.world.item.h @@ -93,4 +93,4 @@ #include "CompassItem.h" #include "HtmlString.h" -#include "FishFoodItem.h" \ No newline at end of file +#include "FishFoodItem.h"