mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-23 07:23:05 +00:00
refactor: remove a bunch of linux-specific ifndefs
Now that we're stubbing winapi through stdafx, these need to go.
This commit is contained in:
parent
4d9a1c73e6
commit
7abf08a804
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@
|
|||
#ifdef __ORBIS__
|
||||
#include <pad.h>
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <math.h>
|
||||
#endif
|
||||
IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu()
|
||||
{
|
||||
m_menu = NULL;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,31 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
#include <atomic>
|
||||
#include <climits>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include <pthread.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <locale>
|
||||
#include <linux/mman.h>
|
||||
#include <sys/mman.h>
|
||||
#include <codecvt>
|
||||
|
||||
#include "winapi_stubs.h"
|
||||
#include "d3d11_stubs.h"
|
||||
#include "xbox_stubs.h"
|
||||
|
|
|
|||
|
|
@ -3,26 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
#include <atomic>
|
||||
#include <climits>
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include <pthread.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <unistd.h>
|
||||
#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<EFBFBD>s game, the next game that player joins will produce a message stating that the host has left.
|
||||
//close(DisconnectPacket::eDisconnect_EndOfStream);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <ctime>
|
||||
|
||||
#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 <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 )
|
||||
|
|
@ -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<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
|
||||
#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;;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,20 +10,6 @@
|
|||
#include <fios2.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <sys/types.h>
|
||||
#include <string>
|
||||
#include <unistd.h> // for access()
|
||||
#include <fcntl.h>
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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__
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 <pthread.h> // 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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue