From f67cfbcd241f712003d2810cfcc66cd3b5b4adb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Nov=C3=A1k?= Date: Mon, 3 Feb 2025 16:11:56 +0100 Subject: [PATCH] Merge branch 'main' of https://github.com/ondra-novak/gates_of_skeldal into main --- CMakeLists.txt | 2 +- game/automap.c | 13 +++---- game/builder.c | 17 +++++----- game/console.c | 77 ++++++++++++++++++++++++++++++++++++++---- game/engine1.h | 1 + game/globals.h | 3 +- game/menu.c | 2 +- game/skeldal.c | 2 +- platform/config.cpp | 8 ++--- platform/istr.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ platform/platform.h | 1 + 11 files changed, 178 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index add59de..a47c99c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ if (MSVC) add_compile_options(/W4 /EHsc /DNOMINMAX) set(STANDARD_LIBRARIES "") else() - add_compile_options(-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-value) + add_compile_options(-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-value -Wno-extern-c-compat) set(STANDARD_LIBRARIES "pthread") endif() diff --git a/game/automap.c b/game/automap.c index a399ec7..a3410a1 100644 --- a/game/automap.c +++ b/game/automap.c @@ -621,17 +621,11 @@ void unwire_automap(void) void *map_keyboard(EVENT_MSG *msg,void **usr) { char c; - static int draw=0; + int draw=0; static int xr,yr; usr; if (msg->msg==E_INIT) xr=yr=0; - if (msg->msg==E_IDLE && draw==1) - { - draw_automap(xr,yr); - draw=0; - } - else draw--; if (msg->msg==E_AUTOMAP_REDRAW) draw=4; if (msg->msg==E_KEYBOARD) { @@ -654,6 +648,9 @@ void *map_keyboard(EVENT_MSG *msg,void **usr) wire_proc(); break; } + if (draw) { + draw_automap(xr,yr); + } } return &map_keyboard; } @@ -859,7 +856,7 @@ T_CLK_MAP clk_kniha[]= }; -static void kniha_keyboard_proc(EVENT_MSG *msg, void **) { +static void kniha_keyboard_proc(EVENT_MSG *msg, void **_) { if (msg->msg == E_KEYBOARD) { int c = quit_request_as_escape(va_arg(msg->data,int)); switch(c>>8) { diff --git a/game/builder.c b/game/builder.c index 72d5136..7b5f2b7 100644 --- a/game/builder.c +++ b/game/builder.c @@ -65,6 +65,7 @@ char set_halucination=0; int hal_sector; int hal_dir; char see_monster=0; +char hide_walls = 0; char lodka=0; int bgr_distance=0; //vzdalenost pozadi od pohledu int bgr_handle=0; @@ -833,7 +834,7 @@ static int draw_basic_sector(int celx, int cely, int sector) { show_cel2(celx, cely, ablock(num_ofsets[OBL_NUM] + obl), 0, 0, 1); if (q->flags & SD_RIGHT_ARC && q->oblouk & 0x0f) show_cel2(celx, cely, ablock(num_ofsets[OBL2_NUM] + obl), 0, 0, 2); - if (q->flags & SD_PRIM_VIS && q->prim) + if (q->flags & SD_PRIM_VIS && q->prim && !hide_walls) show_cel2(celx, cely, ablock( num_ofsets[MAIN_NUM] + q->prim @@ -863,7 +864,7 @@ static int draw_basic_sector(int celx, int cely, int sector) { if (left_shiftup) show_cel(celx, cely, ablock(num_ofsets[LEFT_NUM] + left_shiftup), 0, 0, 2), left_shiftup = 0; - if (q->flags & SD_PRIM_VIS && q->prim) + if (q->flags & SD_PRIM_VIS && q->prim && !hide_walls) show_cel(-celx, cely, ablock( num_ofsets[LEFT_NUM] + q->prim @@ -895,7 +896,7 @@ static int draw_basic_sector(int celx, int cely, int sector) { if (right_shiftup) show_cel(celx, cely, ablock(num_ofsets[RIGHT_NUM] + right_shiftup), 0, 0, 3), right_shiftup = 0; - if (q->flags & SD_PRIM_VIS && q->prim) + if (q->flags & SD_PRIM_VIS && q->prim && !hide_walls) show_cel(celx, cely, ablock( num_ofsets[RIGHT_NUM] + q->prim @@ -1002,18 +1003,18 @@ int draw_sloup_sector(int celx,int cely,int sector) show_cel2(celx,cely,ablock(num_ofsets[OBL_NUM]+obl),0,0,1); if (q->flags & SD_RIGHT_ARC && q->oblouk) show_cel2(celx,cely,ablock(num_ofsets[OBL2_NUM]+obl),0,0,2); - if (q->flags & SD_PRIM_VIS && q->prim) + if (q->flags & SD_PRIM_VIS && q->prim && !hide_walls) show_cel2(celx,cely,ablock(num_ofsets[MAIN_NUM]+q->prim+(q->prim_anim>>4)),0,0,1+(q->oblouk & SD_POSITION)); if (celx<=0) { q=&w[dirs[0]]; - if (q->flags & SD_PRIM_VIS && q->prim) + if (q->flags & SD_PRIM_VIS && q->prim && !hide_walls) show_cel(-celx,cely,ablock(num_ofsets[LEFT_NUM]+q->prim+(q->prim_anim>>4)),0,0,2+(q->oblouk & SD_POSITION)); } if (celx>=0) { q=&w[dirs[2]]; - if (q->flags & SD_PRIM_VIS && q->prim) + if (q->flags & SD_PRIM_VIS && q->prim && !hide_walls) show_cel(celx,cely,ablock(num_ofsets[RIGHT_NUM]+q->prim+(q->prim_anim>>4)),0,0,3+(q->oblouk & SD_POSITION)); } q=&w[dirs[1]]; @@ -1379,8 +1380,8 @@ void play_fx(int x,int y) void play_fx_at(int where) { - static word polex[]={313,290,362}; - static word poley[]={1,1,1}; + static word polex[]={313,290,362,336}; + static word poley[]={1,1,1,1,1}; play_fx(polex[where],poley[where]); } diff --git a/game/console.c b/game/console.c index c6cf5f4..ed188b4 100644 --- a/game/console.c +++ b/game/console.c @@ -74,9 +74,6 @@ char *mc_flags[]= "!SUMMON" }; -void mman_scan(int ) - { - } void show_flags(int number,char **flags,char nums) { @@ -435,7 +432,7 @@ static PARSED_COMMAND parse_command(const char *cmd) { if (!*c) return ret; ret.command = c; ret.args = NULL; - char *sep = strrchr(c, ' '); + char *sep = strchr(c, ' '); if (sep!= NULL) { *sep = 0; ++sep; @@ -453,6 +450,8 @@ static PARSED_COMMAND parse_command(const char *cmd) { return ret; } +extern int hide_walls; + static int process_on_off_command(const char *cmd, char on) { if (stricmp(cmd, "inner-eye") == 0) { show_debug = on; @@ -474,6 +473,10 @@ static int process_on_off_command(const char *cmd, char on) { cur_group=on?10:postavy[0].groupnum; return 1; } + if (stricmp(cmd, "hide-walls") == 0) { + hide_walls = on; + return 1; + } return 0; } @@ -490,6 +493,67 @@ static int process_actions(const char *command) { display_game_status(); return 1; } + if (stricmp(command, "offlers-blessing") == 0) { + money=150000; + play_fx_at(FX_MONEY); + return 1; + } + if (stricmp(command, "i-require-gold") == 0) { + money+=1; + play_fx_at(FX_MONEY); + return 1; + } + if (stricmp(command, "to-the-moon") == 0) { + money+=100000; + play_fx_at(FX_MONEY); + return 1; + } + if (stricmp(command, "echo-location") == 0) { + for (int i = 1; i < mapsize; ++i) { + if (map_coord[i].flags & MC_NOAUTOMAP) continue; + map_coord[i].flags |= MC_AUTOMAP; + } + play_fx_at(FX_MAP); + return 1; + } + return 0; +} + +static void wiz_find_item(const char *name) { + for (int i = 0; i msg == E_KEYBOARD) { int c = va_arg(msg->data, int) & 0xFF; if (c == E_QUIT_GAME_KEY) return; diff --git a/game/engine1.h b/game/engine1.h index 2114f94..bd7abcc 100644 --- a/game/engine1.h +++ b/game/engine1.h @@ -128,6 +128,7 @@ typedef struct drw_enemy_struct char mirror; char stoned; const palette_t *palette; + const char *more_info; }DRW_ENEMY; diff --git a/game/globals.h b/game/globals.h index ee48bea..6c38124 100644 --- a/game/globals.h +++ b/game/globals.h @@ -739,6 +739,7 @@ void draw_blood(char mode,int mob_dostal,int mob_dostal_pocet); #define FX_MAGIC 0 #define FX_BOOK 1 #define FX_MONEY 2 +#define FX_MAP 3 @@ -791,7 +792,7 @@ typedef struct t_clk_map int cursor; }T_CLK_MAP; -#define CLK_MAIN_VIEW 17 +#define CLK_MAIN_VIEW 18 #define MS_GAME_WIN 256 extern T_CLK_MAP clk_main_view[]; //clickovaci mapa pro hlavni vyhled diff --git a/game/menu.c b/game/menu.c index 7ecfdb6..8200dbf 100644 --- a/game/menu.c +++ b/game/menu.c @@ -34,7 +34,7 @@ #define SPEED 3 int speedscroll=3; char low_mem=0; -static volatile char load_ok=0; +//static volatile char load_ok=0; static int cur_pos[]={0,0,0,0,0}; static int cur_dir[]={UNSELECT,UNSELECT,UNSELECT,UNSELECT,UNSELECT}; diff --git a/game/skeldal.c b/game/skeldal.c index 960bda5..da9667e 100644 --- a/game/skeldal.c +++ b/game/skeldal.c @@ -1585,7 +1585,7 @@ void show_help_short() { printf("Use -h for help\n"); } -void quit_cb_exit_wait(void *) { +void quit_cb_exit_wait(void *_) { exit_wait = 1; } diff --git a/platform/config.cpp b/platform/config.cpp index 1a4dcad..d020716 100644 --- a/platform/config.cpp +++ b/platform/config.cpp @@ -96,11 +96,11 @@ long ini_get_value_int(const char *value, int *conv_ok) { if (value != NULL) { long ret = strtol(value, &out, 10); if (*out == 0) { - if (*conv_ok) *conv_ok = 1; + if (conv_ok) *conv_ok = 1; return ret; } } - if (*conv_ok) *conv_ok = 0; + if (conv_ok) *conv_ok = 0; return -1; } @@ -110,11 +110,11 @@ double ini_get_value_double(const char *value, int *conv_ok) { if (value != NULL) { double ret = strtod(value, &out); if (*out == 0) { - if (*conv_ok) *conv_ok = 1; + if (conv_ok) *conv_ok = 1; return ret; } } - if (*conv_ok) *conv_ok = 0; + if (conv_ok) *conv_ok = 0; return -1; } diff --git a/platform/istr.c b/platform/istr.c index 09816e5..042e2c6 100644 --- a/platform/istr.c +++ b/platform/istr.c @@ -21,3 +21,85 @@ void strupr(char *c) { ++c; } } + + +// Funkce pro přeskakování bílých znaků +static const char *skip_whitespace(const char *str) { + while (*str && isspace((unsigned char)*str)) { + str++; + } + return str; +} + +// Funkce porovnávající dvě slova bez ohledu na velikost písmen +static int compare_words(const char *word1, const char *word2, size_t length) { + for (size_t i = 0; i < length; i++) { + if (tolower((unsigned char)word1[i]) != tolower((unsigned char)word2[i])) { + return 0; + } + } + return 1; +} + +// Hlavní vyhledávací funkce +int imatch(const char *text, const char *hledany) { + // Rozdělení hledaného podřetězce na slova + const char *text_ptr = text; + const char *search_ptr = hledany; + + // Iteruj přes slova hledaného podřetězce + while (*search_ptr) { + search_ptr = skip_whitespace(search_ptr); + + // Pokud jsme na konci hledaného textu, ukončíme + if (*search_ptr == '\0') { + break; + } + + // Najdi konec aktuálního slova + const char *search_word_end = search_ptr; + while (*search_word_end && !isspace((unsigned char)*search_word_end)) { + search_word_end++; + } + + size_t search_word_len = search_word_end - search_ptr; + + // Hledání slova v textu + int found = 0; + while (*text_ptr) { + text_ptr = skip_whitespace(text_ptr); + if (*text_ptr == '\0') { + break; + } + + const char *text_word_end = text_ptr; + while (*text_word_end && !isspace((unsigned char)*text_word_end)) { + text_word_end++; + } + + size_t text_word_len = text_word_end - text_ptr; + + // Porovnání aktuálního slova + if (text_word_len >= search_word_len) { + for (int i = text_word_len - search_word_len; i >= 0; --i) { + if (compare_words(text_ptr+i, search_ptr, search_word_len)) { + found = 1; + text_ptr = text_word_end; // Pokračujeme za slovem + break; + } + } + if (found) break; + } + + text_ptr = text_word_end; + } + + if (!found) { + return 0; // Nenalezeno + } + + search_ptr = search_word_end; + } + + return 1; // Všechny části byly nalezeny ve správném pořadí +} diff --git a/platform/platform.h b/platform/platform.h index 4d92b3d..e0982d7 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -70,6 +70,7 @@ FILE *fopen_icase(const char *pathname, const char *mode); const char *file_icase_find(const char *pathname); int stricmp(const char *a, const char *b); +int imatch(const char *haystack, const char *needle); #define MIN(a, b) ((a)<(b)?(a):(b)) #define MAX(a, b) ((a)>(b)?(a):(b)) void strupr(char *c);