From 966633f31018563159b982ee74fc47c2aef972d6 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 30 Sep 2021 15:40:11 +1000
Subject: Override OpenGL version to 3.3


diff --git a/src/main.cpp b/src/main.cpp
index 6fedafd..6514065 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2096,6 +2096,10 @@ int ios_main(int argc, char *argv[])
 int main(int argc, char *argv[])
 #endif
 {
+#ifdef __HAIKU__
+	setenv("MESA_GL_VERSION_OVERRIDE", "3.3", 1);
+	setenv("MESA_GLSL_VERSION_OVERRIDE", "330", 1);
+#endif
 #ifdef __SWITCH__
     constexpr devoptab_t dotab_stdout = {
         .name    = "con",
-- 
2.30.2


From 0a51df627291d3c50dd97553fa35259a509c6137 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 30 Sep 2021 18:12:15 +1000
Subject: Fix settings directory


diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0e646f..599778f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -757,6 +757,10 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
     SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
 endif()
 
+if(HAIKU)
+    target_link_libraries(supertuxkart -lbe -lnetwork)
+endif()
+
 # Wiiuse
 # ------
 if(USE_WIIUSE)
diff --git a/src/io/file_manager.cpp b/src/io/file_manager.cpp
index 4730999..e872064 100644
--- a/src/io/file_manager.cpp
+++ b/src/io/file_manager.cpp
@@ -37,6 +37,11 @@
 #include "io/assets_android.hpp"
 #endif
 
+#ifdef __HAIKU__
+#include <Path.h>
+#include <FindDirectory.h>
+#endif
+
 #include <irrlicht.h>
 
 #include <stdio.h>
@@ -1016,6 +1021,18 @@ void FileManager::checkAndCreateConfigDir()
         const std::string CONFIGDIR("SuperTuxKart");
         m_user_config_dir += CONFIGDIR;
 
+#elif defined(__HAIKU__)
+
+		BPath settings_dir;
+		if (find_directory(B_USER_SETTINGS_DIRECTORY, &settings_dir, true, NULL) == B_OK) {
+			m_user_config_dir = std::string(settings_dir.Path());
+		} else {
+			if (getenv("HOME") != NULL)
+	            m_user_config_dir = getenv("HOME");
+			m_user_config_dir += "/config/settings";
+		}
+        m_user_config_dir += "/SuperTuxKart";
+
 #else
 
         // Remaining unix variants. Use the new standards for config directory
@@ -1081,6 +1098,8 @@ void FileManager::checkAndCreateAddonsDir()
 {
 #if defined(WIN32)
     m_addons_dir  = m_user_config_dir+"../addons/";
+#elif defined(__HAIKU__)
+	m_addons_dir  = m_user_config_dir+"addons/";
 #elif defined(__APPLE__)
     m_addons_dir  = getenv("HOME");
     m_addons_dir += "/Library/Application Support/SuperTuxKart/Addons/";
@@ -1116,7 +1135,7 @@ void FileManager::checkAndCreateAddonsDir()
  */
 void FileManager::checkAndCreateScreenshotDir()
 {
-#if defined(WIN32)
+#if defined(WIN32) || defined(__HAIKU__)
     m_screenshot_dir  = m_user_config_dir+"screenshots/";
 #elif defined(__APPLE__)
     m_screenshot_dir  = getenv("HOME");
@@ -1142,7 +1161,7 @@ void FileManager::checkAndCreateScreenshotDir()
  */
 void FileManager::checkAndCreateReplayDir()
 {
-#if defined(WIN32)
+#if defined(WIN32) || defined(__HAIKU__)
     m_replay_dir = m_user_config_dir + "replay/";
 #elif defined(__APPLE__)
     m_replay_dir  = getenv("HOME");
@@ -1168,7 +1187,7 @@ void FileManager::checkAndCreateReplayDir()
 */
 void FileManager::checkAndCreateCachedTexturesDir()
 {
-#if defined(WIN32)
+#if defined(WIN32) || defined(__HAIKU__)
     m_cached_textures_dir = m_user_config_dir + "cached-textures/";
 #elif defined(__APPLE__)
     m_cached_textures_dir = getenv("HOME");
@@ -1193,7 +1212,7 @@ void FileManager::checkAndCreateCachedTexturesDir()
  */
 void FileManager::checkAndCreateGPDir()
 {
-#if defined(WIN32)
+#if defined(WIN32) || defined(__HAIKU__)
     m_gp_dir = m_user_config_dir + "grandprix/";
 #elif defined(__APPLE__)
     m_gp_dir  = getenv("HOME");
-- 
2.30.2


From 8045b620248b4250087e5a01aaa10bf2190286f5 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 30 Sep 2021 18:19:34 +1000
Subject: Use minimal graphics settings by default


diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp
index 9297c84..88f51f6 100644
--- a/src/config/user_config.hpp
+++ b/src/config/user_config.hpp
@@ -669,7 +669,7 @@ namespace UserConfigParams
         PARAM_DEFAULT(BoolUserConfigParam(false, "enable_light_shaft",
         &m_video_group, "Enable Light Shafts"));
     PARAM_PREFIX BoolUserConfigParam        m_dynamic_lights
-        PARAM_DEFAULT(BoolUserConfigParam(true, "enable_dynamic_lights",
+        PARAM_DEFAULT(BoolUserConfigParam(false, "enable_dynamic_lights",
         &m_video_group, "Enable Dynamic Lights"));
     PARAM_PREFIX BoolUserConfigParam        m_dof
         PARAM_DEFAULT(BoolUserConfigParam(false, "enable_dof",
@@ -906,7 +906,7 @@ namespace UserConfigParams
                                                 "Graphics Quality Settings") );
 
     PARAM_PREFIX IntUserConfigParam        m_particles_effects
-            PARAM_DEFAULT(  IntUserConfigParam(2, "particles-effecs",
+            PARAM_DEFAULT(  IntUserConfigParam(0, "particles-effecs",
                             &m_graphics_quality, "Particles effects: 0 disabled, 1 only important, 2 enabled") );
 
     // This saves the actual user preference.
@@ -925,13 +925,13 @@ namespace UserConfigParams
                 "Whether to display animated characters") );
 
     PARAM_PREFIX IntUserConfigParam        m_geometry_level
-            PARAM_DEFAULT(  IntUserConfigParam(GEOLEVEL_0,
+            PARAM_DEFAULT(  IntUserConfigParam(GEOLEVEL_2,
                             "geometry_level", &m_graphics_quality,
                 "Geometry quality 0=everything is displayed; "
                 "1=a few details are displayed; 2=lowest level, no details") );
 
     PARAM_PREFIX IntUserConfigParam         m_anisotropic
-            PARAM_DEFAULT( IntUserConfigParam(4, "anisotropic",
+            PARAM_DEFAULT( IntUserConfigParam(0, "anisotropic",
                            &m_graphics_quality,
                            "Quality of anisotropic filtering (usual values include 2-4-8-16; 0 to disable)") );
 
@@ -952,7 +952,7 @@ namespace UserConfigParams
                            "ssao", &m_graphics_quality,
                            "Enable Screen Space Ambient Occlusion") );
     PARAM_PREFIX BoolUserConfigParam         m_light_scatter
-            PARAM_DEFAULT(BoolUserConfigParam(true,
+            PARAM_DEFAULT(BoolUserConfigParam(false,
                            "light_scatter", &m_graphics_quality,
                            "Enable light scattering shaders") );
     PARAM_PREFIX IntUserConfigParam          m_shadows_resolution
-- 
2.30.2

