mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 13:00:43 +00:00
- use static init for QAV callbacks.
runtime init order is undefined, so this is not safe.
This commit is contained in:
parent
9bd02634d9
commit
a319687373
3 changed files with 74 additions and 59 deletions
|
@ -33,19 +33,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
enum { kMaxQavClients = 64 };
|
||||
static void (*qavClientCallback[kMaxQavClients])(int, void *);
|
||||
static int nQavClients;
|
||||
extern void (*qavClientCallback[])(int, void *);
|
||||
|
||||
|
||||
int qavRegisterClient(void(*pClient)(int, void *))
|
||||
{
|
||||
assert(nQavClients < kMaxQavClients);
|
||||
qavClientCallback[nQavClients] = pClient;
|
||||
|
||||
return nQavClients++;
|
||||
}
|
||||
|
||||
void DrawFrame(double x, double y, TILE_FRAME *pTile, int stat, int shade, int palnum, bool to3dview)
|
||||
{
|
||||
stat |= pTile->stat;
|
||||
|
@ -147,8 +137,8 @@ void QAV::Play(int start, int end, int nCallback, void *pData)
|
|||
if (pSound->sndRange > 0 && !VanillaMode())
|
||||
sound += Random((pSound->sndRange == 1) ? 2 : pSound->sndRange);
|
||||
|
||||
if (nSprite == -1) PlaySound(sound);
|
||||
else PlaySound3D(&sprite[nSprite], sound, 16+pSound->priority, 6);
|
||||
if (nSprite == -1) sndStartSample(sound, -1, -1, 0);
|
||||
else sfxPlay3DSound(&sprite[nSprite], sound, 16+pSound->priority, 6);
|
||||
}
|
||||
|
||||
if (pFrame->nCallbackId > 0 && nCallback != -1) {
|
||||
|
|
|
@ -87,14 +87,10 @@ struct QAV
|
|||
void Play(int, int, int, void *);
|
||||
void Preload(void);
|
||||
void Precache(HitList &hits);
|
||||
|
||||
void PlaySound(int nSound);
|
||||
void PlaySound3D(spritetype *pSprite, int nSound, int a3, int a4);
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
int qavRegisterClient(void(*pClient)(int, void *));
|
||||
QAV* getQAV(int res_id);
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -85,51 +85,80 @@ void FireBeast(int nTrigger, PLAYER * pPlayer);
|
|||
|
||||
typedef void(*QAVTypeCast)(int, void *);
|
||||
|
||||
int nClientFirePitchfork = qavRegisterClient((QAVTypeCast)FirePitchfork);
|
||||
int nClientFireSpray = qavRegisterClient((QAVTypeCast)FireSpray);
|
||||
int nClientThrowCan = qavRegisterClient((QAVTypeCast)ThrowCan);
|
||||
int nClientDropCan = qavRegisterClient((QAVTypeCast)DropCan);
|
||||
int nClientExplodeCan = qavRegisterClient((QAVTypeCast)ExplodeCan);
|
||||
int nClientThrowBundle = qavRegisterClient((QAVTypeCast)ThrowBundle);
|
||||
int nClientDropBundle = qavRegisterClient((QAVTypeCast)DropBundle);
|
||||
int nClientExplodeBundle = qavRegisterClient((QAVTypeCast)ExplodeBundle);
|
||||
int nClientThrowProx = qavRegisterClient((QAVTypeCast)ThrowProx);
|
||||
int nClientDropProx = qavRegisterClient((QAVTypeCast)DropProx);
|
||||
int nClientThrowRemote = qavRegisterClient((QAVTypeCast)ThrowRemote);
|
||||
int nClientDropRemote = qavRegisterClient((QAVTypeCast)DropRemote);
|
||||
int nClientFireRemote = qavRegisterClient((QAVTypeCast)FireRemote);
|
||||
int nClientFireShotgun = qavRegisterClient((QAVTypeCast)FireShotgun);
|
||||
int nClientEjectShell = qavRegisterClient((QAVTypeCast)EjectShell);
|
||||
int nClientFireTommy = qavRegisterClient((QAVTypeCast)FireTommy);
|
||||
int nClientAltFireSpread2 = qavRegisterClient((QAVTypeCast)AltFireSpread2);
|
||||
int nClientFireSpread = qavRegisterClient((QAVTypeCast)FireSpread);
|
||||
int nClientAltFireSpread = qavRegisterClient((QAVTypeCast)AltFireSpread);
|
||||
int nClientFireFlare = qavRegisterClient((QAVTypeCast)FireFlare);
|
||||
int nClientAltFireFlare = qavRegisterClient((QAVTypeCast)AltFireFlare);
|
||||
int nClientFireVoodoo = qavRegisterClient((QAVTypeCast)FireVoodoo);
|
||||
int nClientAltFireVoodoo = qavRegisterClient((QAVTypeCast)AltFireVoodoo);
|
||||
int nClientFireTesla = qavRegisterClient((QAVTypeCast)FireTesla);
|
||||
int nClientAltFireTesla = qavRegisterClient((QAVTypeCast)AltFireTesla);
|
||||
int nClientFireNapalm = qavRegisterClient((QAVTypeCast)FireNapalm);
|
||||
int nClientFireNapalm2 = qavRegisterClient((QAVTypeCast)FireNapalm2);
|
||||
int nClientFireLifeLeech = qavRegisterClient((QAVTypeCast)FireLifeLeech);
|
||||
int nClientFireBeast = qavRegisterClient((QAVTypeCast)FireBeast);
|
||||
int nClientAltFireLifeLeech = qavRegisterClient((QAVTypeCast)AltFireLifeLeech);
|
||||
int nClientDropVoodoo = qavRegisterClient((QAVTypeCast)DropVoodoo);
|
||||
int nClientAltFireNapalm = qavRegisterClient((QAVTypeCast)AltFireNapalm);
|
||||
void (*qavClientCallback[])(int, void*) =
|
||||
{
|
||||
(QAVTypeCast)FirePitchfork,
|
||||
(QAVTypeCast)FireSpray,
|
||||
(QAVTypeCast)ThrowCan,
|
||||
(QAVTypeCast)DropCan,
|
||||
(QAVTypeCast)ExplodeCan,
|
||||
(QAVTypeCast)ThrowBundle,
|
||||
(QAVTypeCast)DropBundle,
|
||||
(QAVTypeCast)ExplodeBundle,
|
||||
(QAVTypeCast)ThrowProx,
|
||||
(QAVTypeCast)DropProx,
|
||||
(QAVTypeCast)ThrowRemote,
|
||||
(QAVTypeCast)DropRemote,
|
||||
(QAVTypeCast)FireRemote,
|
||||
(QAVTypeCast)FireShotgun,
|
||||
(QAVTypeCast)EjectShell,
|
||||
(QAVTypeCast)FireTommy,
|
||||
(QAVTypeCast)AltFireSpread2,
|
||||
(QAVTypeCast)FireSpread,
|
||||
(QAVTypeCast)AltFireSpread,
|
||||
(QAVTypeCast)FireFlare,
|
||||
(QAVTypeCast)AltFireFlare,
|
||||
(QAVTypeCast)FireVoodoo,
|
||||
(QAVTypeCast)AltFireVoodoo,
|
||||
(QAVTypeCast)FireTesla,
|
||||
(QAVTypeCast)AltFireTesla,
|
||||
(QAVTypeCast)FireNapalm,
|
||||
(QAVTypeCast)FireNapalm2,
|
||||
(QAVTypeCast)FireLifeLeech,
|
||||
(QAVTypeCast)FireBeast,
|
||||
(QAVTypeCast)AltFireLifeLeech,
|
||||
(QAVTypeCast)DropVoodoo,
|
||||
(QAVTypeCast)AltFireNapalm,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
nClientFirePitchfork,
|
||||
nClientFireSpray,
|
||||
nClientThrowCan,
|
||||
nClientDropCan,
|
||||
nClientExplodeCan,
|
||||
nClientThrowBundle,
|
||||
nClientDropBundle,
|
||||
nClientExplodeBundle,
|
||||
nClientThrowProx,
|
||||
nClientDropProx,
|
||||
nClientThrowRemote,
|
||||
nClientDropRemote,
|
||||
nClientFireRemote,
|
||||
nClientFireShotgun,
|
||||
nClientEjectShell,
|
||||
nClientFireTommy,
|
||||
nClientAltFireSpread2,
|
||||
nClientFireSpread,
|
||||
nClientAltFireSpread,
|
||||
nClientFireFlare,
|
||||
nClientAltFireFlare,
|
||||
nClientFireVoodoo,
|
||||
nClientAltFireVoodoo,
|
||||
nClientFireTesla,
|
||||
nClientAltFireTesla,
|
||||
nClientFireNapalm,
|
||||
nClientFireNapalm2,
|
||||
nClientFireLifeLeech,
|
||||
nClientFireBeast,
|
||||
nClientAltFireLifeLeech,
|
||||
nClientDropVoodoo,
|
||||
nClientAltFireNapalm,
|
||||
};
|
||||
|
||||
QAV *weaponQAV[kQAVEnd];
|
||||
|
||||
void QAV::PlaySound(int nSound)
|
||||
{
|
||||
sndStartSample(nSound, -1, -1, 0);
|
||||
}
|
||||
|
||||
void QAV::PlaySound3D(spritetype *pSprite, int nSound, int a3, int a4)
|
||||
{
|
||||
sfxPlay3DSound(pSprite, nSound, a3, a4);
|
||||
}
|
||||
|
||||
char sub_4B1A4(PLAYER *pPlayer)
|
||||
{
|
||||
switch (pPlayer->curWeapon)
|
||||
|
|
Loading…
Reference in a new issue