mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-09 15:48:08 +00:00
fix(Minecraft.World) major fixes, now i need to fix byte bullshit
This commit is contained in:
parent
84f61b0131
commit
115da74e1e
|
|
@ -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})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include <deque>
|
||||
#include "..\Minecraft.World\ArrayWithLength.h"
|
||||
#include "../Minecraft.World/ArrayWithLength.h"
|
||||
|
||||
class ServerPlayer;
|
||||
class PlayerChunkMap;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <climits>
|
||||
#include <cfloat>
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -475,4 +475,4 @@ ByteBuffer_IO::~ByteBuffer_IO()
|
|||
// delete buffer;
|
||||
RenderManager.freeIOMem(buffer);
|
||||
}
|
||||
#endif // __PS3__
|
||||
#endif // __PS3__
|
||||
|
|
|
|||
|
|
@ -20,20 +20,30 @@
|
|||
#define RESERVE_ALLOCATION MEM_RESERVE
|
||||
#define COMMIT_ALLOCATION MEM_COMMIT
|
||||
#else
|
||||
#include "../Minecraft.Client/Windows64/Windows64_App.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <locale>
|
||||
#include <fcntl.h>
|
||||
#include <linux/mman.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#define RESERVE_ALLOCATION 0
|
||||
#define COMMIT_ALLOCATION MAP_PRIVATE | MAP_ANONYMOUS
|
||||
#define PAGE_READWRITE O_RDWR
|
||||
#include <codecvt>
|
||||
#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<char*>(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<std::codecvt_utf8<wchar_t>> 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue