Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blood: Use VIEWPOS enum and other various tweaks #780

Merged
merged 11 commits into from
Feb 17, 2024
24 changes: 12 additions & 12 deletions source/blood/src/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4058,7 +4058,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite)
case kDudeBurningZombieAxe:
case kDudeBurningZombieButcher:
// This does not make sense
pXSprite->burnTime = ClipLow(pXSprite->burnTime-4, 0);
pXSprite->burnTime = ClipLow(pXSprite->burnTime-kTicsPerFrame, 0);
actDamageSprite(actOwnerIdToSpriteId(pXSprite->burnSource), pSprite, kDamageBurn, 8);
break;
}
Expand Down Expand Up @@ -5338,7 +5338,7 @@ void actProcessSprites(void)

if (pXSprite->burnTime > 0)
{
pXSprite->burnTime = ClipLow(pXSprite->burnTime-4,0);
pXSprite->burnTime = ClipLow(pXSprite->burnTime-kTicsPerFrame,0);
actDamageSprite(actOwnerIdToSpriteId(pXSprite->burnSource), pSprite, kDamageBurn, 8);
}

Expand Down Expand Up @@ -5716,14 +5716,14 @@ void actProcessSprites(void)
// do not remove explosion.
// can be useful when designer wants put explosion
// generator in map manually via sprite statnum 2.
pXSprite->data1 = ClipLow(pXSprite->data1 - 4, 0);
pXSprite->data2 = ClipLow(pXSprite->data2 - 4, 0);
pXSprite->data3 = ClipLow(pXSprite->data3 - 4, 0);
pXSprite->data1 = ClipLow(pXSprite->data1 - kTicsPerFrame, 0);
pXSprite->data2 = ClipLow(pXSprite->data2 - kTicsPerFrame, 0);
pXSprite->data3 = ClipLow(pXSprite->data3 - kTicsPerFrame, 0);
}
#else
pXSprite->data1 = ClipLow(pXSprite->data1 - 4, 0);
pXSprite->data2 = ClipLow(pXSprite->data2 - 4, 0);
pXSprite->data3 = ClipLow(pXSprite->data3 - 4, 0);
pXSprite->data1 = ClipLow(pXSprite->data1 - kTicsPerFrame, 0);
pXSprite->data2 = ClipLow(pXSprite->data2 - kTicsPerFrame, 0);
pXSprite->data3 = ClipLow(pXSprite->data3 - kTicsPerFrame, 0);
#endif

if (pXSprite->data1 == 0 && pXSprite->data2 == 0 && pXSprite->data3 == 0 && seqGetStatus(3, nXSprite) < 0)
Expand All @@ -5742,7 +5742,7 @@ void actProcessSprites(void)
XSPRITE *pXSprite = &xsprite[nXSprite];
switch (pSprite->type) {
case kTrapSawCircular:
pXSprite->data2 = ClipLow(pXSprite->data2-4, 0);
pXSprite->data2 = ClipLow(pXSprite->data2-kTicsPerFrame, 0);
break;
case kTrapFlame:
if (pXSprite->state && seqGetStatus(3, nXSprite) < 0) {
Expand Down Expand Up @@ -5799,7 +5799,7 @@ void actProcessSprites(void)
actDamageSprite(actOwnerIdToSpriteId(pXSprite->burnSource), pSprite, kDamageBurn, 8);
break;
default:
pXSprite->burnTime = ClipLow(pXSprite->burnTime-4, 0);
pXSprite->burnTime = ClipLow(pXSprite->burnTime-kTicsPerFrame, 0);
actDamageSprite(actOwnerIdToSpriteId(pXSprite->burnSource), pSprite, kDamageBurn, 8);
break;
}
Expand Down Expand Up @@ -5845,7 +5845,7 @@ void actProcessSprites(void)
if (bDivingSuit || pPlayer->godMode)
pPlayer->underwaterTime = 1200;
else
pPlayer->underwaterTime = ClipLow(pPlayer->underwaterTime-4, 0);
pPlayer->underwaterTime = ClipLow(pPlayer->underwaterTime-kTicsPerFrame, 0);
if (pPlayer->underwaterTime < 1080 && packCheckItem(pPlayer, kPackDivingSuit) && !bDivingSuit)
packUseItem(pPlayer, kPackDivingSuit);
if (!pPlayer->underwaterTime)
Expand All @@ -5858,7 +5858,7 @@ void actProcessSprites(void)
pPlayer->chokeEffect = 0;
if (xvel[nSprite] || yvel[nSprite])
sfxPlay3DSound(pSprite, 709, 100, 2);
pPlayer->bubbleTime = ClipLow(pPlayer->bubbleTime-4, 0);
pPlayer->bubbleTime = ClipLow(pPlayer->bubbleTime-kTicsPerFrame, 0);
}
else if (gGameOptions.nGameType == kGameTypeSinglePlayer)
{
Expand Down
2 changes: 1 addition & 1 deletion source/blood/src/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ void aiProcessDudes(void)

int nXSprite = pSprite->extra;
XSPRITE *pXSprite = &xsprite[nXSprite];
pXSprite->stateTimer = ClipLow(pXSprite->stateTimer-4, 0);
pXSprite->stateTimer = ClipLow(pXSprite->stateTimer-kTicsPerFrame, 0);

switch (pSprite->type)
{
Expand Down
2 changes: 1 addition & 1 deletion source/blood/src/callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void fxZombieBloodSpurt(int nSprite) // 5
if (pXSprite->data1 > 0)
{
evPost(nSprite, 3, 4, kCallbackFXZombieSpurt);
pXSprite->data1 -= 4;
pXSprite->data1 -= kTicsPerFrame;
}
else if (pXSprite->data2 > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion source/blood/src/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern uint8_t gModernMap;



// by NoOne: functions to quckly check range of specifical arrays
// by NoOne: functions to quickly check range of specific arrays
inline bool xspriRangeIsFine(int nXindex) {
return (nXindex > 0 && nXindex < kMaxXSprites);
}
Expand Down
2 changes: 1 addition & 1 deletion source/blood/src/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ void CDemo::Playback(void)
}
}
}
gNetFifoClock += 4;
gNetFifoClock += kTicsPerFrame;
if (!gQuitGame)
ProcessFrame();
ready2send = 0;
Expand Down
4 changes: 2 additions & 2 deletions source/blood/src/mirrors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int
if (viewPlayer >= 0)
{
bakCstat = gPlayer[viewPlayer].pSprite->cstat;
if (gViewPos == 0)
if (gViewPos == VIEWPOS_0)
{
gPlayer[viewPlayer].pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
}
Expand Down Expand Up @@ -460,7 +460,7 @@ void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz, int smooth, int
if (viewPlayer >= 0)
{
bakCstat = gPlayer[viewPlayer].pSprite->cstat;
if (gViewPos == 0)
if (gViewPos == VIEWPOS_0)
{
gPlayer[viewPlayer].pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
}
Expand Down
2 changes: 1 addition & 1 deletion source/blood/src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ void netSendEmptyPackets(void)
{
if (nClock <= totalclock)
{
nClock = totalclock+4;
nClock = totalclock+kTicsPerFrame;
netSendPacketAll(packet, pPacket-packet);
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/blood/src/nnexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5998,7 +5998,7 @@ void playerQavSceneProcess(PLAYER* pPlayer, QAVSCENE* pQavScene) {
} else {

playerQavScenePlay(pPlayer);
pPlayer->weaponTimer = ClipLow(pPlayer->weaponTimer -= 4, 0);
pPlayer->weaponTimer = ClipLow(pPlayer->weaponTimer -= kTicsPerFrame, 0);

}
} else {
Expand Down Expand Up @@ -6060,7 +6060,7 @@ void playerQavScenePlay(PLAYER* pPlayer) {
QAV* pQAV = pQavScene->qavResrc;
pQAV->nSprite = pPlayer->pSprite->index;
int nTicks = pQAV->at10 - pPlayer->weaponTimer;
pQAV->Play(nTicks - 4, nTicks, pPlayer->qavCallback, pPlayer);
pQAV->Play(nTicks - kTicsPerFrame, nTicks, pPlayer->qavCallback, pPlayer);
}
}

Expand Down
26 changes: 13 additions & 13 deletions source/blood/src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ struct DAMAGEINFO {
int at10[3];
};

DAMAGEINFO damageInfo[7] = {
DAMAGEINFO damageInfo[kDamageMax] = {
{ -1, 731, 732, 733, 710, 710, 710 },
{ 1, 742, 743, 744, 711, 711, 711 },
{ 0, 731, 732, 733, 712, 712, 712 },
Expand Down Expand Up @@ -393,15 +393,15 @@ void powerupSetState(PLAYER *pPlayer, int nPowerUp, char bState)

void powerupProcess(PLAYER *pPlayer)
{
pPlayer->packItemTime = ClipLow(pPlayer->packItemTime-4, 0);
pPlayer->packItemTime = ClipLow(pPlayer->packItemTime-kTicsPerFrame, 0);
for (int i = kMaxPowerUps-1; i >= 0; i--)
{
int nPack = powerupToPackItem(i);
if (nPack >= 0)
{
if (pPlayer->packSlots[nPack].isActive)
{
pPlayer->pwUpTime[i] = ClipLow(pPlayer->pwUpTime[i]-4, 0);
pPlayer->pwUpTime[i] = ClipLow(pPlayer->pwUpTime[i]-kTicsPerFrame, 0);
if (pPlayer->pwUpTime[i])
pPlayer->packSlots[nPack].curAmount = (100*pPlayer->pwUpTime[i])/gPowerUpInfo[i].bonusTime;
else
Expand All @@ -414,7 +414,7 @@ void powerupProcess(PLAYER *pPlayer)
}
else if (pPlayer->pwUpTime[i] > 0)
{
pPlayer->pwUpTime[i] = ClipLow(pPlayer->pwUpTime[i]-4, 0);
pPlayer->pwUpTime[i] = ClipLow(pPlayer->pwUpTime[i]-kTicsPerFrame, 0);
if (!pPlayer->pwUpTime[i])
powerupDeactivate(pPlayer, i);
}
Expand Down Expand Up @@ -673,7 +673,7 @@ void playerStart(int nPlayer, int bNewLevel)
ZONE* pStartZone = NULL;

// normal start position
if (gGameOptions.nGameType <= 1)
if (gGameOptions.nGameType <= kGameTypeCoop)
pStartZone = &gStartZone[nPlayer];

#ifdef NOONE_EXTENSIONS
Expand Down Expand Up @@ -1608,7 +1608,7 @@ void ProcessInput(PLAYER *pPlayer)
}
}
if (pPlayer->handTime > 0)
pPlayer->handTime = ClipLow(pPlayer->handTime-4*(6-gGameOptions.nDifficulty), 0);
pPlayer->handTime = ClipLow(pPlayer->handTime-kTicsPerFrame*(6-gGameOptions.nDifficulty), 0);
if (pPlayer->handTime <= 0 && pPlayer->hand)
{
spritetype *pSprite2 = actSpawnDude(pPlayer->pSprite, kDudeHand, pPlayer->pSprite->clipdist<<1, 0);
Expand Down Expand Up @@ -1812,7 +1812,7 @@ void playerProcess(PLAYER *pPlayer)
else
pPlayer->zWeaponVel += mulscale16(dz<<8, 0xc00);
pPlayer->zWeapon += pPlayer->zWeaponVel>>8;
pPlayer->bobPhase = ClipLow(pPlayer->bobPhase-4, 0);
pPlayer->bobPhase = ClipLow(pPlayer->bobPhase-kTicsPerFrame, 0);
nSpeed >>= 16;
if (pPlayer->posture == kPostureSwim)
{
Expand Down Expand Up @@ -1846,12 +1846,12 @@ void playerProcess(PLAYER *pPlayer)
pPlayer->swayWidth = mulscale30(pPosture->swayH*pPlayer->bobPhase, Sin(pPlayer->swayAmp-0x155));
}
pPlayer->flickerEffect = 0;
pPlayer->quakeEffect = ClipLow(pPlayer->quakeEffect-4, 0);
pPlayer->tiltEffect = ClipLow(pPlayer->tiltEffect-4, 0);
pPlayer->visibility = ClipLow(pPlayer->visibility-4, 0);
pPlayer->painEffect = ClipLow(pPlayer->painEffect-4, 0);
pPlayer->blindEffect = ClipLow(pPlayer->blindEffect-4, 0);
pPlayer->pickupEffect = ClipLow(pPlayer->pickupEffect-4, 0);
pPlayer->quakeEffect = ClipLow(pPlayer->quakeEffect-kTicsPerFrame, 0);
pPlayer->tiltEffect = ClipLow(pPlayer->tiltEffect-kTicsPerFrame, 0);
pPlayer->visibility = ClipLow(pPlayer->visibility-kTicsPerFrame, 0);
pPlayer->painEffect = ClipLow(pPlayer->painEffect-kTicsPerFrame, 0);
pPlayer->blindEffect = ClipLow(pPlayer->blindEffect-kTicsPerFrame, 0);
pPlayer->pickupEffect = ClipLow(pPlayer->pickupEffect-kTicsPerFrame, 0);
if (pPlayer == gMe && gMe->pXSprite->health == 0)
pPlayer->hand = 0;
if (!pXSprite->health)
Expand Down
34 changes: 19 additions & 15 deletions source/blood/src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void fakePlayerProcess(PLAYER *pPlayer, GINPUT *pInput)

predict.at34 = predict.at40 - predict.at38 - (12<<8);

predict.at0 = ClipLow(predict.at0-4, 0);
predict.at0 = ClipLow(predict.at0-kTicsPerFrame, 0);

nSpeed >>= 16;
if (predict.at48 == 1)
Expand Down Expand Up @@ -1412,20 +1412,24 @@ void viewDrawMapTitle(void)

void viewDrawAimedPlayerName(void)
{
if (!gShowPlayerNames || (gView->aim.dx == 0 && gView->aim.dy == 0))
if (!gShowPlayerNames || (gGameOptions.nGameType == kGameTypeSinglePlayer) || !gView->pSprite)
return;
const int nX = Cos(gView->pSprite->ang)>>16;
const int nY = Sin(gView->pSprite->ang)>>16;
if (nX == 0 && nY == 0)
return;
const int nZ = gView->slope;

int hit = HitScan(gView->pSprite, gView->zView, gView->aim.dx, gView->aim.dy, gView->aim.dz, CLIPMASK0, 512);
const int hit = HitScan(gView->pSprite, gView->zView, nX, nY, nZ, CLIPMASK0, 512);
if (hit == 3)
{
spritetype* pSprite = &sprite[gHitInfo.hitsprite];
if (IsPlayerSprite(pSprite))
{
char nPlayer = pSprite->type-kDudePlayer1;
char* szName = gProfile[nPlayer].name;
int nPalette = (gPlayer[nPlayer].teamId&3)+11;
viewDrawText(4, szName, 160, 125, -128, nPalette, 1, 1);
}
if (!IsPlayerSprite(pSprite))
return;
char nPlayer = pSprite->type-kDudePlayer1;
char *szName = gProfile[nPlayer].name;
int nPalette = (gPlayer[nPlayer].teamId&3)+11;
viewDrawText(4, szName, 160, 125, -128, nPalette, 1, 1);
}
}

Expand Down Expand Up @@ -3433,7 +3437,7 @@ void viewDrawScreen(void)
lastUpdate = totalclock;
if (!gPaused && (!CGameMenuMgr::m_bActive || gGameOptions.nGameType != kGameTypeSinglePlayer))
{
gInterpolate = ((totalclock-gNetFifoClock)+4).toScale16()/4;
gInterpolate = ((totalclock-gNetFifoClock)+kTicsPerFrame).toScale16()/kTicsPerFrame;
}
if (gInterpolate < 0 || gInterpolate > 65536)
{
Expand Down Expand Up @@ -3525,7 +3529,7 @@ void viewDrawScreen(void)
v4c += shakeBobX;
v48 += shakeBobY;
q16horiz += fix16_from_int(mulscale30(0x40000000-Cos(gView->tiltEffect<<2), 30));
if (gViewPos == 0)
if (gViewPos == VIEWPOS_0)
{
if (gViewHBobbing)
{
Expand Down Expand Up @@ -3740,7 +3744,7 @@ void viewDrawScreen(void)
fix16_t deliriumPitchI = gViewInterpolate ? interpolate(fix16_from_int(deliriumPitchO), fix16_from_int(deliriumPitch), gInterpolate) : fix16_from_int(deliriumPitch);
DrawMirrors(cX, cY, cZ, cA, q16horiz + fix16_from_int(defaultHoriz) + deliriumPitchI, gInterpolate, bLink && !VanillaMode() ? gViewIndex : -1); // only hide self sprite while traversing between sector
int bakCstat = gView->pSprite->cstat;
if (gViewPos == 0) // don't render self while in first person view
if (gViewPos == VIEWPOS_0) // don't render self while in first person view
{
gView->pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
}
Expand Down Expand Up @@ -3843,7 +3847,7 @@ void viewDrawScreen(void)
}
}
#endif
if (gViewPos == 0)
if (gViewPos == VIEWPOS_0)
{
if (gAimReticle)
{
Expand Down Expand Up @@ -3873,7 +3877,7 @@ void viewDrawScreen(void)


}
if (gViewPos == 0 && gView->pXSprite->burnTime > 60)
if (gViewPos == VIEWPOS_0 && gView->pXSprite->burnTime > 60)
{
viewBurnTime(gView->pXSprite->burnTime);
}
Expand Down
Loading
Loading