diff --git a/project/haiku/createpkg.sh b/project/haiku/createpkg.sh new file mode 100755 index 0000000..8558551 --- /dev/null +++ b/project/haiku/createpkg.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +mkdir build-haiku +cd build-haiku +cmake .. +make -j10 + +rm -rf pkg + +mkdir pkg +mkdir -p ./pkg/apps/ +mkdir -p ./pkg/data/minecraftpe +mkdir -p ./pkg/settings/minecraftpe +mkdir -p ./pkg/data/deskbar/menu/Applications/ +mkdir -p ./pkg/data/deskbar/menu/Games/ + +cp -rv ../project/haiku/pkg ./ +cp -v MinecraftPE ./pkg/apps/minecraftpe +cp -v MinecraftPE-server ./pkg/apps/minecraftpe-server +cp -rv data ./pkg/data/minecraftpe + +ln -s ../../../../apps/minecraftpe ./pkg/data/deskbar/menu/Applications/minecraftpe +ln -s ../../../../apps/minecraftpe ./pkg/data/deskbar/menu/Games/minecraftpe + + +package create -C pkg minecraftpe-0.6.1-x86_64.hpkg diff --git a/project/haiku/pkg/.PackageInfo b/project/haiku/pkg/.PackageInfo new file mode 100644 index 0000000..1888644 --- /dev/null +++ b/project/haiku/pkg/.PackageInfo @@ -0,0 +1,27 @@ +name minecraftpe +version 0.6.1-1 +architecture x86_64 +summary "Minecraft Pocket Edition" +description "A port of minecraft pocket edition to Haiku" +packager "Li " +vendor "Mojang" +copyrights { + "Copyright (C) 2026 by Mojang" +} +licenses { + "MIT" +} +provides { + minecraftpe = 0.6.1-1 + app:minecraftpe = 0.6.1-1 +} +requires { + glfw >= 3.3.7-1 + openal >= 1.21.1-5 +} +global-writable-files { + "settings/minecraftpe" directory keep-old +} +urls { + "https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1/" +} diff --git a/src/AppPlatform_glfw.h b/src/AppPlatform_glfw.h index d996860..eeb0444 100755 --- a/src/AppPlatform_glfw.h +++ b/src/AppPlatform_glfw.h @@ -20,6 +20,7 @@ #include #endif + #ifdef __EMSCRIPTEN__ #include #endif @@ -31,12 +32,19 @@ static void png_funcReadFile(png_structp pngPtr, png_bytep data, png_size_t leng class AppPlatform_glfw: public AppPlatform { public: - AppPlatform_glfw() + +#ifdef __HAIKU__ + std::string game_directory = "/system/data/minecraftpe/"; +#else + std::string game_directory = ""; +#endif + + AppPlatform_glfw() { } BinaryBlob readAssetFile(const std::string& filename) override { - FILE* fp = fopen(("data/" + filename).c_str(), "r"); + FILE* fp = fopen((game_directory + "data/" + filename).c_str(), "r"); if (!fp) return BinaryBlob(); @@ -73,7 +81,7 @@ public: TextureData out; - std::string filename = textureFolder? "data/images/" + filename_ + std::string filename = textureFolder? (game_directory + "data/images/") + filename_ : filename_; std::ifstream source(filename.c_str(), std::ios::binary); diff --git a/src/client/OptionsFile.cpp b/src/client/OptionsFile.cpp index ef2a0dc..e86e2ac 100755 --- a/src/client/OptionsFile.cpp +++ b/src/client/OptionsFile.cpp @@ -18,6 +18,8 @@ OptionsFile::OptionsFile() { settingsPath = "options.txt"; #elif defined(__EMSCRIPTEN__) settingsPath = "/games/com.mojang/options.txt"; +#elif defined(__HAIKU__) + settingsPath = "/system/settings/minecraftpe/options.txt"; #else settingsPath = "options.txt"; #endif diff --git a/src/main_glfw.h b/src/main_glfw.h index 042c9fb..a0fc283 100755 --- a/src/main_glfw.h +++ b/src/main_glfw.h @@ -191,8 +191,13 @@ int main(void) { App* app = new MAIN_CLASS(); g_app = app; +#ifdef __HAIKU__ + ((MAIN_CLASS*)g_app)->externalStoragePath = "/system/settings/minecraftpe"; + ((MAIN_CLASS*)g_app)->externalCacheStoragePath = "/system/settings/minecraftpe"; +#else ((MAIN_CLASS*)g_app)->externalStoragePath = "."; ((MAIN_CLASS*)g_app)->externalCacheStoragePath = "."; +#endif g_app->init(appContext); g_app->setSize(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight()); diff --git a/src/platform/CThread.cpp b/src/platform/CThread.cpp index 1592747..6bcd08a 100755 --- a/src/platform/CThread.cpp +++ b/src/platform/CThread.cpp @@ -25,12 +25,19 @@ &m_threadID // pointer to receive thread ID ); #endif - #if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) || defined(__HAIKU__) + #if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) mp_threadFunc = (pthread_fn)threadFunc; pthread_attr_init(&m_attributes); pthread_attr_setdetachstate( &m_attributes, PTHREAD_CREATE_DETACHED ); /*int error =*/ pthread_create(&m_thread, &m_attributes, mp_threadFunc, threadParam); + #endif + #if defined(__HAIKU__) + + mp_threadFunc = (thread_func)threadFunc; + m_thread = spawn_thread(mp_threadFunc, "CThread", 10, threadParam); + int res = resume_thread(m_thread); + #endif #ifdef MACOSX mp_threadFunc = (TaskProc) threadFunc; @@ -53,9 +60,12 @@ #ifdef WIN32 Sleep( millis ); #endif - #if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__HAIKU__) + #if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) usleep(millis * 1000); #endif + #if defined(__HAIKU__) + snooze((bigtime_t)(millis * 1000)); + #endif } CThread::~CThread() @@ -63,11 +73,14 @@ #ifdef WIN32 TerminateThread(m_threadHandle, 0); #endif - #if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__HAIKU__) + #if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) // Thread was created detached; pthread_join on a detached thread is undefined // and causes SIGABRT when the pthread_t is no longer valid. pthread_attr_destroy(&m_attributes); #endif + #if defined(__HAIKU__) + kill_thread(m_thread); + #endif } diff --git a/src/platform/CThread.h b/src/platform/CThread.h index 2cb1704..8781af4 100755 --- a/src/platform/CThread.h +++ b/src/platform/CThread.h @@ -13,7 +13,7 @@ typedef void *( * pthread_fn )( void * ); -#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) || defined(__HAIKU__) +#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) #include #include @@ -21,6 +21,9 @@ typedef void *( * pthread_fn )( void * ); #ifdef MACOSX #include #include +#endif +#ifdef __HAIKU__ +#include #endif class CThread @@ -38,11 +41,15 @@ typedef void *( * pthread_fn )( void * ); DWORD m_threadID; HANDLE m_threadHandle; #endif - #if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) || defined(__HAIKU__) + #if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) pthread_fn mp_threadFunc; pthread_t m_thread; pthread_attr_t m_attributes; #endif +#if defined(__HAIKU__) + thread_func mp_threadFunc; + thread_id m_thread; +#endif #ifdef MACOSX TaskProc mp_threadFunc; MPTaskID m_threadID;