Merge pull request #10 from tropicaaal/refactor/tropical-dev

fix: implement many POSIX stubs over required winapi calls
This commit is contained in:
DecalOverdose
2026-03-03 12:04:46 +04:00
committed by GitHub
26 changed files with 765 additions and 156 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
#include "net.minecraft.world.level.levelgen.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.storage.h"
#include "dimension.h"
#include "Dimension.h"
#include "BiomeSource.h"
#include "FixedBiomeSource.h"
#include "OldChunkStorage.h"
-1
View File
@@ -3,7 +3,6 @@
#include "InputOutputStream.h"
#include "PacketListener.h"
#include "GameEventPacket.h"
#include "../Minecraft.Client/PS3Media/strings.h"
const int GameEventPacket::NO_RESPAWN_BED_AVAILABLE = 0;
+1 -1
View File
@@ -65,7 +65,7 @@ File OldChunkStorage::getFile(int x, int z)
wchar_t xRadix36[64];
wchar_t zRadix36[64];
#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ )
#if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined __linux__ )
assert(0); // need a gcc verison of _itow ?
#else
_itow(x,xRadix36,36);
+1 -1
View File
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "net.minecraft.world.entity.h"
#include "net.minecraft.world.level.pathfinder.h"
#include "path.h"
#include "Path.h"
Path::~Path()
{
+3 -3
View File
@@ -407,7 +407,7 @@ void SparseDataStorage::addNewPlane(int y)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@@ -485,7 +485,7 @@ void SparseDataStorage::updateDataAndCount(__int64 newDataAndCount)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@@ -564,7 +564,7 @@ int SparseDataStorage::compress()
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 != lastDataAndCount )
{
+2
View File
@@ -1,5 +1,7 @@
#pragma once
#ifndef __linux__
#include "xmcore.h"
#endif // __linux__
// 4J added - Storage for data (ie the extra per tile storage). Data is normally stored as 4-bits per tile, in a DataLayer class of 16384 bytes ( 128 x 16 x 16 x 0.5 )
// This class provides more economical storage for such data by taking into consideration that it is quite common for large parts of the data to be very compressible (ie zero).
+3 -3
View File
@@ -413,7 +413,7 @@ void SparseLightStorage::addNewPlane(int y)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@@ -491,7 +491,7 @@ void SparseLightStorage::updateDataAndCount(__int64 newDataAndCount)
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 == lastDataAndCount )
{
@@ -581,7 +581,7 @@ int SparseLightStorage::compress()
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( &dataAndCount, newDataAndCount, lastDataAndCount );
__int64 lastDataAndCount2 = InterlockedCompareExchangeRelease64( (LONG64 *)&dataAndCount, newDataAndCount, lastDataAndCount );
if( lastDataAndCount2 != lastDataAndCount )
{
+2 -2
View File
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "WoodSlabTile.h"
#include "woodtile.h"
#include "treetile.h"
#include "WoodTile.h"
#include "TreeTile.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.biome.h"
#include "net.minecraft.world.item.h"
-66
View File
@@ -1,66 +0,0 @@
#ifndef WLINUX_H
#define WLINUX_H
#pragma once
#include <cstdint>
#include <cstring>
#include <string>
#define TRUE true
#define FALSE false
#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
#define ZeroMemory RtlZeroMemory
#define WINAPI
typedef unsigned int DWORD;
typedef const char *LPCSTR;
typedef bool BOOL;
typedef void* LPVOID;
typedef char WCHAR;
typedef unsigned char BYTE;
typedef BYTE* PBYTE;
typedef const wchar_t* LPCWSTR;
typedef unsigned long long ULONGLONG;
typedef int HRESULT;
typedef unsigned int UINT;
typedef void* HANDLE;
typedef int INT;
typedef long* PLONG;
typedef unsigned int* LPDWORD;
typedef const void* LPCVOID;
typedef char CHAR;
typedef void* PVOID;
typedef unsigned long* ULONG_PTR;
typedef long LONG;
typedef void VOID;
typedef ULONGLONG PlayerUID;
typedef DWORD WORD;
typedef struct {
DWORD LowPart;
long long QuadPart;
LONG HighPart;
} LARGE_INTEGER;
typedef long long LONGLONG;
typedef size_t SIZE_T;
typedef std::wstring LPWSTR;
typedef unsigned char boolean; // java brainrot
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
typedef struct _FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;
#define FILE_BEGIN SEEK_SET
typedef short SHORT;
typedef VOID* XMEMCOMPRESSION_CONTEXT;
typedef VOID* XMEMDECOMPRESSION_CONTEXT;
typedef float FLOAT;
#include "../x64headers/extraX64.h"
#endif // WLINUX_H
-166
View File
@@ -1,166 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Win32 replacements for XBox.
//
//=============================================================================
#if !defined( XBOXSTUBS_H ) && !defined( _X360 )
#define XBOXSTUBS_H
#ifdef _WIN32
#pragma once
#endif
// DecalOverdose: not available in 4J
//#include "tier0/platform.h"
#define POSIX
typedef unsigned int uint;
typedef unsigned long long int uint64;
typedef long long int int64;
#define FORCEINLINE
// Content creation/open flags
#define XCONTENTFLAG_NONE 0x00
#define XCONTENTFLAG_CREATENEW 0x00
#define XCONTENTFLAG_CREATEALWAYS 0x00
#define XCONTENTFLAG_OPENEXISTING 0x00
#define XCONTENTFLAG_OPENALWAYS 0x00
#define XCONTENTFLAG_TRUNCATEEXISTING 0x00
// Content attributes
#define XCONTENTFLAG_NOPROFILE_TRANSFER 0x00
#define XCONTENTFLAG_NODEVICE_TRANSFER 0x00
#define XCONTENTFLAG_STRONG_SIGNED 0x00
#define XCONTENTFLAG_ALLOWPROFILE_TRANSFER 0x00
#define XCONTENTFLAG_MOVEONLY_TRANSFER 0x00
// Console device ports
#define XDEVICE_PORT0 0
#define XDEVICE_PORT1 1
#define XDEVICE_PORT2 2
#define XDEVICE_PORT3 3
#define XUSER_MAX_COUNT 4
#define XUSER_INDEX_NONE 0x000000FE
#define XBX_CLR_DEFAULT 0xFF000000
#define XBX_CLR_WARNING 0x0000FFFF
#define XBX_CLR_ERROR 0x000000FF
#define XBOX_MINBORDERSAFE 0
#define XBOX_MAXBORDERSAFE 0
typedef enum
{
XK_NULL,
XK_BUTTON_UP,
XK_BUTTON_DOWN,
XK_BUTTON_LEFT,
XK_BUTTON_RIGHT,
XK_BUTTON_START,
XK_BUTTON_BACK,
XK_BUTTON_STICK1,
XK_BUTTON_STICK2,
XK_BUTTON_A,
XK_BUTTON_B,
XK_BUTTON_X,
XK_BUTTON_Y,
XK_BUTTON_LEFT_SHOULDER,
XK_BUTTON_RIGHT_SHOULDER,
XK_BUTTON_LTRIGGER,
XK_BUTTON_RTRIGGER,
XK_STICK1_UP,
XK_STICK1_DOWN,
XK_STICK1_LEFT,
XK_STICK1_RIGHT,
XK_STICK2_UP,
XK_STICK2_DOWN,
XK_STICK2_LEFT,
XK_STICK2_RIGHT,
XK_MAX_KEYS,
} xKey_t;
//typedef enum
//{
// XVRB_NONE, // off
// XVRB_ERROR, // fatal error
// XVRB_ALWAYS, // no matter what
// XVRB_WARNING, // non-fatal warnings
// XVRB_STATUS, // status reports
// XVRB_ALL,
//} xverbose_e;
#ifdef POSIX
typedef DWORD COLORREF;
#endif
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
#endif
// typedef struct {
// IN_ADDR ina; // IP address (zero if not static/DHCP)
// IN_ADDR inaOnline; // Online IP address (zero if not online)
// WORD wPortOnline; // Online port
// BYTE abEnet[6]; // Ethernet MAC address
// BYTE abOnline[20]; // Online identification
// } XNADDR;
typedef int XNADDR;
typedef uint64 XUID;
typedef struct {
BYTE ab[8]; // xbox to xbox key identifier
} XNKID;
typedef struct {
BYTE ab[16]; // xbox to xbox key exchange key
} XNKEY;
typedef struct _XSESSION_INFO
{
XNKID sessionID; // 8 bytes
XNADDR hostAddress; // 36 bytes
XNKEY keyExchangeKey; // 16 bytes
} XSESSION_INFO, *PXSESSION_INFO;
typedef struct _XSESSION_REGISTRANT
{
uint64 qwMachineID;
DWORD bTrustworthiness;
DWORD bNumUsers;
XUID *rgUsers;
} XSESSION_REGISTRANT;
typedef struct _XSESSION_REGISTRATION_RESULTS
{
DWORD wNumRegistrants;
XSESSION_REGISTRANT *rgRegistrants;
} XSESSION_REGISTRATION_RESULTS, *PXSESSION_REGISTRATION_RESULTS;
#define XSESSION_CREATE_HOST 0
#define XUSER_DATA_TYPE_INT32 0
#define XSESSION_CREATE_USES_ARBITRATION 0
#define XNET_QOS_LISTEN_ENABLE 0
#define XNET_QOS_LISTEN_DISABLE 0
#define XNET_QOS_LISTEN_SET_DATA 0
FORCEINLINE void XBX_ProcessEvents() {}
FORCEINLINE unsigned int XBX_GetSystemTime() { return 0; }
FORCEINLINE int XBX_GetPrimaryUserId() { return 0; }
FORCEINLINE void XBX_SetPrimaryUserId( DWORD idx ) {}
FORCEINLINE int XBX_GetStorageDeviceId() { return 0; }
FORCEINLINE void XBX_SetStorageDeviceId( DWORD idx ) {}
FORCEINLINE const char *XBX_GetLanguageString() { return ""; }
FORCEINLINE bool XBX_IsLocalized() { return false; }
#define XCONTENT_MAX_DISPLAYNAME_LENGTH 128
#define XCONTENT_MAX_FILENAME_LENGTH 42
#define XBX_INVALID_STORAGE_ID ((DWORD) -1)
#define XBX_STORAGE_DECLINED ((DWORD) -2)
#endif // XBOXSTUBS_H
+7 -11
View File
@@ -9,12 +9,8 @@
#define AUTO_VAR(_var, _val) auto _var = _val
#endif
typedef unsigned __int64;
typedef unsigned __uint64;
#if defined( __linux__ )
#include "linux/wlinux.h"
#include "linux/xbox_valve.h"
#if ( defined _XBOX || defined _WINDOWS64 || defined _DURANGO )
typedef unsigned __int64 __uint64;
#endif
#ifdef _WINDOWS64
@@ -98,6 +94,9 @@ typedef XUID GameSessionUID;
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "../Minecraft.Client/Linux/LinuxStubs.h"
#include "../Minecraft.Client/Linux/xbox_valve.h"
#else
#include <unordered_map>
#include <unordered_set>
@@ -126,11 +125,6 @@ typedef XUID GameSessionUID;
#include <assert.h>
#endif
#if defined(__linux__)
#else
#include "../Minecraft.Client/Xbox/Network/extra.h"
#endif
#include "Definitions.h"
#include "Class.h"
#include "Exceptions.h"
@@ -183,6 +177,7 @@ void MemSect(int sect);
#include "../Minecraft.Client/PSVita/4JLibs/inc/4J_Storage.h"
#include "../Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h"
#elif defined __linux__
// FIXME: Port 4JLibs to POSIX
#include "../Minecraft.Client/Windows64/4JLibs/inc/4J_Profile.h"
#include "../Minecraft.Client/Windows64/4JLibs/inc/4J_Render.h"
#include "../Minecraft.Client/Windows64/4JLibs/inc/4J_Storage.h"
@@ -246,6 +241,7 @@ void MemSect(int sect);
#include "../Minecraft.Client/PSVita/Sentient/SentientManager.h"
#include "../Minecraft.Client/PSVita/Sentient/MinecraftTelemetry.h"
#elif defined(__linux__)
// FIXME: Move and port to ../Minecraft.Client/Linux
#include "../Minecraft.Client/Windows64/Windows64_App.h"
#include "../Minecraft.Client/Windows64Media/strings.h"
#include "../Minecraft.Client/Windows64/Sentient/SentientTelemetryCommon.h"
-38
View File
@@ -23,44 +23,6 @@ const int XUSER_MAX_COUNT = 4;
const int MINECRAFT_NET_MAX_PLAYERS = 8;
#endif
#if defined(__linux__)
typedef struct _RTL_CRITICAL_SECTION {
// //
// // The following field is used for blocking when there is contention for
// // the resource
// //
//
union {
ULONG_PTR RawEvent[4];
} Synchronization;
//
// //
// // The following three fields control entering and exiting the critical
// // section for the resource
// //
//
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread;
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
inline void DeleteCriticalSection(CRITICAL_SECTION* stubEnterCS)
{
}
inline void EnterCriticalSection(CRITICAL_SECTION* stubEnterCS)
{
}
inline void LeaveCriticalSection( CRITICAL_SECTION* stubEnterCS)
{
}
#endif // __linux__
#ifdef __ORBIS__
#include <net.h>
#include <np/np_npid.h>