Merge branch 'ld414-invalid-sound-fix' into 'next'

Ld414 invalid sound fix

This fixes Linedef type 414 crashing the game if an invalid sound number was supplied to it (this can happen if you, say, scrambled THZ2's textures *cough*), whether or not the "Repeat Midtexture" flag is checked.

See merge request !196
This commit is contained in:
Monster Iestyn 2017-06-22 17:26:58 -04:00
commit 1efd2aa770

View file

@ -2437,73 +2437,81 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 414: // Play SFX case 414: // Play SFX
{ {
fixed_t sfxnum; INT32 sfxnum;
sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS;
if (line->tag != 0 && line->flags & ML_EFFECT5) if (sfxnum == sfx_None)
return; // Do nothing!
if (sfxnum < sfx_None || sfxnum >= NUMSFX)
{ {
sector_t *sec; CONS_Debug(DBG_GAMELOGIC, "Line type 414 Executor: sfx number %d is invalid!\n", sfxnum);
return;
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) }
if (line->tag != 0) // Do special stuff only if a non-zero linedef tag is set
{
if (line->flags & ML_EFFECT5) // Repeat Midtexture
{ {
sec = &sectors[secnum]; // Additionally play the sound from tagged sectors' soundorgs
S_StartSound(&sec->soundorg, sfxnum); sector_t *sec;
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
sec = &sectors[secnum];
S_StartSound(&sec->soundorg, sfxnum);
}
}
else if (mo) // A mobj must have triggered the executor
{
// Only trigger if mobj is touching the tag
ffloor_t *rover;
boolean foundit = false;
for(rover = mo->subsector->sector->ffloors; rover; rover = rover->next)
{
if (rover->master->frontsector->tag != line->tag)
continue;
if (mo->z > P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector))
continue;
if (mo->z + mo->height < P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))
continue;
foundit = true;
}
if (mo->subsector->sector->tag == line->tag)
foundit = true;
if (!foundit)
return;
} }
} }
else if (line->tag != 0 && mo)
if (line->flags & ML_NOCLIMB)
{ {
// Only trigger if mobj is touching the tag // play the sound from nowhere, but only if display player triggered it
ffloor_t *rover; if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer]))
boolean foundit = false;
for(rover = mo->subsector->sector->ffloors; rover; rover = rover->next)
{
if (rover->master->frontsector->tag != line->tag)
continue;
if (mo->z > P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector))
continue;
if (mo->z + mo->height < P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))
continue;
foundit = true;
}
if (mo->subsector->sector->tag == line->tag)
foundit = true;
if (!foundit)
return;
}
if (sfxnum < NUMSFX && sfxnum > sfx_None)
{
if (line->flags & ML_NOCLIMB)
{
// play the sound from nowhere, but only if display player triggered it
if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer]))
S_StartSound(NULL, sfxnum);
}
else if (line->flags & ML_EFFECT4)
{
// play the sound from nowhere
S_StartSound(NULL, sfxnum); S_StartSound(NULL, sfxnum);
} }
else if (line->flags & ML_BLOCKMONSTERS) else if (line->flags & ML_EFFECT4)
{ {
// play the sound from calling sector's soundorg // play the sound from nowhere
if (callsec) S_StartSound(NULL, sfxnum);
S_StartSound(&callsec->soundorg, sfxnum); }
else if (mo) else if (line->flags & ML_BLOCKMONSTERS)
S_StartSound(&mo->subsector->sector->soundorg, sfxnum); {
} // play the sound from calling sector's soundorg
if (callsec)
S_StartSound(&callsec->soundorg, sfxnum);
else if (mo) else if (mo)
{ S_StartSound(&mo->subsector->sector->soundorg, sfxnum);
// play the sound from mobj that triggered it }
S_StartSound(mo, sfxnum); else if (mo)
} {
// play the sound from mobj that triggered it
S_StartSound(mo, sfxnum);
} }
} }
break; break;
@ -3476,7 +3484,7 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar
// //
// Is player standing on the sector's "ground"? // Is player standing on the sector's "ground"?
// //
static inline boolean P_MobjReadyToTrigger(mobj_t *mo, sector_t *sec) static boolean P_MobjReadyToTrigger(mobj_t *mo, sector_t *sec)
{ {
if (mo->eflags & MFE_VERTICALFLIP) if (mo->eflags & MFE_VERTICALFLIP)
return (mo->z+mo->height == P_GetSpecialTopZ(mo, sec, sec) && sec->flags & SF_FLIPSPECIAL_CEILING); return (mo->z+mo->height == P_GetSpecialTopZ(mo, sec, sec) && sec->flags & SF_FLIPSPECIAL_CEILING);