Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copied Teeworld patches for the Haiku operating system #3779

Merged
merged 1 commit into from Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions CMakeLists.txt
Expand Up @@ -155,7 +155,7 @@ if(CMAKE_GENERATOR STREQUAL "Ninja")
add_c_compiler_flag_if_supported(OUR_FLAGS -fcolor-diagnostics)
endif()

if(NOT MSVC)
if(NOT MSVC AND NOT HAIKU)
if(CMAKE_VERSION VERSION_LESS 3.1 OR TARGET_OS STREQUAL "mac")
check_cxx_compiler_flag(-std=gnu++11 FLAG_SUPPORTED_std_gnu__11)
if(FLAG_SUPPORTED_std_gnu__11)
Expand Down Expand Up @@ -210,9 +210,15 @@ if(NOT MSVC)
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety)
# TODO: Enable for C++ code except gtest
#add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN "-Wuseless-cast")
else()
if(TARGET_OS STREQUAL "haiku")
set(PLATFORM_CLIENT)
find_package(OpenGL)
set(PLATFORM_LIBS GL network)
endif()
endif()

if(NOT MSVC)
if(NOT MSVC AND NOT HAIKU)
check_c_compiler_flag("-O2;-Wp,-Werror;-D_FORTIFY_SOURCE=2" DEFINE_FORTIFY_SOURCE) # Some distributions define _FORTIFY_SOURCE by themselves.
endif()

Expand Down
7 changes: 7 additions & 0 deletions src/base/detect.h
Expand Up @@ -82,6 +82,13 @@
#define PLATFORM_STRING "beos"
#endif

#if defined(__HAIKU__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_HAIKU 1
#define CONF_PLATFORM_STRING "haiku"
#endif

/* use gcc endianness definitions when available */
#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
Expand Down
10 changes: 10 additions & 0 deletions src/base/system.c
Expand Up @@ -2074,6 +2074,11 @@ int fs_storage_path(const char *appname, char *path, int max)
if(!home)
return -1;

#if defined(CONF_PLATFORM_HAIKU)
str_format(path, max, "%s/config/settings/%s", home, appname);
return 0;
#endif

#if defined(CONF_PLATFORM_MACOS)
snprintf(path, max, "%s/Library/Application Support/%s", home, appname);
#else
Expand Down Expand Up @@ -2113,6 +2118,11 @@ int fs_makedir(const char *path)
return 0;
return -1;
#else
#ifdef CONF_PLATFORM_HAIKU
struct stat st;
if(stat(path, &st) == 0)
return 0;
#endif
if(mkdir(path, 0755) == 0)
return 0;
if(errno == EEXIST)
Expand Down
4 changes: 4 additions & 0 deletions src/base/system.h
Expand Up @@ -631,7 +631,11 @@ void sphore_destroy(SEMAPHORE *sem);
/* if compiled with -pedantic-errors it will complain about long
not being a C90 thing.
*/
#ifdef CONF_PLATFORM_HAIKU
#include <SupportDefs.h>
#else
__extension__ typedef long long int64;
#endif
__extension__ typedef unsigned long long uint64;
#else
typedef long long int64;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/backend_sdl.cpp
Expand Up @@ -4777,7 +4777,7 @@ void CGraphicsBackend_SDL_OpenGL::SetWindowParams(int FullscreenMode, bool IsBor
{
if(FullscreenMode == 1)
{
#if defined(CONF_PLATFORM_MACOS) // Todo SDL: remove this when fixed (game freezes when losing focus in fullscreen)
#if defined(CONF_PLATFORM_MACOS) || defined(CONF_PLATFORM_HAIKU) // Todo SDL: remove this when fixed (game freezes when losing focus in fullscreen)
SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
#else
SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN);
Expand Down
10 changes: 10 additions & 0 deletions src/engine/shared/storage.cpp
Expand Up @@ -6,6 +6,10 @@
#include <engine/client/updater.h>
#include <engine/storage.h>

#ifdef CONF_PLATFORM_HAIKU
#include <stdlib.h>
#endif

class CStorage : public IStorage
{
public:
Expand Down Expand Up @@ -193,6 +197,9 @@ class CStorage : public IStorage

// 3) check for usable path in argv[0]
{
#ifdef CONF_PLATFORM_HAIKU
pArgv0 = realpath(pArgv0, NULL);
#endif
unsigned int Pos = ~0U;
for(unsigned i = 0; pArgv0[i]; i++)
if(pArgv0[i] == '/' || pArgv0[i] == '\\')
Expand All @@ -211,6 +218,9 @@ class CStorage : public IStorage
}
}
}
#ifdef CONF_PLATFORM_HAIKU
free((void *)pArgv0);
#endif

#if defined(CONF_FAMILY_UNIX)
// 4) check for all default locations
Expand Down