SW: Address Sanitization commenceth

git-svn-id: https://svn.eduke32.com/eduke32@8347 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2019-12-03 09:44:46 +00:00 committed by Christoph Oelckers
parent 820bd2545c
commit f19848a1b3
4 changed files with 32 additions and 24 deletions

View file

@ -378,8 +378,8 @@ extern char MessageOutputString[256];
#define TEST_SYNC_KEY(player, sync_num) TEST((player)->input.bits, (1 << (sync_num))) #define TEST_SYNC_KEY(player, sync_num) TEST((player)->input.bits, (1 << (sync_num)))
#define RESET_SYNC_KEY(player, sync_num) RESET((player)->input.bits, (1 << (sync_num))) #define RESET_SYNC_KEY(player, sync_num) RESET((player)->input.bits, (1 << (sync_num)))
#define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = nextspritesect[o], (o) != -1; (o) = (n)) #define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritesect[o], (o) != -1; (o) = (n))
#define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = nextspritestat[o], (o) != -1; (o) = (n)) #define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritestat[o], (o) != -1; (o) = (n))
#define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i]) #define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i])

View file

@ -3641,7 +3641,7 @@ void StackedWaterSplash(PLAYERp pp)
updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum); updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum);
if (SectorIsUnderwaterArea(sectnum)) if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum))
{ {
PlaySound(DIGI_SPLASH1, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan); PlaySound(DIGI_SPLASH1, &pp->posx, &pp->posy, &pp->posz, v3df_dontpan);
} }
@ -4094,7 +4094,7 @@ DoPlayerWadeSuperJump(PLAYERp pp)
{ {
hitinfo.sect = wall[hitinfo.wall].nextsector; hitinfo.sect = wall[hitinfo.wall].nextsector;
if (labs(sector[hitinfo.sect].floorz - pp->posz) < Z(50)) if (hitinfo.sect >= 0 && labs(sector[hitinfo.sect].floorz - pp->posz) < Z(50))
{ {
if (Distance(pp->posx, pp->posy, hitinfo.pos.x, hitinfo.pos.y) < ((((int)pp->SpriteP->clipdist)<<2) + 256)) if (Distance(pp->posx, pp->posy, hitinfo.pos.x, hitinfo.pos.y) < ((((int)pp->SpriteP->clipdist)<<2) + 256))
return TRUE; return TRUE;
@ -4694,7 +4694,7 @@ PlayerCanDiveNoWarp(PLAYERp pp)
updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum); updatesectorz(pp->posx, pp->posy, SPRITEp_BOS(pp->SpriteP), &sectnum);
if (SectorIsUnderwaterArea(sectnum)) if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum))
{ {
pp->cursectnum = sectnum; pp->cursectnum = sectnum;
pp->posz = sector[sectnum].ceilingz; pp->posz = sector[sectnum].ceilingz;

View file

@ -89,7 +89,7 @@ SWBOOL LoadScriptFile(const char *filename)
size = fp.GetLength(); size = fp.GetLength();
scriptbuffer = (char *)AllocMem(size); scriptbuffer = (char *)AllocMem(size+1);
ASSERT(scriptbuffer != NULL); ASSERT(scriptbuffer != NULL);
@ -97,6 +97,7 @@ SWBOOL LoadScriptFile(const char *filename)
ASSERT(readsize == size); ASSERT(readsize == size);
scriptbuffer[readsize] = '\0';
// Convert filebuffer to all upper case // Convert filebuffer to all upper case
//Bstrupr(scriptbuffer); //Bstrupr(scriptbuffer);

View file

@ -2653,12 +2653,12 @@ STATE s_PaperShrapC[] =
SWBOOL MissileHitMatch(short Weapon, short WeaponNum, short hit_sprite) SWBOOL MissileHitMatch(short Weapon, short WeaponNum, short hit_sprite)
{ {
SPRITEp hsp = &sprite[hit_sprite]; SPRITEp hsp = &sprite[hit_sprite];
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
if (WeaponNum <= -1) if (WeaponNum <= -1)
{ {
ASSERT(Weapon >= 0); ASSERT(Weapon >= 0);
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
WeaponNum = wu->WeaponNum; WeaponNum = wu->WeaponNum;
// can be hit by SO only // can be hit by SO only
@ -5760,8 +5760,6 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
{ {
SPRITEp sp = pp->SpriteP; SPRITEp sp = pp->SpriteP;
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
int SpawnZombie(PLAYERp pp, short); int SpawnZombie(PLAYERp pp, short);
@ -5786,6 +5784,9 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
return TRUE; return TRUE;
} }
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon];
if (Weapon > -1 && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0)) if (Weapon > -1 && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0))
pp->DeathType = PLAYER_DEATH_RIPPER; pp->DeathType = PLAYER_DEATH_RIPPER;
@ -5828,14 +5829,14 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
SWBOOL SWBOOL
PlayerTakeDamage(PLAYERp pp, short Weapon) PlayerTakeDamage(PLAYERp pp, short Weapon)
{ {
if (Weapon < 0)
return TRUE;
SPRITEp sp = pp->SpriteP; SPRITEp sp = pp->SpriteP;
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
SPRITEp wp = &sprite[Weapon]; SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon]; USERp wu = User[Weapon];
if (Weapon < 0)
return TRUE;
if (gNet.MultiGameType == MULTI_GAME_NONE) if (gNet.MultiGameType == MULTI_GAME_NONE)
{ {
// ZOMBIE special case for single play // ZOMBIE special case for single play
@ -7607,9 +7608,11 @@ DoDamageTest(short Weapon)
return 0; return 0;
} }
int static int DoHitscanDamage(short Weapon, uint16_t hit_sprite)
DoHitscanDamage(short Weapon, short hit_sprite)
{ {
if (hit_sprite >= MAXSPRITES)
return 0;
SPRITEp wp = &sprite[Weapon]; SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon]; USERp wu = User[Weapon];
unsigned stat; unsigned stat;
@ -10832,8 +10835,8 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy)
{ {
SPRITEp sp = &sprite[SpriteNum]; SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum]; USERp u = User[SpriteNum];
SPRITEp ep = &sprite[enemy]; SPRITEp ep;
USERp eu = User[enemy]; USERp eu;
SPRITEp np; SPRITEp np;
USERp nu; USERp nu;
short New; short New;
@ -10843,6 +10846,9 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy)
if (enemy >= 0) if (enemy >= 0)
{ {
ep = &sprite[enemy];
eu = User[enemy];
// test for already burned // test for already burned
if (TEST(ep->extra, SPRX_BURNABLE) && ep->shade > 40) if (TEST(ep->extra, SPRX_BURNABLE) && ep->shade > 40)
return -1; return -1;
@ -17843,17 +17849,18 @@ SWBOOL
HitscanSpriteAdjust(short SpriteNum, short hit_wall) HitscanSpriteAdjust(short SpriteNum, short hit_wall)
{ {
SPRITEp sp = &sprite[SpriteNum]; SPRITEp sp = &sprite[SpriteNum];
short w, nw, ang = sp->ang, wall_ang; int16_t ang;
int xvect,yvect; int xvect,yvect;
short sectnum; short sectnum;
#if 1 #if 1
w = hit_wall;
nw = wall[w].point2;
wall_ang = NORM_ANGLE(getangle(wall[nw].x - wall[w].x, wall[nw].y - wall[w].y));
if (hit_wall >= 0) if (hit_wall >= 0)
{
uint16_t const w = hit_wall;
uint16_t const nw = wall[hit_wall].point2;
int16_t const wall_ang = NORM_ANGLE(getangle(wall[nw].x - wall[w].x, wall[nw].y - wall[w].y));
ang = sp->ang = NORM_ANGLE(wall_ang + 512); ang = sp->ang = NORM_ANGLE(wall_ang + 512);
}
else else
ang = sp->ang; ang = sp->ang;
#endif #endif
@ -20638,13 +20645,13 @@ void QueueReset(void)
SWBOOL TestDontStick(short SpriteNum, short hit_sect, short hit_wall, int hit_z) SWBOOL TestDontStick(short SpriteNum, short hit_sect, short hit_wall, int hit_z)
{ {
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
WALLp wp; WALLp wp;
if (hit_wall < 0) if (hit_wall < 0)
{ {
ASSERT(SpriteNum>=0); ASSERT(SpriteNum>=0);
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
hit_wall = NORM_WALL(u->ret); hit_wall = NORM_WALL(u->ret);
} }