mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-15 10:46:44 -04:00
fix crash when switching maps in global map
This commit is contained in:
parent
1e7bbcb245
commit
9b199b13a7
4 changed files with 61 additions and 51 deletions
|
@ -61,7 +61,7 @@ char enable_glmap=0;
|
||||||
|
|
||||||
static int map_xr,map_yr;
|
static int map_xr,map_yr;
|
||||||
static int cur_depth;
|
static int cur_depth;
|
||||||
TSTR_LIST texty_v_mape=NULL;
|
static TSTR_LIST texty_v_mape=NULL;
|
||||||
|
|
||||||
#define BOTT 378
|
#define BOTT 378
|
||||||
#define LEFT 520
|
#define LEFT 520
|
||||||
|
@ -96,7 +96,6 @@ T_CLK_MAP clk_teleport_view[]=
|
||||||
{-1,0,0,639,479,empty_clk,0xff,-1},
|
{-1,0,0,639,479,empty_clk,0xff,-1},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
char testclip(int x,int y)
|
char testclip(int x,int y)
|
||||||
{
|
{
|
||||||
return (y>=16 && y<360+16 && x>=8 && x<630);
|
return (y>=16 && y<360+16 && x>=8 && x<630);
|
||||||
|
@ -1054,3 +1053,54 @@ int select_teleport_target(char nolimit)
|
||||||
disable_all_map();
|
disable_all_map();
|
||||||
return last_selected;
|
return last_selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void save_map_description(TMPFILE_WR *f)
|
||||||
|
{
|
||||||
|
int count,max;
|
||||||
|
int32_t i;
|
||||||
|
|
||||||
|
if (texty_v_mape==NULL) max=0;else max=str_count(texty_v_mape);
|
||||||
|
for(i=0,count=0;i<max;i++) if (texty_v_mape[i]!=NULL) count++;
|
||||||
|
temp_storage_write(&count,1*sizeof(count),f);
|
||||||
|
for(i=0;i<max;i++) if (texty_v_mape[i]!=NULL)
|
||||||
|
{
|
||||||
|
word len;
|
||||||
|
len=strlen(texty_v_mape[i]+12)+12+1;
|
||||||
|
temp_storage_write(&len,1*2,f);
|
||||||
|
temp_storage_write(texty_v_mape[i],1*len,f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_map_description(TMPFILE_RD *f)
|
||||||
|
{
|
||||||
|
int32_t count;
|
||||||
|
int32_t i;
|
||||||
|
word len;
|
||||||
|
|
||||||
|
if (texty_v_mape!=NULL)release_list(texty_v_mape);
|
||||||
|
temp_storage_read(&count,1*sizeof(count),f);
|
||||||
|
if (!count)
|
||||||
|
{
|
||||||
|
texty_v_mape=NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
texty_v_mape=create_list(count);
|
||||||
|
for(i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
temp_storage_read(&len,1*2,f);
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
s=(char *)alloca(len);
|
||||||
|
memset(s,1,len-1);
|
||||||
|
s[len-1]=0;
|
||||||
|
str_replace(&texty_v_mape,i,s);
|
||||||
|
}
|
||||||
|
temp_storage_read(texty_v_mape[i],1*len,f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_map_description() {
|
||||||
|
if (texty_v_mape!=NULL)release_list(texty_v_mape);
|
||||||
|
texty_v_mape = NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -235,52 +235,7 @@ void restore_items(TMPFILE_RD *f)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern TSTR_LIST texty_v_mape;
|
|
||||||
|
|
||||||
void save_map_description(TMPFILE_WR *f)
|
|
||||||
{
|
|
||||||
int count,max;
|
|
||||||
int32_t i;
|
|
||||||
|
|
||||||
if (texty_v_mape==NULL) max=0;else max=str_count(texty_v_mape);
|
|
||||||
for(i=0,count=0;i<max;i++) if (texty_v_mape[i]!=NULL) count++;
|
|
||||||
temp_storage_write(&count,1*sizeof(count),f);
|
|
||||||
for(i=0;i<max;i++) if (texty_v_mape[i]!=NULL)
|
|
||||||
{
|
|
||||||
word len;
|
|
||||||
len=strlen(texty_v_mape[i]+12)+12+1;
|
|
||||||
temp_storage_write(&len,1*2,f);
|
|
||||||
temp_storage_write(texty_v_mape[i],1*len,f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void load_map_description(TMPFILE_RD *f)
|
|
||||||
{
|
|
||||||
int32_t count;
|
|
||||||
int32_t i;
|
|
||||||
word len;
|
|
||||||
|
|
||||||
if (texty_v_mape!=NULL)release_list(texty_v_mape);
|
|
||||||
temp_storage_read(&count,1*sizeof(count),f);
|
|
||||||
if (!count)
|
|
||||||
{
|
|
||||||
texty_v_mape=NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
texty_v_mape=create_list(count);
|
|
||||||
for(i=0;i<count;i++)
|
|
||||||
{
|
|
||||||
temp_storage_read(&len,1*2,f);
|
|
||||||
{
|
|
||||||
char *s;
|
|
||||||
s=(char *)alloca(len);
|
|
||||||
memset(s,1,len-1);
|
|
||||||
s[len-1]=0;
|
|
||||||
str_replace(&texty_v_mape,i,s);
|
|
||||||
}
|
|
||||||
temp_storage_read(texty_v_mape[i],1*len,f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void save_vyklenky(TMPFILE_WR *fsta)
|
void save_vyklenky(TMPFILE_WR *fsta)
|
||||||
{
|
{
|
||||||
|
@ -1802,7 +1757,10 @@ static int load_map_state_partial(char *level_fname,int mapsize) //obnovuje stav
|
||||||
bf=(char *)getmem(siz);
|
bf=(char *)getmem(siz);
|
||||||
if (!temp_storage_read(bf,siz*1,fsta)) goto err;
|
if (!temp_storage_read(bf,siz*1,fsta)) goto err;
|
||||||
for (i=0;i<mapsize;i++)
|
for (i=0;i<mapsize;i++)
|
||||||
map_coord[i].flags|=(bf[i>>3]>>(i & 7)) & 1;
|
if ((bf[i>>3]>>(i & 7)) & 1) map_coord[i].flags|=MC_AUTOMAP;
|
||||||
|
if (!temp_storage_read(bf,siz*1,fsta)) goto err;
|
||||||
|
for (i=0;i<mapsize;i++)
|
||||||
|
if ((bf[i>>3]>>(i & 7)) & 1) map_coord[i].flags|=MC_DISCLOSED;
|
||||||
load_map_description(fsta);
|
load_map_description(fsta);
|
||||||
while (temp_storage_read(&i,1*2,fsta) && i<=mapsize*4)
|
while (temp_storage_read(&i,1*2,fsta) && i<=mapsize*4)
|
||||||
if (temp_storage_read(map_sides+i,1*sizeof(TSTENA),fsta)!=sizeof(TSTENA)) goto err;
|
if (temp_storage_read(map_sides+i,1*sizeof(TSTENA),fsta)!=sizeof(TSTENA)) goto err;
|
||||||
|
|
|
@ -1406,6 +1406,9 @@ int load_map_state(void); //obnovuje stav mapy; nutno volat po zavolani load_map
|
||||||
void restore_current_map(void); //pouze obnovuje ulozeny stav aktualni mapy
|
void restore_current_map(void); //pouze obnovuje ulozeny stav aktualni mapy
|
||||||
int load_game(const char *fname);
|
int load_game(const char *fname);
|
||||||
int save_game(long game_time,char *gamename, char is_autosave);
|
int save_game(long game_time,char *gamename, char is_autosave);
|
||||||
|
void save_map_description(TMPFILE_WR *f);
|
||||||
|
void load_map_description(TMPFILE_RD *f);
|
||||||
|
void free_map_description();
|
||||||
void wire_save_load(char save);
|
void wire_save_load(char save);
|
||||||
void do_save_dialog();
|
void do_save_dialog();
|
||||||
char ask_save_dialog(char *name_buffer, size_t name_size);
|
char ask_save_dialog(char *name_buffer, size_t name_size);
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#define DIS (char *)0x1
|
#define DIS (char *)0x1
|
||||||
#define START_HANDLE hl_ptr
|
#define START_HANDLE hl_ptr
|
||||||
|
|
||||||
extern TSTR_LIST texty_v_mape;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -457,14 +457,13 @@ void leave_current_map()
|
||||||
free(flag_map);
|
free(flag_map);
|
||||||
free(map_coord);
|
free(map_coord);
|
||||||
free(map_vyk);map_vyk=NULL;vyk_max=0;
|
free(map_vyk);map_vyk=NULL;vyk_max=0;
|
||||||
if (texty_v_mape!=NULL)release_list(texty_v_mape);
|
free_map_description();
|
||||||
while (d_action!=NULL)
|
while (d_action!=NULL)
|
||||||
{
|
{
|
||||||
void *p=d_action;
|
void *p=d_action;
|
||||||
d_action=d_action->next;
|
d_action=d_action->next;
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
texty_v_mape=NULL;
|
|
||||||
release_list(level_texts);
|
release_list(level_texts);
|
||||||
if (mob_map!=NULL) free(mob_map);
|
if (mob_map!=NULL) free(mob_map);
|
||||||
if (macro_block!=NULL)
|
if (macro_block!=NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue