From 11119f83ed7502365369053c6d0e27595369a542 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Sun, 28 Feb 2021 16:27:10 +1000 Subject: Fix build for Haiku diff --git a/CMakeLists.txt b/CMakeLists.txt index 9579a43..de9c108 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ find_package(LibXml2 REQUIRED) if (CMAKE_SYSTEM_NAME MATCHES "Linux") 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 @@ -243,6 +243,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") diff --git a/consolewin.c b/consolewin.c index 2b410f3..35768d3 100644 --- a/consolewin.c +++ b/consolewin.c @@ -279,7 +279,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 index d14c4fe..78c71ff 100644 --- a/elconfig.c +++ b/elconfig.c @@ -2663,7 +2663,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 \".",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) +#if !defined(WINDOWS) && !defined(OSX) && !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 @@ -2775,9 +2775,9 @@ static void init_ELC_vars(void) add_var(OPT_FLOAT,"chat_win_scale","chatwinscale",get_scale_WM(MW_CHAT),change_win_scale_factor,1.0f,"Chat 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 // FONT TAB @@ -2937,7 +2937,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); - 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); +#ifndef HAIKU + add_var (OPT_BOOL,"use_old_clicker", "oldmclick", &use_old_clicker, change_var, 1, "Mouse Bug", "Unrelated to ATI graphics cards, if clicking to walk doesn't move you, try toggling this option.", TROUBLESHOOT); +#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); add_var(OPT_BOOL,"use_compiled_vertex_array","cva",&use_compiled_vertex_array,change_compiled_vertex_array,1,"Compiled Vertex Array","Some systems will not support the new compiled vertex array in EL. Disable this if some 3D objects do not display correctly.",TROUBLESHOOT); diff --git a/events.c b/events.c index 53ad5a1..51db744 100644 --- a/events.c +++ b/events.c @@ -207,7 +207,7 @@ int HandleEvent (SDL_Event *event) switch( event->type ) { -#if !defined(WINDOWS) && !defined(OSX) +#if !defined(WINDOWS) && !defined(OSX) && !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 d30c326..6b8ecf3 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 4db4a6a..64cac3e 100644 --- a/font.cpp +++ b/font.cpp @@ -1839,6 +1839,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"; #else diff --git a/gamewin.c b/gamewin.c index 89f541a..fe0abc9 100644 --- a/gamewin.c +++ b/gamewin.c @@ -63,7 +63,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 dbd5683..86ba511 100644 --- a/gl_init.c +++ b/gl_init.c @@ -307,7 +307,7 @@ void init_video(void) last_texture = -1; //no active texture video_mode_set = 1; //now you may set the video mode using the % in-game -#if !defined OSX && !defined WINDOWS +#if !defined OSX && !defined WINDOWS && !defined HAIKU init_x11_copy_paste(); #endif diff --git a/io/elpathwrapper.c b/io/elpathwrapper.c index 741461a..4a2ab8b 100644 --- a/io/elpathwrapper.c +++ b/io/elpathwrapper.c @@ -59,6 +59,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"; #else /* *nix */ static const char* cfgdirname = ".elc"; #endif // platform check @@ -856,6 +858,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; @@ -866,14 +871,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 5c6eeb6..430a7dd 100644 --- a/io/ioapi.h +++ b/io/ioapi.h @@ -50,7 +50,7 @@ #include #include "zlib.h" -#if defined(USE_FILE32API) || defined(OSX) +#if defined(USE_FILE32API) || defined(OSX) || defined(HAIKU) #define fopen64 fopen #define ftello64 ftell #define fseeko64 fseek diff --git a/paste.c b/paste.c index 7e70c48..ae6040f 100644 --- a/paste.c +++ b/paste.c @@ -125,6 +125,16 @@ void copy_to_clipboard(const char* text) } } +#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 ed0ff1a..7f26aea 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 +#if !defined OSX && !defined WINDOWS && !defined HAIKU #include diff --git a/widgets.c b/widgets.c index aa08a84..d4d7bfd 100644 --- a/widgets.c +++ b/widgets.c @@ -2516,7 +2516,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) { @@ -2943,7 +2943,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 @@ -2976,7 +2976,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 @@ -3026,7 +3026,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); -- 2.30.0 From 09455e2124abf1d2c8634fe45b3c4722358c19ee Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Sun, 28 Feb 2021 16:43:59 +1000 Subject: Set resource dir diff --git a/main.c b/main.c index e303953..acc7d0a 100644 --- a/main.c +++ b/main.c @@ -521,13 +521,26 @@ void setupWorkingDirectory(const char *argv0, size_t len) } #endif +#ifdef HAIKU +void setupWorkingDirectory(const char *argv0, size_t len) +{ + char *binpath = realpath(argv0, NULL); + if (binpath != NULL) { + char *appdir = strrchr(binpath, '/'); + *appdir = '\0'; + chdir(binpath); + free(binpath); + } +} +#endif + #ifdef WINDOWS int Main(int argc, char **argv) #else int main(int argc, char **argv) #endif { -#ifdef OSX +#if defined OSX || defined HAIKU if (argc > 0) // should always be true setupWorkingDirectory(argv[0], strlen(argv[0])); #endif -- 2.30.0