Eliminate one uinitialized mem access related to projectiles (it's the filler

member, so maybe not *that* bad) and an invalid memory access when trying to
access a per-player gamevar in a player-less context (e.g. WGR2 SVN r25
WGR2GAME.CON line 10448).

git-svn-id: https://svn.eduke32.com/eduke32@2102 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-11-01 22:03:09 +00:00
parent a4ba86ee31
commit b9a4b92bc8
2 changed files with 8 additions and 2 deletions

View file

@ -5632,16 +5632,17 @@ static void C_InitProjectiles(void)
int8_t shade, xrepeat, yrepeat, pal; // 4b
int8_t velmult; // 1b
uint8_t clipdist; // 1b
int8_t filler[6]; // 6b
} defaultprojectile_t;
defaultprojectile_t DefaultProjectile =
{
1, -1, 2048, 0, 0, SMALLSMOKE, -1, -1, 600, BULLETHOLE, -1, 0, 0, 448, g_numFreezeBounces, PIPEBOMB_BOUNCE, 1,
100, -1, -1, -1, -1, -1, -96, 18, 18, 0, 1, 32
100, -1, -1, -1, -1, -1, -96, 18, 18, 0, 1, 32, {0,0,0,0,0,0},
};
// this will only happen if I forget to update this function...
if (offsetof(projectile_t, filler) != sizeof(DefaultProjectile))
if (sizeof(projectile_t) != sizeof(DefaultProjectile))
G_GameExit("ERROR: C_InitProjectiles(): projectile_t mismatch!");
for (i=MAXTILES-1; i>=0; i--)

View file

@ -803,6 +803,11 @@ int32_t __fastcall Gv_GetVarX(register int32_t id)
default:
return ((aGameVars[id].val.lValue ^ -negateResult) + negateResult);
case GAMEVAR_PERPLAYER:
if ((unsigned)vm.g_p >= MAXPLAYERS)
{
id = vm.g_p;
goto badplayer;
}
return ((aGameVars[id].val.plValues[vm.g_p] ^ -negateResult) + negateResult);
case GAMEVAR_PERACTOR:
return ((aGameVars[id].val.plValues[vm.g_i] ^ -negateResult) + negateResult);