diff --git a/Minecraft.Client/CMakeLists.txt b/Minecraft.Client/CMakeLists.txt index faf127f51..10d74ce01 100644 --- a/Minecraft.Client/CMakeLists.txt +++ b/Minecraft.Client/CMakeLists.txt @@ -1239,11 +1239,11 @@ set(Windows source_group("Windows" FILES ${Windows}) set(Windows64 -# "Windows64/Resource.h" -# "Windows64/Windows64_App.cpp" -# "Windows64/Windows64_App.h" -# "Windows64/Windows64_UIController.cpp" -# "Windows64/Windows64_UIController.h" + "Windows64/Resource.h" + "Windows64/Windows64_App.cpp" + "Windows64/Windows64_App.h" + "Windows64/Windows64_UIController.cpp" + "Windows64/Windows64_UIController.h" ) source_group("Windows64" FILES ${Windows64}) diff --git a/Minecraft.Client/PlayerList.h b/Minecraft.Client/PlayerList.h index 14bd6b2da..a3add22b3 100644 --- a/Minecraft.Client/PlayerList.h +++ b/Minecraft.Client/PlayerList.h @@ -1,6 +1,6 @@ #pragma once #include -#include "..\Minecraft.World\ArrayWithLength.h" +#include "../Minecraft.World/ArrayWithLength.h" class ServerPlayer; class PlayerChunkMap; diff --git a/Minecraft.Client/ServerPlayer.h b/Minecraft.Client/ServerPlayer.h index a9b375949..ba0d23d6b 100644 --- a/Minecraft.Client/ServerPlayer.h +++ b/Minecraft.Client/ServerPlayer.h @@ -1,7 +1,7 @@ #pragma once -#include "..\Minecraft.World\net.minecraft.world.entity.player.h" -#include "..\Minecraft.World\net.minecraft.world.inventory.ContainerListener.h" -#include "..\Minecraft.World\ChunkPos.h" +#include "../Minecraft.World/net.minecraft.world.entity.player.h" +#include "../Minecraft.World/net.minecraft.world.inventory.ContainerListener.h" +#include "../Minecraft.World/ChunkPos.h" class PlayerConnection; class MinecraftServer; class ServerPlayerGameMode; diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp index ef9f6cf69..525f16f93 100644 --- a/Minecraft.Client/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Windows64/Windows64_App.cpp @@ -1,17 +1,20 @@ -#include "stdafx.h" -#include "..\Common\Consoles_App.h" -#include "..\User.h" -#include "..\..\Minecraft.Client\Minecraft.h" -#include "..\..\Minecraft.Client\MinecraftServer.h" -#include "..\..\Minecraft.Client\PlayerList.h" -#include "..\..\Minecraft.Client\ServerPlayer.h" -#include "..\..\Minecraft.World\Level.h" -#include "..\..\Minecraft.World\LevelSettings.h" -#include "..\..\Minecraft.World\BiomeSource.h" -#include "..\..\Minecraft.World\LevelType.h" +#include "../../Minecraft.World/stdafx.h" +#include "../Common/Consoles_App.h" +#include "../User.h" +#include "../../Minecraft.Client/Minecraft.h" +#include "../../Minecraft.Client/MinecraftServer.h" +#include "../../Minecraft.Client/PlayerList.h" +#include "../../Minecraft.Client/ServerPlayer.h" +#include "../../Minecraft.World/Level.h" +#include "../../Minecraft.World/LevelSettings.h" +#include "../../Minecraft.World/BiomeSource.h" +#include "../../Minecraft.World/LevelType.h" +#include "Windows64_App.h" CConsoleMinecraftApp app; +#define CONTEXT_GAME_STATE 0 + CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() { } diff --git a/Minecraft.World/BasicTypeContainers.h b/Minecraft.World/BasicTypeContainers.h index 094e9616f..6f72ab593 100644 --- a/Minecraft.World/BasicTypeContainers.h +++ b/Minecraft.World/BasicTypeContainers.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + class Byte { @@ -72,4 +75,4 @@ public: // As such I have renamed it so that we don't confuse it with places where we should use std::string class _String { -}; \ No newline at end of file +}; diff --git a/Minecraft.World/BiomeCache.h b/Minecraft.World/BiomeCache.h index bf509f544..0846fdc14 100644 --- a/Minecraft.World/BiomeCache.h +++ b/Minecraft.World/BiomeCache.h @@ -1,5 +1,5 @@ #pragma once -#include "..\Minecraft.World\JavaIntHash.h" +#include "../Minecraft.World/JavaIntHash.h" class BiomeCache { @@ -49,4 +49,4 @@ public: private: CRITICAL_SECTION m_CS; -}; \ No newline at end of file +}; diff --git a/Minecraft.World/ByteBuffer.cpp b/Minecraft.World/ByteBuffer.cpp index 665147373..dce70acfd 100644 --- a/Minecraft.World/ByteBuffer.cpp +++ b/Minecraft.World/ByteBuffer.cpp @@ -475,4 +475,4 @@ ByteBuffer_IO::~ByteBuffer_IO() // delete buffer; RenderManager.freeIOMem(buffer); } -#endif // __PS3__ \ No newline at end of file +#endif // __PS3__ diff --git a/Minecraft.World/ConsoleSaveFileOriginal.cpp b/Minecraft.World/ConsoleSaveFileOriginal.cpp index df892457b..b8fd81768 100644 --- a/Minecraft.World/ConsoleSaveFileOriginal.cpp +++ b/Minecraft.World/ConsoleSaveFileOriginal.cpp @@ -20,20 +20,30 @@ #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 ) @@ -187,7 +197,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID if( desiredSize > currentHeapSize ) { unsigned int pagesRequired = ( desiredSize + (CSF_PAGE_SIZE - 1 ) ) / CSF_PAGE_SIZE; - void *pvRet = mmap(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE, NULL); + void *pvRet = mmap(NULL, pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE, NULL); if( pvRet == NULL ) { // Out of physical memory @@ -217,7 +227,9 @@ 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 @@ -306,13 +318,25 @@ 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( dwMoveMethod == FILE_END) + if( moveToEnd(dwMoveMethod)) { file->currentFilePointer += file->getFileSize(); } @@ -649,7 +673,9 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) // 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(); @@ -687,14 +713,18 @@ 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)); @@ -718,15 +748,18 @@ 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)); @@ -843,8 +876,12 @@ 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 ); @@ -857,24 +894,36 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, //14 chars for the digits //11 chars for the separators + suffix //25 chars total - wstring cutFileName = m_fileName; + std::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 - snprintf(static_cast(fileName), XCONTENT_MAX_FILENAME_LENGTH + 1, + 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, cutFileName.c_str(), - localTime->tm_mon + 1, localTime->tm_mday, + VER_PRODUCTBUILD, fileNameBuffer, + localTime->tm_mon + 1, localTime->tm_mday, localTime->tm_hour, localTime->tm_min, localTime->tm_sec); #endif // __linux__ -#ifdef _UNICODE +#if defined (_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 @@ -888,25 +937,29 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, if(compressedData != NULL && compressedDataSize > 0) { -#ifdef __PSVITA__ +#if defined __PSVITA__ // AP - Use the access function to save VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); -#else +#elif !defined(__linux__) WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,NULL); +#else + write(hSaveFile,compressedData,compressedDataSize); #endif assert(numberOfBytesWritten == compressedDataSize); } else { -#ifdef __PSVITA__ +#if defined(__PSVITA__) // AP - Use the access function to save VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); -#else +#elif !defined(__linux__) WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,NULL); +#else + write(hSaveFile,compressedData,compressedDataSize); #endif assert(numberOfBytesWritten == fileSize); } -#ifndef __PSVITA__ +#if !defined(__PSVITA__) && !defined(__linux__) CloseHandle( hSaveFile ); #endif diff --git a/Minecraft.World/FileHeader.cpp b/Minecraft.World/FileHeader.cpp index 59e97d9ba..febb021ac 100644 --- a/Minecraft.World/FileHeader.cpp +++ b/Minecraft.World/FileHeader.cpp @@ -1,8 +1,10 @@ #include "stdafx.h" #include "FileHeader.h" - +#include "../Minecraft.Client/Windows64/Windows64_App.cpp" //#define _DEBUG_FILE_HEADER +extern CConsoleMinecraftApp app; + FileHeader::FileHeader() { lastFile = NULL; @@ -245,7 +247,7 @@ void FileHeader::ReadHeader( LPVOID saveMem, ESavePlatform plat /*= SAVE_FILE_PL if(isSaveEndianDifferent()) { // Reverse bytes - System::ReverseWCHARA(entry->data.filename,64); + // System::ReverseWCHARA(entry->data.filename,64); System::ReverseULONG(&entry->data.length); System::ReverseULONG(&entry->data.startOffset); System::ReverseULONGLONG(&entry->data.lastModifiedTime); @@ -678,4 +680,4 @@ ByteOrder FileHeader::getEndian( ESavePlatform plat ) break; } return LITTLEENDIAN; -} \ No newline at end of file +}