- Blood: Remove weaponQAV[] array entirely.

This commit is contained in:
Mitchell Richters 2021-08-23 10:49:47 +10:00
parent 5bfdd74844
commit 6975997ae3

View file

@ -140,8 +140,6 @@ enum
nClientAltFireNapalm, nClientAltFireNapalm,
}; };
static QAV *weaponQAV[kQAVEnd];
static bool sub_4B1A4(PLAYER *pPlayer) static bool sub_4B1A4(PLAYER *pPlayer)
{ {
switch (pPlayer->curWeapon) switch (pPlayer->curWeapon)
@ -228,10 +226,10 @@ void WeaponInit(void)
{ {
for (int i = 0; i < kQAVEnd; i++) for (int i = 0; i < kQAVEnd; i++)
{ {
weaponQAV[i] = getQAV(i); auto pQAV = getQAV(i);
if (!weaponQAV[i]) if (!pQAV)
I_Error("Could not load QAV %d\n", i); I_Error("Could not load QAV %d\n", i);
weaponQAV[i]->nSprite = -1; pQAV->nSprite = -1;
} }
} }
@ -239,8 +237,9 @@ void WeaponPrecache()
{ {
for (int i = 0; i < kQAVEnd; i++) for (int i = 0; i < kQAVEnd; i++)
{ {
if (weaponQAV[i]) auto pQAV = getQAV(i);
weaponQAV[i]->Precache(); if (pQAV)
pQAV->Precache();
} }
} }
@ -249,7 +248,7 @@ void WeaponDraw(PLAYER *pPlayer, int shade, double xpos, double ypos, int palnum
assert(pPlayer != NULL); assert(pPlayer != NULL);
if (pPlayer->weaponQav == kQAVNone) if (pPlayer->weaponQav == kQAVNone)
return; return;
QAV * pQAV = weaponQAV[pPlayer->weaponQav]; auto pQAV = getQAV(pPlayer->weaponQav);
int duration; int duration;
double smoothratio; double smoothratio;
@ -272,7 +271,7 @@ void WeaponPlay(PLAYER *pPlayer)
assert(pPlayer != NULL); assert(pPlayer != NULL);
if (pPlayer->weaponQav == kQAVNone) if (pPlayer->weaponQav == kQAVNone)
return; return;
QAV *pQAV = weaponQAV[pPlayer->weaponQav]; auto pQAV = getQAV(pPlayer->weaponQav);
pQAV->nSprite = pPlayer->pSprite->index; pQAV->nSprite = pPlayer->pSprite->index;
int nTicks = pQAV->duration - pPlayer->weaponTimer; int nTicks = pQAV->duration - pPlayer->weaponTimer;
pQAV->Play(nTicks-4, nTicks, pPlayer->qavCallback, pPlayer); pQAV->Play(nTicks-4, nTicks, pPlayer->qavCallback, pPlayer);
@ -281,13 +280,14 @@ void WeaponPlay(PLAYER *pPlayer)
static void StartQAV(PLAYER *pPlayer, int nWeaponQAV, int callback = -1, bool looped = false) static void StartQAV(PLAYER *pPlayer, int nWeaponQAV, int callback = -1, bool looped = false)
{ {
assert(nWeaponQAV < kQAVEnd); assert(nWeaponQAV < kQAVEnd);
auto pQAV = getQAV(nWeaponQAV);
pPlayer->weaponQav = nWeaponQAV; pPlayer->weaponQav = nWeaponQAV;
pPlayer->weaponTimer = weaponQAV[nWeaponQAV]->duration; pPlayer->weaponTimer = pQAV->duration;
pPlayer->qavCallback = callback; pPlayer->qavCallback = callback;
pPlayer->qavLoop = looped; pPlayer->qavLoop = looped;
pPlayer->qavLastTick = I_GetTime(weaponQAV[nWeaponQAV]->ticrate); pPlayer->qavLastTick = I_GetTime(pQAV->ticrate);
pPlayer->qavTimer = weaponQAV[nWeaponQAV]->duration; pPlayer->qavTimer = pQAV->duration;
//weaponQAV[nWeaponQAV]->Preload(); //pQAV->Preload();
WeaponPlay(pPlayer); WeaponPlay(pPlayer);
pPlayer->weaponTimer -= 4; pPlayer->weaponTimer -= 4;
} }
@ -2029,10 +2029,11 @@ void WeaponProcess(PLAYER *pPlayer) {
{ {
if (bShoot && CheckAmmo(pPlayer, pPlayer->weaponAmmo, 1)) if (bShoot && CheckAmmo(pPlayer, pPlayer->weaponAmmo, 1))
{ {
auto pQAV = getQAV(pPlayer->weaponQav);
while (pPlayer->weaponTimer <= 0) while (pPlayer->weaponTimer <= 0)
{ {
pPlayer->weaponTimer += weaponQAV[pPlayer->weaponQav]->duration; pPlayer->weaponTimer += pQAV->duration;
pPlayer->qavTimer += weaponQAV[pPlayer->weaponQav]->duration; pPlayer->qavTimer += pQAV->duration;
} }
} }
else else