Files
haikuports/games-rpg/eternal_lands/patches/eternal_lands-1.9.7.0.patchset
2025-04-23 11:41:21 +10:00

441 lines
17 KiB
Plaintext

From 56771272aab3d04a7c1b713d7e6164ebe6d9d8b4 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 23 Apr 2025 11:29:53 +1000
Subject: Fix build for Haiku
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8996fe6..2c51ac9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,7 +123,7 @@ find_package(LibXml2 REQUIRED)
if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
find_package(X11 REQUIRED)
endif()
-if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+if (CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "Haiku")
find_package(Iconv REQUIRED)
endif()
# these definitions were re-used from Xapher's opengl client
@@ -261,6 +261,11 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(EXEC "el.linux.bin")
endif()
add_definitions(-DLINUX)
+elseif (CMAKE_SYSTEM_NAME MATCHES "Haiku")
+ if (NOT EXEC)
+ set(EXEC "EternalLands")
+ endif()
+ add_definitions(-DHAIKU)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
if (NOT EXEC)
set(EXEC "el")
@@ -357,6 +362,9 @@ if (USE_SSL)
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
target_link_libraries(${EXEC} -lws2_32)
endif()
+ if (HAIKU)
+ target_link_libraries(${EXEC} -lnetwork)
+ endif()
target_link_libraries(${EXEC} ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
endif()
diff --git a/consolewin.c b/consolewin.c
index 6d6fd0d..e67912f 100644
--- a/consolewin.c
+++ b/consolewin.c
@@ -321,7 +321,7 @@ static int click_console_handler(window_info *win, int mx, int my, Uint32 flags)
if (hud_click(win, mx, my, flags))
return 1;
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
if ( (flags & ELW_MID_MOUSE) )
{
diff --git a/elconfig.c b/elconfig.c
old mode 100755
new mode 100644
index 99221f8..73b0fc9
--- a/elconfig.c
+++ b/elconfig.c
@@ -3001,7 +3001,7 @@ static void init_ELC_vars(void)
add_var(OPT_BOOL, "continent_map_boundaries", "cmb", &show_continent_map_boundaries, change_var, 1, "Map Boundaries On Continent Map", "Show map boundaries on the continent map", HUD);
add_var(OPT_BOOL,"enable_user_menus", "user_menus", &enable_user_menus, toggle_user_menus, 0, "Enable User Menus","Create .menu files in your config directory. First line is the menu name. After that, each line is a command using the format \"Menus Text || command || command\". Prompt for input using \"command text <prompt text>\".",HUD);
add_var(OPT_BOOL,"console_scrollbar_enabled", "console_scrollbar", &console_scrollbar_enabled, toggle_console_scrollbar, 1, "Show Console Scrollbar","If enabled, a scrollbar will be shown in the console window.",HUD);
-#if !defined(WINDOWS) && !defined(OSX) && !defined(ANDROID)
+#if !defined(WINDOWS) && !defined(OSX) && !defined(ANDROID) && !defined(HAIKU)
add_var(OPT_BOOL,"use_clipboard","uclb",&use_clipboard, change_var, 1, "Use Clipboard For Pasting", "Use CLIPBOARD for pasting (as e.g. GNOME does) or use PRIMARY cutbuffer (as xterm does)",HUD);
#endif
@@ -3126,9 +3126,9 @@ static void init_ELC_vars(void)
add_var(OPT_FLOAT,"chancols_win_scale","chancolswinscale",get_scale_WM(MW_CHANCOLS),change_win_scale_factor,1.0f,"Chat channel colours window scaling factor",win_scale_description,FONT,win_scale_min,win_scale_max,win_scale_step);
add_var(OPT_FLOAT,"options_win_scale","optionswinscale",&elconf_custom_scale,change_elconf_win_scale_factor,1.0f,"Options window scaling factor","Multiplied by the user interface scaling factor. Change will take effect after closing then reopening the window.",FONT,win_scale_min,win_scale_max,win_scale_step);
#ifdef NEW_CURSOR
- add_var(OPT_BOOL,"sdl_cursors","sdl_cursors", &sdl_cursors, change_sdl_cursor,1,"Use Standard Black/White Mouse Pointers", "When disabled, use the experimental coloured mouse pointers. Needs the texture from Git dev-data-files/cursor2.dss.", FONT);
- add_var(OPT_BOOL,"big_cursors","big_cursors", &big_cursors, change_var,0,"Use Large Pointers", "When using the experiment coloured mouse pointers, use the large pointer set.", FONT);
- add_var(OPT_FLOAT,"pointer_size","pointer_size", &pointer_size, change_float,1.0,"Coloured Pointer Size", "When using the experiment coloured mouse pointers, set the scale of the pointer. 1.0 is 1:1 scale.", FONT,0.25,4.0,0.05);
+ add_var(OPT_BOOL,"sdl_cursors","sdl_cursors", &sdl_cursors, change_sdl_cursor,0,"Use Standard Black/White Mouse Pointers", "When disabled, use the experimental coloured mouse pointers. Needs the texture from Git dev-data-files/cursor2.dss.", FONT);
+ add_var(OPT_BOOL,"big_cursors","big_cursors", &big_cursors, change_var,1,"Use Large Pointers", "When using the experiment coloured mouse pointers, use the large pointer set.", FONT);
+ add_var(OPT_FLOAT,"pointer_size","pointer_size", &pointer_size, change_float,2.5,"Coloured Pointer Size", "When using the experiment coloured mouse pointers, set the scale of the pointer. 1.0 is 1:1 scale.", FONT,0.25,4.0,0.05);
#endif // NEW_CURSOR
// default fonts
add_var(OPT_STRING_INI,"def_ui_font", "def_ui_font", def_ui_font_str, change_string, sizeof(def_ui_font_str), "def_ui_font", "Default font for UI", FONT);
@@ -3320,7 +3320,9 @@ static void init_ELC_vars(void)
add_var(OPT_BOOL,"shadows_on","shad",&shadows_on,change_shadows,0,"Shadow Bug","Some video cards have trouble with the shadows. Uncheck this if everything you see is white.", TROUBLESHOOT);
// Grum: attempt to work around bug in Ati linux drivers.
add_var(OPT_BOOL,"ati_click_workaround", "atibug", &ati_click_workaround, change_var, 0, "ATI Bug", "If you are using an ATI graphics card and don't move when you click, try this option to work around a bug in their drivers.", TROUBLESHOOT);
+#ifndef HAIKU
add_var (OPT_BOOL,"use_old_clicker", "oldmclick", &use_old_clicker, change_var, 0, "Mouse Bug", "Unrelated to ATI graphics cards, if clicking to walk doesn't move you, try toggling this option.", TROUBLESHOOT);
+#endif
#endif
add_var(OPT_BOOL,"use_new_selection", "uns", &use_new_selection, change_new_selection, 1, "New selection", "Using new selection can give you a higher framerate. However, if your cursor does not change when over characters or items, try disabling this option.", TROUBLESHOOT);
add_var(OPT_BOOL,"clear_mod_keys_on_focus", "clear_mod_keys_on_focus", &clear_mod_keys_on_focus, change_var, 0, "Clear modifier keys when window focused","If you have trouble with modifier keys (shift/ctrl/alt etc) when keyboard focus returns, enable this option to force all modifier keys up.", TROUBLESHOOT);
diff --git a/events.c b/events.c
index f787812..45e548e 100644
--- a/events.c
+++ b/events.c
@@ -286,7 +286,7 @@ int HandleEvent (SDL_Event *event)
break;
#endif
-#if !defined(WINDOWS) && !defined(OSX) && !defined(ANDROID)
+#if !defined(WINDOWS) && !defined(OSX) && !defined(ANDROID) && !defined(HAIKU)
case SDL_SYSWMEVENT:
if (event->syswm.msg->msg.x11.event.type == SelectionNotify)
finishpaste(event->syswm.msg->msg.x11.event.xselection);
diff --git a/eye_candy/eye_candy.cpp b/eye_candy/eye_candy.cpp
index 6e9a07e..a05c5c8 100644
--- a/eye_candy/eye_candy.cpp
+++ b/eye_candy/eye_candy.cpp
@@ -1748,8 +1748,8 @@ namespace ec
delete particle;
for (auto effect: effects)
delete effect;
- for (auto light: lights)
- glDisable(light);
+// for (auto light: lights)
+// glDisable(light);
}
void EyeCandy::set_thresholds(const int _max_particles,
diff --git a/font.cpp b/font.cpp
index 2fa8b60..93c229b 100644
--- a/font.cpp
+++ b/font.cpp
@@ -2054,6 +2054,8 @@ float *font_scales = FontManager::font_scales.data();
int use_ttf = 0;
#ifdef LINUX
char ttf_directory[TTF_DIR_SIZE] = "/usr/share/fonts/TTF";
+#elif defined HAIKU
+char ttf_directory[TTF_DIR_SIZE] = "/system/data/fonts/ttfonts";
#elif defined WINDOWS
char ttf_directory[TTF_DIR_SIZE] = "C:/Windows/Fonts";
#elif defined ANDROID
diff --git a/gamewin.c b/gamewin.c
index 034c201..96dc08c 100644
--- a/gamewin.c
+++ b/gamewin.c
@@ -64,7 +64,7 @@ int have_mouse = 0;
int game_root_win = -1;
// configuration options exported
-int use_old_clicker=0;
+int use_old_clicker=1;
int include_use_cursor_on_animals = 0;
int cm_banner_disabled = 0;
int auto_disable_ranging_lock = 1;
diff --git a/gl_init.c b/gl_init.c
index b28b93f..757b934 100644
--- a/gl_init.c
+++ b/gl_init.c
@@ -472,7 +472,7 @@ void init_video(void)
last_texture = -1; //no active texture
video_mode_set = 1; //now you may set the video mode using the %<foo> in-game
-#if !defined OSX && !defined WINDOWS && !defined ANDROID
+#if !defined OSX && !defined WINDOWS && !defined ANDROID && !defined HAIKU
init_x11_copy_paste();
#endif
diff --git a/io/elpathwrapper.c b/io/elpathwrapper.c
index b35c1dd..758a502 100644
--- a/io/elpathwrapper.c
+++ b/io/elpathwrapper.c
@@ -66,6 +66,8 @@ static const char* cfgdirname = CONFIGDIR;
static const char* cfgdirname = "Library/Application Support/Eternal Lands";
#elif defined(WINDOWS)
static const char* cfgdirname = "Eternal Lands";
+#elif defined(HAIKU)
+static const char* cfgdirname = "config/settings/EternalLands";
#elif defined(ANDROID)
static const char* cfgdirname = "user";
#else /* *nix */
@@ -913,6 +915,9 @@ int search_files_and_apply(const char* base_path, const char *pattern, void (*fn
while (1)
{
+#ifdef HAIKU
+ struct stat info;
+#endif
struct dirent *entry;
errno = 0;
@@ -923,14 +928,22 @@ int search_files_and_apply(const char* base_path, const char *pattern, void (*fn
LOG_ERROR("Failed to read directory %s: %s\n", base_path, strerror(errno));
break;
}
-
+#ifdef HAIKU
+ stat(entry->d_name, &info);
+ if (S_ISDIR(info.st_mode) && max_depth > 0 && strcmp(entry->d_name, ".") != 0
+#else
if (entry->d_type == DT_DIR && max_depth > 0 && strcmp(entry->d_name, ".") != 0
+#endif
&& strcmp(entry->d_name, "..") != 0)
{
safe_snprintf(full_path, sizeof(full_path), "%s/%s", base_path, entry->d_name);
nr_found += search_files_and_apply(full_path, pattern, fn, max_depth-1);
}
+#ifdef HAIKU
+ else if (S_ISREG(info.st_mode) && fnmatch(pattern, entry->d_name, 0) == 0)
+#else
else if (entry->d_type == DT_REG && fnmatch(pattern, entry->d_name, 0) == 0)
+#endif
{
safe_snprintf(full_path, sizeof(full_path), "%s/%s", base_path, entry->d_name);
fn(full_path);
diff --git a/io/ioapi.h b/io/ioapi.h
index 159f7ff..1d529b3 100644
--- a/io/ioapi.h
+++ b/io/ioapi.h
@@ -50,7 +50,7 @@
#include <stdlib.h>
#include "zlib.h"
-#if defined(USE_FILE32API) || defined(OSX) || defined(BSD)
+#if defined(USE_FILE32API) || defined(OSX) || defined(BSD) || defined(HAIKU)
#define fopen64 fopen
#define ftello64 ftell
#define fseeko64 fseek
diff --git a/main.c b/main.c
index 3647581..bb2068b 100644
--- a/main.c
+++ b/main.c
@@ -24,6 +24,10 @@
char *win_command_line;
#endif //WINDOWS
+#ifdef HAIKU
+#include <kernel/image.h>
+#endif
+
#include "2d_objects.h"
#include "3d_objects.h"
#include "actor_scripts.h"
@@ -552,6 +556,22 @@ void setupWorkingDirectory(const char *argv0, size_t len)
}
#endif
+#ifdef HAIKU
+void setupWorkingDirectory(const char *argv0, size_t len)
+{
+ int32 cookie = 0;
+ image_info info;
+ while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+ if (info.type == B_APP_IMAGE) {
+ char *last_slash = strrchr(info.name, '/');
+ *last_slash = '\0';
+ chdir(info.name);
+ break;
+ }
+ }
+}
+#endif
+
#ifdef WINDOWS
int Main(int argc, char **argv)
#else
@@ -561,7 +581,7 @@ int main(int argc, char **argv)
#ifdef ANDROID
initialize_gl4es();
#endif
-#ifdef OSX
+#if defined OSX || defined HAIKU
if (argc > 0) // should always be true
setupWorkingDirectory(argv[0], strlen(argv[0]));
#endif
diff --git a/new_update.c b/new_update.c
index 667e253..e5455ad 100644
--- a/new_update.c
+++ b/new_update.c
@@ -4,6 +4,9 @@
#ifdef WINDOWS
#include <sys/locking.h>
#endif // WINDOWS
+#ifdef HAIKU
+#include <fcntl.h>
+#endif
#include <time.h>
#include <SDL_net.h>
#include <SDL_thread.h>
diff --git a/paste.c b/paste.c
index 9467913..58373fe 100755
--- a/paste.c
+++ b/paste.c
@@ -137,6 +137,16 @@ void start_paste(widget_list *widget)
{
}
+#elif defined HAIKU
+
+void start_paste(widget_list *widget)
+{
+}
+
+void copy_to_clipboard(const char* text)
+{
+}
+
#else
static widget_list *paste_to_widget = NULL;
diff --git a/paste.h b/paste.h
index a1d8e2f..c644b7c 100644
--- a/paste.h
+++ b/paste.h
@@ -46,7 +46,7 @@ void copy_to_clipboard(const char* text);
void copy_to_primary(const char* text);
#endif
-#if !defined OSX && !defined WINDOWS && !defined ANDROID
+#if !defined OSX && !defined WINDOWS && !defined ANDROID && !defined HAIKU
#include <X11/Xlib.h>
diff --git a/widgets.c b/widgets.c
old mode 100755
new mode 100644
index 2696bb0..300c6c8
--- a/widgets.c
+++ b/widgets.c
@@ -2546,7 +2546,7 @@ void _text_field_copy_to_clipboard(text_field *tf)
}
}
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
void _text_field_copy_to_primary(text_field *tf)
{
@@ -2983,7 +2983,7 @@ void update_selection(int x, int y, widget_list* w, int drag)
// drag, set the end position
tf->select.em = tf->select.lines[line].msg;
tf->select.ec = col;
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
_text_field_copy_to_primary(tf);
#endif
@@ -3016,7 +3016,7 @@ static void update_cursor_selection(widget_list* w, int update_end)
{
tf->select.em = tf->select.lines[line].msg;
tf->select.ec = tf->cursor;
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
_text_field_copy_to_primary(tf);
#endif
@@ -3068,7 +3068,7 @@ static int text_field_click(widget_list *w, int mx, int my, Uint32 flags)
_set_edit_pos(tf, mx, my, w->fcat);
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
if (flags & ELW_MID_MOUSE)
start_paste_from_primary(w);
@@ -3682,7 +3682,7 @@ static void pword_insert(password_entry *entry, int pos, const unsigned char* te
pword_update_draw_range_after_insert(entry, cat, size, max_width);
}
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
static void pword_field_copy_to_primary(const password_entry *entry)
{
@@ -3748,7 +3748,7 @@ static int pword_field_keypress(widget_list *w, int mx, int my, SDL_Keycode key_
}
--entry->cursor_pos;
pword_check_after_left_move(entry, w->fcat, w->size, max_width);
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
pword_field_copy_to_primary(entry);
#endif
@@ -3774,7 +3774,7 @@ static int pword_field_keypress(widget_list *w, int mx, int my, SDL_Keycode key_
}
++entry->cursor_pos;
pword_check_after_right_move(entry, w->fcat, w->size, max_width);
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
pword_field_copy_to_primary(entry);
#endif
@@ -3793,7 +3793,7 @@ static int pword_field_keypress(widget_list *w, int mx, int my, SDL_Keycode key_
entry->sel_begin = 0;
entry->cursor_pos = 0;
pword_check_after_left_move(entry, w->fcat, w->size, max_width);
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
pword_field_copy_to_primary(entry);
#endif
@@ -3811,7 +3811,7 @@ static int pword_field_keypress(widget_list *w, int mx, int my, SDL_Keycode key_
entry->sel_end = len;
entry->cursor_pos = len;
pword_check_after_right_move(entry, w->fcat, w->size, max_width);
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
pword_field_copy_to_primary(entry);
#endif
@@ -3829,7 +3829,7 @@ static int pword_field_keypress(widget_list *w, int mx, int my, SDL_Keycode key_
if (sel_text)
{
copy_to_clipboard(sel_text);
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
copy_to_primary(sel_text);
#endif
@@ -3846,7 +3846,7 @@ static int pword_field_keypress(widget_list *w, int mx, int my, SDL_Keycode key_
if (sel_text)
{
copy_to_clipboard(sel_text);
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
copy_to_primary(sel_text);
#endif
@@ -3992,7 +3992,7 @@ static int pword_field_click(widget_list *w, int mx, int my, Uint32 flags)
entry->cursor_pos = pword_pos_under_mouse(entry, mx, space, w->fcat, w->size);
entry->sel_begin = entry->sel_end = -1;
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
if (flags & ELW_MID_MOUSE)
start_paste_from_primary(w);
@@ -4029,7 +4029,7 @@ static int pword_field_drag(widget_list *w, int mx, int my, Uint32 flags, int dx
entry->sel_end = min2i(len, pos + 1);
}
-#if !defined OSX && !defined WINDOWS
+#if !defined OSX && !defined WINDOWS && !defined HAIKU
#ifdef MIDDLE_MOUSE_PASTE
pword_field_copy_to_primary(entry);
#endif
--
2.48.1