mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 23:54:35 +00:00
- this should take care of the S_* interface.
This commit is contained in:
parent
7e8de9d1ba
commit
d13f12cc37
6 changed files with 34 additions and 32 deletions
|
@ -27,10 +27,6 @@ class FSoundID
|
||||||
public:
|
public:
|
||||||
FSoundID() = default;
|
FSoundID() = default;
|
||||||
|
|
||||||
static FSoundID byResId(int ndx)
|
|
||||||
{
|
|
||||||
return FSoundID(S_FindSoundByResID(ndx));
|
|
||||||
}
|
|
||||||
constexpr FSoundID(int id) : ID(id)
|
constexpr FSoundID(int id) : ID(id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,8 +208,8 @@ void A_StartSoundIfNotSame(AActor *self, int soundid, int checksoundid, int chan
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StartSoundIfNotSame, A_StartSoundIfNotSame)
|
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StartSoundIfNotSame, A_StartSoundIfNotSame)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
PARAM_SOUND(soundid);
|
PARAM_INT(soundid);
|
||||||
PARAM_SOUND(checksoundid);
|
PARAM_INT(checksoundid);
|
||||||
PARAM_INT(channel);
|
PARAM_INT(channel);
|
||||||
PARAM_INT(flags);
|
PARAM_INT(flags);
|
||||||
PARAM_FLOAT(volume);
|
PARAM_FLOAT(volume);
|
||||||
|
@ -220,7 +220,13 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StartSoundIfNotSame, A_StartSoundIfNotSa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, IsActorPlayingSound, S_IsActorPlayingSomething)
|
// direct native scripting export.
|
||||||
|
static int S_IsActorPlayingSomethingID(AActor* actor, int channel, int sound_id)
|
||||||
|
{
|
||||||
|
return S_IsActorPlayingSomething(actor, channel, FSoundID::fromInt(sound_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(AActor, IsActorPlayingSound, S_IsActorPlayingSomethingID)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
PARAM_INT(channel);
|
PARAM_INT(channel);
|
||||||
|
|
|
@ -163,7 +163,7 @@ struct FSavedPlayerSoundInfo
|
||||||
{
|
{
|
||||||
FName pclass;
|
FName pclass;
|
||||||
int gender;
|
int gender;
|
||||||
int refid;
|
FSoundID refid;
|
||||||
int lumpnum;
|
int lumpnum;
|
||||||
bool alias;
|
bool alias;
|
||||||
};
|
};
|
||||||
|
@ -180,8 +180,8 @@ extern bool IsFloat (const char *str);
|
||||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||||
|
|
||||||
static int SortPlayerClasses (const void *a, const void *b);
|
static int SortPlayerClasses (const void *a, const void *b);
|
||||||
static int S_DupPlayerSound (const char *pclass, int gender, int refid, int aliasref);
|
static FSoundID S_DupPlayerSound (const char *pclass, int gender, FSoundID refid, FSoundID aliasref);
|
||||||
static void S_SavePlayerSound (const char *pclass, int gender, int refid, int lumpnum, bool alias);
|
static void S_SavePlayerSound (const char *pclass, int gender, FSoundID refid, int lumpnum, bool alias);
|
||||||
static void S_RestorePlayerSounds();
|
static void S_RestorePlayerSounds();
|
||||||
static int S_AddPlayerClass (const char *name);
|
static int S_AddPlayerClass (const char *name);
|
||||||
static int S_AddPlayerGender (int classnum, int gender);
|
static int S_AddPlayerGender (int classnum, int gender);
|
||||||
|
@ -468,8 +468,7 @@ static FSoundID S_AddSound (const char *logicalname, int lumpnum, FScanner *sc)
|
||||||
// Adds the given sound lump to the player sound lists.
|
// Adds the given sound lump to the player sound lists.
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int S_AddPlayerSound (const char *pclass, int gender, int refid,
|
int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, const char *lumpname)
|
||||||
const char *lumpname)
|
|
||||||
{
|
{
|
||||||
int lump=-1;
|
int lump=-1;
|
||||||
|
|
||||||
|
@ -481,7 +480,7 @@ int S_AddPlayerSound (const char *pclass, int gender, int refid,
|
||||||
return S_AddPlayerSound (pclass, gender, refid, lump);
|
return S_AddPlayerSound (pclass, gender, refid, lump);
|
||||||
}
|
}
|
||||||
|
|
||||||
int S_AddPlayerSound (const char *pclass, int gender, int refid, int lumpnum, bool fromskin)
|
int S_AddPlayerSound (const char *pclass, int gender, FSoundID refid, int lumpnum, bool fromskin)
|
||||||
{
|
{
|
||||||
FString fakename;
|
FString fakename;
|
||||||
int id;
|
int id;
|
||||||
|
@ -513,7 +512,7 @@ int S_AddPlayerSound (const char *pclass, int gender, int refid, int lumpnum, bo
|
||||||
// Adds the player sound as an alias to an existing sound.
|
// Adds the player sound as an alias to an existing sound.
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int S_AddPlayerSoundExisting (const char *pclass, int gender, int refid, int aliasto, bool fromskin)
|
int S_AddPlayerSoundExisting (const char *pclass, int gender, FSoundID refid, FSoundID aliasto, bool fromskin)
|
||||||
{
|
{
|
||||||
int classnum = S_AddPlayerClass (pclass);
|
int classnum = S_AddPlayerClass (pclass);
|
||||||
int soundlist = S_AddPlayerGender (classnum, gender);
|
int soundlist = S_AddPlayerGender (classnum, gender);
|
||||||
|
@ -522,7 +521,7 @@ int S_AddPlayerSoundExisting (const char *pclass, int gender, int refid, int ali
|
||||||
|
|
||||||
PlayerSounds[soundlist].AddSound (sfx->link, aliasto);
|
PlayerSounds[soundlist].AddSound (sfx->link, aliasto);
|
||||||
|
|
||||||
if (fromskin) S_SavePlayerSound(pclass, gender, refid, aliasto, true);
|
if (fromskin) S_SavePlayerSound(pclass, gender, refid, aliasto.index(), true);
|
||||||
|
|
||||||
return aliasto;
|
return aliasto;
|
||||||
}
|
}
|
||||||
|
@ -534,7 +533,7 @@ int S_AddPlayerSoundExisting (const char *pclass, int gender, int refid, int ali
|
||||||
// Adds a player sound that uses the same sound as an existing player sound.
|
// Adds a player sound that uses the same sound as an existing player sound.
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int S_DupPlayerSound (const char *pclass, int gender, int refid, int aliasref)
|
FSoundID S_DupPlayerSound (const char *pclass, int gender, FSoundID refid, FSoundID aliasref)
|
||||||
{
|
{
|
||||||
int aliasto = S_LookupPlayerSound (pclass, gender, aliasref);
|
int aliasto = S_LookupPlayerSound (pclass, gender, aliasref);
|
||||||
return S_AddPlayerSoundExisting (pclass, gender, refid, aliasto);
|
return S_AddPlayerSoundExisting (pclass, gender, refid, aliasto);
|
||||||
|
@ -1369,7 +1368,7 @@ static FSoundID S_LookupPlayerSound (int classidx, int gender, FSoundID refid)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void S_SavePlayerSound (const char *pclass, int gender, int refid, int lumpnum, bool alias)
|
static void S_SavePlayerSound (const char *pclass, int gender, FSoundID refid, int lumpnum, bool alias)
|
||||||
{
|
{
|
||||||
FSavedPlayerSoundInfo spi;
|
FSavedPlayerSoundInfo spi;
|
||||||
|
|
||||||
|
@ -1388,7 +1387,7 @@ static void S_RestorePlayerSounds()
|
||||||
FSavedPlayerSoundInfo * spi = &SavedPlayerSounds[i];
|
FSavedPlayerSoundInfo * spi = &SavedPlayerSounds[i];
|
||||||
if (spi->alias)
|
if (spi->alias)
|
||||||
{
|
{
|
||||||
S_AddPlayerSoundExisting(spi->pclass.GetChars(), spi->gender, spi->refid, spi->lumpnum);
|
S_AddPlayerSoundExisting(spi->pclass.GetChars(), spi->gender, spi->refid, FSoundID::fromInt(spi->lumpnum));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -413,7 +413,7 @@ DEFINE_ACTION_FUNCTION(DObject, S_Sound)
|
||||||
PARAM_FLOAT(attn);
|
PARAM_FLOAT(attn);
|
||||||
PARAM_FLOAT(pitch);
|
PARAM_FLOAT(pitch);
|
||||||
PARAM_FLOAT(startTime);
|
PARAM_FLOAT(startTime);
|
||||||
S_SoundPitch(channel & 7, EChanFlags::FromInt(channel & ~7), id, static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
S_SoundPitch(channel & 7, EChanFlags::FromInt(channel & ~7), FSoundID::fromInt(id), static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ DEFINE_ACTION_FUNCTION(DObject, S_StartSound)
|
||||||
PARAM_FLOAT(attn);
|
PARAM_FLOAT(attn);
|
||||||
PARAM_FLOAT(pitch);
|
PARAM_FLOAT(pitch);
|
||||||
PARAM_FLOAT(startTime);
|
PARAM_FLOAT(startTime);
|
||||||
S_SoundPitch(channel, EChanFlags::FromInt(flags), id, static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
S_SoundPitch(channel, EChanFlags::FromInt(flags), FSoundID::fromInt(id), static_cast<float>(volume), static_cast<float>(attn), static_cast<float>(pitch), static_cast<float>(startTime));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol,
|
||||||
|
|
||||||
void A_StartSound(AActor *self, int soundid, int channel, int flags, double volume, double attenuation, double pitch, double startTime)
|
void A_StartSound(AActor *self, int soundid, int channel, int flags, double volume, double attenuation, double pitch, double startTime)
|
||||||
{
|
{
|
||||||
S_PlaySoundPitch(self, channel, EChanFlags::FromInt(flags), soundid, (float)volume, (float)attenuation, (float)pitch, (float)startTime);
|
S_PlaySoundPitch(self, channel, EChanFlags::FromInt(flags), FSoundID::fromInt(soundid), (float)volume, (float)attenuation, (float)pitch, (float)startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void A_PlaySound(AActor* self, int soundid, int channel, double volume, int looping, double attenuation, int local, double pitch)
|
void A_PlaySound(AActor* self, int soundid, int channel, double volume, int looping, double attenuation, int local, double pitch)
|
||||||
|
@ -727,17 +727,17 @@ void S_ChangeActorSoundPitch(AActor *actor, int channel, double pitch)
|
||||||
// Is a sound being played by a specific emitter?
|
// Is a sound being played by a specific emitter?
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool S_GetSoundPlayingInfo (const AActor *actor, int sound_id)
|
bool S_GetSoundPlayingInfo (const AActor *actor, FSoundID sound_id)
|
||||||
{
|
{
|
||||||
return soundEngine->GetSoundPlayingInfo(SOURCE_Actor, actor, sound_id);
|
return soundEngine->GetSoundPlayingInfo(SOURCE_Actor, actor, sound_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool S_GetSoundPlayingInfo (const sector_t *sec, int sound_id)
|
bool S_GetSoundPlayingInfo (const sector_t *sec, FSoundID sound_id)
|
||||||
{
|
{
|
||||||
return soundEngine->GetSoundPlayingInfo(SOURCE_Sector, sec, sound_id);
|
return soundEngine->GetSoundPlayingInfo(SOURCE_Sector, sec, sound_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id)
|
bool S_GetSoundPlayingInfo (const FPolyObj *poly, FSoundID sound_id)
|
||||||
{
|
{
|
||||||
return soundEngine->GetSoundPlayingInfo(SOURCE_Polyobj, poly, sound_id);
|
return soundEngine->GetSoundPlayingInfo(SOURCE_Polyobj, poly, sound_id);
|
||||||
}
|
}
|
||||||
|
@ -748,7 +748,7 @@ bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id)
|
bool S_IsActorPlayingSomething (AActor *actor, int channel, FSoundID sound_id)
|
||||||
{
|
{
|
||||||
if (compatflags & COMPATF_MAGICSILENCE)
|
if (compatflags & COMPATF_MAGICSILENCE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,11 +40,11 @@ void S_StopActorSounds(AActor *actor, int chanmin, int chanmax);
|
||||||
void S_RelinkSound (AActor *from, AActor *to);
|
void S_RelinkSound (AActor *from, AActor *to);
|
||||||
|
|
||||||
// Is the sound playing on one of the emitter's channels?
|
// Is the sound playing on one of the emitter's channels?
|
||||||
bool S_GetSoundPlayingInfo (const AActor *actor, int sound_id);
|
bool S_GetSoundPlayingInfo (const AActor *actor, FSoundID sound_id = INVALID_SOUND);
|
||||||
bool S_GetSoundPlayingInfo (const sector_t *sector, int sound_id);
|
bool S_GetSoundPlayingInfo (const sector_t *sector, FSoundID sound_id = INVALID_SOUND);
|
||||||
bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id);
|
bool S_GetSoundPlayingInfo (const FPolyObj *poly, FSoundID sound_id = INVALID_SOUND);
|
||||||
|
|
||||||
int S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id);
|
bool S_IsActorPlayingSomething (AActor *actor, int channel, FSoundID sound_id = INVALID_SOUND);
|
||||||
|
|
||||||
// Change a playing sound's volume
|
// Change a playing sound's volume
|
||||||
void S_ChangeActorSoundVolume(AActor *actor, int channel, double volume);
|
void S_ChangeActorSoundVolume(AActor *actor, int channel, double volume);
|
||||||
|
@ -55,6 +55,7 @@ void S_ChangeActorSoundPitch(AActor *actor, int channel, double pitch);
|
||||||
// Stores/retrieves playing channel information in an archive.
|
// Stores/retrieves playing channel information in an archive.
|
||||||
void S_SerializeSounds(FSerializer &arc);
|
void S_SerializeSounds(FSerializer &arc);
|
||||||
|
|
||||||
|
// these must retain their integer sound IDs because they are direct native functions for ZScript.
|
||||||
void A_PlaySound(AActor *self, int soundid, int channel, double volume, int looping, double attenuation, int local, double pitch);
|
void A_PlaySound(AActor *self, int soundid, int channel, double volume, int looping, double attenuation, int local, double pitch);
|
||||||
void A_StartSound(AActor* self, int soundid, int channel, int flags, double volume, double attenuation, double pitch, double startTime = 0.);
|
void A_StartSound(AActor* self, int soundid, int channel, int flags, double volume, double attenuation, double pitch, double startTime = 0.);
|
||||||
static void S_SetListener(AActor *listenactor);
|
static void S_SetListener(AActor *listenactor);
|
||||||
|
|
|
@ -72,9 +72,9 @@ const char *S_GetSoundClass(AActor *pp);
|
||||||
FSoundID S_FindSkinnedSound (AActor *actor, FSoundID refid);
|
FSoundID S_FindSkinnedSound (AActor *actor, FSoundID refid);
|
||||||
int S_FindSkinnedSoundEx (AActor *actor, const char *logicalname, const char *extendedname);
|
int S_FindSkinnedSoundEx (AActor *actor, const char *logicalname, const char *extendedname);
|
||||||
FSoundID S_AddSound (const char *logicalname, const char *lumpname, FScanner *sc=NULL); // Add sound by lumpname
|
FSoundID S_AddSound (const char *logicalname, const char *lumpname, FScanner *sc=NULL); // Add sound by lumpname
|
||||||
int S_AddPlayerSound (const char *playerclass, const int gender, int refid, const char *lumpname);
|
int S_AddPlayerSound (const char *playerclass, const int gender, FSoundID refid, const char *lumpname);
|
||||||
int S_AddPlayerSound (const char *playerclass, const int gender, int refid, int lumpnum, bool fromskin=false);
|
int S_AddPlayerSound (const char *playerclass, const int gender, FSoundID refid, int lumpnum, bool fromskin=false);
|
||||||
int S_AddPlayerSoundExisting (const char *playerclass, const int gender, int refid, int aliasto, bool fromskin=false);
|
int S_AddPlayerSoundExisting (const char *playerclass, const int gender, FSoundID refid, FSoundID aliasto, bool fromskin=false);
|
||||||
void S_MarkPlayerSounds (AActor *player);
|
void S_MarkPlayerSounds (AActor *player);
|
||||||
void S_ShrinkPlayerSoundLists ();
|
void S_ShrinkPlayerSoundLists ();
|
||||||
unsigned int S_GetMSLength(FSoundID sound);
|
unsigned int S_GetMSLength(FSoundID sound);
|
||||||
|
|
Loading…
Reference in a new issue