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
|
BEGIN_BLD_NS
|
||||||
|
|
||||||
enum { kMaxQavClients = 64 };
|
extern void (*qavClientCallback[])(int, void *);
|
||||||
static void (*qavClientCallback[kMaxQavClients])(int, void *);
|
|
||||||
static int nQavClients;
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
void DrawFrame(double x, double y, TILE_FRAME *pTile, int stat, int shade, int palnum, bool to3dview)
|
||||||
{
|
{
|
||||||
stat |= pTile->stat;
|
stat |= pTile->stat;
|
||||||
|
@ -147,8 +137,8 @@ void QAV::Play(int start, int end, int nCallback, void *pData)
|
||||||
if (pSound->sndRange > 0 && !VanillaMode())
|
if (pSound->sndRange > 0 && !VanillaMode())
|
||||||
sound += Random((pSound->sndRange == 1) ? 2 : pSound->sndRange);
|
sound += Random((pSound->sndRange == 1) ? 2 : pSound->sndRange);
|
||||||
|
|
||||||
if (nSprite == -1) PlaySound(sound);
|
if (nSprite == -1) sndStartSample(sound, -1, -1, 0);
|
||||||
else PlaySound3D(&sprite[nSprite], sound, 16+pSound->priority, 6);
|
else sfxPlay3DSound(&sprite[nSprite], sound, 16+pSound->priority, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFrame->nCallbackId > 0 && nCallback != -1) {
|
if (pFrame->nCallbackId > 0 && nCallback != -1) {
|
||||||
|
|
|
@ -87,14 +87,10 @@ struct QAV
|
||||||
void Play(int, int, int, void *);
|
void Play(int, int, int, void *);
|
||||||
void Preload(void);
|
void Preload(void);
|
||||||
void Precache(HitList &hits);
|
void Precache(HitList &hits);
|
||||||
|
|
||||||
void PlaySound(int nSound);
|
|
||||||
void PlaySound3D(spritetype *pSprite, int nSound, int a3, int a4);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
int qavRegisterClient(void(*pClient)(int, void *));
|
|
||||||
QAV* getQAV(int res_id);
|
QAV* getQAV(int res_id);
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
|
@ -85,51 +85,80 @@ void FireBeast(int nTrigger, PLAYER * pPlayer);
|
||||||
|
|
||||||
typedef void(*QAVTypeCast)(int, void *);
|
typedef void(*QAVTypeCast)(int, void *);
|
||||||
|
|
||||||
int nClientFirePitchfork = qavRegisterClient((QAVTypeCast)FirePitchfork);
|
void (*qavClientCallback[])(int, void*) =
|
||||||
int nClientFireSpray = qavRegisterClient((QAVTypeCast)FireSpray);
|
{
|
||||||
int nClientThrowCan = qavRegisterClient((QAVTypeCast)ThrowCan);
|
(QAVTypeCast)FirePitchfork,
|
||||||
int nClientDropCan = qavRegisterClient((QAVTypeCast)DropCan);
|
(QAVTypeCast)FireSpray,
|
||||||
int nClientExplodeCan = qavRegisterClient((QAVTypeCast)ExplodeCan);
|
(QAVTypeCast)ThrowCan,
|
||||||
int nClientThrowBundle = qavRegisterClient((QAVTypeCast)ThrowBundle);
|
(QAVTypeCast)DropCan,
|
||||||
int nClientDropBundle = qavRegisterClient((QAVTypeCast)DropBundle);
|
(QAVTypeCast)ExplodeCan,
|
||||||
int nClientExplodeBundle = qavRegisterClient((QAVTypeCast)ExplodeBundle);
|
(QAVTypeCast)ThrowBundle,
|
||||||
int nClientThrowProx = qavRegisterClient((QAVTypeCast)ThrowProx);
|
(QAVTypeCast)DropBundle,
|
||||||
int nClientDropProx = qavRegisterClient((QAVTypeCast)DropProx);
|
(QAVTypeCast)ExplodeBundle,
|
||||||
int nClientThrowRemote = qavRegisterClient((QAVTypeCast)ThrowRemote);
|
(QAVTypeCast)ThrowProx,
|
||||||
int nClientDropRemote = qavRegisterClient((QAVTypeCast)DropRemote);
|
(QAVTypeCast)DropProx,
|
||||||
int nClientFireRemote = qavRegisterClient((QAVTypeCast)FireRemote);
|
(QAVTypeCast)ThrowRemote,
|
||||||
int nClientFireShotgun = qavRegisterClient((QAVTypeCast)FireShotgun);
|
(QAVTypeCast)DropRemote,
|
||||||
int nClientEjectShell = qavRegisterClient((QAVTypeCast)EjectShell);
|
(QAVTypeCast)FireRemote,
|
||||||
int nClientFireTommy = qavRegisterClient((QAVTypeCast)FireTommy);
|
(QAVTypeCast)FireShotgun,
|
||||||
int nClientAltFireSpread2 = qavRegisterClient((QAVTypeCast)AltFireSpread2);
|
(QAVTypeCast)EjectShell,
|
||||||
int nClientFireSpread = qavRegisterClient((QAVTypeCast)FireSpread);
|
(QAVTypeCast)FireTommy,
|
||||||
int nClientAltFireSpread = qavRegisterClient((QAVTypeCast)AltFireSpread);
|
(QAVTypeCast)AltFireSpread2,
|
||||||
int nClientFireFlare = qavRegisterClient((QAVTypeCast)FireFlare);
|
(QAVTypeCast)FireSpread,
|
||||||
int nClientAltFireFlare = qavRegisterClient((QAVTypeCast)AltFireFlare);
|
(QAVTypeCast)AltFireSpread,
|
||||||
int nClientFireVoodoo = qavRegisterClient((QAVTypeCast)FireVoodoo);
|
(QAVTypeCast)FireFlare,
|
||||||
int nClientAltFireVoodoo = qavRegisterClient((QAVTypeCast)AltFireVoodoo);
|
(QAVTypeCast)AltFireFlare,
|
||||||
int nClientFireTesla = qavRegisterClient((QAVTypeCast)FireTesla);
|
(QAVTypeCast)FireVoodoo,
|
||||||
int nClientAltFireTesla = qavRegisterClient((QAVTypeCast)AltFireTesla);
|
(QAVTypeCast)AltFireVoodoo,
|
||||||
int nClientFireNapalm = qavRegisterClient((QAVTypeCast)FireNapalm);
|
(QAVTypeCast)FireTesla,
|
||||||
int nClientFireNapalm2 = qavRegisterClient((QAVTypeCast)FireNapalm2);
|
(QAVTypeCast)AltFireTesla,
|
||||||
int nClientFireLifeLeech = qavRegisterClient((QAVTypeCast)FireLifeLeech);
|
(QAVTypeCast)FireNapalm,
|
||||||
int nClientFireBeast = qavRegisterClient((QAVTypeCast)FireBeast);
|
(QAVTypeCast)FireNapalm2,
|
||||||
int nClientAltFireLifeLeech = qavRegisterClient((QAVTypeCast)AltFireLifeLeech);
|
(QAVTypeCast)FireLifeLeech,
|
||||||
int nClientDropVoodoo = qavRegisterClient((QAVTypeCast)DropVoodoo);
|
(QAVTypeCast)FireBeast,
|
||||||
int nClientAltFireNapalm = qavRegisterClient((QAVTypeCast)AltFireNapalm);
|
(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];
|
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)
|
char sub_4B1A4(PLAYER *pPlayer)
|
||||||
{
|
{
|
||||||
switch (pPlayer->curWeapon)
|
switch (pPlayer->curWeapon)
|
||||||
|
|
Loading…
Reference in a new issue