- sanitized tileGetSurfType.

This commit is contained in:
Christoph Oelckers 2021-08-27 21:49:18 +02:00
parent 9221262dfc
commit 5b057415da
6 changed files with 26 additions and 20 deletions

View file

@ -4210,7 +4210,7 @@ static void actTouchFloor(DBloodActor* actor, int nSector)
actDamageSprite(actor, actor, nDamageType, scale(4, nDamage, 120) << 4);
}
if (tileGetSurfType(nSector + 0x4000) == kSurfLava)
if (tileGetSurfType(sector[nSector].floorpicnum) == kSurfLava)
{
actDamageSprite(actor, actor, kDamageBurn, 16);
sfxPlay3DSound(actor, 352, 5, 2);
@ -5244,7 +5244,7 @@ void MoveDude(DBloodActor* actor)
else
pSprite->flags |= 4;
switch (tileGetSurfType(floorColl.legacyVal))
switch (tileGetSurfType(floorColl))
{
case kSurfWater:
gFX.fxSpawnActor(FX_9, pSprite->sectnum, pSprite->x, pSprite->y, floorZ, 0);
@ -7341,7 +7341,7 @@ void MakeSplash(DBloodActor* actor)
pSprite->flags &= ~2;
int nXSprite = pSprite->extra;
pSprite->z -= 4 << 8;
int nSurface = tileGetSurfType(actor->hit().florhit.legacyVal);
int nSurface = tileGetSurfType(actor->hit().florhit);
switch (pSprite->type)
{
case kThingDripWater:

View file

@ -107,6 +107,8 @@ extern int nPrecacheCount;
void tilePrecacheTile(int nTile, int nType, int palette);
char tileGetSurfType(int hit);
struct Collision;
int tileGetSurfType(int hit);
int tileGetSurfType(Collision& hit);
END_BLD_NS

View file

@ -1556,7 +1556,7 @@ int getSpriteMassBySize(DBloodActor* actor)
int yrepeat = pSprite->yrepeat;
// take surface type into account
switch (tileGetSurfType(pSprite->index + 0xc000))
switch (tileGetSurfType(pSprite->picnum))
{
case 1: massDiv = 16; break; // stone
case 2: massDiv = 18; break; // metal
@ -1855,7 +1855,7 @@ void debrisMove(int listIndex)
moveHit = floorColl;
DBloodActor* pFX = NULL, *pFX2 = NULL;
switch (tileGetSurfType(floorColl.legacyVal)) {
switch (tileGetSurfType(floorColl)) {
case kSurfLava:
if ((pFX = gFX.fxSpawnActor(FX_10, pSprite->sectnum, pSprite->x, pSprite->y, floorZ, 0)) == NULL) break;
for (i = 0; i < 7; i++) {

View file

@ -2155,7 +2155,7 @@ void playerLandingSound(PLAYER *pPlayer)
{
if (!gGameOptions.bFriendlyFire && pHit->florhit.type == kHitSprite && IsTargetTeammate(pPlayer, &pHit->florhit.actor->s()))
return;
char nSurf = tileGetSurfType(pHit->florhit.legacyVal);
int nSurf = tileGetSurfType(pHit->florhit);
if (nSurf)
sfxPlay3DSound(pSprite, surfaceSound[nSurf], -1, 0);
}

View file

@ -369,7 +369,8 @@ void SEQINST::Update()
if (!VanillaMode() && pSequence->frames[frameIndex].surfaceSound && zvel[pSprite->index] == 0 && xvel[pSprite->index] != 0) {
if (gUpperLink[pSprite->sectnum] >= 0) break; // don't play surface sound for stacked sectors
int surf = tileGetSurfType(pSprite->sectnum + 0x4000); if (!surf) break;
int surf = tileGetSurfType(sector[pSprite->sectnum].floorpicnum);
if (!surf) break;
static int surfSfxMove[15][4] = {
/* {snd1, snd2, gameVolume, myVolume} */
{800,801,80,25},

View file

@ -71,21 +71,24 @@ void GameInterface::LoadGameTextures()
}
}
char tileGetSurfType(int hit)
int tileGetSurfType(int hit)
{
int n = hit & 0x3fff;
switch (hit&0xc000)
return surfType[hit];
}
int tileGetSurfType(Collision& hit)
{
switch (hit.type)
{
case 0x4000:
return surfType[sector[n].floorpicnum];
case 0x6000:
return surfType[sector[n].ceilingpicnum];
case 0x8000:
return surfType[wall[n].picnum];
case 0xc000:
return surfType[sprite[n].picnum];
default:
return 0;
case kHitSector:
return surfType[sector[hit.index].floorpicnum];
case kHitWall:
return surfType[wall[hit.index].picnum];
case kHitSprite:
return surfType[hit.actor->s().picnum];
}
return 0;
}
void GameInterface::SetTileProps(int tile, int surf, int vox, int shade)