From 846c7701d49df10bf2787c488ce9ab936875fc02 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 9 Aug 2008 12:29:23 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@953 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/funct.h | 4 +-- polymer/eduke32/source/game.c | 2 +- polymer/eduke32/source/gameexec.c | 42 ++++++++++++++++++------------- polymer/eduke32/source/sector.c | 30 ++++++++++++++++------ 4 files changed, 49 insertions(+), 29 deletions(-) diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index c74cf3da6..8b0c10362 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -47,8 +47,8 @@ extern int isadoorwall(int dapic); extern int isanunderoperator(int lotag); extern int isanearoperator(int lotag); extern inline int checkcursectnums(int sect); -extern inline int ldist(spritetype *s1,spritetype *s2); -extern inline int dist(spritetype *s1,spritetype *s2); +extern int ldist(spritetype *s1,spritetype *s2); +extern int dist(spritetype *s1,spritetype *s2); extern int findplayer(spritetype *s,int *d); extern int findotherplayer(int p,int *d); extern void doanimations(void); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index cd046549b..c062038fb 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2025,7 +2025,7 @@ static void coolgaugetext(int snum) if (sprite[p->i].pal == 1 && p->last_extra < 2) altdigitalnumber(40,-(200-22),1,-16,10+16); - else if (!althud_flashing || p->last_extra > 25 || totalclock&32) + else if (!althud_flashing || p->last_extra > (p->max_player_health>>2) || totalclock&32) altdigitalnumber(40,-(200-22),p->last_extra,-16,10+16); if (althud_shadows) diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 060b91c22..70df1aeca 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -7050,12 +7050,15 @@ static int parse(void) int lSprite=GetGameVarID(*insptr++, g_i, g_p), lVar1=*insptr++; j=*insptr++; + if (lSprite < 0 || lSprite >= MAXSPRITES) + { + OSD_Printf(CON_ERROR "CON_GETACTORVAR/CON_SETACTORVAR: invalid sprite ID %d\n",line_num,lSprite); + break; + } + if (tw == CON_SETACTORVAR) { - if (lSprite >= 0 && lSprite < MAXSPRITES) - SetGameVarID(lVar1, GetGameVarID(j, g_i, g_p), lSprite, g_p); - else - OSD_Printf(CON_ERROR "CON_SETACTORVAR: invalid sprite ID %d\n",line_num,lSprite); + SetGameVarID(lVar1, GetGameVarID(j, g_i, g_p), lSprite, g_p); break; } SetGameVarID(j, GetGameVarID(lVar1, lSprite, g_p), g_i, g_p); @@ -7076,12 +7079,15 @@ static int parse(void) { int lVar1=*insptr++, lVar2=*insptr++; + if (iPlayer < 0 || iPlayer >= ud.multimode) + { + OSD_Printf(CON_ERROR "CON_GETPLAYERVAR/CON_SETPLAYERVAR: invalid player ID %d\n",line_num,iPlayer); + break; + } + if (tw == CON_SETPLAYERVAR) { - if (iPlayer >= 0 && iPlayer < ud.multimode) - SetGameVarID(lVar1, GetGameVarID(lVar2, g_i, g_p), g_i, iPlayer); - else - OSD_Printf(CON_ERROR "CON_SETPLAYERVAR: invalid player ID %d\n",line_num,iPlayer); + SetGameVarID(lVar1, GetGameVarID(lVar2, g_i, g_p), g_i, iPlayer); break; } SetGameVarID(lVar2, GetGameVarID(lVar1, g_i, iPlayer), g_i, g_p); @@ -7203,7 +7209,7 @@ static int parse(void) int asize = GetGameVarID(*insptr++, g_i, g_p); if (asize > 0) { - OSD_Printf(OSDTEXT_GREEN "resizing array %s, old size %d new size %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize); + OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize); aGameArrays[j].plValues=Brealloc(aGameArrays[j].plValues, sizeof(int) * asize); aGameArrays[j].size = asize; } @@ -7441,17 +7447,17 @@ static int parse(void) break; case CON_STARTTRACK: - insptr++; - music_select=(ud.volume_number*MAXLEVELS)+(*(insptr++)); - if (map[(unsigned char)music_select].musicfn != NULL) - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); - break; - case CON_STARTTRACKVAR: insptr++; - music_select=(ud.volume_number*MAXLEVELS)+(GetGameVarID(*(insptr++), g_i, g_p)); - if (map[(unsigned char)music_select].musicfn != NULL) - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); + if (tw == CON_STARTTRACK) music_select=(ud.volume_number*MAXLEVELS)+(*(insptr++)); + else music_select=(ud.volume_number*MAXLEVELS)+(GetGameVarID(*(insptr++), g_i, g_p)); + if (map[(unsigned char)music_select].musicfn == NULL) + { + OSD_Printf(CON_ERROR "CON_STARTTRACK/CON_STARTTRACKVAR: null music for map %d\n",line_num,music_select); + insptr++; + break; + } + playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); break; case CON_GETTEXTURECEILING: diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 2da3ec94c..93621917d 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -196,18 +196,32 @@ inline int checkcursectnums(int sect) return -1; } -inline int ldist(spritetype *s1,spritetype *s2) +int ldist(spritetype *s1,spritetype *s2) { - int i = FindDistance2D(s1->x-s2->x, s1->y-s2->y); - if (!i) return 1; - return i; + int x= klabs(s1->x-s2->x); + int y= klabs(s1->y-s2->y); + + if (x>1); + return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6)); + } } -inline int dist(spritetype *s1,spritetype *s2) +int dist(spritetype *s1,spritetype *s2) { - int i = FindDistance3D(s1->x-s2->x, s1->y-s2->y, (s1->z-s2->z)>>4); - if (!i) return 1; - return i; + int x= klabs(s1->x-s2->x); + int y= klabs(s1->y-s2->y); + int z= klabs((s1->z-s2->z)>>4); + + if (x>4) + (t>>2) + (t>>3)); + } } int findplayer(spritetype *s,int *d)