mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
fix crashes
This commit is contained in:
parent
04ab5898ef
commit
a8c9fced4c
12 changed files with 65 additions and 59 deletions
|
@ -606,7 +606,7 @@ static int process_actions(const char *command) {
|
||||||
if (istrcmp(command, "world-list") == 0) {
|
if (istrcmp(command, "world-list") == 0) {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
list_files(gpathtable[SR_MAP], file_type_normal|file_type_just_name, add_file_to_console, &cnt);
|
list_files(gpathtable[SR_MAP], file_type_normal|file_type_just_name, add_file_to_console, &cnt);
|
||||||
printf("\n");
|
wzprintf("\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (istrcmp(command, "beam-me-up") == 0) {
|
if (istrcmp(command, "beam-me-up") == 0) {
|
||||||
|
|
88
game/enemy.c
88
game/enemy.c
|
@ -543,51 +543,53 @@ int q_vidis_postavu(int sector,int dir,TMOB *p,int *otocit_se,char ret)
|
||||||
{
|
{
|
||||||
char ok=0;
|
char ok=0;
|
||||||
THUMAN *ps=&postavy[i];
|
THUMAN *ps=&postavy[i];
|
||||||
xs=map_coord[sector].x-map_coord[postavy[i].sektor].x;
|
if (ps->used && ps->inmaphash == current_map_hash) {
|
||||||
ys=map_coord[sector].y-map_coord[postavy[i].sektor].y;
|
xs=map_coord[sector].x-map_coord[postavy[i].sektor].x;
|
||||||
d=MAX(abs(xs),abs(ys));
|
ys=map_coord[sector].y-map_coord[postavy[i].sektor].y;
|
||||||
if (d<=p->dohled && (!(ps->vlastnosti[VLS_KOUZLA] & SPL_INVIS)||p->vlajky & MOB_SENSE) && ps->used && ps->lives && ps->inmaphash == current_map_hash)
|
d=MAX(abs(xs),abs(ys));
|
||||||
switch(dir)
|
if (d<=p->dohled && (!(ps->vlastnosti[VLS_KOUZLA] & SPL_INVIS)||p->vlajky & MOB_SENSE) && ps->used && ps->lives && ps->inmaphash == current_map_hash)
|
||||||
{
|
switch(dir)
|
||||||
case 0:ok=ys>=0;break;
|
|
||||||
case 1:ok=xs<=0;break;
|
|
||||||
case 2:ok=ys<=0;break;
|
|
||||||
case 3:ok=xs>=0;break;
|
|
||||||
}
|
|
||||||
if (ok)
|
|
||||||
if (je_mozne_videt(sector,postavy[i].sektor,SD_MONST_IMPS | SD_PLAY_IMPS))
|
|
||||||
{
|
|
||||||
int alt = 0;
|
|
||||||
if (ys>=abs(xs)) {nd=0;alt=xs>0?3:1;}
|
|
||||||
else if (xs>=abs(ys)) {nd=3;alt=ys>0?0:2;}
|
|
||||||
else if (ys<=(-abs(xs))) {nd=2;alt=xs>0?1:3;}
|
|
||||||
else if (xs<=(-abs(ys))) {nd=1;alt=ys>0?2:0;}
|
|
||||||
if (mob_check_next_sector(p->sector,nd,p->stay_strategy & MOB_BIG,p->vlajky & MOB_PASSABLE)==1)
|
|
||||||
{
|
{
|
||||||
nd=alt;
|
case 0:ok=ys>=0;break;
|
||||||
if (mob_check_next_sector(p->sector,nd,p->stay_strategy & MOB_BIG,p->vlajky & MOB_PASSABLE)==1)
|
case 1:ok=xs<=0;break;
|
||||||
{
|
case 2:ok=ys<=0;break;
|
||||||
nd=(alt+2)&3;
|
case 3:ok=xs>=0;break;
|
||||||
if (mob_check_next_sector(p->sector,nd,p->stay_strategy & MOB_BIG,p->vlajky & MOB_PASSABLE)==1)
|
|
||||||
{
|
|
||||||
nd=(alt+3)&3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
if (ok)
|
||||||
else d=255;
|
if (je_mozne_videt(sector,postavy[i].sektor,SD_MONST_IMPS | SD_PLAY_IMPS))
|
||||||
else d=255;
|
{
|
||||||
if (d!=255)
|
int alt = 0;
|
||||||
{
|
if (ys>=abs(xs)) {nd=0;alt=xs>0?3:1;}
|
||||||
d*=2;
|
else if (xs>=abs(ys)) {nd=3;alt=ys>0?0:2;}
|
||||||
if (xs!=0 && ys!=0) d+=3;//dej prednost tem co jsou na tve souradnici.
|
else if (ys<=(-abs(xs))) {nd=2;alt=xs>0?1:3;}
|
||||||
if (d<dis || (d==dis && rnd(10)<3))
|
else if (xs<=(-abs(ys))) {nd=1;alt=ys>0?2:0;}
|
||||||
{
|
if (mob_check_next_sector(p->sector,nd,p->stay_strategy & MOB_BIG,p->vlajky & MOB_PASSABLE)==1)
|
||||||
dis=d;*otocit_se=nd;att_sect=postavy[i].sektor;
|
{
|
||||||
z=i;
|
nd=alt;
|
||||||
}
|
if (mob_check_next_sector(p->sector,nd,p->stay_strategy & MOB_BIG,p->vlajky & MOB_PASSABLE)==1)
|
||||||
}
|
{
|
||||||
}
|
nd=(alt+2)&3;
|
||||||
|
if (mob_check_next_sector(p->sector,nd,p->stay_strategy & MOB_BIG,p->vlajky & MOB_PASSABLE)==1)
|
||||||
|
{
|
||||||
|
nd=(alt+3)&3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else d=255;
|
||||||
|
else d=255;
|
||||||
|
if (d!=255)
|
||||||
|
{
|
||||||
|
d*=2;
|
||||||
|
if (xs!=0 && ys!=0) d+=3;//dej prednost tem co jsou na tve souradnici.
|
||||||
|
if (d<dis || (d==dis && rnd(10)<3))
|
||||||
|
{
|
||||||
|
dis=d;*otocit_se=nd;att_sect=postavy[i].sektor;
|
||||||
|
z=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (dis==255) dis=-2;
|
if (dis==255) dis=-2;
|
||||||
if (ret)return z;else return dis/2;
|
if (ret)return z;else return dis/2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -618,6 +618,7 @@ void show_cel(int celx,int cely,const void *stena,int xofs,int yofs,char rev, in
|
||||||
x=x3d->xpos+xofs;
|
x=x3d->xpos+xofs;
|
||||||
if (-x>realsx) return;
|
if (-x>realsx) return;
|
||||||
p=stena;p+=SHADE_PAL+2*2+2;
|
p=stena;p+=SHADE_PAL+2*2+2;
|
||||||
|
zoom.texture_end = p + txtsx*txtsy;
|
||||||
i=0;
|
i=0;
|
||||||
while (x<0)
|
while (x<0)
|
||||||
{
|
{
|
||||||
|
@ -690,6 +691,7 @@ void show_cel2(int celx,int cely,const void *stena,int xofs,int yofs,char rev, i
|
||||||
if (celx<=0) x=x3d->xpos+xofs; else x=x3d->xpos2+xofs;
|
if (celx<=0) x=x3d->xpos+xofs; else x=x3d->xpos2+xofs;
|
||||||
if (-x>realsx) return;
|
if (-x>realsx) return;
|
||||||
p=stena;p+=SHADE_PAL+2*2+2;
|
p=stena;p+=SHADE_PAL+2*2+2;
|
||||||
|
zoom.texture_end = p + txtsx*txtsy;
|
||||||
i=0;
|
i=0;
|
||||||
while (x<0)
|
while (x<0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@ typedef struct zoominfo
|
||||||
word *palette;
|
word *palette;
|
||||||
word ycount;
|
word ycount;
|
||||||
word xmax;
|
word xmax;
|
||||||
|
const void *texture_end;
|
||||||
}ZOOMINFO;
|
}ZOOMINFO;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ void sikma_zleva_##suffx(void) \
|
||||||
word cy = zoom.ycount; \
|
word cy = zoom.ycount; \
|
||||||
const unsigned char *pixmap = zoom.texture; \
|
const unsigned char *pixmap = zoom.texture; \
|
||||||
const short *ytable = zoom.ytable; \
|
const short *ytable = zoom.ytable; \
|
||||||
while (cy) { \
|
while (cy && pixmap < (const unsigned char *)zoom.texture_end) { \
|
||||||
const int32_t *xtable = zoom.xtable; \
|
const int32_t *xtable = zoom.xtable; \
|
||||||
word cx = zoom.xmax; \
|
word cx = zoom.xmax; \
|
||||||
word *scr_iter = scr; \
|
word *scr_iter = scr; \
|
||||||
|
@ -48,7 +48,7 @@ void sikma_zprava_##suffx(void) \
|
||||||
word cy = zoom.ycount; \
|
word cy = zoom.ycount; \
|
||||||
const unsigned char *pixmap = zoom.texture; \
|
const unsigned char *pixmap = zoom.texture; \
|
||||||
const short *ytable = zoom.ytable; \
|
const short *ytable = zoom.ytable; \
|
||||||
while (cy) { \
|
while (cy && pixmap < (const unsigned char *)zoom.texture_end) { \
|
||||||
const int32_t *xtable = zoom.xtable; \
|
const int32_t *xtable = zoom.xtable; \
|
||||||
word cx = zoom.xmax; \
|
word cx = zoom.xmax; \
|
||||||
word *scr_iter = scr; \
|
word *scr_iter = scr; \
|
||||||
|
|
|
@ -208,7 +208,7 @@ void restore_items(TMPFILE_RD *f)
|
||||||
int32_t i,j;
|
int32_t i,j;
|
||||||
|
|
||||||
for(i=0;i<mapsize*4;i++) if (map_items[i]!=NULL) free(map_items[i]);
|
for(i=0;i<mapsize*4;i++) if (map_items[i]!=NULL) free(map_items[i]);
|
||||||
memset(map_items,0,mapsize*16);
|
memset(map_items,0,mapsize*4*sizeof(*map_items));
|
||||||
while(temp_storage_read(&i,sizeof(i),f) && i!=-1)
|
while(temp_storage_read(&i,sizeof(i),f) && i!=-1)
|
||||||
{
|
{
|
||||||
temp_storage_read(&j,sizeof(j),f);
|
temp_storage_read(&j,sizeof(j),f);
|
||||||
|
|
|
@ -1193,7 +1193,7 @@ void fletna_pridej_notu(char note)
|
||||||
{
|
{
|
||||||
note+=65;
|
note+=65;
|
||||||
fletna_str[pos]=note;
|
fletna_str[pos]=note;
|
||||||
if (pos==13) memmove(fletna_str,fletna_str+1,pos-1);
|
if (pos==countof(fletna_str)) memmove(fletna_str,fletna_str+1,pos-1);
|
||||||
else pos++;
|
else pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,7 +1415,7 @@ int load_string_list_ex(TSTR_LIST *list,const char *filename)
|
||||||
return lin;
|
return lin;
|
||||||
}
|
}
|
||||||
if (i==-1) break;
|
if (i==-1) break;
|
||||||
while ((j=temp_storage_getc(f))<33 && j!=EOF);
|
while ((j=temp_storage_getc(f))<33 && j!=EOF && j!='\n');
|
||||||
if (j!=EOF) temp_storage_ungetc(f);
|
if (j!=EOF) temp_storage_ungetc(f);
|
||||||
if (temp_storage_gets(c,1022,f)==NULL)
|
if (temp_storage_gets(c,1022,f)==NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2049,11 +2049,11 @@ int weigth_defect(THUMAN *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char check_double_wield() {
|
static char check_double_wield() {
|
||||||
short i1 = human_selected->wearing[PO_RUKA_L]-1;
|
short i1 = human_selected->wearing[PO_RUKA_L];
|
||||||
short i2 = human_selected->wearing[PO_RUKA_R]-1;
|
short i2 = human_selected->wearing[PO_RUKA_R];
|
||||||
if (!i1 || !i2) return 0;
|
if (!i1 || !i2) return 0;
|
||||||
const TITEM *it1 = glob_items+i1;
|
const TITEM *it1 = glob_items+i1-1;
|
||||||
const TITEM *it2 = glob_items+i2;
|
const TITEM *it2 = glob_items+i2-1;
|
||||||
if (it1->druh!=TYP_UTOC || it2->druh!=TYP_UTOC ) return 0;
|
if (it1->druh!=TYP_UTOC || it2->druh!=TYP_UTOC ) return 0;
|
||||||
for (int i = VLS_SILA; i <=VLS_OBRAT; ++i) {
|
for (int i = VLS_SILA; i <=VLS_OBRAT; ++i) {
|
||||||
if ((it1->podminky[i] + it2->podminky[i] > human_selected->vlastnosti[i])
|
if ((it1->podminky[i] + it2->podminky[i] > human_selected->vlastnosti[i])
|
||||||
|
|
|
@ -925,15 +925,14 @@ void spell_pripojenia(int owner)
|
||||||
{
|
{
|
||||||
int sect;
|
int sect;
|
||||||
sect=postavy[i].sektor;
|
sect=postavy[i].sektor;
|
||||||
if (map_coord[sect].flags & MC_NOSUMMON)
|
if (sect > 0 && sect < mapsize && map_coord[sect].flags & MC_NOSUMMON) {
|
||||||
if (h==NULL) h=postavy+i;else more=1;
|
if (h==NULL) h=postavy+i;else more=1;
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
postavy[i].sektor=postavy[owner].sektor;
|
postavy[i].sektor=postavy[owner].sektor;
|
||||||
postavy[i].direction=postavy[owner].direction;
|
postavy[i].direction=postavy[owner].direction;
|
||||||
postavy[i].inmaphash = postavy[owner].inmaphash;
|
postavy[i].inmaphash = postavy[owner].inmaphash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto_group();
|
auto_group();
|
||||||
if (more) bott_disp_text(texty[89]);
|
if (more) bott_disp_text(texty[89]);
|
||||||
else if (h!=NULL)
|
else if (h!=NULL)
|
||||||
|
|
|
@ -149,7 +149,7 @@ void new_setup()
|
||||||
|
|
||||||
mix_back_sound(256000-16384);
|
mix_back_sound(256000-16384);
|
||||||
memset(&ctl,0,sizeof(ctl));
|
memset(&ctl,0,sizeof(ctl));
|
||||||
change_click_map(setup,4);
|
change_click_map(setup,countof(setup));
|
||||||
set_font(H_FBOLD,SETUP_COL2);
|
set_font(H_FBOLD,SETUP_COL2);
|
||||||
default_font=curfont;
|
default_font=curfont;
|
||||||
memcpy(f_default,charcolors,sizeof(f_default));
|
memcpy(f_default,charcolors,sizeof(f_default));
|
||||||
|
|
|
@ -544,7 +544,8 @@ void play_sample_at_sector(int sample,int listener,int source,int track, char lo
|
||||||
int oldtrack;
|
int oldtrack;
|
||||||
|
|
||||||
if (!sound_enabled) return;
|
if (!sound_enabled) return;
|
||||||
if (map_coord[listener].layer!=map_coord[source].layer) return;
|
if (listener<0 || listener>=mapsize || map_coord[listener].layer!=map_coord[source].layer) return;
|
||||||
|
if (source<0 || source >=mapsize) return;
|
||||||
xd=map_coord[source].x;
|
xd=map_coord[source].x;
|
||||||
yd=map_coord[source].y;
|
yd=map_coord[source].y;
|
||||||
chan=find_free_channel(track);
|
chan=find_free_channel(track);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
void SDLContext::SDL_Deleter::operator ()(SDL_Window* window) {
|
void SDLContext::SDL_Deleter::operator ()(SDL_Window* window) {
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue