mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 14:10:27 -04:00
Merge branch 'main' of https://github.com/ondra-novak/gates_of_skeldal
into main
This commit is contained in:
parent
73b949fb2e
commit
f67cfbcd24
11 changed files with 178 additions and 30 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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 <item_count; ++i) {
|
||||
if (imatch(glob_items[i].jmeno, name)
|
||||
|| imatch(glob_items[i].popis, name)) {
|
||||
wzprintf("i%d %s - %s\n",i, glob_items[i].jmeno, glob_items[i].popis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void wiz_find_monster(const char *name) {
|
||||
|
||||
alock(H_ENEMY);
|
||||
const TMOB *mobs =(TMOB *)ablock(H_ENEMY);
|
||||
size_t cnt = get_handle_size(H_ENEMY)/sizeof(TMOB);
|
||||
|
||||
|
||||
for (size_t i = 0; i <cnt; ++i) {
|
||||
if (imatch(mobs[i].name, name)) {
|
||||
wzprintf("m%d %s\n", i, mobs[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int process_with_params(const char *cmd, const char *args) {
|
||||
if (stricmp(cmd, "locate") == 0) {
|
||||
if (args[0] == 0) return 0;
|
||||
wiz_find_item(args);
|
||||
wiz_find_monster(args);
|
||||
console_add_line("");
|
||||
return 1;
|
||||
}
|
||||
if (stricmp(cmd, "say") == 0) {
|
||||
console_add_line(args);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -503,11 +567,12 @@ static int process_command(PARSED_COMMAND cmd) {
|
|||
}
|
||||
if (onoff != -1) {
|
||||
return process_on_off_command(cmd.command, onoff);
|
||||
}
|
||||
} else
|
||||
return process_with_params(cmd.command, cmd.args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void console_keyboard(EVENT_MSG *msg, void **) {
|
||||
static void console_keyboard(EVENT_MSG *msg, void **_) {
|
||||
if (msg->msg == E_KEYBOARD) {
|
||||
int c = va_arg(msg->data, int) & 0xFF;
|
||||
if (c == E_QUIT_GAME_KEY) return;
|
||||
|
|
|
@ -128,6 +128,7 @@ typedef struct drw_enemy_struct
|
|||
char mirror;
|
||||
char stoned;
|
||||
const palette_t *palette;
|
||||
const char *more_info;
|
||||
}DRW_ENEMY;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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í
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue