From 7abf08a804a4b1e76e2209255a0e121a01af94d5 Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 3 Mar 2026 18:16:42 -0600 Subject: [PATCH] refactor: remove a bunch of linux-specific ifndefs Now that we're stubbing winapi through stdafx, these need to go. --- .../Common/Audio/Consoles_SoundEngine.h | 2 +- Minecraft.Client/Common/Audio/SoundEngine.h | 6 - .../UI/IUIScene_AbstractContainerMenu.cpp | 3 - Minecraft.Client/Linux/Stubs/LinuxStubs.h | 25 ++++ Minecraft.Client/Linux/Stubs/winapi_stubs.h | 56 ++++--- .../Windows64/Miles/include/mss.h | 2 +- Minecraft.World/Connection.cpp | 8 +- Minecraft.World/ConsoleSaveFileOriginal.cpp | 138 +++++------------- Minecraft.World/File.cpp | 14 -- Minecraft.World/FileOutputStream.cpp | 2 - Minecraft.World/Socket.cpp | 28 ---- Minecraft.World/compression.cpp | 13 +- 12 files changed, 98 insertions(+), 199 deletions(-) diff --git a/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h b/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h index 52ff1dbb9..ff6f5c466 100644 --- a/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h +++ b/Minecraft.Client/Common/Audio/Consoles_SoundEngine.h @@ -18,7 +18,7 @@ #include "../../windows64/Miles/include/mss.h" #elif defined(__linux__) // (DecalOverdose)HACK + TODO: Find native Linux headers and libs for this, but for now I'm using Win64 ones -// #include "../../windows64/Miles/include/mss.h" +#include "../../Windows64/Miles/include/mss.h" #else // PS4 // 4J Stu - Temp define to get Miles to link, can likely be removed when we get a new version of Miles #define _SEKRIT2 diff --git a/Minecraft.Client/Common/Audio/SoundEngine.h b/Minecraft.Client/Common/Audio/SoundEngine.h index 0c8107963..3e9059dad 100644 --- a/Minecraft.Client/Common/Audio/SoundEngine.h +++ b/Minecraft.Client/Common/Audio/SoundEngine.h @@ -3,12 +3,6 @@ class Mob; class Options; using namespace std; #include "../../../Minecraft.World/SoundTypes.h" -#ifdef __linux__ -typedef float F32; -typedef HANDLE HMSOUNDBANK; -typedef HANDLE HDIGDRIVER; -typedef unsigned int HSTREAM; -#endif // __linux__ enum eMUSICFILES { diff --git a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp index 5e81ab11d..945d204de 100644 --- a/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -12,9 +12,6 @@ #ifdef __ORBIS__ #include #endif -#ifdef __linux__ -#include -#endif IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu() { m_menu = NULL; diff --git a/Minecraft.Client/Linux/Stubs/LinuxStubs.h b/Minecraft.Client/Linux/Stubs/LinuxStubs.h index d936f7c39..338202771 100644 --- a/Minecraft.Client/Linux/Stubs/LinuxStubs.h +++ b/Minecraft.Client/Linux/Stubs/LinuxStubs.h @@ -3,6 +3,31 @@ #pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "winapi_stubs.h" #include "d3d11_stubs.h" #include "xbox_stubs.h" diff --git a/Minecraft.Client/Linux/Stubs/winapi_stubs.h b/Minecraft.Client/Linux/Stubs/winapi_stubs.h index 146b8149d..93d0428c3 100644 --- a/Minecraft.Client/Linux/Stubs/winapi_stubs.h +++ b/Minecraft.Client/Linux/Stubs/winapi_stubs.h @@ -3,26 +3,6 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #define TRUE true #define FALSE false #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length)) @@ -139,6 +119,32 @@ typedef float FLOAT; #define FILE_CURRENT SEEK_CUR #define FILE_END SEEK_END +#define PAGE_NOACCESS 0x01 +#define PAGE_READONLY 0x02 +#define PAGE_READWRITE 0x04 +#define PAGE_WRITECOPY 0x08 +#define PAGE_EXECUTE 0x10 +#define PAGE_EXECUTE_READ 0x20 +#define PAGE_EXECUTE_READWRITE 0x40 +#define PAGE_EXECUTE_WRITECOPY 0x80 +#define PAGE_GUARD 0x100 +#define PAGE_NOCACHE 0x200 +#define PAGE_WRITECOMBINE 0x400 +#define PAGE_USER_READONLY 0x1000 +#define PAGE_USER_READWRITE 0x2000 +#define MEM_COMMIT 0x1000 +#define MEM_RESERVE 0x2000 +#define MEM_DECOMMIT 0x4000 +#define MEM_RELEASE 0x8000 +#define MEM_FREE 0x10000 +#define MEM_PRIVATE 0x20000 +#define MEM_RESET 0x80000 +#define MEM_TOP_DOWN 0x100000 +#define MEM_NOZERO 0x800000 +#define MEM_LARGE_PAGES 0x20000000 +#define MEM_HEAP 0x40000000 +#define MEM_16MB_PAGES 0x80000000 + #define INVALID_HANDLE_VALUE ((HANDLE)(ULONG_PTR)-1) // https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime @@ -215,6 +221,11 @@ typedef struct _SYSTEMTIME { // https://learn.microsoft.com/en-us/cpp/c-runtime-library/truncate?view=msvc-170 #define _TRUNCATE ((size_t)-1) +#define DECLARE_HANDLE(name) typedef HANDLE name +DECLARE_HANDLE(HINSTANCE); + +typedef HINSTANCE HMODULE; + typedef pthread_mutex_t RTL_CRITICAL_SECTION; typedef pthread_mutex_t* PRTL_CRITICAL_SECTION; @@ -709,7 +720,7 @@ typedef struct { int manual_reset; } Event; -HANDLE CreateEvent(int manual_reset, int initial_state) { +static inline HANDLE CreateEvent(int manual_reset, int initial_state) { Event* ev = (Event*)malloc(sizeof(Event)); pthread_mutex_init(&ev->mutex, NULL); pthread_cond_init(&ev->cond, NULL); @@ -718,4 +729,7 @@ HANDLE CreateEvent(int manual_reset, int initial_state) { return (HANDLE)ev; } +static inline HMODULE GetModuleHandle(LPCSTR lpModuleName) { return 0; } + + #endif // WINAPISTUBS_H diff --git a/Minecraft.Client/Windows64/Miles/include/mss.h b/Minecraft.Client/Windows64/Miles/include/mss.h index 531dcbc92..9164a5f7b 100644 --- a/Minecraft.Client/Windows64/Miles/include/mss.h +++ b/Minecraft.Client/Windows64/Miles/include/mss.h @@ -97,7 +97,7 @@ EXPGROUP(_RootGroup) // IS_SPU for PS3 SPU // IS_WII for Wii -#include "rrCore.h" +#include "rrcore.h" //#define MILES_CHECK_OFFSETS #ifdef MILES_CHECK_OFFSETS diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp index a21ecd0de..069c30579 100644 --- a/Minecraft.World/Connection.cpp +++ b/Minecraft.World/Connection.cpp @@ -17,12 +17,6 @@ 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); @@ -314,7 +308,7 @@ bool Connection::readTick() // printf("Con:0x%x readTick close EOS\n",this); // 4J Stu - Remove this line - // Fix for #10410 - UI: If the player is removed from a splitscreened host’s game, the next game that player joins will produce a message stating that the host has left. + // Fix for #10410 - UI: If the player is removed from a splitscreened host�s game, the next game that player joins will produce a message stating that the host has left. //close(DisconnectPacket::eDisconnect_EndOfStream); } diff --git a/Minecraft.World/ConsoleSaveFileOriginal.cpp b/Minecraft.World/ConsoleSaveFileOriginal.cpp index b8fd81768..403a35627 100644 --- a/Minecraft.World/ConsoleSaveFileOriginal.cpp +++ b/Minecraft.World/ConsoleSaveFileOriginal.cpp @@ -11,39 +11,21 @@ #include "../Minecraft.World/LevelData.h" #include "../Minecraft.Client/Common/GameRules/LevelGenerationOptions.h" #include "../Minecraft.World/net.minecraft.world.level.chunk.storage.h" -#include #ifdef _XBOX #define RESERVE_ALLOCATION MEM_RESERVE | MEM_LARGE_PAGES #define COMMIT_ALLOCATION MEM_COMMIT | MEM_LARGE_PAGES -#elif !defined(__linux__) +#else #define RESERVE_ALLOCATION MEM_RESERVE #define COMMIT_ALLOCATION MEM_COMMIT -#else -#include "../Minecraft.Client/Windows64/Windows64_App.h" -#include -#include -#include -#include -#include -#include -#include -#define RESERVE_ALLOCATION 0 -#define COMMIT_ALLOCATION MAP_PRIVATE | MAP_ANONYMOUS -#define PAGE_READWRITE O_RDWR -#include #endif -extern CConsoleMinecraftApp app; - unsigned int ConsoleSaveFileOriginal::pagesCommitted = 0; void *ConsoleSaveFileOriginal::pvHeap = NULL; ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID pvSaveData /*= NULL*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) { -#ifndef __linux__ InitializeCriticalSectionAndSpinCount(&m_lock,5120); -#endif // __linux__ // One time initialise of static stuff required for our storage if( pvHeap == NULL ) @@ -55,7 +37,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID // AP - The Vita doesn't have virtual memory so a pretend system has been implemented in PSVitaStubs.cpp. // All access to the memory must be done via the access function as the pointer returned from VirtualAlloc // can't be used directly. - pvHeap = mmap(NULL, NULL, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE, NULL ); + pvHeap = VirtualAlloc(NULL, MAX_PAGE_COUNT * CSF_PAGE_SIZE, RESERVE_ALLOCATION, PAGE_READWRITE ); } pvSaveMem = pvHeap; @@ -91,7 +73,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID unsigned int pagesRequired = ( heapSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE; - void *pvRet = mmap(NULL, pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE, NULL); + void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); if( pvRet == NULL ) { #ifndef _CONTENT_PACKAGE @@ -131,7 +113,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID #ifdef __PS3__ StorageManager.FreeSaveData(); #endif - printf("Filesize - %d, Adjusted size - %d\n",fileSize,storageLength); + app.DebugPrintf("Filesize - %d, Adjusted size - %d\n",fileSize,storageLength); fileSize = storageLength; } @@ -168,7 +150,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID if(decompSize == 0) { // 4J Stu - Saves created between 2/12/2011 and 7/12/2011 will have this problem - printf("Invalid save data format\n"); + app.DebugPrintf("Invalid save data format\n"); ZeroMemory( pvSourceData, fileSize ); // Clear the first 8 bytes that reference the header header.WriteHeader( pvSourceData ); @@ -197,7 +179,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID if( desiredSize > currentHeapSize ) { unsigned int pagesRequired = ( desiredSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE; - void *pvRet = mmap(NULL, pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE, NULL); + void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); if( pvRet == NULL ) { // Out of physical memory @@ -227,9 +209,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID ConsoleSaveFileOriginal::~ConsoleSaveFileOriginal() { -#ifndef __linux__ VirtualFree( pvHeap, MAX_PAGE_COUNT * CSF_PAGE_SIZE, MEM_DECOMMIT ); -#endif pagesCommitted = 0; // Make sure we don't have any thumbnail data still waiting round - we can't need it now we've destroyed the save file anyway #if defined _XBOX @@ -318,25 +298,13 @@ void ConsoleSaveFileOriginal::deleteFile( FileEntry *file ) ReleaseSaveAccess(); } -#if defined(__linux__) -bool moveToEnd(int fd) -{ - off_t fileSize = lseek(fd, 0, SEEK_END); - if (fileSize == (off_t)-1) { - perror("lseek failed"); - return false; - } - return true; -} -#endif - void ConsoleSaveFileOriginal::setFilePointer(FileEntry *file,LONG lDistanceToMove,PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod) { LockSaveAccess(); file->currentFilePointer = file->data.startOffset + lDistanceToMove; - if( moveToEnd(dwMoveMethod)) + if( dwMoveMethod == FILE_END) { file->currentFilePointer += file->getFileSize(); } @@ -519,7 +487,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt if( desiredSize > currentHeapSize ) { unsigned int pagesRequired = ( desiredSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE; - void *pvRet = mmap(NULL, pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE, NULL); + void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE); if( pvRet == NULL ) { // Out of physical memory @@ -668,14 +636,21 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) { LockSaveAccess(); +#ifdef __PSVITA__ + // On Vita we've had problems with saves being corrupted on rapid save/save-exiting so seems prudent to wait for idle + while( StorageManager.GetSaveState() != C4JStorage::ESaveGame_Idle ) + { + app.DebugPrintf("Flush wait\n"); + Sleep(10); + } +#endif + finalizeWrite(); // Get the frequency of the timer LARGE_INTEGER qwTicksPerSec, qwTime, qwNewTime, qwDeltaTime; float fElapsedTime = 0.0f; -#ifndef __linux__ QueryPerformanceFrequency( &qwTicksPerSec ); -#endif // __linux__ float fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; unsigned int fileSize = header.GetFileSize(); @@ -713,23 +688,19 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) // Pre-calculate the buffer size required for the compressed data PIXBeginNamedEvent(0,"Pre-calc save compression"); // Save the start time -#if !defined(__linux__) QueryPerformanceCounter( &qwTime ); -#endif // __linux__ #ifdef __PSVITA__ // AP - get the compressed size via the access function. This uses a special RLE format VirtualCompress(NULL,&compLength,pvSaveMem,fileSize); #else Compression::getCompression()->Compress(NULL,&compLength,pvSaveMem,fileSize); #endif -#if !defined(__linux__) QueryPerformanceCounter( &qwNewTime ); -#endif // __linux__ qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); - printf("Check buffer size: Elapsed time %f\n", fElapsedTime); + app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime); PIXEndNamedEvent(); // We add 4 bytes to the start so that we can signal compressed data @@ -748,22 +719,19 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) // Re-compress all save data before we save it to disk PIXBeginNamedEvent(0,"Actual save compression"); // Save the start time -#if !defined(__linux__) QueryPerformanceCounter( &qwTime ); -#endif // __LINUX__ #ifdef __PSVITA__ // AP - compress via the access function. This uses a special RLE format VirtualCompress(compData+8,&compLength,pvSaveMem,fileSize); #else Compression::getCompression()->Compress(compData+8,&compLength,pvSaveMem,fileSize); #endif -#if !defined(__linux__) QueryPerformanceCounter( &qwNewTime ); -#endif // __linux__ + qwDeltaTime.QuadPart = qwNewTime.QuadPart - qwTime.QuadPart; fElapsedTime = fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); - printf("Compress: Elapsed time %f\n", fElapsedTime); + app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime); PIXEndNamedEvent(); ZeroMemory(compData,8); @@ -771,7 +739,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) memcpy( compData, &saveVer, sizeof(int) ); memcpy( compData+4, &fileSize, sizeof(int) ); - printf("Save data compressed from %d to %d\n", fileSize, compLength); + app.DebugPrintf("Save data compressed from %d to %d\n", fileSize, compLength); #endif PBYTE pbThumbnailData=NULL; @@ -825,7 +793,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) #elif (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WINDOWS64) // set the icon and save image StorageManager.SetSaveImages(pbThumbnailData,dwThumbnailDataSize,pbDataSaveImage,dwDataSizeSaveImage,bTextMetadata,iTextMetadataBytes); - printf("Save thumbnail size %d\n",dwThumbnailDataSize); + app.DebugPrintf("Save thumbnail size %d\n",dwThumbnailDataSize); // save the data StorageManager.SaveSaveData( &ConsoleSaveFileOriginal::SaveSaveDataCallback, this ); @@ -876,90 +844,52 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, if(!targetFileDir.exists()) targetFileDir.mkdir(); -#if defined(_WIN32) wchar_t *fileName = new wchar_t[XCONTENT_MAX_FILENAME_LENGTH+1]; -#else - // DecalOverdose(FIXME): - const char* fileName = new char[XCONTENT_MAX_FILENAME_LENGTH + 1]; -#endif // _wIN32 -#if defined(_WIN32) + SYSTEMTIME t; GetSystemTime( &t ); -#else - // DecalOverdose: JARVIS DON'T PULL AN ALIEN SWARM: GLOBAL OFFENSIVE - std::time_t t = std::time(0); - std::tm* localTime = std::localtime(&t); -#endif // _WIN32 //14 chars for the digits //11 chars for the separators + suffix //25 chars total - std::wstring cutFileName = m_fileName; + wstring cutFileName = m_fileName; if(m_fileName.length() > XCONTENT_MAX_FILENAME_LENGTH - 25) { cutFileName = m_fileName.substr(0, XCONTENT_MAX_FILENAME_LENGTH - 25); } - -#ifndef __linux__ - swprintf(fileName, XCONTENT_MAX_FILENAME_LENGTH+1, L"\\v%04d-%ls%02d.%02d.%02d.%02d.%02d.mcs",VER_PRODUCTBUILD,cutFileName.c_str(), t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); -#else - char fileNameBuffer[XCONTENT_MAX_FILENAME_LENGTH + 1]; - std::memset(fileNameBuffer, 0, sizeof(fileNameBuffer)); - wcstombs(fileNameBuffer, cutFileName.c_str(), XCONTENT_MAX_FILENAME_LENGTH); - snprintf(fileName, XCONTENT_MAX_FILENAME_LENGTH + 1, - "\\v%04d-%s%02d.%02d.%02d.%02d.%02d.mcs", - VER_PRODUCTBUILD, fileNameBuffer, - localTime->tm_mon + 1, localTime->tm_mday, - localTime->tm_hour, localTime->tm_min, localTime->tm_sec); -#endif // __linux__ -#if defined (_UNICODE) +#ifdef _UNICODE wstring wtemp = targetFileDir.getPath() + wstring(fileName); LPCWSTR lpFileName = wtemp.c_str(); -#elif defined(__linux__) - std::wstring wtemp = targetFileDir.getPath(); - std::wstring wfileName(fileName, fileName + strlen(fileName)); - wtemp += wfileName; - std::wstring_convert> converter; - std::string tempStr = converter.to_bytes(wtemp); - const char* lpFileName = tempStr.c_str(); #else LPCSTR lpFileName = wstringtofilename( targetFileDir.getPath() + wstring(fileName) ); #endif -#if !defined __PSVITA__ && !defined(__linux__) +#ifndef __PSVITA__ HANDLE hSaveFile = CreateFile( lpFileName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); #endif -#if defined(__linux__) - int hSaveFile = open(lpFileName, O_RDWR); -#endif // __linux__ - if(compressedData != NULL && compressedDataSize > 0) { -#if defined __PSVITA__ +#ifdef __PSVITA__ // AP - Use the access function to save VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); -#elif !defined(__linux__) - WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,NULL); #else - write(hSaveFile,compressedData,compressedDataSize); + WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,NULL); #endif assert(numberOfBytesWritten == compressedDataSize); } else { -#if defined(__PSVITA__) +#ifdef __PSVITA__ // AP - Use the access function to save VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); -#elif !defined(__linux__) - WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,NULL); #else - write(hSaveFile,compressedData,compressedDataSize); + WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,NULL); #endif assert(numberOfBytesWritten == fileSize); } -#if !defined(__PSVITA__) && !defined(__linux__) +#ifndef __PSVITA__ CloseHandle( hSaveFile ); #endif @@ -1119,12 +1049,12 @@ void ConsoleSaveFileOriginal::ConvertToLocalPlatform() wstring suffix(L".mcr"); if( fName.compare(fName.length() - suffix.length(), suffix.length(), suffix) == 0 ) { - printf("Processing a region file: %ls\n",fName.c_str()); + app.DebugPrintf("Processing a region file: %ls\n",fName.c_str()); ConvertRegionFile(File(fe->data.filename) ); } else { - printf("%ls is not a region file, ignoring\n", fName.c_str()); + app.DebugPrintf("%ls is not a region file, ignoring\n", fName.c_str()); } } @@ -1134,4 +1064,4 @@ void ConsoleSaveFileOriginal::ConvertToLocalPlatform() void *ConsoleSaveFileOriginal::getWritePointer(FileEntry *file) { return (char *)pvSaveMem + file->currentFilePointer;; -} +} \ No newline at end of file diff --git a/Minecraft.World/File.cpp b/Minecraft.World/File.cpp index 1d754833e..4de4f2e07 100644 --- a/Minecraft.World/File.cpp +++ b/Minecraft.World/File.cpp @@ -10,20 +10,6 @@ #include #endif -#if defined(__linux__) -#include -#include -#include -#include -#include -#include -#include -#include -#include // for access() -#include -#define MAX_PATH PATH_MAX -#endif - const wchar_t File::pathSeparator = L'\\'; #ifdef _XBOX const wstring File::pathRoot = L"GAME:"; // Path root after pathSeparator has been removed diff --git a/Minecraft.World/FileOutputStream.cpp b/Minecraft.World/FileOutputStream.cpp index 5de8176a8..c281ee225 100644 --- a/Minecraft.World/FileOutputStream.cpp +++ b/Minecraft.World/FileOutputStream.cpp @@ -59,9 +59,7 @@ FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HAN if( m_fileHandle == INVALID_HANDLE_VALUE ) { // TODO 4J Stu - Any form of error/exception handling -#ifndef __linux__ DWORD error = GetLastError(); -#endif // __linux__ } } diff --git a/Minecraft.World/Socket.cpp b/Minecraft.World/Socket.cpp index 55fb33a85..f0b05208a 100644 --- a/Minecraft.World/Socket.cpp +++ b/Minecraft.World/Socket.cpp @@ -25,7 +25,6 @@ void Socket::Initialise(ServerConnection *serverConnection) // Only initialise everything else once - just setting up static data, one time xrnm things, thread for ticking sockets static bool init = false; -#if !defined(__linux__) if( init ) { for( int i = 0; i < 2; i++ ) @@ -42,14 +41,11 @@ void Socket::Initialise(ServerConnection *serverConnection) } return; } -#endif init = true; for( int i = 0; i < 2; i++ ) { -#if !defined(__linux__) InitializeCriticalSection(&Socket::s_hostQueueLock[i]); -#endif s_hostOutStream[i] = new SocketOutputStreamLocal(i); s_hostInStream[i] = new SocketInputStreamLocal(i); } @@ -86,9 +82,7 @@ Socket::Socket(INetworkPlayer *player, bool response /* = false*/, bool hostLoca for( int i = 0; i < 2; i++ ) { -#if !defined(__linux__) InitializeCriticalSection(&m_queueLockNetwork[i]); -#endif // __linux__ m_inputStream[i] = NULL; m_outputStream[i] = NULL; m_endClosed[i] = false; @@ -136,7 +130,6 @@ void Socket::setPlayer(INetworkPlayer *player) void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHost /*= true*/) { -#ifndef __linux__ int queueIdx = SOCKET_CLIENT_END; if(!fromHost) queueIdx = SOCKET_SERVER_END; @@ -153,7 +146,6 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos m_queueNetwork[queueIdx].push(*pbData++); } LeaveCriticalSection(&m_queueLockNetwork[queueIdx]); -#endif // __linux__ } void Socket::addIncomingSocket(Socket *socket) @@ -270,7 +262,6 @@ Socket::SocketInputStreamLocal::SocketInputStreamLocal(int queueIdx) // Try and get an input byte, blocking until one is available int Socket::SocketInputStreamLocal::read() { -#if !defined(__linux__) while(m_streamOpen && ShutdownManager::ShouldRun(ShutdownManager::eConnectionReadThreads)) { if(TryEnterCriticalSection(&s_hostQueueLock[m_queueIdx])) @@ -286,8 +277,6 @@ int Socket::SocketInputStreamLocal::read() } Sleep(1); } -#endif // __linux__ - return -1; } // Try and get an input array of bytes, blocking until enough bytes are available @@ -299,7 +288,6 @@ int Socket::SocketInputStreamLocal::read(byteArray b) // Try and get an input range of bytes, blocking until enough bytes are available int Socket::SocketInputStreamLocal::read(byteArray b, unsigned int offset, unsigned int length) { -#ifndef __linux__ while(m_streamOpen) { if(TryEnterCriticalSection(&s_hostQueueLock[m_queueIdx])) @@ -318,18 +306,14 @@ int Socket::SocketInputStreamLocal::read(byteArray b, unsigned int offset, unsig } Sleep(1); } -#endif // __linux__ - return -1; } void Socket::SocketInputStreamLocal::close() { -#ifndef __linux__ m_streamOpen = false; EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); s_hostQueue[m_queueIdx].empty(); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); -#endif // __linux__ } /////////////////////////////////// Socket for output, on local connection //////////////////// @@ -342,7 +326,6 @@ Socket::SocketOutputStreamLocal::SocketOutputStreamLocal(int queueIdx) void Socket::SocketOutputStreamLocal::write(unsigned int b) { -#ifndef __linux__ if( m_streamOpen != true ) { return; @@ -350,7 +333,6 @@ void Socket::SocketOutputStreamLocal::write(unsigned int b) EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); s_hostQueue[m_queueIdx].push((byte)b); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); -#endif // __linux__ } void Socket::SocketOutputStreamLocal::write(byteArray b) @@ -360,7 +342,6 @@ void Socket::SocketOutputStreamLocal::write(byteArray b) void Socket::SocketOutputStreamLocal::write(byteArray b, unsigned int offset, unsigned int length) { -#ifndef __linux__ if( m_streamOpen != true ) { return; @@ -373,17 +354,14 @@ void Socket::SocketOutputStreamLocal::write(byteArray b, unsigned int offset, un } LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); MemSect(0); -#endif // __linux__ } void Socket::SocketOutputStreamLocal::close() { -#ifndef __linux__ m_streamOpen = false; EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); s_hostQueue[m_queueIdx].empty(); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); -#endif // __linux__ } /////////////////////////////////// Socket for input, on network connection //////////////////// @@ -398,7 +376,6 @@ Socket::SocketInputStreamNetwork::SocketInputStreamNetwork(Socket *socket, int q // Try and get an input byte, blocking until one is available int Socket::SocketInputStreamNetwork::read() { -#ifndef __linux__ while(m_streamOpen && ShutdownManager::ShouldRun(ShutdownManager::eConnectionReadThreads)) { if(TryEnterCriticalSection(&m_socket->m_queueLockNetwork[m_queueIdx])) @@ -414,8 +391,6 @@ int Socket::SocketInputStreamNetwork::read() } Sleep(1); } -#endif // __linux__ - return -1; } // Try and get an input array of bytes, blocking until enough bytes are available @@ -427,7 +402,6 @@ int Socket::SocketInputStreamNetwork::read(byteArray b) // Try and get an input range of bytes, blocking until enough bytes are available int Socket::SocketInputStreamNetwork::read(byteArray b, unsigned int offset, unsigned int length) { -#ifndef __linux__ while(m_streamOpen) { if(TryEnterCriticalSection(&m_socket->m_queueLockNetwork[m_queueIdx])) @@ -446,8 +420,6 @@ int Socket::SocketInputStreamNetwork::read(byteArray b, unsigned int offset, uns } Sleep(1); } -#endif // __linux__ - return -1; } void Socket::SocketInputStreamNetwork::close() diff --git a/Minecraft.World/compression.cpp b/Minecraft.World/compression.cpp index eb581bd04..cf4fd7055 100644 --- a/Minecraft.World/compression.cpp +++ b/Minecraft.World/compression.cpp @@ -1,24 +1,15 @@ #include "stdafx.h" #include "compression.h" -#if defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64 +#if defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64 || defined __linux__ #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; @@ -511,10 +502,8 @@ Compression::Compression() #endif m_decompressType = m_localDecompressType; -#ifndef __linux__ InitializeCriticalSection(&rleCompressLock); InitializeCriticalSection(&rleDecompressLock); -#endif // __linux__ } Compression::~Compression()