From f622fe08a8e197ac93d05c862e73fd2240d39f3e Mon Sep 17 00:00:00 2001 From: JuiceyDev Date: Wed, 4 Mar 2026 23:17:28 +0100 Subject: [PATCH] fixed most stuff theres still linker issues --- 4J.Storage/4J_Storage.cpp | 9 + 4J.Storage/4J_Storage.h | 14 +- Minecraft.Client/Build/CMakeLists.txt | 11 +- .../Build/Common/Audio/SoundEngine.cpp | 13 +- .../Common/UI/UIControl_EnchantmentButton.cpp | 2 + .../Build/Common/UI/UIControl_Touch.cpp | 3 +- .../Build/Common/UI/UIController.cpp | 2 - .../UI/UIScene_InGameSaveManagementMenu.cpp | 6 + .../Build/Common/UI/UIScene_Intro.cpp | 2 + Minecraft.Client/Build/Extrax64Stubs.cpp | 4 +- Minecraft.Client/Build/stubs.cpp | 4 + .../Platform/DurangoMedia/loc/strings.h | 12 ++ .../Platform/Linux/Stubs/winapi_stubs.h | 199 ++++++++++++++++++ Minecraft.World/Build/CMakeLists.txt | 4 +- 14 files changed, 269 insertions(+), 16 deletions(-) diff --git a/4J.Storage/4J_Storage.cpp b/4J.Storage/4J_Storage.cpp index 939165bef..afdfd22af 100644 --- a/4J.Storage/4J_Storage.cpp +++ b/4J.Storage/4J_Storage.cpp @@ -81,3 +81,12 @@ unsigned int C4JStorage::CRC(unsigned char *buf, int len) { } return ~crc; } + +int C4JStorage::AddSubfile(int regionIndex) { (void)regionIndex; return 0; } +unsigned int C4JStorage::GetSubfileCount() { return 0; } +void C4JStorage::GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size) { (void)i; if(regionIndex) *regionIndex=0; if(data) *data=0; if(size) *size=0; } +void C4JStorage::ResetSubfiles() {} +void C4JStorage::UpdateSubfile(int index, void* data, unsigned int size) { (void)index; (void)data; (void)size; } +void C4JStorage::SaveSubfiles(int (*Func)(void*, const bool), void* param) { if(Func) Func(param, true); } +C4JStorage::ESaveGameState C4JStorage::GetSaveState() { return ESaveGame_Idle; } +void C4JStorage::ContinueIncompleteOperation() {} diff --git a/4J.Storage/4J_Storage.h b/4J.Storage/4J_Storage.h index ca83c46e7..7fa3f0745 100644 --- a/4J.Storage/4J_Storage.h +++ b/4J.Storage/4J_Storage.h @@ -337,10 +337,16 @@ public: unsigned int CRC(unsigned char *buf, int len); -// #ifdef _DEBUG -// void SetSaveName(int i); -// #endif - // string table for all the Storage problems. Loaded by the application + int AddSubfile(int regionIndex); + unsigned int GetSubfileCount(); + void GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size); + void ResetSubfiles(); + void UpdateSubfile(int index, void* data, unsigned int size); + void SaveSubfiles(int (*Func)(void*, const bool), void* param); + ESaveGameState GetSaveState(); + + void ContinueIncompleteOperation(); + C4JStringTable *m_pStringTable; }; diff --git a/Minecraft.Client/Build/CMakeLists.txt b/Minecraft.Client/Build/CMakeLists.txt index 805ee5739..f1824aeac 100644 --- a/Minecraft.Client/Build/CMakeLists.txt +++ b/Minecraft.Client/Build/CMakeLists.txt @@ -418,8 +418,8 @@ set(Common__Source_Files__UI__Controls "Common/UI/UIControl_TextInput.h" "Common/UI/UIControl_TexturePackList.cpp" "Common/UI/UIControl_TexturePackList.h" -# "Common/UI/UIControl_Touch.cpp" -# "Common/UI/UIControl_Touch.h" + "Common/UI/UIControl_Touch.cpp" + "Common/UI/UIControl_Touch.h" ) source_group("Common\\Source Files\\UI\\Controls" FILES ${Common__Source_Files__UI__Controls}) @@ -526,8 +526,8 @@ set(Common__Source_Files__UI__Scenes__In-Game_Menu_Screens "Common/UI/UIScene_InGameInfoMenu.h" "Common/UI/UIScene_InGamePlayerOptionsMenu.cpp" "Common/UI/UIScene_InGamePlayerOptionsMenu.h" -# "Common/UI/UIScene_InGameSaveManagementMenu.cpp" -# "Common/UI/UIScene_InGameSaveManagementMenu.h" + "Common/UI/UIScene_InGameSaveManagementMenu.cpp" + "Common/UI/UIScene_InGameSaveManagementMenu.h" "Common/UI/UIScene_PauseMenu.cpp" "Common/UI/UIScene_PauseMenu.h" "Common/UI/UIScene_SignEntryMenu.cpp" @@ -1104,6 +1104,8 @@ set(Linux "../Platform/Linux/Linux_UIController.cpp" "../Platform/Linux/Linux_Minecraft.cpp" "../Platform/Linux/Linux_App.cpp" + "../Platform/Linux/LinuxGL.cpp" + "../Platform/Linux/linux_game_stubs.cpp" ) source_group("Linux" FILES ${Linux}) @@ -5233,6 +5235,7 @@ if(UNIX AND NOT APPLE) target_link_libraries(${PROJECT_NAME} PRIVATE Minecraft.World OpenGL::GL + GLU ${GLFW3_LIBRARIES} 4J_Input 4J_Profile diff --git a/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp b/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp index 5dead08fb..f5707cdef 100644 --- a/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp +++ b/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp @@ -25,7 +25,7 @@ #endif // take out Orbis until they are done -#if defined _XBOX +#if defined _XBOX || defined(__linux__) SoundEngine::SoundEngine() {} void SoundEngine::init(Options *pOptions) @@ -52,6 +52,13 @@ void SoundEngine::addStreaming(const wstring& name, File *file) {} char *SoundEngine::ConvertSoundPathToName(const wstring& name, bool bConvertSpaces) { return NULL; } bool SoundEngine::isStreamingWavebankReady() { return true; } void SoundEngine::playMusicTick() {}; +void SoundEngine::SetStreamingSounds(int, int, int, int, int, int, int) {} +void SoundEngine::updateSystemMusicPlaying(bool) {} +#ifdef __linux__ +char SoundEngine::m_szSoundPath[]={"Sound/"}; +char SoundEngine::m_szMusicPath[]={"music/"}; +char SoundEngine::m_szRedistName[]={"redist64"}; +#endif #else @@ -95,6 +102,8 @@ char SoundEngine::m_szRedistName[]={"redist"}; #endif +#ifndef __linux__ + F32 AILCALLBACK custom_falloff_function (HSAMPLE S, F32 distance, F32 rolloff_factor, @@ -1666,3 +1675,5 @@ F32 AILCALLBACK custom_falloff_function (HSAMPLE S, return result; } + +#endif \ No newline at end of file diff --git a/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp b/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp index c8a365c94..955d0d718 100644 --- a/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp +++ b/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp @@ -1,4 +1,6 @@ #include "../../../../Minecraft.World/Build/stdafx.h" +#include +#include #include "UI.h" #include "UIControl_EnchantmentButton.h" #include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" diff --git a/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp b/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp index 07419543e..3abdea101 100644 --- a/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp +++ b/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp @@ -18,7 +18,7 @@ void UIControl_Touch::init(int iId) { m_id = iId; - // 4J-TomK - add this touch control to the vita touch box list +#if !defined(__linux__) switch(m_parentScene->GetParentLayer()->m_iLayer) { case eUILayer_Error: @@ -28,6 +28,7 @@ void UIControl_Touch::init(int iId) ui.TouchBoxAdd(this,m_parentScene); break; } +#endif } void UIControl_Touch::ReInit() diff --git a/Minecraft.Client/Build/Common/UI/UIController.cpp b/Minecraft.Client/Build/Common/UI/UIController.cpp index df8d64680..f5ed2c407 100644 --- a/Minecraft.Client/Build/Common/UI/UIController.cpp +++ b/Minecraft.Client/Build/Common/UI/UIController.cpp @@ -1285,7 +1285,6 @@ void UIController::setupCustomDrawGameStateAndMatrices(UIScene *scene, CustomDra void UIController::endCustomDrawGameState() { #if defined(__ORBIS__) || defined(__linux__) - // TO BE IMPLEMENTED RenderManager.Clear(GL_DEPTH_BUFFER_BIT); #else RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &m_customRenderingClearRect); @@ -2506,7 +2505,6 @@ C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT if (message == -1) { #if defined(_XBOX_ONE) || defined(_WINDOWS64) || defined(__linux__) - // IDS_CONTENT_RESTRICTION doesn't exist on XB1 message = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE; #else message = IDS_CONTENT_RESTRICTION; diff --git a/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp b/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp index e4c10af20..e6d544918 100644 --- a/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp +++ b/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp @@ -190,7 +190,9 @@ void UIScene_InGameSaveManagementMenu::tick() { if(m_bUpdateSaveSize) { +#if defined(_XBOX_ONE) || defined(__ORBIS__) m_spaceIndicatorSaves.selectSave(m_iSaveListIndex); +#endif m_bUpdateSaveSize = false; } @@ -200,7 +202,9 @@ void UIScene_InGameSaveManagementMenu::tick() m_pSaveDetails=StorageManager.ReturnSavesInfo(); if(m_pSaveDetails!=NULL) { +#if defined(_XBOX_ONE) || defined(__ORBIS__) m_spaceIndicatorSaves.reset(); +#endif m_bSavesDisplayed=true; @@ -286,6 +290,8 @@ void UIScene_InGameSaveManagementMenu::tick() (wchar_t *)u16Message, // destination buffer MAX_SAVEFILENAME_LENGTH // size of destination buffer, in WCHAR's ); +#elif defined(__linux__) + mbstowcs((wchar_t *)u16Message, m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH); #else #ifdef __PS3 size_t srcmax,dstmax; diff --git a/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp b/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp index 857426f18..a16729007 100644 --- a/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp +++ b/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp @@ -30,6 +30,8 @@ UIScene_Intro::UIScene_Intro(int iPad, void *initData, UILayer *parentLayer) : U int platformIdx = 4; #elif defined(__PSVITA__) int platformIdx = 5; +#elif defined(__linux__) + int platformIdx = 0; #endif IggyDataValue result; diff --git a/Minecraft.Client/Build/Extrax64Stubs.cpp b/Minecraft.Client/Build/Extrax64Stubs.cpp index e17b2f615..ea7c6394e 100644 --- a/Minecraft.Client/Build/Extrax64Stubs.cpp +++ b/Minecraft.Client/Build/Extrax64Stubs.cpp @@ -256,7 +256,7 @@ HRESULT XMemDecompress( XMEMDECOMPRESSION_CONTEXT Context, VOID *pDestination, SIZE_T *pDestSize, - CONST VOID *pSource, + VOID *pSource, SIZE_T SrcSize ) { @@ -287,7 +287,7 @@ HRESULT XMemCompress( XMEMCOMPRESSION_CONTEXT Context, VOID *pDestination, SIZE_T *pDestSize, - CONST VOID *pSource, + VOID *pSource, SIZE_T SrcSize ) { diff --git a/Minecraft.Client/Build/stubs.cpp b/Minecraft.Client/Build/stubs.cpp index 0c7e680a3..ad16cc431 100644 --- a/Minecraft.Client/Build/stubs.cpp +++ b/Minecraft.Client/Build/stubs.cpp @@ -1,5 +1,7 @@ #include "stdafx.h" +#ifndef __linux__ + void glReadPixels(int,int, int, int, int, int, ByteBuffer *) { } @@ -116,4 +118,6 @@ DWORD XCamSetView( ) { return 0; } XCAMDEVICESTATE XCamGetStatus() { return XCAMDEVICESTATE_DISCONNECTED; } +#endif + #endif \ No newline at end of file diff --git a/Minecraft.Client/Platform/DurangoMedia/loc/strings.h b/Minecraft.Client/Platform/DurangoMedia/loc/strings.h index 65759e893..00d0722a2 100644 --- a/Minecraft.Client/Platform/DurangoMedia/loc/strings.h +++ b/Minecraft.Client/Platform/DurangoMedia/loc/strings.h @@ -1955,3 +1955,15 @@ #define IDS_YOU_DIED 1953 #define IDS_YOU_HAVE 1954 #define IDS_ZOMBIE 1955 + +#ifdef __linux__ +#ifndef IDS_ERROR_NETWORK_TITLE +#define IDS_ERROR_NETWORK_TITLE IDS_ERROR_NETWORK +#endif +#ifndef IDS_ONLINE_SERVICE_TITLE +#define IDS_ONLINE_SERVICE_TITLE IDS_ERROR_NETWORK +#endif +#ifndef IDS_CONTENT_RESTRICTION +#define IDS_CONTENT_RESTRICTION IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE +#endif +#endif diff --git a/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h b/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h index f4638c8e9..998c7b394 100644 --- a/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h +++ b/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h @@ -4,6 +4,7 @@ #pragma once #include +#include #define TRUE true #define FALSE false @@ -781,6 +782,198 @@ static inline HANDLE CreateEvent(int manual_reset, int initial_state) { return (HANDLE)ev; } +static inline HANDLE CreateEvent(void*, BOOL manual_reset, BOOL initial_state, void*) { + return CreateEvent(manual_reset, initial_state); +} + +static inline BOOL SetEvent(HANDLE hEvent) { + Event* ev = (Event*)hEvent; + if (!ev) return FALSE; + pthread_mutex_lock(&ev->mutex); + ev->signaled = 1; + if (ev->manual_reset) pthread_cond_broadcast(&ev->cond); + else pthread_cond_signal(&ev->cond); + pthread_mutex_unlock(&ev->mutex); + return TRUE; +} + +static inline BOOL ResetEvent(HANDLE hEvent) { + Event* ev = (Event*)hEvent; + if (!ev) return FALSE; + pthread_mutex_lock(&ev->mutex); + ev->signaled = 0; + pthread_mutex_unlock(&ev->mutex); + return TRUE; +} + +#define WAIT_OBJECT_0 0 +#define WAIT_TIMEOUT 258 +#define WAIT_FAILED ((DWORD)0xFFFFFFFF) +#define INFINITE 0xFFFFFFFF + +static inline DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { + Event* ev = (Event*)hHandle; + if (!ev) return WAIT_FAILED; + pthread_mutex_lock(&ev->mutex); + if (dwMilliseconds == INFINITE) { + while (!ev->signaled) pthread_cond_wait(&ev->cond, &ev->mutex); + } else if (dwMilliseconds > 0) { + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += dwMilliseconds / 1000; + ts.tv_nsec += (dwMilliseconds % 1000) * 1000000; + if (ts.tv_nsec >= 1000000000) { ts.tv_sec++; ts.tv_nsec -= 1000000000; } + while (!ev->signaled) { + if (pthread_cond_timedwait(&ev->cond, &ev->mutex, &ts) != 0) { + pthread_mutex_unlock(&ev->mutex); + return WAIT_TIMEOUT; + } + } + } else { + if (!ev->signaled) { pthread_mutex_unlock(&ev->mutex); return WAIT_TIMEOUT; } + } + if (!ev->manual_reset) ev->signaled = 0; + pthread_mutex_unlock(&ev->mutex); + return WAIT_OBJECT_0; +} + +static inline DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds) { + if (bWaitAll) { + for (DWORD i = 0; i < nCount; i++) WaitForSingleObject(lpHandles[i], dwMilliseconds); + return WAIT_OBJECT_0; + } + for (int pass = 0; pass < 1000; pass++) { + for (DWORD i = 0; i < nCount; i++) { + if (WaitForSingleObject(lpHandles[i], 0) == WAIT_OBJECT_0) return WAIT_OBJECT_0 + i; + } + usleep(1000); + } + return WAIT_TIMEOUT; +} + +static inline void CloseHandle_Event(HANDLE hEvent) { + Event* ev = (Event*)hEvent; + if (!ev) return; + pthread_mutex_destroy(&ev->mutex); + pthread_cond_destroy(&ev->cond); + free(ev); +} + +#define STILL_ACTIVE 259 +#define CREATE_SUSPENDED 0x00000004 +#define THREAD_PRIORITY_LOWEST (-2) +#define THREAD_PRIORITY_BELOW_NORMAL (-1) +#define THREAD_PRIORITY_NORMAL 0 +#define THREAD_PRIORITY_ABOVE_NORMAL 1 +#define THREAD_PRIORITY_HIGHEST 2 +#define THREAD_PRIORITY_TIME_CRITICAL 15 + +typedef DWORD (*LPTHREAD_START_ROUTINE)(void*); + +struct LinuxThread { + pthread_t thread; + LPTHREAD_START_ROUTINE func; + void* param; + DWORD threadId; + DWORD exitCode; + int suspended; + pthread_mutex_t suspendMutex; + pthread_cond_t suspendCond; +}; + +static inline void* _linux_thread_entry(void* arg) { + LinuxThread* lt = (LinuxThread*)arg; + pthread_mutex_lock(<->suspendMutex); + while (lt->suspended) pthread_cond_wait(<->suspendCond, <->suspendMutex); + pthread_mutex_unlock(<->suspendMutex); + lt->exitCode = lt->func(lt->param); + return NULL; +} + +static DWORD g_nextThreadId = 1000; + +static inline HANDLE CreateThread(void*, SIZE_T stackSize, LPTHREAD_START_ROUTINE lpStartAddress, void* lpParameter, DWORD dwCreationFlags, DWORD* lpThreadId) { + LinuxThread* lt = (LinuxThread*)calloc(1, sizeof(LinuxThread)); + lt->func = lpStartAddress; + lt->param = lpParameter; + lt->exitCode = STILL_ACTIVE; + lt->suspended = (dwCreationFlags & CREATE_SUSPENDED) ? 1 : 0; + lt->threadId = __sync_fetch_and_add(&g_nextThreadId, 1); + pthread_mutex_init(<->suspendMutex, NULL); + pthread_cond_init(<->suspendCond, NULL); + if (lpThreadId) *lpThreadId = lt->threadId; + pthread_attr_t attr; + pthread_attr_init(&attr); + if (stackSize > 0) pthread_attr_setstacksize(&attr, stackSize); + pthread_create(<->thread, &attr, _linux_thread_entry, lt); + pthread_attr_destroy(&attr); + return (HANDLE)lt; +} + +static inline DWORD ResumeThread(HANDLE hThread) { + LinuxThread* lt = (LinuxThread*)hThread; + if (!lt) return (DWORD)-1; + pthread_mutex_lock(<->suspendMutex); + lt->suspended = 0; + pthread_cond_signal(<->suspendCond); + pthread_mutex_unlock(<->suspendMutex); + return 0; +} + +static inline BOOL SetThreadPriority(HANDLE hThread, int nPriority) { + (void)hThread; (void)nPriority; + return TRUE; +} + +static inline BOOL GetExitCodeThread(HANDLE hThread, DWORD* lpExitCode) { + LinuxThread* lt = (LinuxThread*)hThread; + if (!lt || !lpExitCode) return FALSE; + *lpExitCode = lt->exitCode; + return TRUE; +} + +static inline DWORD GetCurrentThreadId() { + return (DWORD)(unsigned long)pthread_self(); +} + +static inline HANDLE GetCurrentThread() { + return (HANDLE)(unsigned long)pthread_self(); +} + +template +static inline int sprintf_s(char (&buf)[N], const char* fmt, ...) { + va_list args; + va_start(args, fmt); + int ret = vsnprintf(buf, N, fmt, args); + va_end(args); + return ret; +} + +static inline int sprintf_s(char* buf, size_t sz, const char* fmt, ...) { + va_list args; + va_start(args, fmt); // fucking horrid + int ret = vsnprintf(buf, sz, fmt, args); + va_end(args); + return ret; +} + +template +static inline int swprintf_s(wchar_t (&buf)[N], const wchar_t* fmt, ...) { + va_list args; + va_start(args, fmt); + int ret = vswprintf(buf, N, fmt, args); + va_end(args); + return ret; +} + +static inline int swprintf_s(wchar_t* buf, size_t sz, const wchar_t* fmt, ...) { + va_list args; + va_start(args, fmt); + int ret = vswprintf(buf, sz, fmt, args); + va_end(args); + return ret; +} + static inline HMODULE GetModuleHandle(LPCSTR lpModuleName) { return 0; } static inline LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { @@ -791,5 +984,11 @@ static inline BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType assert(0 && "FIXME: implement VirtualFree"); } +#define swscanf_s swscanf +#define sscanf_s sscanf +#define _wcsicmp wcscasecmp +#define _stricmp strcasecmp +#define _strnicmp strncasecmp +#define _wcsnicmp wcsncasecmp #endif // WINAPISTUBS_H diff --git a/Minecraft.World/Build/CMakeLists.txt b/Minecraft.World/Build/CMakeLists.txt index 845d05422..a1e93b28e 100644 --- a/Minecraft.World/Build/CMakeLists.txt +++ b/Minecraft.World/Build/CMakeLists.txt @@ -29,8 +29,8 @@ set(ConsoleHelpers__ConsoleSaveFileIO "../IO/Files/ConsoleSaveFileOriginal.h" "../IO/Files/ConsoleSaveFileOutputStream.cpp" "../IO/Files/ConsoleSaveFileOutputStream.h" -# "ConsoleSaveFileSplit.cpp" -# "ConsoleSaveFileSplit.h" + "../IO/Files/ConsoleSaveFileSplit.cpp" + "../IO/Files/ConsoleSaveFileSplit.h" "../IO/Files/ConsoleSavePath.h" "../IO/Files/FileHeader.cpp" "../IO/Files/FileHeader.h"