diff --git a/contributors.md b/contributors.md index ed85e30416..5c906fa9d1 100644 --- a/contributors.md +++ b/contributors.md @@ -57,6 +57,7 @@ Includes all git commit authors. Aliases are GitHub user names. * Hielke Morsink (Broxzier) - Tile inspector, heightmap loader, misc. * Joël Troch (JoelTroch) - Keyboard shortcuts for ride construction. * Thomas Delebo (delebota) - Misc. +* Brian Callahan (ibara) - OpenBSD port. ## Bug fixes * (halfbro) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 0aaab405e0..47d25f1cd1 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -7,6 +7,7 @@ - Feature: [#5576] Add a persistent 'display real names of guests' setting. - Feature: OpenRCT2 now starts up on the display it was last shown on. - Feature: [#5611] Add support for Android +- Feature: [#5706] Add support for OpenBSD - Improved: Construction rights can now be placed on park entrances. - Improved: Mouse can now be dragged to select scenery when saving track designs - Fix: [#259] Money making glitch involving swamps (original bug) diff --git a/src/openrct2-ui/UiContext.Linux.cpp b/src/openrct2-ui/UiContext.Linux.cpp index 763518fd63..0ef85c8d8c 100644 --- a/src/openrct2-ui/UiContext.Linux.cpp +++ b/src/openrct2-ui/UiContext.Linux.cpp @@ -14,7 +14,7 @@ *****************************************************************************/ #pragma endregion -#if defined(__linux__) && !defined(__ANDROID__) +#if (defined(__linux__) || defined(__OpenBSD__)) && !defined(__ANDROID__) #include #include @@ -50,6 +50,7 @@ namespace OpenRCT2 { namespace Ui bool IsSteamOverlayAttached() override { +#ifdef __linux__ // See http://syprog.blogspot.ru/2011/12/listing-loaded-shared-objects-in-linux.html struct lmap { @@ -84,6 +85,9 @@ namespace OpenRCT2 { namespace Ui dlclose(processHandle); } return result; +#else + return false; // Needed for OpenBSD, likely all other Unixes. +#endif } void ShowMessageBox(SDL_Window * window, const std::string &message) override @@ -351,4 +355,4 @@ namespace OpenRCT2 { namespace Ui } } } -#endif // __linux__ +#endif // __linux__ || __OpenBSD__ diff --git a/src/openrct2/Version.h b/src/openrct2/Version.h index c2c9b08d94..8835a1ad21 100644 --- a/src/openrct2/Version.h +++ b/src/openrct2/Version.h @@ -61,6 +61,9 @@ #ifdef __ANDROID__ #define OPENRCT2_PLATFORM "Android" #endif +#ifdef __OpenBSD__ + #define OPENRCT2_PLATFORM "OpenBSD" +#endif #ifndef OPENRCT2_PLATFORM #error Unknown platform! #endif diff --git a/src/openrct2/core/FileStream.hpp b/src/openrct2/core/FileStream.hpp index 29f033c6a2..a3081e0376 100644 --- a/src/openrct2/core/FileStream.hpp +++ b/src/openrct2/core/FileStream.hpp @@ -116,7 +116,7 @@ public: { #if defined(_MSC_VER) return _ftelli64(_file); -#elif (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__) +#elif (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__) || defined(__OpenBSD__) return ftello(_file); #else return ftello64(_file); @@ -142,7 +142,7 @@ public: _fseeki64(_file, offset, SEEK_END); break; } -#elif (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__) +#elif (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__) || defined(__OpenBSD__) switch (origin) { case STREAM_SEEK_BEGIN: fseeko(_file, offset, SEEK_SET); diff --git a/src/openrct2/core/String.hpp b/src/openrct2/core/String.hpp index 89459e59ed..97d43173df 100644 --- a/src/openrct2/core/String.hpp +++ b/src/openrct2/core/String.hpp @@ -16,6 +16,7 @@ #pragma once +#include #include #include #include "../common.h" diff --git a/src/openrct2/localisation/localisation.c b/src/openrct2/localisation/localisation.c index 10214ac111..f175e0dfeb 100644 --- a/src/openrct2/localisation/localisation.c +++ b/src/openrct2/localisation/localisation.c @@ -1372,7 +1372,7 @@ sint32 win1252_to_utf8(utf8string dst, const char *src, size_t srcLength, size_t //log_warning("converting %s of size %d", src, srcLength); char *buffer_conv = strndup(src, srcLength); char *buffer_orig = buffer_conv; - const char *to_charset = "UTF8"; + const char *to_charset = "UTF-8"; const char *from_charset = "CP1252"; iconv_t cd = iconv_open(to_charset, from_charset); if ((iconv_t)-1 == cd) diff --git a/src/openrct2/platform/linux.c b/src/openrct2/platform/linux.c index 70cc81419e..aebbb84177 100644 --- a/src/openrct2/platform/linux.c +++ b/src/openrct2/platform/linux.c @@ -18,7 +18,7 @@ // Despite the name, this file contains support for more OSs besides Linux, provided the necessary ifdefs remain small. // Otherwise, they should be spun off into their own files. -#if (defined(__linux__) || defined(__FREEBSD__)) && !defined(__ANDROID__) +#if (defined(__linux__) || defined(__FREEBSD__) || defined(__OpenBSD__)) && !defined(__ANDROID__) #ifdef __FREEBSD__ #include @@ -56,6 +56,10 @@ void platform_get_exe_path(utf8 *outPath, size_t outSize) log_fatal("failed to get process path"); } +#elif defined(__OpenBSD__) + // There is no way to get the path name of a running executable. + // If you are not using the port or package, you must change this line! + strlcpy(exePath, "/usr/local/bin/", sizeof(exePath)); #else #error "Platform does not support full path exe retrieval" #endif diff --git a/test/tests/CMakeLists.txt b/test/tests/CMakeLists.txt index 144ac356b4..11d63eb051 100644 --- a/test/tests/CMakeLists.txt +++ b/test/tests/CMakeLists.txt @@ -104,7 +104,11 @@ set(LANGUAGEPACK_TEST_SOURCES "${ROOT_DIR}/src/openrct2/localisation/LanguagePack.cpp" ) add_executable(test_languagepack ${LANGUAGEPACK_TEST_SOURCES}) -target_link_libraries(test_languagepack ${GTEST_LIBRARIES} test-common dl z SDL2) +if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD") + # Include libdl for dlopen + set(LDL dl) +endif () +target_link_libraries(test_languagepack ${GTEST_LIBRARIES} test-common ${LDL} z SDL2) add_test(NAME languagepack COMMAND test_languagepack) # INI test @@ -117,7 +121,7 @@ set(INI_TEST_SOURCES "${ROOT_DIR}/src/openrct2/core/MemoryStream.cpp" ) add_executable(test_ini ${INI_TEST_SOURCES}) -target_link_libraries(test_ini ${GTEST_LIBRARIES} test-common dl z) +target_link_libraries(test_ini ${GTEST_LIBRARIES} test-common ${LDL} z) add_test(NAME ini COMMAND test_ini) # String test @@ -125,7 +129,7 @@ set(STRING_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/StringTest.cpp" ) add_executable(test_string ${STRING_TEST_SOURCES}) -target_link_libraries(test_string ${GTEST_LIBRARIES} test-common dl z) +target_link_libraries(test_string ${GTEST_LIBRARIES} test-common ${LDL} z) add_test(NAME string COMMAND test_string) if (NOT DISABLE_RCT2_TESTS) @@ -133,13 +137,13 @@ if (NOT DISABLE_RCT2_TESTS) set(RIDE_RATINGS_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/RideRatings.cpp" "${CMAKE_CURRENT_LIST_DIR}/TestData.cpp") add_executable(test_ride_ratings ${RIDE_RATINGS_TEST_SOURCES}) - target_link_libraries(test_ride_ratings ${GTEST_LIBRARIES} libopenrct2 dl z) + target_link_libraries(test_ride_ratings ${GTEST_LIBRARIES} libopenrct2 ${LDL} z) add_test(NAME ride_ratings COMMAND test_ride_ratings) # Multi-launch test set(MULTILAUNCH_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/MultiLaunch.cpp" "${CMAKE_CURRENT_LIST_DIR}/TestData.cpp") add_executable(test_multilaunch ${MULTILAUNCH_TEST_SOURCES}) - target_link_libraries(test_multilaunch ${GTEST_LIBRARIES} libopenrct2 dl z) + target_link_libraries(test_multilaunch ${GTEST_LIBRARIES} libopenrct2 ${LDL} z) add_test(NAME multilaunch COMMAND test_multilaunch) endif ()