Copied Teeworld patches for the Haiku operating system

Co-authored-by: Gerasim Troeglazov <3dEyes@gmail.com>
This commit is contained in:
Panagiotis Vasilopoulos 2021-04-17 18:49:41 +03:00 committed by def
parent 2bc420bef8
commit 6c02076c05
6 changed files with 40 additions and 3 deletions

View file

@ -155,7 +155,7 @@ if(CMAKE_GENERATOR STREQUAL "Ninja")
add_c_compiler_flag_if_supported(OUR_FLAGS -fcolor-diagnostics) add_c_compiler_flag_if_supported(OUR_FLAGS -fcolor-diagnostics)
endif() endif()
if(NOT MSVC) if(NOT MSVC AND NOT HAIKU)
if(CMAKE_VERSION VERSION_LESS 3.1 OR TARGET_OS STREQUAL "mac") if(CMAKE_VERSION VERSION_LESS 3.1 OR TARGET_OS STREQUAL "mac")
check_cxx_compiler_flag(-std=gnu++11 FLAG_SUPPORTED_std_gnu__11) check_cxx_compiler_flag(-std=gnu++11 FLAG_SUPPORTED_std_gnu__11)
if(FLAG_SUPPORTED_std_gnu__11) if(FLAG_SUPPORTED_std_gnu__11)
@ -210,9 +210,15 @@ if(NOT MSVC)
add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety) add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety)
# TODO: Enable for C++ code except gtest # TODO: Enable for C++ code except gtest
#add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN "-Wuseless-cast") #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() 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. check_c_compiler_flag("-O2;-Wp,-Werror;-D_FORTIFY_SOURCE=2" DEFINE_FORTIFY_SOURCE) # Some distributions define _FORTIFY_SOURCE by themselves.
endif() endif()

View file

@ -82,6 +82,13 @@
#define PLATFORM_STRING "beos" #define PLATFORM_STRING "beos"
#endif #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 */ /* use gcc endianness definitions when available */
#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun) #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)

View file

@ -2074,6 +2074,11 @@ int fs_storage_path(const char *appname, char *path, int max)
if(!home) if(!home)
return -1; 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) #if defined(CONF_PLATFORM_MACOS)
snprintf(path, max, "%s/Library/Application Support/%s", home, appname); snprintf(path, max, "%s/Library/Application Support/%s", home, appname);
#else #else
@ -2113,6 +2118,11 @@ int fs_makedir(const char *path)
return 0; return 0;
return -1; return -1;
#else #else
#ifdef CONF_PLATFORM_HAIKU
struct stat st;
if(stat(path, &st) == 0)
return 0;
#endif
if(mkdir(path, 0755) == 0) if(mkdir(path, 0755) == 0)
return 0; return 0;
if(errno == EEXIST) if(errno == EEXIST)

View file

@ -631,7 +631,11 @@ void sphore_destroy(SEMAPHORE *sem);
/* if compiled with -pedantic-errors it will complain about long /* if compiled with -pedantic-errors it will complain about long
not being a C90 thing. not being a C90 thing.
*/ */
#ifdef CONF_PLATFORM_HAIKU
#include <SupportDefs.h>
#else
__extension__ typedef long long int64; __extension__ typedef long long int64;
#endif
__extension__ typedef unsigned long long uint64; __extension__ typedef unsigned long long uint64;
#else #else
typedef long long int64; typedef long long int64;

View file

@ -4777,7 +4777,7 @@ void CGraphicsBackend_SDL_OpenGL::SetWindowParams(int FullscreenMode, bool IsBor
{ {
if(FullscreenMode == 1) 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); SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
#else #else
SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN); SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN);

View file

@ -6,6 +6,10 @@
#include <engine/client/updater.h> #include <engine/client/updater.h>
#include <engine/storage.h> #include <engine/storage.h>
#ifdef CONF_PLATFORM_HAIKU
#include <stdlib.h>
#endif
class CStorage : public IStorage class CStorage : public IStorage
{ {
public: public:
@ -193,6 +197,9 @@ public:
// 3) check for usable path in argv[0] // 3) check for usable path in argv[0]
{ {
#ifdef CONF_PLATFORM_HAIKU
pArgv0 = realpath(pArgv0, NULL);
#endif
unsigned int Pos = ~0U; unsigned int Pos = ~0U;
for(unsigned i = 0; pArgv0[i]; i++) for(unsigned i = 0; pArgv0[i]; i++)
if(pArgv0[i] == '/' || pArgv0[i] == '\\') if(pArgv0[i] == '/' || pArgv0[i] == '\\')
@ -211,6 +218,9 @@ public:
} }
} }
} }
#ifdef CONF_PLATFORM_HAIKU
free((void *)pArgv0);
#endif
#if defined(CONF_FAMILY_UNIX) #if defined(CONF_FAMILY_UNIX)
// 4) check for all default locations // 4) check for all default locations