diff --git a/Minecraft.World/AddEntityPacket.cpp b/Minecraft.World/AddEntityPacket.cpp index 6231537d6..acacbb37a 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,8 @@ 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; - xRot = xRotp; + yRot = static_cast(yRotp); + xRot = static_cast(xRotp); 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 @@ -55,7 +55,7 @@ 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->readShort(); - type = dis->readByte(); + type = std::to_integer(dis->readByte()); #ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readInt(); @@ -79,7 +79,7 @@ void AddEntityPacket::read(DataInputStream *dis) // throws IOException TODO 4J void AddEntityPacket::write(DataOutputStream *dos) // throws IOException TODO 4J JEV add throws statement { dos->writeShort(id); - dos->writeByte(type); + dos->writeByte(static_cast(type)); #ifdef _LARGE_WORLDS dos->writeInt(x); dos->writeInt(y); diff --git a/Minecraft.World/AddGlobalEntityPacket.cpp b/Minecraft.World/AddGlobalEntityPacket.cpp index bfb27331d..d1111aa4d 100644 --- a/Minecraft.World/AddGlobalEntityPacket.cpp +++ b/Minecraft.World/AddGlobalEntityPacket.cpp @@ -39,7 +39,7 @@ AddGlobalEntityPacket::AddGlobalEntityPacket(shared_ptr e) void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException { id = dis->readInt(); - type = dis->readByte(); + type = std::to_integer(dis->readByte()); x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); @@ -48,7 +48,7 @@ void AddGlobalEntityPacket::read(DataInputStream *dis) // throws IOException void AddGlobalEntityPacket::write(DataOutputStream *dos) // throws IOException { dos->writeInt(id); - dos->writeByte(type); + dos->writeByte(static_cast(type)); dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); diff --git a/Minecraft.World/AddMobPacket.cpp b/Minecraft.World/AddMobPacket.cpp index 7e744c047..05e37056e 100644 --- a/Minecraft.World/AddMobPacket.cpp +++ b/Minecraft.World/AddMobPacket.cpp @@ -14,8 +14,8 @@ AddMobPacket::AddMobPacket() x = 0; y = 0; z = 0; - yRot = 0; - xRot = 0; + yRot = static_cast(0); + xRot = static_cast(0); entityData = nullptr; unpack = NULL; } @@ -29,16 +29,16 @@ AddMobPacket::AddMobPacket(shared_ptr mob, int yRotp, int xRotp, int xp, in { id = mob->entityId; - type = (byte) EntityIO::getId(mob); + type = EntityIO::getId(mob); // 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; - xRot = xRotp; - yHeadRot = yHeadRotp; + yRot = static_cast(yRotp); + xRot = static_cast(xRotp); + yHeadRot = static_cast(yHeadRotp); // yRot = (byte) (mob->yRot * 256 / 360); // xRot = (byte) (mob->xRot * 256 / 360); // yHeadRot = (byte) (mob->yHeadRot * 256 / 360); @@ -67,7 +67,7 @@ AddMobPacket::AddMobPacket(shared_ptr mob, int yRotp, int xRotp, int xp, in void AddMobPacket::read(DataInputStream *dis) //throws IOException { id = dis->readShort(); - type = dis->readByte() & 0xff; + type = std::to_integer(dis->readByte()) & 0xff; #ifdef _LARGE_WORLDS x = dis->readInt(); y = dis->readInt(); @@ -91,7 +91,7 @@ void AddMobPacket::read(DataInputStream *dis) //throws IOException void AddMobPacket::write(DataOutputStream *dos) //throws IOException { dos->writeShort(id); - dos->writeByte(type & 0xff); + dos->writeByte(static_cast(type & 0xff)); #ifdef _LARGE_WORLDS dos->writeInt(x); dos->writeInt(y); diff --git a/Minecraft.World/AddPlayerPacket.cpp b/Minecraft.World/AddPlayerPacket.cpp index f3d8a32b7..80275391c 100644 --- a/Minecraft.World/AddPlayerPacket.cpp +++ b/Minecraft.World/AddPlayerPacket.cpp @@ -44,7 +44,7 @@ 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 + yHeadRot = static_cast(yHeadRotp); // 4J Added // yRot = (byte) (player->yRot * 256 / 360); // xRot = (byte) (player->xRot * 256 / 360); @@ -71,13 +71,13 @@ void AddPlayerPacket::read(DataInputStream *dis) //throws IOException x = dis->readInt(); y = dis->readInt(); z = dis->readInt(); - yRot = dis->readByte(); - xRot = dis->readByte(); + yRot = static_cast(dis->readByte()); + xRot = static_cast(dis->readByte()); yHeadRot = dis->readByte(); // 4J Added carriedItem = dis->readShort(); xuid = dis->readPlayerUID(); OnlineXuid = dis->readPlayerUID(); - m_playerIndex = dis->readByte(); + m_playerIndex = static_cast(dis->readByte()); INT skinId = dis->readInt(); m_skinId = *(DWORD *)&skinId; INT capeId = dis->readInt(); @@ -96,13 +96,13 @@ void AddPlayerPacket::write(DataOutputStream *dos) //throws IOException dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); - dos->writeByte(yRot); - dos->writeByte(xRot); - dos->writeByte(yHeadRot); // 4J Added + dos->writeByte(static_cast(yRot)); + dos->writeByte(static_cast(xRot)); + dos->writeByte(static_cast(m_playerIndex)); // 4J Added dos->writeShort(carriedItem); dos->writePlayerUID(xuid); dos->writePlayerUID(OnlineXuid); - dos->writeByte(m_playerIndex); + dos->writeByte(static_cast(m_playerIndex)); // 4J Added dos->writeInt(m_skinId); dos->writeInt(m_capeId); dos->writeInt(m_uiGamePrivileges); diff --git a/Minecraft.World/Command.cpp b/Minecraft.World/Command.cpp index f6d0e5929..35ee91a06 100644 --- a/Minecraft.World/Command.cpp +++ b/Minecraft.World/Command.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" #include "net.minecraft.commands.h" -#include "..\Minecraft.Client\MinecraftServer.h" -#include "..\Minecraft.Client\PlayerList.h" -#include "..\Minecraft.Client\ServerPlayer.h" +#include "../Minecraft.Client/MinecraftServer.h" +#include "../Minecraft.Client/PlayerList.h" +#include "../Minecraft.Client/ServerPlayer.h" #include "Command.h" AdminLogCommand *Command::logger; @@ -42,4 +42,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 68b74ca9e..0f494ba49 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" void CommandDispatcher::performCommand(shared_ptr sender, EGameCommand command, byteArray commandData) { @@ -31,4 +32,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 4392fe542..a21ecd0de 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -4,7 +4,7 @@ #include "Connection.h" #include "ThreadName.h" #include "compression.h" -#include "..\Minecraft.Client\PS3\PS3Extras\ShutdownManager.h" +#include "../Minecraft.Client/PS3/PS3Extras/ShutdownManager.h" // This should always be enabled, except for debugging use #ifndef _DEBUG @@ -17,14 +17,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; @@ -51,11 +57,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; @@ -602,7 +608,7 @@ 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()) ; @@ -633,7 +639,7 @@ int Connection::runClose(void* lpParam) //try { - Sleep(2000); + sleep(2000); if (con->running) { // 4J TODO writeThread.interrupt(); @@ -657,7 +663,7 @@ int Connection::runSendAndQuit(void* lpParam) //try { - Sleep(2000); + sleep(2000); if (con->running) { // 4J TODO writeThread.interrupt(); diff --git a/Minecraft.World/EnchantItemCommand.cpp b/Minecraft.World/EnchantItemCommand.cpp index aa02b5336..b5bf6e655 100644 --- a/Minecraft.World/EnchantItemCommand.cpp +++ b/Minecraft.World/EnchantItemCommand.cpp @@ -2,7 +2,7 @@ #include "net.minecraft.network.packet.h" #include "net.minecraft.world.item.h" #include "net.minecraft.world.item.enchantment.h" -#include "..\Minecraft.Client\ServerPlayer.h" +#include "../Minecraft.Client/ServerPlayer.h" #include "EnchantItemCommand.h" EGameCommand EnchantItemCommand::getId() @@ -82,4 +82,4 @@ shared_ptr EnchantItemCommand::preparePacket(shared_ptr( new GameCommandPacket(eGameCommand_EnchantItem, baos.toByteArray() )); -} \ No newline at end of file +} diff --git a/Minecraft.World/ExperienceCommand.cpp b/Minecraft.World/ExperienceCommand.cpp index b8ac2efcb..14cf676c3 100644 --- a/Minecraft.World/ExperienceCommand.cpp +++ b/Minecraft.World/ExperienceCommand.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "net.minecraft.commands.h" -#include "..\Minecraft.Client\MinecraftServer.h" -#include "..\Minecraft.Client\PlayerList.h" +#include "../Minecraft.Client/MinecraftServer.h" +#include "../Minecraft.Client/PlayerList.h" #include "ExperienceCommand.h" EGameCommand ExperienceCommand::getId() @@ -38,4 +38,4 @@ shared_ptr ExperienceCommand::getPlayer(PlayerUID playerId) //} else { // return player; //} -} \ No newline at end of file +} diff --git a/Minecraft.World/FileOutputStream.cpp b/Minecraft.World/FileOutputStream.cpp index 557ba812d..5de8176a8 100644 --- a/Minecraft.World/FileOutputStream.cpp +++ b/Minecraft.World/FileOutputStream.cpp @@ -1,6 +1,14 @@ #include "stdafx.h" #include "File.h" #include "FileOutputStream.h" +#include +#include +#include +#include +#include +#include +#include +#include //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 +37,13 @@ FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HAN FILE_ATTRIBUTE_NORMAL , // file attributes NULL // 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,15 +58,17 @@ 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() { if( m_fileHandle != INVALID_HANDLE_VALUE ) - CloseHandle( m_fileHandle ); + ::close( m_fileHandle ); } //Writes the specified byte to this file output stream. Implements the write method of OutputStream. @@ -59,10 +76,9 @@ FileOutputStream::~FileOutputStream() //b - the byte to be written. void FileOutputStream::write(unsigned int b) { - DWORD numberOfBytesWritten; - byte value = (byte) b; +#if defined(_WIN32) BOOL result = WriteFile( m_fileHandle, // handle to file &value, // data buffer @@ -70,6 +86,11 @@ void FileOutputStream::write(unsigned int b) &numberOfBytesWritten, // number of bytes written NULL // 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 +107,7 @@ void FileOutputStream::write(unsigned int b) //b - the data. void FileOutputStream::write(byteArray b) { - DWORD numberOfBytesWritten; - +#if defined(_WIN32) BOOL result = WriteFile( m_fileHandle, // handle to file &b.data, // data buffer @@ -95,6 +115,11 @@ void FileOutputStream::write(byteArray b) &numberOfBytesWritten, // number of bytes written NULL // 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 +141,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 +151,11 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng &numberOfBytesWritten, // number of bytes written NULL // 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 +172,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/GiveItemCommand.cpp b/Minecraft.World/GiveItemCommand.cpp index 1d13592f4..687e3ae17 100644 --- a/Minecraft.World/GiveItemCommand.cpp +++ b/Minecraft.World/GiveItemCommand.cpp @@ -2,7 +2,7 @@ #include "net.minecraft.commands.h" #include "net.minecraft.world.item.h" #include "net.minecraft.network.packet.h" -#include "..\Minecraft.Client\ServerPlayer.h" +#include "../Minecraft.Client/ServerPlayer.h" #include "GiveItemCommand.h" EGameCommand GiveItemCommand::getId() @@ -47,4 +47,4 @@ shared_ptr GiveItemCommand::preparePacket(shared_ptr dos.writeUTF(tag); return shared_ptr( new GameCommandPacket(eGameCommand_Give, baos.toByteArray() )); -} \ No newline at end of file +} diff --git a/Minecraft.World/Minecraft.World.cpp b/Minecraft.World/Minecraft.World.cpp index 304954438..7854c030f 100644 --- a/Minecraft.World/Minecraft.World.cpp +++ b/Minecraft.World/Minecraft.World.cpp @@ -32,7 +32,7 @@ #include "RandomScatteredLargeFeature.h" #include "Minecraft.World.h" -#include "..\Minecraft.Client\ServerLevel.h" +#include "../Minecraft.Client/ServerLevel.h" #include "SparseLightStorage.h" #include "SparseDataStorage.h" #include "McRegionChunkStorage.h" diff --git a/Minecraft.World/Stat.h b/Minecraft.World/Stat.h index 3c2ab071d..e46900773 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 40da99fef..975d27089 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) { @@ -80,10 +81,10 @@ Tag *Tag::setName(const wstring& name) Tag *Tag::readNamedTag(DataInput *dis) { byte type = dis->readByte(); - if (type == 0) return new EndTag(); + if ( static_cast(type) == 0) 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) { app.DebugPrintf("readNamedTag read a type of 255\n"); #ifndef _CONTENT_PACKAGE @@ -178,4 +179,4 @@ 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 8577f03df..7d998adaa 100644 --- a/Minecraft.World/TextureAndGeometryPacket.h +++ b/Minecraft.World/TextureAndGeometryPacket.h @@ -2,8 +2,8 @@ using namespace std; #include "Packet.h" -#include "..\Minecraft.Client\Model.h" -#include "..\Minecraft.Client\SkinBox.h" +#include "../Minecraft.Client/Model.h" +#include "../Minecraft.Client/SkinBox.h" class DLCSkinFile; @@ -32,4 +32,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 aa3ced4f6..8e016607c 100644 --- a/Minecraft.World/TileEntity.h +++ b/Minecraft.World/TileEntity.h @@ -2,7 +2,7 @@ using namespace std; #include "HashExtension.h" -#include "..\Minecraft.World\JavaIntHash.h" +#include "../Minecraft.World/JavaIntHash.h" class Level; class Packet; @@ -71,4 +71,4 @@ public: virtual shared_ptr clone() = 0; protected: void clone(shared_ptr tileEntity); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/TimeCommand.cpp b/Minecraft.World/TimeCommand.cpp index e667a420a..3069b5590 100644 --- a/Minecraft.World/TimeCommand.cpp +++ b/Minecraft.World/TimeCommand.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "net.minecraft.commands.h" -#include "..\Minecraft.Client\MinecraftServer.h" -#include "..\Minecraft.Client\ServerLevel.h" +#include "../Minecraft.Client/MinecraftServer.h" +#include "../Minecraft.Client/ServerLevel.h" #include "net.minecraft.network.packet.h" #include "TimeCommand.h" @@ -77,4 +77,4 @@ shared_ptr TimeCommand::preparePacket(bool night) dos.writeBoolean(night); return shared_ptr( new GameCommandPacket(eGameCommand_Time, baos.toByteArray() )); -} \ No newline at end of file +} diff --git a/Minecraft.World/ToggleDownfallCommand.cpp b/Minecraft.World/ToggleDownfallCommand.cpp index 1ae2f3a90..83aa39844 100644 --- a/Minecraft.World/ToggleDownfallCommand.cpp +++ b/Minecraft.World/ToggleDownfallCommand.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -#include "..\Minecraft.Client\MinecraftServer.h" -#include "..\Minecraft.Client\ServerLevel.h" +#include "../Minecraft.Client/MinecraftServer.h" +#include "../Minecraft.Client/ServerLevel.h" #include "net.minecraft.commands.h" #include "net.minecraft.world.level.h" #include "net.minecraft.world.level.storage.h" @@ -27,4 +27,4 @@ void ToggleDownfallCommand::doToggleDownfall() shared_ptr ToggleDownfallCommand::preparePacket() { return shared_ptr( new GameCommandPacket(eGameCommand_ToggleDownfall, byteArray() )); -} \ No newline at end of file +} diff --git a/Minecraft.World/compression.cpp b/Minecraft.World/compression.cpp index 99c5228ab..f7315f0bd 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 = NULL; @@ -26,31 +34,32 @@ Compression::ThreadStorage::~ThreadStorage() void Compression::CreateNewThreadStorage() { - ThreadStorage *tls = new ThreadStorage(); - if(tlsDefault == NULL ) + ThreadStorage* tls = new ThreadStorage(); + if (tlsDefault == nullptr) { - tlsIdx = TlsAlloc(); + pthread_key_create(&tlsIdx, nullptr); tlsDefault = tls; } - TlsSetValue(tlsIdx, tls); + pthread_setspecific(tlsIdx, tls); } void Compression::UseDefaultThreadStorage() { - TlsSetValue(tlsIdx, tlsDefault); + pthread_setspecific(tlsIdx, tlsDefault); } void Compression::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); - if( tls == tlsDefault ) return; - - delete tls; + ThreadStorage* tls = (ThreadStorage*)pthread_getspecific(tlsIdx); // POSIX equivalent + if (tls != tlsDefault) + { + delete tls; + } } Compression *Compression::getCompression() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = (ThreadStorage *)pthread_getspecific(tlsIdx); return tls->compression; } @@ -502,8 +511,10 @@ Compression::Compression() #endif m_decompressType = m_localDecompressType; +#ifndef __linux__ InitializeCriticalSection(&rleCompressLock); InitializeCriticalSection(&rleDecompressLock); +#endif // __linux__ } Compression::~Compression() diff --git a/Minecraft.World/net.minecraft.world.item.h b/Minecraft.World/net.minecraft.world.item.h index 0300b9547..221a4a4e3 100644 --- a/Minecraft.World/net.minecraft.world.item.h +++ b/Minecraft.World/net.minecraft.world.item.h @@ -34,7 +34,7 @@ #include "ShearsItem.h" #include "ShovelItem.h" #include "SignItem.h" -#include "SnowBallItem.h" +#include "SnowballItem.h" #include "StoneSlabTileItem.h" #include "TileItem.h" #include "TilePlanterItem.h" @@ -77,4 +77,4 @@ // 4J Added #include "ClockItem.h" -#include "CompassItem.h" \ No newline at end of file +#include "CompassItem.h"