mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
fix some asan crashes
This commit is contained in:
parent
0e251dcd05
commit
e2fb5b9910
8 changed files with 54 additions and 19 deletions
|
@ -758,7 +758,7 @@ static void key_check(EVENT_MSG *msg,void **unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
void wire_dialog();
|
void wire_dialog();
|
||||||
void wire_dialog_drw()
|
void wire_dialog_drw(void)
|
||||||
{
|
{
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
wire_dialog();
|
wire_dialog();
|
||||||
|
|
|
@ -1711,7 +1711,7 @@ void wire_save_load(char save) {
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
mute_all_tracks(0);
|
mute_all_tracks(0);
|
||||||
force_save=save & 1;
|
force_save=save & 1;
|
||||||
current_game_slot_list = get_all_savegames(current_campaign, save);
|
current_game_slot_list = get_all_savegames(current_campaign, save & (1+4));
|
||||||
curcolor = RGB555(0,0,0);
|
curcolor = RGB555(0,0,0);
|
||||||
bar32(0, 17, 639, 17 + 360);
|
bar32(0, 17, 639, 17 + 360);
|
||||||
if (save == 1) {
|
if (save == 1) {
|
||||||
|
|
|
@ -1514,7 +1514,7 @@ static int add_number_cb(EVENT_MSG *msg, void *x) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_number() {
|
static void add_number(void) {
|
||||||
if (o_aktual) {
|
if (o_aktual) {
|
||||||
int n = o_aktual->id - 40;
|
int n = o_aktual->id - 40;
|
||||||
goto_control(10);
|
goto_control(10);
|
||||||
|
@ -1523,7 +1523,7 @@ static void add_number() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void remove_number() {
|
static void remove_number(void) {
|
||||||
if (o_aktual) {
|
if (o_aktual) {
|
||||||
goto_control(10);
|
goto_control(10);
|
||||||
send_message_to(add_number_cb,NULL, E_KEYBOARD, 'O'<<8);
|
send_message_to(add_number_cb,NULL, E_KEYBOARD, 'O'<<8);
|
||||||
|
@ -1540,7 +1540,7 @@ THAGGLERESULT smlouvat_dlg(int cena,int puvod,int pocet,int posledni, int money,
|
||||||
char j = is_joystick_used();
|
char j = is_joystick_used();
|
||||||
|
|
||||||
set_font(H_FBOLD,RGB555(31,31,31));
|
set_font(H_FBOLD,RGB555(31,31,31));
|
||||||
add_window(170,130,300,100+j*20,H_WINTXTR,3,20,20);
|
add_window(170,130,300,100+j*135,H_WINTXTR,3,20,20);
|
||||||
define(-1,10,15,1,1,0,label,texty[241]);
|
define(-1,10,15,1,1,0,label,texty[241]);
|
||||||
define(-1,150,15,100,13,0,label,int2ascii(cena,buffer,10));
|
define(-1,150,15,100,13,0,label,int2ascii(cena,buffer,10));
|
||||||
set_font(H_FBOLD,MSG_COLOR1);
|
set_font(H_FBOLD,MSG_COLOR1);
|
||||||
|
@ -1551,11 +1551,14 @@ THAGGLERESULT smlouvat_dlg(int cena,int puvod,int pocet,int posledni, int money,
|
||||||
define(30,110,20,80,20,2,button,texty[230]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui);
|
define(30,110,20,80,20,2,button,texty[230]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui);
|
||||||
if (j) {
|
if (j) {
|
||||||
char nstr[2] = "0";
|
char nstr[2] = "0";
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
nstr[0] = i+48;
|
int gx = (2-(i % 3))*35;
|
||||||
define(40+i, 10+i*24,50,22,20,0,button,nstr);property(def_border(0,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(add_number);
|
int gy = (i/3)*35;
|
||||||
|
nstr[0] = i+49;
|
||||||
|
define(41+i, 50+gx,85+gy,30,30,2,button,nstr);property(def_border(0,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(add_number);
|
||||||
}
|
}
|
||||||
define(50, 20,50,20,20,1,button,"<-");property(def_border(0,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(remove_number);
|
define(40, 85,50,30,30,2,button,"0");property(def_border(0,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(add_number);
|
||||||
|
define(50, 50,50,30,30,2,button,"<-");property(def_border(0,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(remove_number);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
redraw_window();
|
redraw_window();
|
||||||
|
|
|
@ -2249,7 +2249,7 @@ static void fast_inv_action(void) {
|
||||||
int x = ms_last_event.x;
|
int x = ms_last_event.x;
|
||||||
int y = ms_last_event.y;
|
int y = ms_last_event.y;
|
||||||
const T_CLK_MAP *item = find_in_click_map_entry(x, y, clk_inv_view, CLK_INV_VIEW, MS_EVENT_MOUSE_LPRESS);
|
const T_CLK_MAP *item = find_in_click_map_entry(x, y, clk_inv_view, CLK_INV_VIEW, MS_EVENT_MOUSE_LPRESS);
|
||||||
if (item->proc == &uloz_sip) {
|
if (item && item->proc == &uloz_sip) {
|
||||||
uloz_sip_action(1);
|
uloz_sip_action(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,10 @@ void skeldal_checkbox(OBJREC *);
|
||||||
void setup_ok_button(OBJREC *);
|
void setup_ok_button(OBJREC *);
|
||||||
void skeldal_soupak(OBJREC *);
|
void skeldal_soupak(OBJREC *);
|
||||||
|
|
||||||
|
static void exit_setup_action(void) {
|
||||||
|
unwire_setup();
|
||||||
|
wire_proc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,7 +202,7 @@ void new_setup()
|
||||||
define(200+i*10,50+i*60,30,30,200,0,skeldal_soupak,effects[i]==SND_MUSIC?127:255);c_default(get_snd_effect(effects[i]));
|
define(200+i*10,50+i*60,30,30,200,0,skeldal_soupak,effects[i]==SND_MUSIC?127:255);c_default(get_snd_effect(effects[i]));
|
||||||
on_control_change(do_setup_change);
|
on_control_change(do_setup_change);
|
||||||
}
|
}
|
||||||
define(300,559,336,81,21,0,setup_ok_button,texty[174]);on_control_change(unwire_setup);
|
define(300,559,336,81,21,0,setup_ok_button,texty[174]);on_control_change(exit_setup_action);
|
||||||
property(NULL,ablock(H_FTINY),&color_topbar,0);
|
property(NULL,ablock(H_FTINY),&color_topbar,0);
|
||||||
redraw_window();
|
redraw_window();
|
||||||
add_to_timer(TM_CHECKBOX,4,-1,checkbox_animator);
|
add_to_timer(TM_CHECKBOX,4,-1,checkbox_animator);
|
||||||
|
@ -210,6 +214,7 @@ void game_setup_(void)
|
||||||
new_setup();
|
new_setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char game_setup(int id,int xa,int ya,int xr,int yr)
|
char game_setup(int id,int xa,int ya,int xr,int yr)
|
||||||
{
|
{
|
||||||
id;xa;ya;xr;yr;
|
id;xa;ya;xr;yr;
|
||||||
|
|
|
@ -208,10 +208,10 @@ T_CLK_MAP clk_runes[]=
|
||||||
#define CLK_POWER_WHO 7
|
#define CLK_POWER_WHO 7
|
||||||
T_CLK_MAP clk_power[]=
|
T_CLK_MAP clk_power[]=
|
||||||
{
|
{
|
||||||
{-1,500,376,637,480,power_info,1,H_MS_DEFAULT},
|
{-1,500,376,637,480,power_info,1,-1},
|
||||||
{0,535,391,637,411,power,2,H_MS_DEFAULT},
|
{0,535,391,637,411,power,2,-1},
|
||||||
{1,535,421,637,441,power,2,H_MS_DEFAULT},
|
{1,535,421,637,441,power,2,-1},
|
||||||
{2,535,451,637,471,power,2,H_MS_DEFAULT},
|
{2,535,451,637,471,power,2,-1},
|
||||||
{-1,0,0,639,377,cancel_power,2+8,-1},
|
{-1,0,0,639,377,cancel_power,2+8,-1},
|
||||||
{-1,0,378,639,479,cancel_power,8,-1},
|
{-1,0,378,639,479,cancel_power,8,-1},
|
||||||
{-1,54,378,497,479,ask_who_proc,2,-1},
|
{-1,54,378,497,479,ask_who_proc,2,-1},
|
||||||
|
@ -1723,6 +1723,23 @@ char cancel_runes(int id,int xa,int ya,int xr,int yr)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void select_rune_kbd(EVENT_MSG *ev, void **user_ptr) {
|
||||||
|
if (ev->msg == E_KEYBOARD) {
|
||||||
|
int v = quit_request_as_escape(va_arg(ev->data, int));
|
||||||
|
switch (v>>8) {
|
||||||
|
default: return;
|
||||||
|
case 1: cancel_runes(0,0,0,0,0);return;
|
||||||
|
case 32:
|
||||||
|
case 'M':sel_zivel = (sel_zivel +1) % 5;break;
|
||||||
|
case 30:
|
||||||
|
case 'K':sel_zivel = (sel_zivel +4) % 5;break;
|
||||||
|
}
|
||||||
|
free(runebar);runebar=NULL;
|
||||||
|
display_rune_bar(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void unwire_select_rune(void)
|
void unwire_select_rune(void)
|
||||||
{
|
{
|
||||||
wire_proc=wire_select_rune;
|
wire_proc=wire_select_rune;
|
||||||
|
@ -1730,6 +1747,7 @@ void unwire_select_rune(void)
|
||||||
delete_from_timer(TM_SCENE);
|
delete_from_timer(TM_SCENE);
|
||||||
cancel_render=1;
|
cancel_render=1;
|
||||||
free(runebar);runebar=NULL;
|
free(runebar);runebar=NULL;
|
||||||
|
send_message(E_DONE,E_KEYBOARD, select_rune_kbd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wire_select_rune(void)
|
void wire_select_rune(void)
|
||||||
|
@ -1747,6 +1765,7 @@ void wire_select_rune(void)
|
||||||
change_click_map(clk_runes,CLK_RUNES);
|
change_click_map(clk_runes,CLK_RUNES);
|
||||||
add_to_timer(TM_DELAIER,12,1,display_rune_bar);
|
add_to_timer(TM_DELAIER,12,1,display_rune_bar);
|
||||||
add_to_timer(TM_SCENE,gamespeed,-1,rune_bar_redrawing);
|
add_to_timer(TM_SCENE,gamespeed,-1,rune_bar_redrawing);
|
||||||
|
send_message(E_ADD,E_KEYBOARD, select_rune_kbd);
|
||||||
unwire_proc=unwire_select_rune;
|
unwire_proc=unwire_select_rune;
|
||||||
cancel_render=1;
|
cancel_render=1;
|
||||||
}
|
}
|
||||||
|
@ -1758,6 +1777,7 @@ void wire_select_rune_fly()
|
||||||
change_click_map(clk_runes,CLK_RUNES);
|
change_click_map(clk_runes,CLK_RUNES);
|
||||||
add_to_timer(TM_DELAIER,12,1,display_rune_bar);
|
add_to_timer(TM_DELAIER,12,1,display_rune_bar);
|
||||||
add_to_timer(TM_SCENE,gamespeed,-1,rune_bar_redrawing);
|
add_to_timer(TM_SCENE,gamespeed,-1,rune_bar_redrawing);
|
||||||
|
send_message(E_ADD,E_KEYBOARD, select_rune_kbd);
|
||||||
unwire_proc=unwire_select_rune;
|
unwire_proc=unwire_select_rune;
|
||||||
cancel_render=1;
|
cancel_render=1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -782,7 +782,7 @@ void input_line_event(EVENT_MSG *msg,OBJREC *o)
|
||||||
{
|
{
|
||||||
case 'M':if (cursor<slen) cursor++;break;
|
case 'M':if (cursor<slen) cursor++;break;
|
||||||
case 'K':if (cursor>0) cursor--;break;
|
case 'K':if (cursor>0) cursor--;break;
|
||||||
case 'S':if (cursor<slen) strcpy(&c[cursor],&c[cursor+1]);slen--;break;
|
case 'S':if (cursor<slen) {memmove(c+cursor, c+cursor+1, slen - cursor);slen--;}break;
|
||||||
case 'G':cursor=0;break;
|
case 'G':cursor=0;break;
|
||||||
case 'O':cursor=slen;break;
|
case 'O':cursor=slen;break;
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,12 @@ void input_line_event(EVENT_MSG *msg,OBJREC *o)
|
||||||
if (key)
|
if (key)
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 8:if (cursor>0) {strcpy(&c[cursor-1],&c[cursor]);cursor--;}break;
|
case 8:if (cursor>0) {
|
||||||
|
memmove(c+cursor-1, c+cursor, slen-cursor);
|
||||||
|
--slen;
|
||||||
|
c[slen] = 0;
|
||||||
|
cursor--;
|
||||||
|
}break;
|
||||||
case 0:break;
|
case 0:break;
|
||||||
case 13:break;
|
case 13:break;
|
||||||
case 27:strcpy(c,save);slen=strlen(c);if (cursor>slen) cursor=slen;break;
|
case 27:strcpy(c,save);slen=strlen(c);if (cursor>slen) cursor=slen;break;
|
||||||
|
|
|
@ -6,14 +6,16 @@
|
||||||
|
|
||||||
int timerspeed_val = TIMERSPEED;
|
int timerspeed_val = TIMERSPEED;
|
||||||
|
|
||||||
|
static auto start_tm = std::chrono::steady_clock::now();;
|
||||||
|
|
||||||
int get_timer_value() {
|
int get_timer_value() {
|
||||||
auto n = std::chrono::steady_clock::now();
|
auto n = std::chrono::steady_clock::now();
|
||||||
return std::chrono::duration_cast<std::chrono::milliseconds>(n.time_since_epoch()).count()/timerspeed_val;
|
return std::chrono::duration_cast<std::chrono::milliseconds>(n-start_tm).count()/timerspeed_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_game_tick_count() {
|
uint32_t get_game_tick_count() {
|
||||||
auto n = std::chrono::steady_clock::now();
|
auto n = std::chrono::steady_clock::now();
|
||||||
return std::chrono::duration_cast<std::chrono::milliseconds>(n.time_since_epoch()).count();
|
return std::chrono::duration_cast<std::chrono::milliseconds>(n-start_tm).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep_ms(uint32_t x) {
|
void sleep_ms(uint32_t x) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue