From a2fec2f3fcd1499d048aeabd214410a817a5a8a5 Mon Sep 17 00:00:00 2001 From: Peppersawce Date: Tue, 25 Nov 2025 15:16:58 +0100 Subject: Haiku patches diff --git a/CMakeLists.txt b/CMakeLists.txt index b6edd7f..5e33ea6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,7 +368,7 @@ else () set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif () - if (APPLE AND NOT USE_MMAP) + if (HAIKU OR (APPLE AND NOT USE_MMAP)) set(CMAKE_POSITION_INDEPENDENT_CODE OFF) else () set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/src/openrct2-ui/CMakeLists.txt b/src/openrct2-ui/CMakeLists.txt index cd3e3cc..d46972e 100644 --- a/src/openrct2-ui/CMakeLists.txt +++ b/src/openrct2-ui/CMakeLists.txt @@ -38,7 +38,7 @@ endif () if (NOT DISABLE_OPENGL AND NOT EMSCRIPTEN) # GL doesn't work nicely with macOS, while find_package doesn't work with multiarch on Ubuntu. - if (APPLE) + if (APPLE OR HAIKU) find_package(OpenGL REQUIRED) elseif (NOT WIN32) PKG_CHECK_MODULES(GL REQUIRED gl) @@ -100,7 +100,7 @@ endif () if (NOT DISABLE_OPENGL) if (WIN32) target_link_libraries(openrct2 opengl32) - elseif (APPLE) + elseif (APPLE OR HAIKU) target_link_libraries(openrct2 ${OPENGL_LIBRARY}) else () target_link_libraries(openrct2 ${GL_LIBRARIES}) diff --git a/src/openrct2-ui/UiContext.Linux.cpp b/src/openrct2-ui/UiContext.Linux.cpp index 7b2978d..cb785aa 100644 --- a/src/openrct2-ui/UiContext.Linux.cpp +++ b/src/openrct2-ui/UiContext.Linux.cpp @@ -129,14 +129,14 @@ namespace OpenRCT2::Ui void OpenFolder(const std::string& path) override { - const char* args[] = { "xdg-open", path.c_str(), nullptr }; + const char* args[] = { "open", path.c_str(), nullptr }; Platform::Execute(args); } void OpenURL(const std::string& url) override { #ifndef __EMSCRIPTEN__ - const char* args[] = { "xdg-open", url.c_str(), nullptr }; + const char* args[] = { "open", url.c_str(), nullptr }; Platform::Execute(args); #else MAIN_THREAD_EM_ASM({ window.open(UTF8ToString($0)); }, url.c_str()); diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt index f314c9c..e74c6be 100644 --- a/src/openrct2/CMakeLists.txt +++ b/src/openrct2/CMakeLists.txt @@ -180,7 +180,7 @@ if (MINGW) target_link_libraries(libopenrct2 -fstack-protector-strong) endif() -if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD") +if (UNIX AND NOT HAIKU AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD") # Include libdl for dlopen target_link_libraries(libopenrct2 dl) endif () diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index e697a8a..aa405f1 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -482,7 +482,7 @@ namespace OpenRCT2 _discordService = std::make_unique(); } #endif - +#ifndef __HAIKU__ if (Platform::ProcessIsElevated()) { std::string elevationWarning = _localisationService->GetString(STR_ADMIN_NOT_RECOMMENDED); @@ -495,6 +495,7 @@ namespace OpenRCT2 _uiContext->ShowMessageBox(elevationWarning); } } +#endif if (Platform::IsRunningInWine()) { diff --git a/src/openrct2/Version.h b/src/openrct2/Version.h index c56269e..ac7ba84 100644 --- a/src/openrct2/Version.h +++ b/src/openrct2/Version.h @@ -72,6 +72,9 @@ #ifdef __EMSCRIPTEN__ #define OPENRCT2_PLATFORM "Emscripten" #endif +#ifdef __HAIKU__ + #define OPENRCT2_PLATFORM "Haiku" +#endif #ifndef OPENRCT2_PLATFORM #error Unknown platform! #endif diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index a12c789..d74d808 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -128,7 +128,7 @@ namespace OpenRCT2::Audio } } -#ifndef __linux__ +#if not defined(__linux__) && not defined(__HAIKU__) // The first device is always system default on Windows and macOS std::string defaultDevice = LanguageGetString(STR_OPTIONS_SOUND_VALUE_DEFAULT); devices.insert(devices.begin(), defaultDevice); diff --git a/src/openrct2/core/FileScanner.cpp b/src/openrct2/core/FileScanner.cpp index 74a3d54..f9afe7e 100644 --- a/src/openrct2/core/FileScanner.cpp +++ b/src/openrct2/core/FileScanner.cpp @@ -12,7 +12,7 @@ #define WIN32_LEAN_AND_MEAN #endif #include -#elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#elif defined(__unix__) || defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__)) #include #include #include @@ -251,7 +251,7 @@ private: #endif // _WIN32 -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(__unix__) || defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__)) class FileScannerUnix final : public FileScannerBase { @@ -290,7 +290,9 @@ private: { DirectoryChild result; result.Name = std::string(node->d_name); - if (node->d_type == DT_DIR) + struct stat stbuf; + stat(node->d_name, &stbuf); + if (S_ISDIR(stbuf.st_mode)) { result.Type = DirectoryChildType::directory; } @@ -324,7 +326,7 @@ std::unique_ptr Path::ScanDirectory(const std::string& pattern, bo { #ifdef _WIN32 return std::make_unique(pattern, recurse); -#elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#elif defined(__unix__) || defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__)) return std::make_unique(pattern, recurse); #endif } diff --git a/src/openrct2/core/String.cpp b/src/openrct2/core/String.cpp index 10218ef..f7be97c 100644 --- a/src/openrct2/core/String.cpp +++ b/src/openrct2/core/String.cpp @@ -38,7 +38,7 @@ #include "StringBuilder.h" #include "UTF8.h" -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(__unix__) || defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__)) #include #define _stricmp(x, y) strcasecmp((x), (y)) #endif diff --git a/src/openrct2/network/Socket.cpp b/src/openrct2/network/Socket.cpp index 795b96b..a76caff 100644 --- a/src/openrct2/network/Socket.cpp +++ b/src/openrct2/network/Socket.cpp @@ -74,6 +74,10 @@ #endif // _WIN32 // clang-format on +#ifdef __HAIKU__ + #include +#endif + #include "Socket.h" namespace OpenRCT2::Network diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp index 5bcb8f9..1b464be 100644 --- a/src/openrct2/platform/Platform.Linux.cpp +++ b/src/openrct2/platform/Platform.Linux.cpp @@ -38,6 +38,10 @@ #include "../localisation/Language.h" #include "Platform.h" + #ifdef __HAIKU__ + #include + #endif + namespace OpenRCT2::Platform { // EnvLangGuard allows us to temporarily set the user's locale @@ -150,8 +154,8 @@ namespace OpenRCT2::Platform }; static constexpr u8string_view SearchLocations[] = { "/data", - "../share/openrct2", - "/usr/local/share/openrct2", + "/boot/system/data/openrct2", + "/boot/home/config/data/openrct2", "/var/lib/openrct2", "/usr/share/openrct2", }; @@ -180,6 +184,16 @@ namespace OpenRCT2::Platform { LOG_FATAL("failed to read /proc/self/exe"); } + #elif defined(__HAIKU__) + image_info info; + int32 cookie = 0; + + while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) >= B_OK) { + if (info.type == B_APP_IMAGE) { + strlcpy(exePath, info.name, sizeof(exePath)); + break; + } + } #elif defined(__FreeBSD__) || defined(__NetBSD__) #if defined(__FreeBSD__) const int32_t mib[] = { -- 2.52.0 From d85ac36365ed223d8c1f95b8c9c38a9a972c0972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Duval?= Date: Tue, 23 Dec 2025 11:58:37 +0100 Subject: Haiku patch for gcc diff --git a/src/openrct2-ui/UiContext.Linux.cpp b/src/openrct2-ui/UiContext.Linux.cpp index cb785aa..12513c6 100644 --- a/src/openrct2-ui/UiContext.Linux.cpp +++ b/src/openrct2-ui/UiContext.Linux.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#if (defined(__unix__) || defined(__EMSCRIPTEN__)) && !defined(__ANDROID__) && !defined(__APPLE__) +#if (defined(__unix__) || defined(__HAIKU__) || defined(__EMSCRIPTEN__)) && !defined(__ANDROID__) && !defined(__APPLE__) #include "UiContext.h" diff --git a/src/openrct2/core/Range.hpp b/src/openrct2/core/Range.hpp index 49adfd9..f055e10 100644 --- a/src/openrct2/core/Range.hpp +++ b/src/openrct2/core/Range.hpp @@ -29,6 +29,10 @@ struct Range T Change{}; private: + #if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + #endif Iterator(const Range& range, T initialValue) : Lower(range.Lower) , Upper(range.Upper) @@ -36,6 +40,9 @@ struct Range , Change(range.Upper >= range.Lower ? 1 : -1) { } + #if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic pop + #endif public: Iterator& operator++() diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp index 1b464be..10bb18e 100644 --- a/src/openrct2/platform/Platform.Linux.cpp +++ b/src/openrct2/platform/Platform.Linux.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#if defined(__unix__) && !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__) +#if (defined(__unix__) || defined(__HAIKU__)) && !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__) #include "../Diagnostic.h" diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 5329756..f8dee1e 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__HAIKU__) #include "Platform.h" diff --git a/src/openrct2/platform/Platform.h b/src/openrct2/platform/Platform.h index 6d477c7..94e9aba 100644 --- a/src/openrct2/platform/Platform.h +++ b/src/openrct2/platform/Platform.h @@ -147,7 +147,7 @@ namespace OpenRCT2::Platform SteamPaths GetSteamPaths(); bool triggerSteamDownload(); -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__HAIKU__) std::string GetEnvironmentPath(const char* name); std::string GetHomePath(); #endif -- 2.52.0 From 3a05fa620126970ae4415f4e79bc5a317114de40 Mon Sep 17 00:00:00 2001 From: Peppersawce Date: Tue, 23 Dec 2025 14:58:19 +0100 Subject: Disable installing linux desktop files diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e33ea6..8a2b6da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -517,6 +517,7 @@ if (NOT MACOS_BUNDLE OR (MACOS_BUNDLE AND WITH_TESTS)) endif() install(TARGETS "openrct2-cli" OPTIONAL RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") install(FILES ${DOC_FILES} DESTINATION "${CMAKE_INSTALL_DOCDIR}") + if (NOT HAIKU) install(FILES "distribution/linux/io.openrct2.openrct2.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo") if (NOT DISABLE_GUI) install(FILES "resources/logo/icon_x16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "openrct2.png") @@ -534,6 +535,7 @@ if (NOT MACOS_BUNDLE OR (MACOS_BUNDLE AND WITH_TESTS)) install(FILES "distribution/linux/io.openrct2.uri.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") endif() install(FILES "distribution/linux/io.openrct2.mimeinfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages/" RENAME "openrct2.xml") + endif() install(DIRECTORY "distribution/man/" DESTINATION "${CMAKE_INSTALL_MANDIR}/man6" FILES_MATCHING PATTERN "*.6") if (MACOS_USE_DEPENDENCIES) -- 2.52.0 From 726948309b8fa4980f330be5bd51ae6343cccfe4 Mon Sep 17 00:00:00 2001 From: Peppersawce Date: Wed, 24 Dec 2025 14:51:59 +0100 Subject: Disable multi-threading by default diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 2aef53b..672cb20 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -238,7 +238,7 @@ namespace OpenRCT2::Config // Always have multi-threading disabled in debug builds, this makes things slower. model->multiThreading = false; #else - model->multiThreading = reader->GetBoolean("multithreading", true); + model->multiThreading = reader->GetBoolean("multithreading", false); #endif // _DEBUG model->trapCursor = reader->GetBoolean("trap_cursor", false); model->autoOpenShops = reader->GetBoolean("auto_open_shops", false); -- 2.52.0