Skip to content

Commit

Permalink
- Exhumed: fixed surace collisions of projectiles.
Browse files Browse the repository at this point in the history
There was some commented out undefined behavior here, we need to properly define this case.
  • Loading branch information
coelckers committed Jan 24, 2022
1 parent 30adac6 commit 0e89bff
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions source/games/exhumed/src/bullet.cpp
Expand Up @@ -379,39 +379,23 @@ int MoveBullet(int nBullet)
z2 = pActor->spr.pos.Z;
pHitSect = pActor->sector();

#if 0
// Original code. This was producing some beautiful undefined behavior in the first case because the index can be anything, not just a wall.
if (coll.exbits)
{
hitwall = coll & 0x3FFF;
goto HITWALL;
}
else
{
switch (coll & 0xc000)
{
case 0x8000:
hitwall = coll & 0x3FFF;
goto HITWALL;
case 0xc000:
hitsprite = coll & 0x3FFF;
goto HITSPRITE;
}
}
#else
switch (coll.type)
{
case kHitWall:
pHitWall = coll.hitWall;
goto HITWALL;
case 0xc000:
case kHitSprite:
if (!coll.exbits)
{
hitactor = coll.actor();
goto HITSPRITE;
}
default:
if (coll.exbits)
goto HITSECT;
break;

}
#endif
}

nVal = coll.type || coll.exbits? 1:0;
Expand Down Expand Up @@ -503,6 +487,7 @@ int MoveBullet(int nBullet)
}
}

HITSECT:
if (pHitSect != nullptr) // NOTE: hitsect can be -1. this check wasn't in original code. TODO: demo compatiblity?
{
if (hitactor == nullptr && pHitWall == nullptr)
Expand Down

0 comments on commit 0e89bff

Please sign in to comment.