mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-11 16:37:14 +00:00
Use standard byte counts for base save data
This commit is contained in:
parent
0ab0fd9209
commit
0437fb921f
|
|
@ -426,8 +426,8 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const std::ws
|
|||
LevelGenerationOptions *levelGen = app.getLevelGenerationOptions();
|
||||
if( levelGen != NULL && levelGen->requiresBaseSave())
|
||||
{
|
||||
DWORD fileSize = 0;
|
||||
LPVOID pvSaveData = levelGen->getBaseSaveData(fileSize);
|
||||
unsigned int fileSize = 0;
|
||||
std::uint8_t *pvSaveData = levelGen->getBaseSaveData(fileSize);
|
||||
if(pvSaveData && fileSize != 0) bLevelGenBaseSave = true;
|
||||
}
|
||||
ConsoleSaveFileSplit *newFormatSave = NULL;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ LevelGenerationOptions::LevelGenerationOptions()
|
|||
m_bRequiresGameRules = false;
|
||||
|
||||
m_pbBaseSaveData = NULL;
|
||||
m_dwBaseSaveSize = 0;
|
||||
m_baseSaveSize = 0;
|
||||
}
|
||||
|
||||
LevelGenerationOptions::~LevelGenerationOptions()
|
||||
|
|
@ -331,7 +331,7 @@ void LevelGenerationOptions::clearSchematics()
|
|||
m_schematics.clear();
|
||||
}
|
||||
|
||||
ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const std::wstring &filename, PBYTE pbData, DWORD dwLen)
|
||||
ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const std::wstring &filename, std::uint8_t *pbData, unsigned int dataLength)
|
||||
{
|
||||
// If we have already loaded this, just return
|
||||
AUTO_VAR(it, m_schematics.find(filename));
|
||||
|
|
@ -345,7 +345,7 @@ ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const std::wstri
|
|||
}
|
||||
|
||||
ConsoleSchematicFile *schematic = NULL;
|
||||
byteArray data(pbData,dwLen);
|
||||
byteArray data(pbData, dataLength);
|
||||
ByteArrayInputStream bais(data);
|
||||
DataInputStream dis(&bais);
|
||||
schematic = new ConsoleSchematicFile();
|
||||
|
|
@ -497,10 +497,10 @@ void LevelGenerationOptions::setBaseSavePath(const std::wstring &x) { info()->se
|
|||
|
||||
bool LevelGenerationOptions::ready() { return info()->ready(); }
|
||||
|
||||
void LevelGenerationOptions::setBaseSaveData(PBYTE pbData, DWORD dwSize) { m_pbBaseSaveData = pbData; m_dwBaseSaveSize = dwSize; }
|
||||
PBYTE LevelGenerationOptions::getBaseSaveData(DWORD &size) { size = m_dwBaseSaveSize; return m_pbBaseSaveData; }
|
||||
bool LevelGenerationOptions::hasBaseSaveData() { return m_dwBaseSaveSize > 0 && m_pbBaseSaveData != NULL; }
|
||||
void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete m_pbBaseSaveData; m_pbBaseSaveData = NULL; m_dwBaseSaveSize = 0; }
|
||||
void LevelGenerationOptions::setBaseSaveData(std::uint8_t *pbData, unsigned int dataSize) { m_pbBaseSaveData = pbData; m_baseSaveSize = dataSize; }
|
||||
std::uint8_t *LevelGenerationOptions::getBaseSaveData(unsigned int &size) { size = m_baseSaveSize; return m_pbBaseSaveData; }
|
||||
bool LevelGenerationOptions::hasBaseSaveData() { return m_baseSaveSize > 0 && m_pbBaseSaveData != NULL; }
|
||||
void LevelGenerationOptions::deleteBaseSaveData() { delete[] m_pbBaseSaveData; m_pbBaseSaveData = NULL; m_baseSaveSize = 0; }
|
||||
|
||||
bool LevelGenerationOptions::hasLoadedData() { return m_hasLoadedData; }
|
||||
void LevelGenerationOptions::setLoadedData() { m_hasLoadedData = true; }
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ private:
|
|||
|
||||
bool m_hasLoadedData;
|
||||
|
||||
PBYTE m_pbBaseSaveData;
|
||||
DWORD m_dwBaseSaveSize;
|
||||
std::uint8_t *m_pbBaseSaveData;
|
||||
unsigned int m_baseSaveSize;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -138,8 +138,8 @@ public:
|
|||
|
||||
bool ready();
|
||||
|
||||
void setBaseSaveData(PBYTE pbData, DWORD dwSize);
|
||||
PBYTE getBaseSaveData(DWORD &size);
|
||||
void setBaseSaveData(std::uint8_t *pbData, unsigned int dataSize);
|
||||
std::uint8_t *getBaseSaveData(unsigned int &size);
|
||||
bool hasBaseSaveData();
|
||||
void deleteBaseSaveData();
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ private:
|
|||
void clearSchematics();
|
||||
|
||||
public:
|
||||
ConsoleSchematicFile *loadSchematicFile(const std::wstring &filename, PBYTE pbData, DWORD dwLen);
|
||||
ConsoleSchematicFile *loadSchematicFile(const std::wstring &filename, std::uint8_t *pbData, unsigned int dataLength);
|
||||
|
||||
public:
|
||||
ConsoleSchematicFile *getSchematicFile(const std::wstring &filename);
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
bool ReadPortableBinaryFile(File &file, uint8_t *&data, DWORD &size)
|
||||
bool ReadPortableBinaryFile(File &file, std::uint8_t *&data, unsigned int &size)
|
||||
{
|
||||
const __int64 fileLength = file.length();
|
||||
if (fileLength < 0 || fileLength > static_cast<__int64>(std::numeric_limits<DWORD>::max()))
|
||||
if (fileLength < 0 || fileLength > static_cast<__int64>(std::numeric_limits<unsigned int>::max()))
|
||||
{
|
||||
data = NULL;
|
||||
size = 0;
|
||||
|
|
@ -33,10 +33,10 @@ namespace
|
|||
}
|
||||
|
||||
const std::size_t capacity = static_cast<std::size_t>(fileLength);
|
||||
uint8_t *buffer = new uint8_t[capacity == 0 ? 1 : capacity];
|
||||
std::uint8_t *buffer = new std::uint8_t[capacity == 0 ? 1 : capacity];
|
||||
const PortableFileIO::BinaryReadResult readResult = PortableFileIO::ReadBinaryFile(file.getPath(), buffer, capacity);
|
||||
if (readResult.status != PortableFileIO::BinaryReadStatus::ok
|
||||
|| readResult.fileSize > std::numeric_limits<DWORD>::max())
|
||||
|| readResult.fileSize > std::numeric_limits<unsigned int>::max())
|
||||
{
|
||||
delete [] buffer;
|
||||
data = NULL;
|
||||
|
|
@ -45,7 +45,7 @@ namespace
|
|||
}
|
||||
|
||||
data = buffer;
|
||||
size = static_cast<DWORD>(readResult.fileSize);
|
||||
size = static_cast<unsigned int>(readResult.fileSize);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -223,7 +223,7 @@ void DLCTexturePack::loadColourTable()
|
|||
DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp");
|
||||
|
||||
std::uint32_t dwSize = 0;
|
||||
uint8_t *pbData = dataFile->getData(dwSize);
|
||||
std::uint8_t *pbData = dataFile->getData(dwSize);
|
||||
|
||||
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
|
||||
WCHAR szResourceLocator[ LOCATOR_SIZE ];
|
||||
|
|
@ -343,8 +343,8 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen
|
|||
|
||||
if(xzpPath.exists())
|
||||
{
|
||||
uint8_t *pbData = NULL;
|
||||
DWORD bytesRead = 0;
|
||||
std::uint8_t *pbData = NULL;
|
||||
unsigned int bytesRead = 0;
|
||||
if( ReadPortableBinaryFile(xzpPath, pbData, bytesRead) )
|
||||
{
|
||||
DLCUIDataFile *uiDLCFile = (DLCUIDataFile *)texturePack->m_dlcDataPack->addFile(DLCManager::e_DLCType_UIData,L"TexturePack.xzp");
|
||||
|
|
@ -374,12 +374,12 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen
|
|||
File grf( getFilePath(texturePack->m_dlcInfoPack->GetPackID(), dlcFile->getGrfPath() ) );
|
||||
if (grf.exists())
|
||||
{
|
||||
uint8_t *pbData = NULL;
|
||||
DWORD dwFileSize = 0;
|
||||
if( ReadPortableBinaryFile(grf, pbData, dwFileSize) )
|
||||
std::uint8_t *pbData = NULL;
|
||||
unsigned int fileSize = 0;
|
||||
if( ReadPortableBinaryFile(grf, pbData, fileSize) )
|
||||
{
|
||||
// 4J-PB - is it possible that we can get here after a read fail and it's not an error?
|
||||
dlcFile->setGrfData(pbData, dwFileSize, texturePack->m_stringTable);
|
||||
dlcFile->setGrfData(pbData, fileSize, texturePack->m_stringTable);
|
||||
|
||||
delete [] pbData;
|
||||
|
||||
|
|
@ -397,12 +397,12 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen
|
|||
File grf(getFilePath(texturePack->m_dlcInfoPack->GetPackID(), levelGen->getBaseSavePath() ));
|
||||
if (grf.exists())
|
||||
{
|
||||
uint8_t *pbData = NULL;
|
||||
DWORD dwFileSize = 0;
|
||||
if( ReadPortableBinaryFile(grf, pbData, dwFileSize) )
|
||||
std::uint8_t *pbData = NULL;
|
||||
unsigned int fileSize = 0;
|
||||
if( ReadPortableBinaryFile(grf, pbData, fileSize) )
|
||||
{
|
||||
// 4J-PB - is it possible that we can get here after a read fail and it's not an error?
|
||||
levelGen->setBaseSaveData(pbData, dwFileSize);
|
||||
levelGen->setBaseSaveData(pbData, fileSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -481,7 +481,7 @@ void DLCTexturePack::loadUI()
|
|||
DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp");
|
||||
|
||||
std::uint32_t dwSize = 0;
|
||||
uint8_t *pbData = dataFile->getData(dwSize);
|
||||
std::uint8_t *pbData = dataFile->getData(dwSize);
|
||||
|
||||
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
|
||||
WCHAR szResourceLocator[ LOCATOR_SIZE ];
|
||||
|
|
@ -555,7 +555,7 @@ std::wstring DLCTexturePack::getXuiRootPath()
|
|||
DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp");
|
||||
|
||||
std::uint32_t dwSize = 0;
|
||||
uint8_t *pbData = dataFile->getData(dwSize);
|
||||
std::uint8_t *pbData = dataFile->getData(dwSize);
|
||||
|
||||
const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string
|
||||
WCHAR szResourceLocator[ LOCATOR_SIZE ];
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
unsigned int ConsoleSaveFileOriginal::pagesCommitted = 0;
|
||||
void *ConsoleSaveFileOriginal::pvHeap = NULL;
|
||||
|
||||
ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, void *pvSaveData /*= NULL*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/)
|
||||
ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, void *pvSaveData /*= NULL*/, unsigned int initialFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/)
|
||||
{
|
||||
InitializeCriticalSectionAndSpinCount(&m_lock,5120);
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, v
|
|||
pvSaveMem = pvHeap;
|
||||
m_fileName = fileName;
|
||||
|
||||
DWORD fileSize = dFileSize;
|
||||
unsigned int fileSize = initialFileSize;
|
||||
|
||||
// Load a save from the game rules
|
||||
bool bLevelGenBaseSave = false;
|
||||
|
|
@ -61,7 +61,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, v
|
|||
if( forceCleanSave )
|
||||
fileSize = 0;
|
||||
|
||||
DWORD heapSize = std::max( fileSize, (DWORD)(1024 * 1024 * 2)); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with
|
||||
unsigned int heapSize = std::max(fileSize, 1024u * 1024u * 2u); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with
|
||||
|
||||
// Initially committ enough room to store headSize bytes (using CSF_PAGE_SIZE pages, so rounding up here). We should only ever have one save file at a time,
|
||||
// and the pages should be decommitted in the dtor, so pages committed should always be zero at this point.
|
||||
|
|
@ -173,9 +173,9 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, v
|
|||
}
|
||||
|
||||
// Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries
|
||||
DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
|
||||
DWORD desiredSize = decompSize;
|
||||
unsigned int desiredSize = decompSize;
|
||||
|
||||
if( desiredSize > currentHeapSize )
|
||||
{
|
||||
|
|
@ -239,13 +239,13 @@ void ConsoleSaveFileOriginal::deleteFile( FileEntry *file )
|
|||
|
||||
LockSaveAccess();
|
||||
|
||||
DWORD numberOfBytesRead = 0;
|
||||
DWORD numberOfBytesWritten = 0;
|
||||
unsigned int numberOfBytesRead = 0;
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
|
||||
const int bufferSize = 4096;
|
||||
int amountToRead = bufferSize;
|
||||
uint8_t buffer[bufferSize];
|
||||
DWORD bufferDataSize = 0;
|
||||
std::uint8_t buffer[bufferSize];
|
||||
unsigned int bufferDataSize = 0;
|
||||
|
||||
|
||||
char *readStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize();
|
||||
|
|
@ -482,15 +482,15 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, unsigned int nNumb
|
|||
const unsigned int bufferSize = 4096;
|
||||
unsigned int amountToRead = bufferSize;
|
||||
//assert( nNumberOfBytesToWrite <= bufferSize );
|
||||
static uint8_t buffer1[bufferSize];
|
||||
static uint8_t buffer2[bufferSize];
|
||||
DWORD buffer1Size = 0;
|
||||
DWORD buffer2Size = 0;
|
||||
static std::uint8_t buffer1[bufferSize];
|
||||
static std::uint8_t buffer2[bufferSize];
|
||||
unsigned int buffer1Size = 0;
|
||||
unsigned int buffer2Size = 0;
|
||||
|
||||
// Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries
|
||||
DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
|
||||
DWORD desiredSize = header.GetFileSize() + nNumberOfBytesToWrite;
|
||||
unsigned int desiredSize = header.GetFileSize() + nNumberOfBytesToWrite;
|
||||
|
||||
if( desiredSize > currentHeapSize )
|
||||
{
|
||||
|
|
@ -577,7 +577,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, unsigned int nNumb
|
|||
// Fill buffer 1 from file
|
||||
if( (readStartOffset - bufferSize) < spaceStartOffset )
|
||||
{
|
||||
amountToRead = (DWORD)(readStartOffset - spaceStartOffset);
|
||||
amountToRead = static_cast<unsigned int>(readStartOffset - spaceStartOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -674,11 +674,11 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
|
|||
// On PS3, don't compress the data as we can't really afford the extra memory this requires for the output buffer. Instead we'll be writing
|
||||
// directly from the save data.
|
||||
StorageManager.SetSaveData(pvSaveMem,fileSize);
|
||||
uint8_t *compData = (uint8_t *)pvSaveMem;
|
||||
std::uint8_t *compData = (std::uint8_t *)pvSaveMem;
|
||||
#else
|
||||
// Attempt to allocate the required memory
|
||||
// We do not own this, it belongs to the StorageManager
|
||||
uint8_t *compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
std::uint8_t *compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
|
||||
#ifdef __PSVITA__
|
||||
// AP - make sure we always allocate just what is needed so it will only SAVE what is needed.
|
||||
|
|
@ -716,7 +716,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
|
|||
compLength = compLength+8;
|
||||
|
||||
// Attempt to allocate the required memory
|
||||
compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -824,7 +824,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
|
|||
|
||||
#if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WINDOWS64)
|
||||
|
||||
int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
|
||||
int ConsoleSaveFileOriginal::SaveSaveDataCallback(void *lpParam, bool bRes)
|
||||
{
|
||||
ConsoleSaveFile *pClass=(ConsoleSaveFile *)lpParam;
|
||||
|
||||
|
|
@ -842,7 +842,7 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/,
|
|||
|
||||
unsigned int fileSize = header.GetFileSize();
|
||||
|
||||
DWORD numberOfBytesWritten = 0;
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
#ifdef _XBOX
|
||||
File targetFileDir(L"GAME:\\Saves");
|
||||
#else
|
||||
|
|
@ -999,8 +999,8 @@ bool ConsoleSaveFileOriginal::isLocalEndianDifferent( ESavePlatform plat )
|
|||
|
||||
void ConsoleSaveFileOriginal::ConvertRegionFile(File sourceFile)
|
||||
{
|
||||
DWORD numberOfBytesWritten = 0;
|
||||
DWORD numberOfBytesRead = 0;
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
unsigned int numberOfBytesRead = 0;
|
||||
|
||||
RegionFile sourceRegionFile(this, &sourceFile);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ private:
|
|||
|
||||
public:
|
||||
#if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WINDOWS64)
|
||||
static int SaveSaveDataCallback(LPVOID lpParam,bool bRes);
|
||||
static int SaveSaveDataCallback(void *lpParam, bool bRes);
|
||||
#endif
|
||||
ConsoleSaveFileOriginal(const std::wstring &fileName, void *pvSaveData = NULL, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL);
|
||||
ConsoleSaveFileOriginal(const std::wstring &fileName, void *pvSaveData = NULL, unsigned int fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL);
|
||||
virtual ~ConsoleSaveFileOriginal();
|
||||
|
||||
// 4J Stu - Initial implementation is intended to have a similar interface to the standard Xbox file access functions
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ void ConsoleSaveFileSplit::RegionFileReference::Compress()
|
|||
unsigned char *dataIn = data;
|
||||
unsigned char *dataInLast = data + fileEntry->data.length;
|
||||
|
||||
// int64_t startTime = System::currentTimeMillis();
|
||||
// std::int64_t startTime = System::currentTimeMillis();
|
||||
|
||||
// One pass through to work out storage space required for compressed data
|
||||
unsigned int outputSize = 4; // 4 bytes required to store the uncompressed size for faster decompression
|
||||
|
|
@ -189,14 +189,14 @@ void ConsoleSaveFileSplit::RegionFileReference::Compress()
|
|||
}
|
||||
assert(( dataOut - dataCompressed ) == outputSize );
|
||||
dataCompressedSize = outputSize;
|
||||
// int64_t endTime = System::currentTimeMillis();
|
||||
// std::int64_t endTime = System::currentTimeMillis();
|
||||
// app.DebugPrintf("Compressing region file 0x%.8x from %d to %d bytes - %dms\n", fileEntry->data.regionIndex, fileEntry->data.length, dataCompressedSize, endTime - startTime);
|
||||
}
|
||||
|
||||
// Decompress from dataCompressed -> data. See comment in Compress method for format
|
||||
void ConsoleSaveFileSplit::RegionFileReference::Decompress()
|
||||
{
|
||||
// int64_t startTime = System::currentTimeMillis();
|
||||
// std::int64_t startTime = System::currentTimeMillis();
|
||||
fileEntry->data.length = *((unsigned int *)dataCompressed);
|
||||
|
||||
// If this is unusually large, then test how big it would be when expanded before trying to allocate. Matching the expanded size
|
||||
|
|
@ -285,7 +285,7 @@ void ConsoleSaveFileSplit::RegionFileReference::Decompress()
|
|||
data = NULL;
|
||||
assert(0);
|
||||
}
|
||||
// int64_t endTime = System::currentTimeMillis();
|
||||
// std::int64_t endTime = System::currentTimeMillis();
|
||||
// app.DebugPrintf("Decompressing region file from 0x%.8x %d to %d bytes - %dms\n", fileEntry->data.regionIndex, dataCompressedSize, fileEntry->data.length, endTime - startTime);//
|
||||
}
|
||||
|
||||
|
|
@ -380,9 +380,9 @@ FileEntry *ConsoleSaveFileSplit::GetRegionFileEntry(unsigned int regionIndex)
|
|||
return newRef->fileEntry;
|
||||
}
|
||||
|
||||
ConsoleSaveFileSplit::ConsoleSaveFileSplit(const std::wstring &fileName, void *pvSaveData /*= NULL*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/)
|
||||
ConsoleSaveFileSplit::ConsoleSaveFileSplit(const std::wstring &fileName, void *pvSaveData /*= NULL*/, unsigned int initialFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/)
|
||||
{
|
||||
DWORD fileSize = dFileSize;
|
||||
unsigned int fileSize = initialFileSize;
|
||||
|
||||
// Load a save from the game rules
|
||||
bool bLevelGenBaseSave = false;
|
||||
|
|
@ -419,7 +419,7 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit(ConsoleSaveFile *sourceSave, bool alr
|
|||
|
||||
std::vector<FileEntry *> *sourceFiles = sourceSave->getFilesWithPrefix(L"");
|
||||
|
||||
DWORD bytesWritten;
|
||||
unsigned int bytesWritten = 0;
|
||||
for(AUTO_VAR(it, sourceFiles->begin()); it != sourceFiles->end(); ++it)
|
||||
{
|
||||
FileEntry *sourceEntry = *it;
|
||||
|
|
@ -438,7 +438,7 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit(ConsoleSaveFile *sourceSave, bool alr
|
|||
}
|
||||
}
|
||||
|
||||
void ConsoleSaveFileSplit::_init(const std::wstring &fileName, void *pvSaveData, DWORD fileSize, ESavePlatform plat)
|
||||
void ConsoleSaveFileSplit::_init(const std::wstring &fileName, void *pvSaveData, unsigned int fileSize, ESavePlatform plat)
|
||||
{
|
||||
InitializeCriticalSectionAndSpinCount(&m_lock,5120);
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring &fileName, void *pvSaveData,
|
|||
regionFiles[regionIndex] = regionFileRef;
|
||||
}
|
||||
|
||||
DWORD heapSize = std::max( fileSize, (DWORD)(1024 * 1024 * 2)); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with
|
||||
unsigned int heapSize = std::max(fileSize, 1024u * 1024u * 2u); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with
|
||||
|
||||
// Initially committ enough room to store headSize bytes (using CSF_PAGE_SIZE pages, so rounding up here). We should only ever have one save file at a time,
|
||||
// and the pages should be decommitted in the dtor, so pages committed should always be zero at this point.
|
||||
|
|
@ -538,9 +538,9 @@ void ConsoleSaveFileSplit::_init(const std::wstring &fileName, void *pvSaveData,
|
|||
{
|
||||
|
||||
// Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries
|
||||
DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
|
||||
DWORD desiredSize = decompSize;
|
||||
unsigned int desiredSize = decompSize;
|
||||
|
||||
if( desiredSize > currentHeapSize )
|
||||
{
|
||||
|
|
@ -637,13 +637,13 @@ void ConsoleSaveFileSplit::deleteFile( FileEntry *file )
|
|||
|
||||
LockSaveAccess();
|
||||
|
||||
DWORD numberOfBytesRead = 0;
|
||||
DWORD numberOfBytesWritten = 0;
|
||||
unsigned int numberOfBytesRead = 0;
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
|
||||
const int bufferSize = 4096;
|
||||
int amountToRead = bufferSize;
|
||||
uint8_t buffer[bufferSize];
|
||||
DWORD bufferDataSize = 0;
|
||||
std::uint8_t buffer[bufferSize];
|
||||
unsigned int bufferDataSize = 0;
|
||||
|
||||
|
||||
char *readStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize();
|
||||
|
|
@ -911,7 +911,7 @@ bool ConsoleSaveFileSplit::closeHandle( FileEntry *file )
|
|||
// In this method, attempt to write any dirty region files, subject to maintaining a maximum write output rate. Writing is prioritised by time since the region was last written.
|
||||
void ConsoleSaveFileSplit::tick()
|
||||
{
|
||||
int64_t currentTime = System::currentTimeMillis();
|
||||
std::int64_t currentTime = System::currentTimeMillis();
|
||||
|
||||
// Don't do anything if the save system is up to something...
|
||||
if( StorageManager.GetSaveState() != C4JStorage::ESaveGame_Idle )
|
||||
|
|
@ -1052,15 +1052,15 @@ void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry *file, unsigned int nNumberO
|
|||
const unsigned int bufferSize = 4096;
|
||||
unsigned int amountToRead = bufferSize;
|
||||
//assert( nNumberOfBytesToWrite <= bufferSize );
|
||||
static uint8_t buffer1[bufferSize];
|
||||
static uint8_t buffer2[bufferSize];
|
||||
DWORD buffer1Size = 0;
|
||||
DWORD buffer2Size = 0;
|
||||
static std::uint8_t buffer1[bufferSize];
|
||||
static std::uint8_t buffer2[bufferSize];
|
||||
unsigned int buffer1Size = 0;
|
||||
unsigned int buffer2Size = 0;
|
||||
|
||||
// Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries
|
||||
DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE;
|
||||
|
||||
DWORD desiredSize = header.GetFileSize() + nNumberOfBytesToWrite;
|
||||
unsigned int desiredSize = header.GetFileSize() + nNumberOfBytesToWrite;
|
||||
|
||||
if( desiredSize > currentHeapSize )
|
||||
{
|
||||
|
|
@ -1142,7 +1142,7 @@ void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry *file, unsigned int nNumberO
|
|||
// Fill buffer 1 from file
|
||||
if( (readStartOffset - bufferSize) < spaceStartOffset )
|
||||
{
|
||||
amountToRead = (DWORD)(readStartOffset - spaceStartOffset);
|
||||
amountToRead = static_cast<unsigned int>(readStartOffset - spaceStartOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1360,7 +1360,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
|
|||
|
||||
// Attempt to allocate the required memory
|
||||
// We do not own this, it belongs to the StorageManager
|
||||
uint8_t *compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
std::uint8_t *compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
|
||||
// If we failed to allocate then compData will be NULL
|
||||
// Pre-calculate the compressed data size so that we can attempt to allocate a smaller buffer
|
||||
|
|
@ -1387,7 +1387,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
|
|||
compLength = compLength+8;
|
||||
|
||||
// Attempt to allocate the required memory
|
||||
compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
}
|
||||
|
||||
if(compData != NULL)
|
||||
|
|
@ -1464,7 +1464,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
|
|||
}
|
||||
}
|
||||
|
||||
int ConsoleSaveFileSplit::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
|
||||
int ConsoleSaveFileSplit::SaveSaveDataCallback(void *lpParam, bool bRes)
|
||||
{
|
||||
ConsoleSaveFileSplit *pClass=(ConsoleSaveFileSplit *)lpParam;
|
||||
|
||||
|
|
@ -1477,7 +1477,7 @@ int ConsoleSaveFileSplit::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ConsoleSaveFileSplit::SaveRegionFilesCallback(LPVOID lpParam,bool bRes)
|
||||
int ConsoleSaveFileSplit::SaveRegionFilesCallback(void *lpParam, bool bRes)
|
||||
{
|
||||
ConsoleSaveFileSplit *pClass=(ConsoleSaveFileSplit *)lpParam;
|
||||
|
||||
|
|
@ -1496,7 +1496,7 @@ void ConsoleSaveFileSplit::DebugFlushToFile(void *compressedData /*= NULL*/, uns
|
|||
|
||||
unsigned int fileSize = header.GetFileSize();
|
||||
|
||||
DWORD numberOfBytesWritten = 0;
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
|
||||
File targetFileDir(L"Saves");
|
||||
|
||||
|
|
@ -1649,8 +1649,8 @@ void ConsoleSaveFileSplit::setEndian(ByteOrder endian)
|
|||
|
||||
void ConsoleSaveFileSplit::ConvertRegionFile(File sourceFile)
|
||||
{
|
||||
DWORD numberOfBytesWritten = 0;
|
||||
DWORD numberOfBytesRead = 0;
|
||||
unsigned int numberOfBytesWritten = 0;
|
||||
unsigned int numberOfBytesRead = 0;
|
||||
|
||||
RegionFile sourceRegionFile(this, &sourceFile);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ private:
|
|||
class WriteHistory
|
||||
{
|
||||
public:
|
||||
int64_t writeTime;
|
||||
std::int64_t writeTime;
|
||||
unsigned int writeSize;
|
||||
} ;
|
||||
|
||||
class DirtyRegionFile
|
||||
{
|
||||
public:
|
||||
int64_t lastWritten;
|
||||
std::int64_t lastWritten;
|
||||
unsigned int fileRef;
|
||||
bool operator<(const DirtyRegionFile& rhs) const { return lastWritten < rhs.lastWritten; }
|
||||
};
|
||||
|
|
@ -46,11 +46,11 @@ private:
|
|||
unsigned int dataCompressedSize;
|
||||
int index;
|
||||
bool dirty;
|
||||
int64_t lastWritten;
|
||||
std::int64_t lastWritten;
|
||||
};
|
||||
std::unordered_map<unsigned int, RegionFileReference *> regionFiles;
|
||||
std::vector<WriteHistory> writeHistory;
|
||||
int64_t m_lastTickTime;
|
||||
std::int64_t m_lastTickTime;
|
||||
|
||||
FileEntry *GetRegionFileEntry(unsigned int regionIndex);
|
||||
|
||||
|
|
@ -79,14 +79,14 @@ private:
|
|||
void processSubfilesForWrite();
|
||||
void processSubfilesAfterWrite();
|
||||
public:
|
||||
static int SaveSaveDataCallback(LPVOID lpParam,bool bRes);
|
||||
static int SaveRegionFilesCallback(LPVOID lpParam,bool bRes);
|
||||
static int SaveSaveDataCallback(void *lpParam, bool bRes);
|
||||
static int SaveRegionFilesCallback(void *lpParam, bool bRes);
|
||||
|
||||
private:
|
||||
void _init(const std::wstring &fileName, void *pvSaveData, DWORD fileSize, ESavePlatform plat);
|
||||
void _init(const std::wstring &fileName, void *pvSaveData, unsigned int fileSize, ESavePlatform plat);
|
||||
|
||||
public:
|
||||
ConsoleSaveFileSplit(const std::wstring &fileName, void *pvSaveData = NULL, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL);
|
||||
ConsoleSaveFileSplit(const std::wstring &fileName, void *pvSaveData = NULL, unsigned int fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL);
|
||||
ConsoleSaveFileSplit(ConsoleSaveFile *sourceSave, bool alreadySmallRegions = true, ProgressListener *progress = NULL);
|
||||
virtual ~ConsoleSaveFileSplit();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue