- Replaced the naive area sound implementation with one that takes into

consideration the size and shape of the sector producing the sound. See
  the lifts on Doom 2 MAP30 and compare with previous versions.
- Fixed: The stop sound for sector-based sound sequences was not played with
  the CHAN_AREA flag.
- Removed the distinction between S_Sound() and S_SoundID() functions. Use
  S_Sound() for both names and IDs from now on.


SVN r1034 (trunk)
This commit is contained in:
Randy Heit 2008-06-15 02:25:09 +00:00
parent 0e6e1da970
commit 9e42cdaf08
66 changed files with 609 additions and 435 deletions

View file

@ -1,8 +1,19 @@
June 14, 2008
- Replaced the naive area sound implementation with one that takes into
consideration the size and shape of the sector producing the sound. See
the lifts on Doom 2 MAP30 and compare with previous versions.
June 14, 2008 (Changes by Graf Zahl)
- Fixed: The UDMF parser stored plane rotation angles as fixed_t, not angle_t.
- Grouped the sector plane texture transformation values into a separate
structure and replaced all access to them with wrapper functions.
June 13, 2008
- Fixed: The stop sound for sector-based sound sequences was not played with
the CHAN_AREA flag.
- Removed the distinction between S_Sound() and S_SoundID() functions. Use
S_Sound() for both names and IDs from now on.
June 12, 2008
- Add environment 255, 255 as a way to get the software underwater effect in
any zone you want.

View file

@ -41,6 +41,7 @@
#include "doomdef.h"
#include "r_blend.h"
#include "s_sound.h"
//
// NOTES: AActor
@ -721,12 +722,12 @@ public:
DWORD Translation;
// [RH] Stuff that used to be part of an Actor Info
WORD SeeSound;
WORD AttackSound;
WORD PainSound;
WORD DeathSound;
WORD ActiveSound;
WORD UseSound; // [RH] Sound to play when an actor is used.
FSoundIDNoInit SeeSound;
FSoundIDNoInit AttackSound;
FSoundIDNoInit PainSound;
FSoundIDNoInit DeathSound;
FSoundIDNoInit ActiveSound;
FSoundIDNoInit UseSound; // [RH] Sound to play when an actor is used.
fixed_t Speed;
fixed_t FloatSpeed;
@ -863,20 +864,4 @@ inline T *Spawn (fixed_t x, fixed_t y, fixed_t z, replace_t allowreplacement)
#define S_FREETARGMOBJ 1
struct FSoundIndex
{
int Index;
};
struct FSoundIndexWord
{
WORD Index;
};
FArchive &operator<< (FArchive &arc, FSoundIndex &snd);
FArchive &operator<< (FArchive &arc, FSoundIndexWord &snd);
#define AR_SOUND(id) (*(FSoundIndex *)&(id))
#define AR_SOUNDW(id) (*(FSoundIndexWord *)&(id))
#endif // __P_MOBJ_H__

View file

@ -842,7 +842,7 @@ static int PatchThing (int thingy)
}
else if (stricmp (Line1 + linelen - 6, " sound") == 0)
{
int snd;
FSoundID snd;
if (val == 0 || val >= (unsigned long)NumSounds)
{
@ -850,16 +850,12 @@ static int PatchThing (int thingy)
{ // Sound was not a (valid) number,
// so treat it as an actual sound name.
stripwhite (Line2);
snd = S_FindSound (Line2);
}
else
{
snd = 0;
snd = Line2;
}
}
else
{
snd = S_FindSound (GetName (SoundMap[val-1]));
snd = GetName (SoundMap[val-1]);
}
if (!strnicmp (Line1, "Alert", 5))

View file

@ -620,7 +620,7 @@ void F_CastTicker (void)
castnum = 0;
if (castorder[castnum].info->SeeSound)
{
S_SoundID (CHAN_VOICE, castorder[castnum].info->SeeSound, 1, ATTN_NONE);
S_Sound (CHAN_VOICE, castorder[castnum].info->SeeSound, 1, ATTN_NONE);
}
caststate = castorder[castnum].info->SeeState;
// [RH] Skip monsters that have been hacked to no longer have attack states
@ -732,12 +732,11 @@ bool F_CastResponder (event_t* ev)
castattacking = false;
if (castnum == 16)
{
//int id = S_LookupPlayerSound (
S_Sound (players[consoleplayer].mo, CHAN_VOICE, "*death", 1, ATTN_NONE);
}
else if (castorder[castnum].info->DeathSound)
{
S_SoundID (CHAN_VOICE, castorder[castnum].info->DeathSound, 1, ATTN_NONE);
S_Sound (CHAN_VOICE, castorder[castnum].info->DeathSound, 1, ATTN_NONE);
}
}

View file

@ -187,7 +187,7 @@ static void BrainishExplosion (fixed_t x, fixed_t y, fixed_t z)
AActor *boom = Spawn("Rocket", x, y, z, NO_REPLACE);
if (boom != NULL)
{
boom->DeathSound = S_FindSound("misc/brainexplode");
boom->DeathSound = "misc/brainexplode";
boom->momz = pr_brainscream() << 9;
boom->SetState (&ABossBrain::States[S_BRAINEXPLODE]);
boom->effects = 0;

View file

@ -18,7 +18,7 @@ void A_HeadAttack (AActor *self)
if (self->CheckMeleeRange ())
{
int damage = (pr_headattack()%6+1)*10;
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self);
return;

View file

@ -103,8 +103,8 @@ void A_Saw (AActor *actor)
player_t *player;
AActor *linetarget;
int fullsound;
int hitsound;
FSoundID fullsound;
FSoundID hitsound;
const PClass * pufftype = NULL;
if (NULL == (player = actor->player))
@ -122,15 +122,15 @@ void A_Saw (AActor *actor)
int index = CheckIndex (4, NULL);
if (index >= 0)
{
fullsound = StateParameters[index];
hitsound = StateParameters[index+1];
fullsound = FSoundID(StateParameters[index]);
hitsound = FSoundID(StateParameters[index+1]);
damage = EvalExpressionI (StateParameters[index+2], actor);
pufftype = PClass::FindClass ((ENamedName)StateParameters[index+3]);
}
else
{
fullsound = S_FindSound("weapons/sawfull");
hitsound = S_FindSound("weapons/sawhit");
fullsound = "weapons/sawfull";
hitsound = "weapons/sawhit";
}
if (pufftype == NULL) pufftype = PClass::FindClass(NAME_BulletPuff);
if (damage == 0) damage = 2;
@ -146,10 +146,10 @@ void A_Saw (AActor *actor)
if (!linetarget)
{
S_SoundID (actor, CHAN_WEAPON, fullsound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, fullsound, 1, ATTN_NORM);
return;
}
S_SoundID (actor, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
// turn to face target
angle = R_PointToAngle2 (actor->x, actor->y,

View file

@ -30,7 +30,7 @@ void A_SkullAttack (AActor *self)
dest = self->target;
self->flags |= MF_SKULLFLY;
S_SoundID (self, CHAN_VOICE, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_VOICE, self->AttackSound, 1, ATTN_NORM);
A_FaceTarget (self);
an = self->angle >> ANGLETOFINESHIFT;
self->momx = FixedMul (SKULLSPEED, finecosine[an]);

View file

@ -58,7 +58,7 @@ void A_SPosAttackUseAtkSound (AActor *self)
if (!self->target)
return;
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
A_SPosAttack2 (self);
}
@ -89,7 +89,7 @@ void A_CPosAttack (AActor *self)
self->visdir = 1;
}
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
A_FaceTarget (self);
bangle = self->angle;
slope = P_AimLineAttack (self, bangle, MISSILERANGE);

View file

@ -463,7 +463,7 @@ void A_Srcr1Attack (AActor *actor)
{
return;
}
S_SoundID (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NORM);
if (actor->CheckMeleeRange ())
{
int damage = pr_scrc1atk.HitDice (8);
@ -613,7 +613,7 @@ void A_Srcr2Attack (AActor *actor)
{
return;
}
S_SoundID (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NONE);
S_Sound (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NONE);
if (actor->CheckMeleeRange())
{
int damage = pr_s2a.HitDice (20);

View file

@ -260,7 +260,7 @@ void A_ImpMeAttack (AActor *self)
{
return;
}
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
if (self->CheckMeleeRange ())
{
int damage = 5+(pr_impmeatk()&7);
@ -288,7 +288,7 @@ void A_ImpMsAttack (AActor *self)
}
dest = self->target;
self->flags |= MF_SKULLFLY;
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
A_FaceTarget (self);
an = self->angle >> ANGLETOFINESHIFT;
self->momx = FixedMul (12*FRACUNIT, finecosine[an]);
@ -316,7 +316,7 @@ void A_ImpMsAttack2 (AActor *self)
{
return;
}
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
if (self->CheckMeleeRange ())
{
int damage = 5+(pr_impmsatk2()&7);

View file

@ -2535,7 +2535,7 @@ void A_SkullRodStorm (AActor *actor)
P_CheckMissileSpawn (mo);
if (actor->special1 != -1 && !S_IsActorPlayingSomething (actor, CHAN_BODY, -1))
{
S_SoundID (actor, CHAN_BODY|CHAN_LOOP, actor->special1, 1, ATTN_NORM);
S_Sound (actor, CHAN_BODY|CHAN_LOOP, actor->special1, 1, ATTN_NORM);
}
}
@ -2874,7 +2874,7 @@ void A_FirePhoenixPL2 (AActor *actor)
angle_t angle;
fixed_t x, y, z;
fixed_t slope;
int soundid;
FSoundID soundid;
player_t *player;
APhoenixRod *flamethrower;
@ -2883,7 +2883,7 @@ void A_FirePhoenixPL2 (AActor *actor)
return;
}
soundid = S_FindSound ("weapons/phoenixpowshoot");
soundid = "weapons/phoenixpowshoot";
flamethrower = static_cast<APhoenixRod *> (player->ReadyWeapon);
if (flamethrower == NULL || --flamethrower->FlameCount == 0)
@ -2907,7 +2907,7 @@ void A_FirePhoenixPL2 (AActor *actor)
mo->momz = FixedMul (mo->Speed, slope);
if (!player->refire || !S_IsActorPlayingSomething (actor, CHAN_WEAPON, -1))
{
S_SoundID (actor, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON|CHAN_LOOP, soundid, 1, ATTN_NORM);
}
P_CheckMissileSpawn (mo);
}

View file

@ -215,7 +215,7 @@ void A_KnightAttack (AActor *actor)
return;
}
// Throw axe
S_SoundID (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NORM);
if (actor->flags & MF_SHADOW || pr_knightatk () < 40)
{ // Red axe
P_SpawnMissileZ (actor, actor->z + 36*FRACUNIT, actor->target, RUNTIME_CLASS(ARedAxe));

View file

@ -183,7 +183,7 @@ void A_WizAtk3 (AActor *actor)
{
return;
}
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
if (actor->CheckMeleeRange())
{
int damage = pr_wizatk3.HitDice (4);

View file

@ -236,7 +236,7 @@ void A_BishopAttack (AActor *actor)
{
return;
}
S_SoundID (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_BODY, actor->AttackSound, 1, ATTN_NORM);
if (actor->CheckMeleeRange())
{
int damage = pr_atk.HitDice (4);

View file

@ -254,12 +254,12 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
int damage = pr_dragonseek.HitDice (10);
P_DamageMobj (actor->target, actor, actor, damage, NAME_Melee);
P_TraceBleed (damage, actor->target, actor);
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
}
else if (pr_dragonseek() < 128 && P_CheckMissileRange(actor))
{
P_SpawnMissile(actor, target, RUNTIME_CLASS(ADragonFireball));
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
}
actor->target = oldTarget;
}
@ -368,12 +368,12 @@ void A_DragonFlight (AActor *actor)
int damage = pr_dragonflight.HitDice (8);
P_DamageMobj (actor->target, actor, actor, damage, NAME_Melee);
P_TraceBleed (damage, actor->target, actor);
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
}
else if (abs(actor->angle-angle) <= ANGLE_1*20)
{
actor->SetState (actor->MissileState);
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
}
}
else

View file

@ -1310,7 +1310,7 @@ void A_SpawnBishop(AActor *actor)
void A_SorcererBishopEntry(AActor *actor)
{
Spawn<ASorcFX3Explosion> (actor->x, actor->y, actor->z, ALLOW_REPLACE);
S_SoundID (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NORM);
}
//============================================================================

View file

@ -418,7 +418,7 @@ void A_CorpseExplode (AActor *actor)
mo->momx = pr_foo.Random2()<<(FRACBITS-6);
mo->momy = pr_foo.Random2()<<(FRACBITS-6);
}
S_SoundID (actor, CHAN_BODY, actor->DeathSound, 1, ATTN_IDLE);
S_Sound (actor, CHAN_BODY, actor->DeathSound, 1, ATTN_IDLE);
actor->Destroy ();
}
@ -739,7 +739,7 @@ void A_SoAExplode (AActor *actor)
actor->x, actor->y, actor->z, ALLOW_REPLACE);
}
}
S_SoundID (actor, CHAN_BODY, actor->DeathSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_BODY, actor->DeathSound, 1, ATTN_NORM);
actor->Destroy ();
}

View file

@ -352,7 +352,7 @@ void A_IceGuyAttack (AActor *actor)
finecosine[an]), actor->y+FixedMul(actor->radius>>1,
finesine[an]), actor->z+40*FRACUNIT, actor, actor->target,
RUNTIME_CLASS(AIceGuyFX));
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
}
//============================================================================

View file

@ -159,6 +159,6 @@ void A_Summon (AActor *actor)
// Make smoke puff
Spawn<AMinotaurSmoke> (actor->x, actor->y, actor->z, ALLOW_REPLACE);
S_SoundID (actor, CHAN_VOICE, mo->ActiveSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, mo->ActiveSound, 1, ATTN_NORM);
}
}

View file

@ -930,7 +930,7 @@ void A_MinotaurChase (AActor *actor)
{
if (actor->AttackSound)
{
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
}
actor->SetState (actor->MeleeState);
return;

View file

@ -1517,7 +1517,7 @@ END_DEFAULTS
void APowerDamage::InitEffect( )
{
// Use sound channel 5 to avoid interference with other actions.
if (Owner != NULL) S_SoundID(Owner, 5, SeeSound, 1.0f, ATTN_NONE);
if (Owner != NULL) S_Sound(Owner, 5, SeeSound, 1.0f, ATTN_NONE);
}
//===========================================================================
@ -1529,7 +1529,7 @@ void APowerDamage::InitEffect( )
void APowerDamage::EndEffect( )
{
// Use sound channel 5 to avoid interference with other actions.
if (Owner != NULL) S_SoundID(Owner, 5, DeathSound, 1.0f, ATTN_NONE);
if (Owner != NULL) S_Sound(Owner, 5, DeathSound, 1.0f, ATTN_NONE);
}
//===========================================================================
@ -1552,7 +1552,7 @@ void APowerDamage::ModifyDamage(int damage, FName damageType, int &newdamage, bo
damage = newdamage = FixedMul(damage, *pdf);
if (*pdf > 0 && damage == 0) damage = newdamage = 1; // don't allow zero damage as result of an underflow
if (Owner != NULL && *pdf > FRACUNIT) S_SoundID(Owner, 5, ActiveSound, 1.0f, ATTN_NONE);
if (Owner != NULL && *pdf > FRACUNIT) S_Sound(Owner, 5, ActiveSound, 1.0f, ATTN_NONE);
}
}
if (Inventory != NULL) Inventory->ModifyDamage(damage, damageType, newdamage, passive);
@ -1573,7 +1573,7 @@ END_DEFAULTS
void APowerProtection::InitEffect( )
{
// Use sound channel 5 to avoid interference with other actions.
if (Owner != NULL) S_SoundID(Owner, 5, SeeSound, 1.0f, ATTN_NONE);
if (Owner != NULL) S_Sound(Owner, 5, SeeSound, 1.0f, ATTN_NONE);
}
//===========================================================================
@ -1585,7 +1585,7 @@ void APowerProtection::InitEffect( )
void APowerProtection::EndEffect( )
{
// Use sound channel 5 to avoid interference with other actions.
if (Owner != NULL) S_SoundID(Owner, 5, DeathSound, 1.0f, ATTN_NONE);
if (Owner != NULL) S_Sound(Owner, 5, DeathSound, 1.0f, ATTN_NONE);
}
//===========================================================================
@ -1607,7 +1607,7 @@ void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage
if (pdf == NULL) pdf = &def;
damage = newdamage = FixedMul(damage, *pdf);
if (Owner != NULL && *pdf < FRACUNIT) S_SoundID(Owner, 5, ActiveSound, 1.0f, ATTN_NONE);
if (Owner != NULL && *pdf < FRACUNIT) S_Sound(Owner, 5, ActiveSound, 1.0f, ATTN_NONE);
}
}
if (Inventory != NULL) Inventory->ModifyDamage(damage, damageType, newdamage, passive);

View file

@ -41,7 +41,7 @@ struct Lock
TArray<Keygroup *> keylist;
char * message;
char * remotemsg;
int locksound;
FSoundID locksound;
int rgb;
Lock()
@ -222,7 +222,7 @@ static void ParseLock(FScanner &sc)
delete locks[keynum];
}
locks[keynum] = lock;
locks[keynum]->locksound = S_FindSound("misc/keytry");
locks[keynum]->locksound = "misc/keytry";
ignorekey=false;
}
else if (keynum != -1)
@ -266,7 +266,7 @@ static void ParseLock(FScanner &sc)
case 4: // locksound
sc.MustGetString();
lock->locksound = S_FindSound(sc.String);
lock->locksound = sc.String;
break;
default:
@ -390,10 +390,7 @@ void P_DeinitKeyMessages()
bool P_CheckKeys (AActor *owner, int keynum, bool remote)
{
const char *failtext = NULL;
int failsound = 0;
failtext = NULL;
failsound = 0;
FSoundID failsound;
if (keynum<=0 || keynum>255) return true;
// Just a safety precaution. The messages should have been initialized upon game start.
@ -406,7 +403,7 @@ bool P_CheckKeys (AActor *owner, int keynum, bool remote)
else
failtext = "That doesn't seem to work";
failsound = S_FindSound("misc/keytry");
failsound = "misc/keytry";
}
else
{
@ -420,7 +417,7 @@ bool P_CheckKeys (AActor *owner, int keynum, bool remote)
if (owner == players[consoleplayer].camera)
{
PrintMessage(failtext);
S_SoundID (owner, CHAN_VOICE, failsound, 1, ATTN_NORM);
S_Sound (owner, CHAN_VOICE, failsound, 1, ATTN_NORM);
}
return false;

View file

@ -474,7 +474,7 @@ void AInventory::Serialize (FArchive &arc)
{
Icon = TexMan.ReadTexture (arc);
}
arc << AR_SOUNDW(PickupSound);
arc << PickupSound;
}
//===========================================================================
@ -1011,7 +1011,7 @@ const char *AInventory::PickupMessage ()
void AInventory::PlayPickupSound (AActor *toucher)
{
S_SoundID (toucher, CHAN_PICKUP, PickupSound, 1,
S_Sound (toucher, CHAN_PICKUP, PickupSound, 1,
(ItemFlags & IF_FANCYPICKUPSOUND) &&
(toucher == NULL || toucher->CheckLocalView (consoleplayer))
? ATTN_NONE : ATTN_NORM);

View file

@ -4,6 +4,7 @@
#include "dobject.h"
#include "actor.h"
#include "info.h"
#include "s_sound.h"
#define MAX_MANA 200
@ -140,7 +141,7 @@ public:
DWORD ItemFlags;
const PClass *PickupFlash; // actor to spawn as pickup flash
WORD PickupSound;
FSoundIDNoInit PickupSound;
virtual void BecomeItem ();
virtual void BecomePickup ();
@ -211,7 +212,7 @@ public:
int AmmoUse1, AmmoUse2; // How much ammo to use with each shot
int Kickback;
fixed_t YAdjust; // For viewing the weapon fullscreen
WORD UpSound, ReadySound; // Sounds when coming up and idle
FSoundIDNoInit UpSound, ReadySound; // Sounds when coming up and idle
const PClass *SisterWeaponType; // Another weapon to pick up with this one
const PClass *ProjectileType; // Projectile used by primary attack
const PClass *AltProjectileType; // Projectile used by alternate attack

View file

@ -36,7 +36,7 @@ DEarthquake::DEarthquake (AActor *center, int intensity, int duration,
int damrad, int tremrad)
: DThinker(STAT_EARTHQUAKE)
{
m_QuakeSFX = S_FindSound ("world/quake");
m_QuakeSFX = "world/quake";
m_Spot = center;
// Radii are specified in tile units (64 pixels)
m_DamageRadius = damrad << (FRACBITS+6);
@ -56,7 +56,7 @@ void DEarthquake::Serialize (FArchive &arc)
Super::Serialize (arc);
arc << m_Spot << m_Intensity << m_Countdown
<< m_TremorRadius << m_DamageRadius;
m_QuakeSFX = S_FindSound ("world/quake");
m_QuakeSFX = "world/quake";
}
//==========================================================================
@ -80,7 +80,7 @@ void DEarthquake::Tick ()
if (!S_IsActorPlayingSomething (m_Spot, CHAN_BODY, m_QuakeSFX))
{
S_SoundID (m_Spot, CHAN_BODY | CHAN_LOOP, m_QuakeSFX, 1, ATTN_NORM);
S_Sound (m_Spot, CHAN_BODY | CHAN_LOOP, m_QuakeSFX, 1, ATTN_NORM);
}
if (m_DamageRadius > 0)
{

View file

@ -159,7 +159,7 @@ public:
fixed_t m_TremorRadius, m_DamageRadius;
int m_Intensity;
int m_Countdown;
int m_QuakeSFX;
FSoundID m_QuakeSFX;
static int StaticGetQuakeIntensity (AActor *viewer);

View file

@ -47,7 +47,7 @@ void AWeapon::Serialize (FArchive &arc)
<< AmmoUse1 << AmmoUse2
<< Kickback
<< YAdjust
<< AR_SOUNDW(UpSound) << AR_SOUNDW(ReadySound)
<< UpSound << ReadySound
<< SisterWeaponType
<< ProjectileType << AltProjectileType
<< SelectionOrder

View file

@ -57,8 +57,8 @@ void ADegninOre::GetExplodeParms (int &damage, int &dist, bool &hurtSource)
damage = dist = 192;
RenderStyle = STYLE_Add; // [RH] Make the explosion glow
// Does strife automatically play the death sound on death?
S_SoundID (this, CHAN_BODY, DeathSound, 1, ATTN_NORM);
// Does Strife automatically play the death sound on death?
S_Sound (this, CHAN_BODY, DeathSound, 1, ATTN_NORM);
}
void A_RemoveForceField (AActor *self)

View file

@ -444,7 +444,7 @@ void A_GetHurt (AActor *self)
self->flags4 |= MF4_INCOMBAT;
if ((pr_gethurt() % 5) == 0)
{
S_SoundID (self, CHAN_VOICE, self->PainSound, 1, ATTN_NORM);
S_Sound (self, CHAN_VOICE, self->PainSound, 1, ATTN_NORM);
self->health--;
}
if (self->health <= 0)
@ -526,7 +526,7 @@ void A_TurretLook (AActor *self)
}
if (self->SeeSound != 0)
{
S_SoundID (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM);
S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM);
}
self->LastHeard = NULL;
self->threshold = 10;
@ -792,7 +792,7 @@ void A_FLoopActiveSound (AActor *self)
{
if (self->ActiveSound != 0 && !(level.time & 7))
{
S_SoundID (self, CHAN_VOICE, self->ActiveSound, 1, ATTN_NORM);
S_Sound (self, CHAN_VOICE, self->ActiveSound, 1, ATTN_NORM);
}
}
@ -809,7 +809,7 @@ void A_LoopActiveSound (AActor *self)
{
if (self->ActiveSound != 0 && !S_IsActorPlayingSomething (self, CHAN_VOICE, -1))
{
S_SoundID (self, CHAN_VOICE|CHAN_LOOP, self->ActiveSound, 1, ATTN_NORM);
S_Sound (self, CHAN_VOICE|CHAN_LOOP, self->ActiveSound, 1, ATTN_NORM);
}
}
@ -948,7 +948,7 @@ END_DEFAULTS
void A_ItBurnsItBurns (AActor *self)
{
int burnsound = S_FindSound ("human/imonfire");
FSoundID burnsound = "human/imonfire";
if (burnsound != 0)
{
self->DeathSound = burnsound;

View file

@ -179,7 +179,7 @@ void P_DaggerAlert (AActor *target, AActor *emitter)
looker->target = target;
if (looker->SeeSound)
{
S_SoundID (looker, CHAN_VOICE, looker->SeeSound, 1, ATTN_NORM);
S_Sound (looker, CHAN_VOICE, looker->SeeSound, 1, ATTN_NORM);
}
looker->SetState (looker->SeeState);
looker->flags4 |= MF4_INCOMBAT;
@ -1787,7 +1787,7 @@ void A_FireGrenade (AActor *self)
if (grenade->SeeSound != 0)
{
S_SoundID (grenade, CHAN_VOICE, grenade->SeeSound, 1, ATTN_NORM);
S_Sound (grenade, CHAN_VOICE, grenade->SeeSound, 1, ATTN_NORM);
}
grenade->momz = FixedMul (finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)], grenade->Speed) + 8*FRACUNIT;

View file

@ -96,7 +96,7 @@ static BYTE *sgDefaults;
static void ApplyActorDefault (int defnum, const char *datastr, int dataint)
{
int datasound = 0;
FSoundID datasound;
FState *datastate = NULL;
const PClass *datatype;
@ -104,7 +104,7 @@ static void ApplyActorDefault (int defnum, const char *datastr, int dataint)
{
if (defnum <= ADEF_Inventory_PickupSound)
{
datasound = S_FindSound (datastr);
datasound = datastr;
}
}
else if (defnum > ADEF_LastString && dataint >= 0 && dataint < PROP_CLEAR_STATE)

View file

@ -2303,23 +2303,23 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
break;
case APROP_SeeSound:
actor->SeeSound = S_FindSound (FBehavior::StaticLookupString (value));
actor->SeeSound = FBehavior::StaticLookupString(value);
break;
case APROP_AttackSound:
actor->AttackSound = S_FindSound (FBehavior::StaticLookupString (value));
actor->AttackSound = FBehavior::StaticLookupString(value);
break;
case APROP_PainSound:
actor->PainSound = S_FindSound (FBehavior::StaticLookupString (value));
actor->PainSound = FBehavior::StaticLookupString(value);
break;
case APROP_DeathSound:
actor->DeathSound = S_FindSound (FBehavior::StaticLookupString (value));
actor->DeathSound = FBehavior::StaticLookupString(value);
break;
case APROP_ActiveSound:
actor->ActiveSound = S_FindSound (FBehavior::StaticLookupString (value));
actor->ActiveSound = FBehavior::StaticLookupString(value);
break;
}
}
@ -4182,7 +4182,7 @@ int DLevelScript::RunScript ()
{
if (activationline)
{
SN_StartSequence (activationline->frontsector, lookup, 0, true);
SN_StartSequence (activationline->frontsector, CHAN_FULLHEIGHT, lookup, 0);
}
}
sp--;

View file

@ -64,16 +64,16 @@ void DCeiling::PlayCeilingSound ()
{
if (m_Sector->seqType >= 0)
{
SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_PLATFORM, 0, false);
SN_StartSequence (m_Sector, CHAN_CEILING, m_Sector->seqType, SEQ_PLATFORM, 0, false);
}
else
{
if (m_Silent == 2)
SN_StartSequence (m_Sector, "Silence", 0, false);
SN_StartSequence (m_Sector, CHAN_CEILING, "Silence", 0);
else if (m_Silent == 1)
SN_StartSequence (m_Sector, "CeilingSemiSilent", 0, false);
SN_StartSequence (m_Sector, CHAN_CEILING, "CeilingSemiSilent", 0);
else
SN_StartSequence (m_Sector, "CeilingNormal", 0, false);
SN_StartSequence (m_Sector, CHAN_CEILING, "CeilingNormal", 0);
}
}

View file

@ -329,7 +329,7 @@ static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, DWORD &prevSpeaker
// The speaker's voice for this node, if any.
speech.Sound[8] = 0;
sprintf (fullsound, "svox/%s", speech.Sound);
node->SpeakerVoice = S_FindSound (fullsound);
node->SpeakerVoice = fullsound;
// The speaker's name, if any.
speech.Name[16] = 0;
@ -398,7 +398,7 @@ static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, DWORD &prevSpeaker
if (speech.VoiceNumber != 0)
{
sprintf (fullsound, "svox/voc%u", speech.VoiceNumber);
node->SpeakerVoice = S_FindSound (fullsound);
node->SpeakerVoice = fullsound;
}
else
{
@ -715,7 +715,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
if (CurNode->SpeakerVoice != 0)
{
I_SetMusicVolume (dlg_musicvolume);
S_SoundID (npc, CHAN_VOICE|CHAN_NOPAUSE, CurNode->SpeakerVoice, 1, ATTN_NORM);
S_Sound (npc, CHAN_VOICE|CHAN_NOPAUSE, CurNode->SpeakerVoice, 1, ATTN_NORM);
}
if (pc->player != &players[consoleplayer])

View file

@ -21,7 +21,7 @@ struct FStrifeDialogueNode
const PClass *SpeakerType;
char *SpeakerName;
int SpeakerVoice;
FSoundID SpeakerVoice;
int Backdrop;
char *Dialogue;

View file

@ -234,7 +234,7 @@ void DDoor::DoorSound (bool raise) const
if (m_Sector->seqType >= 0)
{
SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_DOOR, choice, true);
SN_StartSequence (m_Sector, CHAN_CEILING, m_Sector->seqType, SEQ_DOOR, choice);
}
else
{
@ -295,7 +295,7 @@ void DDoor::DoorSound (bool raise) const
}
break;
}
SN_StartSequence (m_Sector, snd, choice, true);
SN_StartSequence (m_Sector, CHAN_CEILING, snd, choice);
}
}
@ -562,7 +562,7 @@ bool DAnimatedDoor::StartClosing ()
m_Line2->flags |= ML_BLOCKING;
if (ani.CloseSound != NULL)
{
SN_StartSequence (m_Sector, ani.CloseSound, 1, true);
SN_StartSequence (m_Sector, CHAN_CEILING, ani.CloseSound, 1);
}
m_Status = Closing;
@ -740,7 +740,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay)
MoveCeiling (2048*FRACUNIT, topdist, 1);
if (DoorAnimations[m_WhichDoorIndex].OpenSound != NULL)
{
SN_StartSequence (m_Sector, DoorAnimations[m_WhichDoorIndex].OpenSound, 1, true);
SN_StartSequence (m_Sector, CHAN_FULLHEIGHT, DoorAnimations[m_WhichDoorIndex].OpenSound, 1);
}
}

View file

@ -439,13 +439,13 @@ void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end
{
if (!silent)
{
int sound;
FSoundID sound;
// Allow other sounds than 'weapons/railgf'!
if (!source->player) sound = source->AttackSound;
else if (source->player->ReadyWeapon) sound = source->player->ReadyWeapon->AttackSound;
else sound = 0;
if (!sound) sound=S_FindSound("weapons/railgf");
if (!sound) sound = "weapons/railgf";
// The railgun's sound is special. It gets played from the
// point on the slug's trail that is closest to the hearing player.
@ -457,7 +457,7 @@ void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end
if (abs(mo->x - FLOAT2FIXED(start.X)) < 20 * FRACUNIT
&& (mo->y - FLOAT2FIXED(start.Y)) < 20 * FRACUNIT)
{ // This player (probably) fired the railgun
S_SoundID (mo, CHAN_WEAPON, sound, 1, ATTN_NORM);
S_Sound (mo, CHAN_WEAPON, sound, 1, ATTN_NORM);
}
else
{
@ -471,7 +471,7 @@ void P_DrawRailTrail (AActor *source, const FVector3 &start, const FVector3 &end
point = start + r * dir;
dir.Z = dirz;
S_SoundID (FLOAT2FIXED(point.X), FLOAT2FIXED(point.Y), mo->z,
S_Sound (FLOAT2FIXED(point.X), FLOAT2FIXED(point.Y), mo->z,
CHAN_WEAPON, sound, 1, ATTN_NORM);
}
}

View file

@ -1629,11 +1629,11 @@ void A_Look (AActor *actor)
{
if (actor->flags2 & MF2_BOSS)
{ // full volume
S_SoundID (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NONE);
S_Sound (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NONE);
}
else
{
S_SoundID (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NORM);
}
}
@ -1992,7 +1992,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
if (meleestate && actor->CheckMeleeRange ())
{
if (actor->AttackSound)
S_SoundID (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM);
actor->SetState (meleestate);
actor->flags &= ~MF_INCHASE;
@ -2345,11 +2345,11 @@ void A_Scream (AActor *actor)
if (actor->flags2 & MF2_BOSS)
{
// full volume
S_SoundID (actor, CHAN_VOICE, actor->DeathSound, 1, ATTN_NONE);
S_Sound (actor, CHAN_VOICE, actor->DeathSound, 1, ATTN_NONE);
}
else
{
S_SoundID (actor, CHAN_VOICE, actor->DeathSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, actor->DeathSound, 1, ATTN_NORM);
}
}
}
@ -2371,7 +2371,7 @@ void A_XXScream (AActor *actor)
}
else
{
S_SoundID (actor, CHAN_VOICE, actor->DeathSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, actor->DeathSound, 1, ATTN_NORM);
}
}
@ -2474,7 +2474,7 @@ void A_Pain (AActor *actor)
if (actor->player && actor->player->morphTics == 0)
{
const char *pain_amount;
int sfx_id = 0;
FSoundID sfx_id;
if (actor->health < 25)
pain_amount = "*pain25";
@ -2491,25 +2491,25 @@ void A_Pain (AActor *actor)
FString pain_sound = pain_amount;
pain_sound += '-';
pain_sound += actor->player->LastDamageType;
sfx_id = S_FindSound (pain_sound);
sfx_id = pain_sound;
if (sfx_id == 0)
{
// Try again without a specific pain amount.
pain_sound = "*pain-";
pain_sound += actor->player->LastDamageType;
sfx_id = S_FindSound (pain_sound);
sfx_id = pain_sound;
}
}
if (sfx_id == 0)
{
sfx_id = S_FindSound (pain_amount);
sfx_id = pain_amount;
}
S_SoundID (actor, CHAN_VOICE, sfx_id, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, sfx_id, 1, ATTN_NORM);
}
else if (actor->PainSound)
{
S_SoundID (actor, CHAN_VOICE, actor->PainSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, actor->PainSound, 1, ATTN_NORM);
}
}

View file

@ -867,11 +867,11 @@ void A_LookEx (AActor *actor)
{
if (flags & LOF_FULLVOLSEESOUND)
{ // full volume
S_SoundID (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NONE);
S_Sound (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NONE);
}
else
{
S_SoundID (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, actor->SeeSound, 1, ATTN_NORM);
}
}

View file

@ -321,11 +321,11 @@ static void StartFloorSound (sector_t *sec)
{
if (sec->seqType >= 0)
{
SN_StartSequence (sec, sec->seqType, SEQ_PLATFORM, 0, false);
SN_StartSequence (sec, CHAN_FLOOR, sec->seqType, SEQ_PLATFORM, 0);
}
else
{
SN_StartSequence (sec, "Floor", 0, false);
SN_StartSequence (sec, CHAN_FLOOR, "Floor", 0);
}
}

View file

@ -2639,7 +2639,7 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
AActor *puffDefaults = GetDefaultByType (pufftype);
if (puffDefaults->ActiveSound)
{ // Play miss sound
S_SoundID (t1, CHAN_WEAPON, puffDefaults->ActiveSound, 1, ATTN_NORM);
S_Sound (t1, CHAN_WEAPON, puffDefaults->ActiveSound, 1, ATTN_NORM);
}
if (puffDefaults->flags3 & MF3_ALWAYSPUFF)
{ // Spawn the puff anyway
@ -4111,20 +4111,17 @@ bool P_ChangeSector (sector_t *sector, int crunch, int amt, int floorOrCeil, boo
cpos.movemidtex = false;
cpos.sector = sector;
// [RH] Use different functions for the four different types of sector
// movement. Also update the soundorg's z-coordinate for 3D sound.
// [RH] Use different functions for the four different types of sector movement.
switch (floorOrCeil)
{
case 0:
// floor
iterator = (amt < 0) ? PIT_FloorDrop : PIT_FloorRaise;
sector->soundorg[2] = sector->floorplane.ZatPoint (sector->soundorg[0], sector->soundorg[1]);
break;
case 1:
// ceiling
iterator = (amt < 0) ? PIT_CeilingLower : PIT_CeilingRaise;
sector->soundorg[2] = sector->ceilingplane.ZatPoint (sector->soundorg[0], sector->soundorg[1]);
break;
case 2:

View file

@ -294,12 +294,12 @@ void AActor::Serialize (FArchive &arc)
<< id
<< FloatBobPhase
<< Translation
<< AR_SOUNDW(SeeSound)
<< AR_SOUNDW(AttackSound)
<< AR_SOUNDW(PainSound)
<< AR_SOUNDW(DeathSound)
<< AR_SOUNDW(ActiveSound)
<< AR_SOUNDW(UseSound)
<< SeeSound
<< AttackSound
<< PainSound
<< DeathSound
<< ActiveSound
<< UseSound
<< Speed
<< FloatSpeed
<< Mass
@ -1148,7 +1148,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target)
if (mo->DeathSound)
{
S_SoundID (mo, CHAN_VOICE, mo->DeathSound, 1,
S_Sound (mo, CHAN_VOICE, mo->DeathSound, 1,
(mo->flags3 & MF3_FULLVOLDEATH) ? ATTN_NONE : ATTN_NORM);
}
}
@ -1208,7 +1208,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane)
if (SeeSound && !(flags4 & MF4_NOBOUNCESOUND))
{
S_SoundID (this, CHAN_VOICE, SeeSound, 1, ATTN_IDLE);
S_Sound (this, CHAN_VOICE, SeeSound, 1, ATTN_IDLE);
}
if ((flags2 & MF2_BOUNCETYPE) == MF2_DOOMBOUNCE)
@ -1624,7 +1624,7 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
mo->momy = FixedMul (speed, finesine[angle]);
if (mo->SeeSound && !(mo->flags4&MF4_NOBOUNCESOUND))
{
S_SoundID (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_IDLE);
S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_IDLE);
}
return;
}
@ -1642,7 +1642,7 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
{
if (mo->SeeSound && !(mo->flags3 & MF3_NOWALLBOUNCESND))
{
S_SoundID (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_IDLE);
S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_IDLE);
}
return;
}
@ -2363,7 +2363,7 @@ void AActor::Howl ()
int howl = GetClass()->Meta.GetMetaInt(AMETA_HowlSound);
if (!S_IsActorPlayingSomething(this, CHAN_BODY, howl))
{
S_SoundID (this, CHAN_BODY, howl, 1, ATTN_NORM);
S_Sound (this, CHAN_BODY, howl, 1, ATTN_NORM);
}
}
@ -2455,7 +2455,7 @@ void AActor::PlayActiveSound ()
{
if (ActiveSound && !S_IsActorPlayingSomething (this, CHAN_VOICE, -1))
{
S_SoundID (this, CHAN_VOICE, ActiveSound, 1,
S_Sound (this, CHAN_VOICE, ActiveSound, 1,
(flags3 & MF3_FULLVOLACTIVE) ? ATTN_NONE : ATTN_IDLE);
}
}
@ -4099,11 +4099,11 @@ AActor *P_SpawnPuff (const PClass *pufftype, fixed_t x, fixed_t y, fixed_t z, an
if ((flags & PF_HITTHING) && puff->SeeSound)
{ // Hit thing sound
S_SoundID (puff, CHAN_BODY, puff->SeeSound, 1, ATTN_NORM);
S_Sound (puff, CHAN_BODY, puff->SeeSound, 1, ATTN_NORM);
}
else if (puff->AttackSound)
{
S_SoundID (puff, CHAN_BODY, puff->AttackSound, 1, ATTN_NORM);
S_Sound (puff, CHAN_BODY, puff->AttackSound, 1, ATTN_NORM);
}
}
@ -4382,13 +4382,13 @@ bool P_HitWater (AActor * thing, sector_t * sec, fixed_t z)
}
if (mo)
{
S_SoundID (mo, CHAN_ITEM, smallsplash ?
S_Sound (mo, CHAN_ITEM, smallsplash ?
splash->SmallSplashSound : splash->NormalSplashSound,
1, ATTN_IDLE);
}
else
{
S_SoundID (thing->x, thing->y, z, CHAN_ITEM, smallsplash ?
S_Sound (thing->x, thing->y, z, CHAN_ITEM, smallsplash ?
splash->SmallSplashSound : splash->NormalSplashSound,
1, ATTN_IDLE);
}
@ -4506,18 +4506,18 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner)
{
if (!(missile->flags & MF_SPAWNSOUNDSOURCE))
{
S_SoundID (missile, CHAN_VOICE, missile->SeeSound, 1, ATTN_NORM);
S_Sound (missile, CHAN_VOICE, missile->SeeSound, 1, ATTN_NORM);
}
else if (spawner != NULL)
{
S_SoundID (spawner, CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM);
S_Sound (spawner, CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM);
}
else
{
// If there is no spawner use the spawn position.
// But not in a silenced sector.
if (!(missile->Sector->Flags & SECF_SILENT))
S_SoundID (&missile->x, CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM);
S_Sound (&missile->x, CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM);
}
}
}
@ -4987,25 +4987,3 @@ void AActor::SetIdle()
if (idle == NULL) idle = SpawnState;
SetState(idle);
}
FArchive &operator<< (FArchive &arc, FSoundIndex &snd)
{
if (arc.IsStoring ())
{
arc.WriteName (snd.Index ? S_sfx[snd.Index].name.GetChars() : NULL);
}
else
{
const char *name = arc.ReadName ();
snd.Index = name != NULL ? S_FindSound (name) : 0;
}
return arc;
}
FArchive &operator<< (FArchive &arc, FSoundIndexWord &snd)
{
FSoundIndex snd2 = { snd.Index };
arc << snd2;
snd.Index = snd2.Index;
return arc;
}

View file

@ -190,9 +190,9 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed,
}
if (sector->seqType >= 0)
SN_StartSequence (sector, sector->seqType, SEQ_PLATFORM, 0, false);
SN_StartSequence (sector, CHAN_FLOOR, sector->seqType, SEQ_PLATFORM, 0);
else
SN_StartSequence (sector, "Floor", 0, false);
SN_StartSequence (sector, CHAN_FLOOR, "Floor", 0);
}
bool EV_DoPillar (DPillar::EPillar type, int tag, fixed_t speed, fixed_t height,

View file

@ -58,9 +58,9 @@ void DPlat::Serialize (FArchive &arc)
void DPlat::PlayPlatSound (const char *sound)
{
if (m_Sector->seqType >= 0)
SN_StartSequence (m_Sector, m_Sector->seqType, SEQ_PLATFORM, 0, false);
SN_StartSequence (m_Sector, CHAN_FLOOR, m_Sector->seqType, SEQ_PLATFORM, 0);
else
SN_StartSequence (m_Sector, sound, 0, false);
SN_StartSequence (m_Sector, CHAN_FLOOR, sound, 0);
}
//
@ -174,7 +174,7 @@ void DPlat::Tick ()
m_Status = down;
if (m_Type == platToggle)
SN_StartSequence (m_Sector, "Silence", 0, false);
SN_StartSequence (m_Sector, CHAN_FLOOR, "Silence", 0);
else
PlayPlatSound ("Platform");
}
@ -352,7 +352,7 @@ manual_plat:
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.d;
plat->m_Status = DPlat::down;
SN_StartSequence (sec, "Silence", 0, false);
SN_StartSequence (sec, CHAN_FLOOR, "Silence", 0);
break;
case DPlat::platDownToNearestFloor:

View file

@ -192,7 +192,7 @@ void P_BringUpWeapon (player_t *player)
{
if (weapon->UpSound)
{
S_SoundID (player->mo, CHAN_WEAPON, weapon->UpSound, 1, ATTN_NORM);
S_Sound (player->mo, CHAN_WEAPON, weapon->UpSound, 1, ATTN_NORM);
}
newstate = weapon->GetUpState ();
}
@ -391,7 +391,7 @@ void A_WeaponReady(AActor *actor)
{
if (!(weapon->WeaponFlags & WIF_READYSNDHALF) || pr_wpnreadysnd() < 128)
{
S_SoundID (actor, CHAN_WEAPON, weapon->ReadySound, 1, ATTN_NORM);
S_Sound (actor, CHAN_WEAPON, weapon->ReadySound, 1, ATTN_NORM);
}
}

View file

@ -695,3 +695,67 @@ void sector_t::SetFade(int r, int g, int b)
PalEntry fade = PalEntry (r,g,b);
ColorMap = GetSpecialLights (ColorMap->Color, fade, ColorMap->Desaturate);
}
//===========================================================================
//
// sector_t :: ClosestPoint
//
// Given a point (x,y), returns the point (ox,oy) on the sector's defining
// lines that is nearest to (x,y).
//
//===========================================================================
void sector_t::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy) const
{
int i;
double x = fx, y = fy;
double bestdist = HUGE_VAL;
double bestx = 0, besty = 0;
for (i = 0; i < linecount; ++i)
{
vertex_t *v1 = lines[i]->v1;
vertex_t *v2 = lines[i]->v2;
double a = v2->x - v1->x;
double b = v2->y - v1->y;
double den = a*a + b*b;
double ix, iy, dist;
if (den == 0)
{ // Line is actually a point!
ix = v1->x;
iy = v1->y;
}
else
{
double num = (x - v1->x) * a + (y - v1->y) * b;
double u = num / den;
if (u <= 0)
{
ix = v1->x;
iy = v1->y;
}
else if (u >= 1)
{
ix = v2->x;
iy = v2->y;
}
else
{
ix = v1->x + u * a;
iy = v1->y + u * b;
}
}
a = (ix - x);
b = (iy - y);
dist = a*a + b*b;
if (dist < bestdist)
{
bestdist = dist;
bestx = ix;
besty = iy;
}
}
ox = fixed_t(bestx);
oy = fixed_t(besty);
}

View file

@ -586,7 +586,7 @@ void P_PlayerOnSpecialFlat (player_t *player, int floorType)
}
if (Terrains[floorType].Splash != -1)
{
S_SoundID (player->mo, CHAN_AUTO,
S_Sound (player->mo, CHAN_AUTO,
Splashes[Terrains[floorType].Splash].NormalSplashSound, 1,
ATTN_IDLE);
}

View file

@ -80,8 +80,8 @@ struct FSwitchDef
{
int PreTexture; // texture to switch from
WORD PairIndex; // switch def to use to return to PreTexture
SWORD Sound; // sound to play at start of animation
WORD NumFrames; // # of animation frames
FSoundID Sound; // sound to play at start of animation
bool QuestPanel; // Special texture for Strife mission
struct frame // Array of times followed by array of textures
{ // actual length of each array is <NumFrames>
@ -323,9 +323,8 @@ FSwitchDef *ParseSwitchDef (FScanner &sc, bool ignoreBad)
FSwitchDef::frame thisframe;
int picnum;
bool bad;
SWORD sound;
FSoundID sound;
sound = 0;
bad = false;
while (sc.GetString ())
@ -337,7 +336,7 @@ FSwitchDef *ParseSwitchDef (FScanner &sc, bool ignoreBad)
sc.ScriptError ("Switch state already has a sound");
}
sc.MustGetString ();
sound = S_FindSound (sc.String);
sound = sc.String;
}
else if (sc.Compare ("pic"))
{
@ -584,12 +583,14 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques
pt[0] = line->v1->x + (line->dx >> 1);
pt[1] = line->v1->y + (line->dy >> 1);
pt[2] = 0;
side->SetTexture(texture, SwitchList[i]->u[0].Texture);
if (useAgain || SwitchList[i]->NumFrames > 1)
playsound = P_StartButton (side, texture, i, pt[0], pt[1], !!useAgain);
else
playsound = true;
if (playsound) S_SoundID (pt, CHAN_VOICE|CHAN_LISTENERZ|CHAN_IMMOBILE, sound, 1, ATTN_STATIC);
if (playsound)
S_Sound (pt, CHAN_VOICE|CHAN_LISTENERZ|CHAN_IMMOBILE, sound, 1, ATTN_STATIC);
if (quest != NULL)
{
*quest = SwitchList[i]->QuestPanel;
@ -656,9 +657,9 @@ void DActiveButton::Tick ()
m_Frame = 65535;
pt[0] = m_X;
pt[1] = m_Y;
S_SoundID (pt, CHAN_VOICE|CHAN_LISTENERZ|CHAN_IMMOBILE,
def->Sound != 0 ? def->Sound
: S_FindSound ("switches/normbutn"), 1, ATTN_STATIC);
S_Sound (pt, CHAN_VOICE|CHAN_LISTENERZ|CHAN_IMMOBILE,
def->Sound != 0 ? def->Sound : FSoundID("switches/normbutn"),
1, ATTN_STATIC);
bFlippable = false;
}
else

View file

@ -574,8 +574,7 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw
case GEN_Sound:
sc.MustGetString ();
val = S_FindSound (sc.String);
SET_FIELD (int, val);
SET_FIELD (FSoundID, FSoundID(sc.String));
if (val == 0)
{
Printf ("Unknown sound %s in %s %s\n",

View file

@ -38,6 +38,7 @@
#include "m_fixed.h"
#include "tarray.h"
#include "name.h"
#include "s_sound.h"
extern TArray<BYTE> TerrainTypes;
@ -47,8 +48,8 @@ void P_InitTerrainTypes ();
struct FSplashDef
{
FName Name;
int SmallSplashSound;
int NormalSplashSound;
FSoundID SmallSplashSound;
FSoundID NormalSplashSound;
const PClass *SmallSplash;
const PClass *SplashBase;
const PClass *SplashChunk;
@ -71,8 +72,8 @@ struct FTerrainDef
float StepVolume;
int WalkStepTics;
int RunStepTics;
int LeftStepSound;
int RightStepSound;
FSoundID LeftStepSound;
FSoundID RightStepSound;
bool IsLiquid;
bool AllowProtection;
fixed_t Friction;

View file

@ -607,7 +607,7 @@ bool APlayerPawn::UseInventory (AInventory *item)
}
if (player == &players[consoleplayer])
{
S_SoundID (this, CHAN_ITEM, item->UseSound, 1, ATTN_NORM);
S_Sound (this, CHAN_ITEM, item->UseSound, 1, ATTN_NORM);
StatusBar->FlashItem (itemtype);
}
return true;
@ -1193,7 +1193,7 @@ void A_PlayerScream (AActor *self)
if (self->player == NULL || self->DeathSound != 0)
{
S_SoundID (self, CHAN_VOICE, self->DeathSound, 1, ATTN_NORM);
S_Sound (self, CHAN_VOICE, self->DeathSound, 1, ATTN_NORM);
return;
}
@ -1242,7 +1242,7 @@ void A_PlayerScream (AActor *self)
}
}
}
S_SoundID (self, chan, sound, 1, ATTN_NORM);
S_Sound (self, chan, sound, 1, ATTN_NORM);
}
@ -2185,7 +2185,7 @@ void P_PlayerThink (player_t *player)
int id = S_FindSkinnedSound (player->mo, "*falling");
if (id != 0 && !S_IsActorPlayingSomething (player->mo, CHAN_VOICE, id))
{
S_SoundID (player->mo, CHAN_VOICE, id, 1, ATTN_NORM);
S_Sound (player->mo, CHAN_VOICE, id, 1, ATTN_NORM);
}
}
// check for use

View file

@ -357,6 +357,7 @@ struct sector_t
void AdjustFloorClip () const;
void SetColor(int r, int g, int b, int desat);
void SetFade(int r, int g, int b);
void ClosestPoint(fixed_t x, fixed_t y, fixed_t &ox, fixed_t &oy) const;
DInterpolation *SetInterpolation(int position, bool attach);
void StopInterpolation(int position);

View file

@ -420,7 +420,7 @@ static int STACK_ARGS skinsorter (const void *a, const void *b)
void R_InitSkins (void)
{
WORD playersoundrefs[NUMSKINSOUNDS];
FSoundID playersoundrefs[NUMSKINSOUNDS];
spritedef_t temp;
int sndlumps[NUMSKINSOUNDS];
char key[65];
@ -438,7 +438,7 @@ void R_InitSkins (void)
for (j = 0; j < NUMSKINSOUNDS; ++j)
{
playersoundrefs[j] = S_FindSound (skinsoundnames[j][1]);
playersoundrefs[j] = skinsoundnames[j][1];
}
while ((base = Wads.FindLump ("S_SKIN", &lastlump, true)) != -1)

View file

@ -186,8 +186,8 @@ MidiDeviceMap MidiDevices;
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void S_StartNamedSound (AActor *ent, fixed_t *pt, int channel,
const char *name, float volume, float attenuation);
FSoundChan *S_StartSound (fixed_t *pt, AActor *mover, sector_t *sec, int channel,
FSoundID sound_id, float volume, float attenuation);
extern bool IsFloat (const char *str);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@ -201,7 +201,7 @@ static void S_RestorePlayerSounds();
static int S_AddPlayerClass (const char *name);
static int S_AddPlayerGender (int classnum, int gender);
static int S_FindPlayerClass (const char *name);
static int S_LookupPlayerSound (int classidx, int gender, int refid);
static int S_LookupPlayerSound (int classidx, int gender, FSoundID refid);
static void S_ParsePlayerSoundCommon (FScanner &sc, FString &pclass, int &gender, int &refid);
static void S_AddSNDINFO (int lumpnum);
static void S_AddBloodSFX (int lumpnum);
@ -1534,7 +1534,7 @@ int S_LookupPlayerSound (const char *pclass, int gender, const char *name)
return refid;
}
int S_LookupPlayerSound (const char *pclass, int gender, int refid)
int S_LookupPlayerSound (const char *pclass, int gender, FSoundID refid)
{
if (!S_sfx[refid].bPlayerReserve)
{ // Not a player sound, so just return this sound
@ -1544,7 +1544,7 @@ int S_LookupPlayerSound (const char *pclass, int gender, int refid)
return S_LookupPlayerSound (S_FindPlayerClass (pclass), gender, refid);
}
static int S_LookupPlayerSound (int classidx, int gender, int refid)
static int S_LookupPlayerSound (int classidx, int gender, FSoundID refid)
{
int ingender = gender;
@ -1695,12 +1695,7 @@ bool S_AreSoundsEquivalent (AActor *actor, int id1, int id2)
// Calls S_LookupPlayerSound, deducing the class and gender from actor.
//==========================================================================
int S_FindSkinnedSound (AActor *actor, const char *name)
{
return S_FindSkinnedSound (actor, S_FindSound (name));
}
int S_FindSkinnedSound (AActor *actor, int refid)
int S_FindSkinnedSound (AActor *actor, FSoundID refid)
{
const char *pclass;
int gender = GENDER_MALE;
@ -1728,17 +1723,17 @@ int S_FindSkinnedSound (AActor *actor, int refid)
int S_FindSkinnedSoundEx (AActor *actor, const char *name, const char *extendedname)
{
FString fullname;
int id;
FSoundID id;
// Look for "name-extendedname";
fullname = name;
fullname += '-';
fullname += extendedname;
id = S_FindSound (fullname);
id = fullname;
if (id == 0)
{ // Look for "name"
id = S_FindSound (name);
id = name;
}
return S_FindSkinnedSound (actor, id);
}
@ -1885,7 +1880,7 @@ void AAmbientSound::Tick ()
if (ambient->sound[0])
{
S_StartNamedSound (this, NULL, CHAN_BODY|CHAN_LOOP, ambient->sound,
S_StartSound (NULL, this, NULL, CHAN_BODY|CHAN_LOOP, ambient->sound,
ambient->volume, ambient->attenuation);
SetTicker (ambient);
}
@ -1898,7 +1893,7 @@ void AAmbientSound::Tick ()
{
if (ambient->sound[0])
{
S_StartNamedSound (this, NULL, CHAN_BODY, ambient->sound,
S_StartSound (NULL, this, NULL, CHAN_BODY, ambient->sound,
ambient->volume, ambient->attenuation);
SetTicker (ambient);
}

View file

@ -96,32 +96,56 @@ typedef struct {
class DSeqActorNode : public DSeqNode
{
DECLARE_CLASS (DSeqActorNode, DSeqNode)
DECLARE_CLASS(DSeqActorNode, DSeqNode)
HAS_OBJECT_POINTERS
public:
DSeqActorNode (AActor *actor, int sequence, int modenum);
void Destroy ();
void Serialize (FArchive &arc);
void MakeSound (int loop) { S_SoundID (m_Actor, CHAN_BODY|loop, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); }
bool IsPlaying () { return S_IsActorPlayingSomething (m_Actor, CHAN_BODY, m_CurrentSoundID); }
void *Source () { return m_Actor; }
DSeqNode *SpawnChild (int seqnum) { return SN_StartSequence (m_Actor, seqnum, SEQ_NOTRANS, m_ModeNum, true); }
DSeqActorNode(AActor *actor, int sequence, int modenum);
void Destroy();
void Serialize(FArchive &arc);
void MakeSound(int loop, FSoundID id)
{
S_Sound(m_Actor, CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten);
}
bool IsPlaying()
{
return S_IsActorPlayingSomething (m_Actor, CHAN_BODY, m_CurrentSoundID);
}
void *Source()
{
return m_Actor;
}
DSeqNode *SpawnChild(int seqnum)
{
return SN_StartSequence (m_Actor, seqnum, SEQ_NOTRANS, m_ModeNum, true);
}
private:
DSeqActorNode () {}
DSeqActorNode() {}
TObjPtr<AActor> m_Actor;
};
class DSeqPolyNode : public DSeqNode
{
DECLARE_CLASS (DSeqPolyNode, DSeqNode)
DECLARE_CLASS(DSeqPolyNode, DSeqNode)
public:
DSeqPolyNode (FPolyObj *poly, int sequence, int modenum);
void Destroy ();
void Serialize (FArchive &arc);
void MakeSound (int loop) { S_SoundID (&m_Poly->startSpot[0], CHAN_BODY|loop, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); }
bool IsPlaying () { return S_GetSoundPlayingInfo (&m_Poly->startSpot[0], m_CurrentSoundID); }
void *Source () { return m_Poly; }
DSeqNode *SpawnChild (int seqnum) { return SN_StartSequence (m_Poly, seqnum, SEQ_NOTRANS, m_ModeNum, true); }
DSeqPolyNode(FPolyObj *poly, int sequence, int modenum);
void Destroy();
void Serialize(FArchive &arc);
void MakeSound(int loop, FSoundID id)
{
S_Sound (&m_Poly->startSpot[0], CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten);
}
bool IsPlaying()
{
return S_GetSoundPlayingInfo (&m_Poly->startSpot[0], m_CurrentSoundID);
}
void *Source()
{
return m_Poly;
}
DSeqNode *SpawnChild (int seqnum)
{
return SN_StartSequence (m_Poly, seqnum, SEQ_NOTRANS, m_ModeNum, true);
}
private:
DSeqPolyNode () {}
FPolyObj *m_Poly;
@ -129,20 +153,32 @@ private:
class DSeqSectorNode : public DSeqNode
{
DECLARE_CLASS (DSeqSectorNode, DSeqNode)
DECLARE_CLASS(DSeqSectorNode, DSeqNode)
public:
DSeqSectorNode (sector_t *sec, int sequence, int modenum, bool is_door);
void Destroy ();
void Serialize (FArchive &arc);
void MakeSound (int loop) { S_SoundID (&m_Sector->soundorg[0], CHAN_BODY|(m_IsDoor ? 0 : CHAN_AREA)|loop, m_CurrentSoundID, clamp(m_Volume, 0.f, 1.f), m_Atten); Looping = !!loop; }
bool IsPlaying () { return S_GetSoundPlayingInfo (m_Sector->soundorg, m_CurrentSoundID); }
void *Source () { return m_Sector; }
DSeqNode *SpawnChild (int seqnum) { return SN_StartSequence (m_Sector, seqnum, SEQ_NOTRANS, m_ModeNum, true); }
bool Looping;
DSeqSectorNode(sector_t *sec, int chan, int sequence, int modenum);
void Destroy();
void Serialize(FArchive &arc);
void MakeSound(int loop, FSoundID id)
{
Channel = (Channel & 7) | CHAN_AREA | loop;
S_Sound(m_Sector, Channel, id, clamp(m_Volume, 0.f, 1.f), m_Atten);
}
bool IsPlaying()
{
return S_GetSoundPlayingInfo (m_Sector->soundorg, m_CurrentSoundID);
}
void *Source()
{
return m_Sector;
}
DSeqNode *SpawnChild(int seqnum)
{
return SN_StartSequence (m_Sector, Channel, seqnum, SEQ_NOTRANS, m_ModeNum, true);
}
int Channel;
private:
DSeqSectorNode() {}
sector_t *m_Sector;
bool m_IsDoor;
};
// When destroyed, destroy the sound sequences too.
@ -152,7 +188,7 @@ struct FSoundSequencePtrArray : public TArray<FSoundSequence *>
{
for (unsigned int i = 0; i < Size(); ++i)
{
M_Free ((*this)[i]);
M_Free((*this)[i]);
}
}
};
@ -161,7 +197,7 @@ struct FSoundSequencePtrArray : public TArray<FSoundSequence *>
static void AssignTranslations (FScanner &sc, int seq, seqtype_t type);
static void AssignHexenTranslations (void);
static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray<DWORD> &ScriptTemp, bool bDoorSound);
static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray<DWORD> &ScriptTemp);
static int FindSequence (const char *searchname);
static int FindSequence (FName seqname);
static bool TwiddleSeqNum (int &sequence, seqtype_t type);
@ -271,7 +307,7 @@ void DSeqNode::Serialize (FArchive &arc)
<< m_Prev
<< m_ChildSeqNode
<< m_ParentSeqNode
<< AR_SOUND(m_CurrentSoundID)
<< m_CurrentSoundID
<< Sequences[m_Sequence]->SeqName;
arc.WriteCount (m_SequenceChoices.Size());
@ -283,7 +319,8 @@ void DSeqNode::Serialize (FArchive &arc)
else
{
FName seqName;
int delayTics = 0, id;
int delayTics = 0;
FSoundID id;
float volume;
int atten = ATTN_NORM;
int seqnum;
@ -298,7 +335,7 @@ void DSeqNode::Serialize (FArchive &arc)
<< m_Prev
<< m_ChildSeqNode
<< m_ParentSeqNode
<< AR_SOUND(id)
<< id
<< seqName;
seqnum = FindSequence (seqName);
@ -398,7 +435,7 @@ IMPLEMENT_CLASS (DSeqSectorNode)
void DSeqSectorNode::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << m_Sector << Looping << m_IsDoor;
arc << m_Sector << Channel;
}
//==========================================================================
@ -448,7 +485,6 @@ static void AssignHexenTranslations (void)
if (HexenSequences[i].Seqs[j] & 0x40)
{
trans = 64 * SEQ_DOOR;
Sequences[seq]->bDoorSound |= true;
}
else if (HexenSequences[i].Seqs[j] & 0x80)
trans = 64 * SEQ_ENVIRONMENT;
@ -505,8 +541,6 @@ void S_ParseSndSeq (int levellump)
FScanner sc(lump);
while (sc.GetString ())
{
bool bDoorSound = false;
if (*sc.String == ':' || *sc.String == '[')
{
if (curseq != -1)
@ -531,7 +565,6 @@ void S_ParseSndSeq (int levellump)
ScriptTemp.Clear();
stopsound = 0;
slot = NAME_None;
bDoorSound = false;
if (seqtype == '[')
{
sc.SetCMode (true);
@ -548,7 +581,7 @@ void S_ParseSndSeq (int levellump)
if (sc.String[0] == ']')
{ // End of this definition
ScriptTemp[0] = MakeCommand(SS_CMD_SELECT, (ScriptTemp.Size()-1)/2);
AddSequence (curseq, seqname, slot, stopsound, ScriptTemp, bDoorSound);
AddSequence (curseq, seqname, slot, stopsound, ScriptTemp);
curseq = -1;
sc.SetCMode (false);
}
@ -565,7 +598,6 @@ void S_ParseSndSeq (int levellump)
{
seqtype_t seqtype = seqtype_t(sc.MustMatchString (SSStrings + SS_STRING_PLATFORM));
AssignTranslations (sc, curseq, seqtype);
if (seqtype == SEQ_DOOR) bDoorSound = true;
}
}
continue;
@ -664,7 +696,7 @@ void S_ParseSndSeq (int levellump)
break;
case SS_STRING_END:
AddSequence (curseq, seqname, slot, stopsound, ScriptTemp, bDoorSound);
AddSequence (curseq, seqname, slot, stopsound, ScriptTemp);
curseq = -1;
break;
@ -674,7 +706,6 @@ void S_ParseSndSeq (int levellump)
case SS_STRING_DOOR:
AssignTranslations (sc, curseq, SEQ_DOOR);
bDoorSound = true;
break;
case SS_STRING_ENVIRONMENT:
@ -697,13 +728,12 @@ void S_ParseSndSeq (int levellump)
AssignHexenTranslations ();
}
static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray<DWORD> &ScriptTemp, bool bDoorSound)
static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray<DWORD> &ScriptTemp)
{
Sequences[curseq] = (FSoundSequence *)M_Malloc (sizeof(FSoundSequence) + sizeof(DWORD)*ScriptTemp.Size());
Sequences[curseq]->SeqName = seqname;
Sequences[curseq]->Slot = slot;
Sequences[curseq]->StopSound = stopsound;
Sequences[curseq]->bDoorSound = bDoorSound;
memcpy (Sequences[curseq]->Script, &ScriptTemp[0], sizeof(DWORD)*ScriptTemp.Size());
Sequences[curseq]->Script[ScriptTemp.Size()] = MakeCommand(SS_CMD_END, 0);
}
@ -753,12 +783,11 @@ DSeqPolyNode::DSeqPolyNode (FPolyObj *poly, int sequence, int modenum)
{
}
DSeqSectorNode::DSeqSectorNode (sector_t *sec, int sequence, int modenum, bool is_door)
DSeqSectorNode::DSeqSectorNode (sector_t *sec, int chan, int sequence, int modenum)
: DSeqNode (sequence, modenum),
Looping (false),
Channel (chan),
m_Sector (sec)
{
m_IsDoor = is_door;
}
//==========================================================================
@ -802,7 +831,7 @@ DSeqNode *SN_StartSequence (AActor *actor, int sequence, seqtype_t type, int mod
return NULL;
}
DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int modenum, bool is_door, bool nostop)
DSeqNode *SN_StartSequence (sector_t *sector, int chan, int sequence, seqtype_t type, int modenum, bool nostop)
{
if (!nostop)
{
@ -810,7 +839,7 @@ DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int
}
if (TwiddleSeqNum (sequence, type))
{
return new DSeqSectorNode (sector, sequence, modenum, is_door);
return new DSeqSectorNode (sector, chan, sequence, modenum);
}
return NULL;
}
@ -854,12 +883,12 @@ DSeqNode *SN_StartSequence (AActor *actor, FName seqname, int modenum)
return NULL;
}
DSeqNode *SN_StartSequence (sector_t *sec, const char *seqname, int modenum, bool is_door)
DSeqNode *SN_StartSequence (sector_t *sec, int chan, const char *seqname, int modenum)
{
int seqnum = FindSequence (seqname);
if (seqnum >= 0)
{
return SN_StartSequence (sec, seqnum, SEQ_NOTRANS, modenum, is_door);
return SN_StartSequence (sec, chan, seqnum, SEQ_NOTRANS, modenum);
}
return NULL;
}
@ -940,16 +969,16 @@ void DSeqActorNode::Destroy ()
if (m_StopSound >= 0)
S_StopSound (m_Actor, CHAN_BODY);
if (m_StopSound >= 1)
S_SoundID (m_Actor, CHAN_BODY, m_StopSound, m_Volume, m_Atten);
MakeSound (0, m_StopSound);
Super::Destroy();
}
void DSeqSectorNode::Destroy ()
{
if (m_StopSound >= 0)
S_StopSound (m_Sector->soundorg, CHAN_BODY);
S_StopSound (m_Sector->soundorg, Channel & 7);
if (m_StopSound >= 1)
S_SoundID (m_Sector->soundorg, CHAN_BODY, m_StopSound, m_Volume, m_Atten);
MakeSound (0, m_StopSound);
Super::Destroy();
}
@ -958,7 +987,7 @@ void DSeqPolyNode::Destroy ()
if (m_StopSound >= 0)
S_StopSound (m_Poly->startSpot, CHAN_BODY);
if (m_StopSound >= 1)
S_SoundID (m_Poly->startSpot, CHAN_BODY, m_StopSound, m_Volume, m_Atten);
MakeSound (0, m_StopSound);
Super::Destroy();
}
@ -977,7 +1006,7 @@ bool SN_IsMakingLoopingSound (sector_t *sector)
DSeqNode *next = node->NextSequence();
if (node->Source() == (void *)sector)
{
return static_cast<DSeqSectorNode *> (node)->Looping;
return !!(static_cast<DSeqSectorNode *>(node)->Channel & CHAN_LOOP);
}
node = next;
}
@ -1007,8 +1036,8 @@ void DSeqNode::Tick ()
case SS_CMD_PLAY:
if (!IsPlaying())
{
m_CurrentSoundID = GetData(*m_SequencePtr);
MakeSound (0);
m_CurrentSoundID = FSoundID(GetData(*m_SequencePtr));
MakeSound (0, m_CurrentSoundID);
}
m_SequencePtr++;
break;
@ -1029,16 +1058,16 @@ void DSeqNode::Tick ()
if (!IsPlaying())
{
// Does not advance sequencePtr, so it will repeat as necessary.
m_CurrentSoundID = GetData(*m_SequencePtr);
MakeSound (CHAN_LOOP);
m_CurrentSoundID = FSoundID(GetData(*m_SequencePtr));
MakeSound (CHAN_LOOP, m_CurrentSoundID);
}
return;
case SS_CMD_PLAYLOOP:
// Like SS_CMD_PLAYREPEAT, sequencePtr is not advanced, so this
// command will repeat until the sequence is stopped.
m_CurrentSoundID = GetData(m_SequencePtr[0]);
MakeSound (0);
m_CurrentSoundID = FSoundID(GetData(m_SequencePtr[0]));
MakeSound (0, m_CurrentSoundID);
m_DelayUntilTic = TIME_REFERENCE + m_SequencePtr[1];
return;
@ -1246,7 +1275,7 @@ void SN_ChangeNodeData (int nodeNum, int seqOffset, int delayTics, float volume,
node->ChangeData (seqOffset, delayTics, volume, currentSoundID);
}
void DSeqNode::ChangeData (int seqOffset, int delayTics, float volume, int currentSoundID)
void DSeqNode::ChangeData (int seqOffset, int delayTics, float volume, FSoundID currentSoundID)
{
m_DelayUntilTic = TIME_REFERENCE + delayTics;
m_Volume = volume;

View file

@ -26,12 +26,12 @@ public:
void StopAndDestroy ();
void Destroy ();
void Tick ();
void ChangeData (int seqOffset, int delayTics, float volume, int currentSoundID);
void ChangeData (int seqOffset, int delayTics, float volume, FSoundID currentSoundID);
void AddChoice (int seqnum, seqtype_t type);
FName GetSequenceName() const;
static void StaticMarkHead() { GC::Mark(SequenceListHead); }
virtual void MakeSound (int loop) {}
virtual void MakeSound (int loop, FSoundID id) {}
virtual void *Source () { return NULL; }
virtual bool IsPlaying () { return false; }
virtual DSeqNode *SpawnChild (int seqnum) { return NULL; }
@ -48,10 +48,10 @@ protected:
SDWORD *m_SequencePtr;
int m_Sequence;
int m_CurrentSoundID;
FSoundID m_CurrentSoundID;
int m_StopSound;
int m_DelayUntilTic;
float m_Volume;
int m_StopSound;
int m_Atten;
int m_ModeNum;
@ -75,7 +75,6 @@ struct FSoundSequence
FName SeqName;
FName Slot;
int StopSound;
bool bDoorSound;
SDWORD Script[1]; // + more until end of sequence script
};
@ -83,8 +82,8 @@ void S_ParseSndSeq (int levellump);
DSeqNode *SN_StartSequence (AActor *mobj, int sequence, seqtype_t type, int modenum, bool nostop=false);
DSeqNode *SN_StartSequence (AActor *mobj, const char *name, int modenum);
DSeqNode *SN_StartSequence (AActor *mobj, FName seqname, int modenum);
DSeqNode *SN_StartSequence (sector_t *sector, int sequence, seqtype_t type, int modenum, bool full3d, bool nostop=false);
DSeqNode *SN_StartSequence (sector_t *sector, const char *name, int modenum, bool full3d);
DSeqNode *SN_StartSequence (sector_t *sector, int chan, int sequence, seqtype_t type, int modenum, bool nostop=false);
DSeqNode *SN_StartSequence (sector_t *sector, int chan, const char *name, int modenum);
DSeqNode *SN_StartSequence (FPolyObj *poly, int sequence, seqtype_t type, int modenum, bool nostop=false);
DSeqNode *SN_StartSequence (FPolyObj *poly, const char *name, int modenum);
void SN_StopSequence (AActor *mobj);

View file

@ -91,11 +91,12 @@ extern float S_GetMusicVolume (const char *music);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
FSoundChan *S_StartSound(fixed_t *pt, AActor *mover, sector_t *sec, int channel,
FSoundID sound_id, float volume, float attenuation);
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static fixed_t P_AproxDistance2(fixed_t *listener, fixed_t x, fixed_t y);
static void S_StartSound(fixed_t *pt, AActor *mover, int channel,
int sound_id, float volume, float attenuation);
static bool S_CheckSoundLimit(sfxinfo_t *sfx, float pos[3], int NearLimit);
static void S_ActivatePlayList(bool goBack);
static void CalcPosVel(fixed_t *pt, AActor *mover, int constz, float pos[3],
@ -637,8 +638,8 @@ void CalcPosVel (fixed_t *pt, AActor *mover, int constz,
// calculating volume
//==========================================================================
static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
int sound_id, float volume, float attenuation)
FSoundChan *S_StartSound (fixed_t *pt, AActor *mover, sector_t *sec, int channel,
FSoundID sound_id, float volume, float attenuation)
{
sfxinfo_t *sfx;
int chanflags;
@ -651,7 +652,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
float vel[3];
if (sound_id <= 0 || volume <= 0 || GSnd == NULL)
return;
return NULL;
org_id = sound_id;
chanflags = channel & ~7;
@ -686,7 +687,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
{
if (mover != NULL && mover != players[consoleplayer].camera)
{
return;
return NULL;
}
}
channel &= 7;
@ -697,7 +698,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
// Scale volume according to SNDINFO data.
volume = MIN(volume * sfx->Volume, 1.f);
if (volume <= 0)
return;
return NULL;
// When resolving a link we do not want to get the NearLimit of
// the referenced sound so some additional checks are required
@ -708,17 +709,17 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
{
if (sfx->bPlayerReserve)
{
sound_id = S_FindSkinnedSound (mover, sound_id);
sound_id = FSoundID(S_FindSkinnedSound (mover, sound_id));
NearLimit = S_sfx[sound_id].NearLimit;
}
else if (sfx->bRandomHeader)
{
sound_id = S_PickReplacement (sound_id);
sound_id = FSoundID(S_PickReplacement (sound_id));
if (NearLimit < 0) NearLimit = S_sfx[sound_id].NearLimit;
}
else
{
sound_id = sfx->link;
sound_id = FSoundID(sfx->link);
if (NearLimit < 0) NearLimit = S_sfx[sound_id].NearLimit;
}
sfx = &S_sfx[sound_id];
@ -726,13 +727,13 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
// If this is a singular sound, don't play it if it's already playing.
if (sfx->bSingular && S_CheckSingular(sound_id))
return;
return NULL;
// If this sound doesn't like playing near itself, don't play it if
// that's what would happen.
if (NearLimit > 0 && pt != NULL && mover != players[consoleplayer].camera &&
S_CheckSoundLimit(sfx, pos, NearLimit))
return;
return NULL;
// Make sure the sound is loaded.
if (sfx->data == NULL)
@ -747,7 +748,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
// The empty sound never plays.
if (sfx->lumpnum == sfx_empty)
{
return;
return NULL;
}
// Select priority.
@ -780,7 +781,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
}
if (channel == 0)
{ // Crap. No free channels.
return;
return NULL;
}
}
}
@ -810,7 +811,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
if (attenuation > 0)
{
chan = GSnd->StartSound3D (sfx, volume, attenuation, pitch, basepriority, pos, vel, chanflags);
chan = GSnd->StartSound3D (sfx, volume, attenuation, pitch, basepriority, pos, vel, sec, channel, chanflags);
chanflags |= CHAN_IS3D;
}
else
@ -824,6 +825,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
chan->OrgID = org_id;
chan->Mover = mover;
chan->Pt = pt != NULL ? pt : &chan->X;
chan->Sector = sec;
chan->SfxInfo = sfx;
chan->EntChannel = channel;
chan->Volume = volume;
@ -836,94 +838,68 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
mover->SoundChans |= 1 << channel;
}
}
return chan;
}
//==========================================================================
//
// S_SoundID
// S_Sound - Unpositioned version
//
//==========================================================================
void S_SoundID (int channel, int sound_id, float volume, int attenuation)
void S_Sound (int channel, FSoundID sound_id, float volume, int attenuation)
{
S_StartSound ((fixed_t *)NULL, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation));
S_StartSound ((fixed_t *)NULL, NULL, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation));
}
void S_SoundID (AActor *ent, int channel, int sound_id, float volume, int attenuation)
//==========================================================================
//
// S_Sound - Actor is source
//
//==========================================================================
void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, int attenuation)
{
if (ent->Sector->Flags & SECF_SILENT)
return;
S_StartSound (&ent->x, ent, channel, sound_id, volume, SELECT_ATTEN(attenuation));
S_StartSound (&ent->x, ent, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation));
}
void S_SoundID (fixed_t *pt, int channel, int sound_id, float volume, int attenuation)
//==========================================================================
//
// S_Sound - A random coordinate is source
//
//==========================================================================
void S_Sound (fixed_t *pt, int channel, FSoundID sound_id, float volume, int attenuation)
{
S_StartSound (pt, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation));
S_StartSound (pt, NULL, NULL, channel, sound_id, volume, SELECT_ATTEN(attenuation));
}
void S_SoundID (fixed_t x, fixed_t y, fixed_t z, int channel, int sound_id, float volume, int attenuation)
//==========================================================================
//
// S_Sound - A point is source
//
//==========================================================================
void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sound_id, float volume, int attenuation)
{
fixed_t pt[3];
pt[0] = x;
pt[1] = y;
pt[2] = z;
S_StartSound (pt, NULL, channel|CHAN_IMMOBILE, sound_id, volume, SELECT_ATTEN(attenuation));
S_StartSound (pt, NULL, NULL, channel|CHAN_IMMOBILE, sound_id, volume, SELECT_ATTEN(attenuation));
}
//==========================================================================
//
// S_StartNamedSound
// S_Sound - An entire sector is source
//
//==========================================================================
void S_StartNamedSound (AActor *ent, fixed_t *pt, int channel,
const char *name, float volume, float attenuation)
void S_Sound (sector_t *sec, int channel, FSoundID sfxid, float volume, int attenuation)
{
int sfx_id;
if (name == NULL || (ent != NULL && ent->Sector->Flags & SECF_SILENT))
{
return;
}
sfx_id = S_FindSound (name);
if (sfx_id == 0)
DPrintf ("Unknown sound %s\n", name);
if (ent)
S_StartSound (&ent->x, ent, channel, sfx_id, volume, attenuation);
else
S_StartSound (pt, NULL, channel, sfx_id, volume, attenuation);
}
//==========================================================================
//
// S_Sound
//
//==========================================================================
void S_Sound (int channel, const char *name, float volume, int attenuation)
{
S_StartNamedSound ((AActor *)NULL, NULL, channel, name, volume, SELECT_ATTEN(attenuation));
}
void S_Sound (AActor *ent, int channel, const char *name, float volume, int attenuation)
{
S_StartNamedSound (ent, NULL, channel, name, volume, SELECT_ATTEN(attenuation));
}
void S_Sound (fixed_t *pt, int channel, const char *name, float volume, int attenuation)
{
S_StartNamedSound (NULL, pt, channel, name, volume, SELECT_ATTEN(attenuation));
}
void S_Sound (fixed_t x, fixed_t y, int channel, const char *name, float volume, int attenuation)
{
fixed_t pt[3];
pt[0] = x;
pt[1] = y;
S_StartNamedSound (NULL, pt, channel|CHAN_LISTENERZ|CHAN_IMMOBILE,
name, volume, SELECT_ATTEN(attenuation));
S_StartSound (sec->soundorg, NULL, sec, channel, sfxid, volume, attenuation);
}
//==========================================================================
@ -1200,6 +1176,26 @@ void S_UpdateSounds (void *listener_p)
GSnd->UpdateSounds();
}
//==========================================================================
//
// FArchive & << FSoundID &
//
//==========================================================================
FArchive &operator<<(FArchive &arc, FSoundID &sid)
{
if (arc.IsStoring())
{
arc.WriteName((const char *)sid);
}
else
{
sid = arc.ReadName();
}
return arc;
}
//==========================================================================
//
// S_ActivatePlayList
@ -1800,8 +1796,8 @@ CCMD (cachesound)
}
for (int i = 1; i < argv.argc(); ++i)
{
int sfxnum = S_FindSound (argv[i]);
if (sfxnum > 0)
FSoundID sfxnum = argv[i];
if (sfxnum != 0)
{
S_CacheSound (&S_sfx[sfxnum]);
}

View file

@ -74,9 +74,90 @@ enum
ROLLOFF_Custom // Lookup volume from SNDCURVE
};
int S_FindSound (const char *logicalname);
// the complete set of sound effects
extern TArray<sfxinfo_t> S_sfx;
// An index into the S_sfx[] array.
class FSoundID
{
public:
FSoundID()
{
ID = 0;
}
FSoundID(int id)
{
ID = id;
}
FSoundID(const char *name)
{
ID = S_FindSound(name);
}
FSoundID(const FString &name)
{
ID = S_FindSound(name);
}
FSoundID(const FSoundID &other)
{
ID = other.ID;
}
FSoundID &operator=(const FSoundID &other)
{
ID = other.ID;
return *this;
}
FSoundID &operator=(const char *name)
{
ID = S_FindSound(name);
return *this;
}
FSoundID &operator=(const FString &name)
{
ID = S_FindSound(name);
return *this;
}
operator int() const
{
return ID;
}
operator FString() const
{
return ID ? S_sfx[ID].name : "";
}
operator const char *() const
{
return ID ? S_sfx[ID].name.GetChars() : NULL;
}
private:
int ID;
protected:
enum EDummy { NoInit };
FSoundID(EDummy) {}
};
class FSoundIDNoInit : public FSoundID
{
public:
FSoundIDNoInit() : FSoundID(NoInit) {}
FSoundID &operator=(const FSoundID &other)
{
return FSoundID::operator=(other);
}
FSoundID &operator=(const char *name)
{
return FSoundID::operator=(name);
}
FSoundID &operator=(const FString &name)
{
return FSoundID::operator=(name);
}
};
FArchive &operator<<(FArchive &arc, FSoundID &sid);
// Default rolloff information.
extern int S_RolloffType;
extern float S_MinDistance;
@ -85,12 +166,14 @@ extern BYTE *S_SoundCurve;
extern int S_SoundCurveSize;
// Information about one playing sound.
struct sector_t;
struct FSoundChan
{
void *SysChannel;// Channel information from the system interface.
FSoundChan *NextChan; // Next channel in this list.
FSoundChan **PrevChan; // Previous channel in this list.
AActor *Mover; // Used for velocity.
sector_t *Sector; // Sector for area sounds.
fixed_t *Pt; // Origin of sound.
sfxinfo_t *SfxInfo; // Sound information.
fixed_t X,Y,Z; // Origin if Mover is NULL.
@ -129,14 +212,11 @@ void S_PrecacheLevel ();
void S_CacheSound (sfxinfo_t *sfx);
// Start sound for thing at <ent>
void S_Sound (int channel, const char *name, float volume, int attenuation);
void S_Sound (AActor *ent, int channel, const char *name, float volume, int attenuation);
void S_Sound (fixed_t *pt, int channel, const char *name, float volume, int attenuation);
//void S_Sound (fixed_t x, fixed_t y, int channel, const char *name, float volume, int attenuation);
void S_SoundID (int channel, int sfxid, float volume, int attenuation);
void S_SoundID (AActor *ent, int channel, int sfxid, float volume, int attenuation);
void S_SoundID (fixed_t *pt, int channel, int sfxid, float volume, int attenuation);
void S_SoundID (fixed_t x, fixed_t y, fixed_t z, int channel, int sfxid, float volume, int attenuation);
void S_Sound (int channel, FSoundID sfxid, float volume, int attenuation);
void S_Sound (AActor *ent, int channel, FSoundID sfxid, float volume, int attenuation);
void S_Sound (fixed_t *pt, int channel, FSoundID sfxid, float volume, int attenuation);
void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sfxid, float volume, int attenuation);
void S_Sound (sector_t *sec, int channel, FSoundID sfxid, float volume, int attenuation);
// sound channels
// channel 0 never willingly overrides
@ -159,9 +239,16 @@ void S_SoundID (fixed_t x, fixed_t y, fixed_t z, int channel, int sfxid, float v
#define CHAN_IMMOBILE 16
#define CHAN_MAYBE_LOCAL 32
#define CHAN_NOPAUSE 64 // do not pause this sound in menus
#define CHAN_AREA 128 // Sound plays from all around within MinDistance
#define CHAN_AREA 128 // Sound plays from all around. Only valid with sector sounds.
#define CHAN_LOOP 256
#define CHAN_IS3D 1 // internal flag
// Channel alias for sector sounds. These define how listener height is
// used when calculating 3D sound volume.
#define CHAN_FLOOR 1 // Sound comes from the floor.
#define CHAN_CEILING 2 // Sound comes from the ceiling.
#define CHAN_FULLHEIGHT 3 // Sound comes entire height of the sector.
#define CHAN_IS3D (1<<24) // internal flag
#define CHAN_PICKUP (CHAN_ITEM|CHAN_MAYBE_LOCAL)
@ -223,15 +310,13 @@ void S_ParseReverbDef ();
void S_UnloadReverbDef ();
void S_HashSounds ();
int S_FindSound (const char *logicalname);
int S_FindSoundNoHash (const char *logicalname);
bool S_AreSoundsEquivalent (AActor *actor, int id1, int id2);
bool S_AreSoundsEquivalent (AActor *actor, const char *name1, const char *name2);
int S_LookupPlayerSound (const char *playerclass, int gender, const char *logicalname);
int S_LookupPlayerSound (const char *playerclass, int gender, int refid);
int S_FindSkinnedSound (AActor *actor, const char *logicalname);
int S_LookupPlayerSound (const char *playerclass, int gender, FSoundID refid);
int S_FindSkinnedSound (AActor *actor, FSoundID refid);
int S_FindSkinnedSoundEx (AActor *actor, const char *logicalname, const char *extendedname);
int S_FindSkinnedSound (AActor *actor, int refid);
int S_FindSoundByLump (int lump);
int S_AddSound (const char *logicalname, const char *lumpname, FScanner *sc=NULL); // Add sound by lumpname
int S_AddSoundLump (const char *logicalname, int lump); // Add sound by lump index

View file

@ -57,6 +57,7 @@ extern HWND Window;
#include "i_music.h"
#include "i_musicinterns.h"
#include "v_text.h"
#include "p_local.h"
// MACROS ------------------------------------------------------------------
@ -1433,7 +1434,7 @@ FSoundChan *FMODSoundRenderer::StartSound(sfxinfo_t *sfx, float vol, int pitch,
CVAR(Float, snd_3dspread, 180, 0)
FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float distscale,
int pitch, int priority, float pos[3], float vel[3], int chanflags)
int pitch, int priority, float pos[3], float vel[3], sector_t *sector, int channum, int chanflags)
{
int id = int(sfx - &S_sfx[0]);
FMOD_RESULT result;
@ -1489,7 +1490,7 @@ FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float dis
{
mode = (mode & ~FMOD_LOOP_OFF) | FMOD_LOOP_NORMAL;
}
mode = SetChanHeadSettings(chan, sfx, pos, chanflags, mode);
mode = SetChanHeadSettings(chan, sfx, pos, channum, chanflags, sector, mode);
chan->setMode(mode);
chan->setChannelGroup((!(chanflags & CHAN_NOPAUSE) && !SFXPaused) ? PausableSfx : SfxGroup);
if (freq != 0)
@ -1523,7 +1524,7 @@ FSoundChan *FMODSoundRenderer::StartSound3D(sfxinfo_t *sfx, float vol, float dis
//
//==========================================================================
FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t *sfx, float pos[3], int chanflags, FMOD_MODE oldmode) const
FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t *sfx, float pos[3], int channum, int chanflags, sector_t *sec, FMOD_MODE oldmode) const
{
if (players[consoleplayer].camera == NULL)
{
@ -1533,24 +1534,61 @@ FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t
cpos[0] = FIXED2FLOAT(players[consoleplayer].camera->x);
cpos[2] = FIXED2FLOAT(players[consoleplayer].camera->y);
cpos[1] = FIXED2FLOAT(players[consoleplayer].camera->z);
if (chanflags & CHAN_AREA)
if ((chanflags & CHAN_AREA) && sec != NULL)
{
const double interp_range = 256.0;
double dx = cpos[0] - pos[0], dy = cpos[1] - pos[1], dz = cpos[2] - pos[2];
double min_dist = sfx->MinDistance == 0 ? (S_MinDistance == 0 ? 150 : S_MinDistance * 0.75) : sfx->MinDistance;
double dist_sqr = dx*dx + dy*dy + dz*dz;
fixed_t ox = fixed_t(pos[0] * 65536);
fixed_t oy = fixed_t(pos[1] * 65536);
fixed_t cx, cy, cz;
float level, old_level;
if (dist_sqr <= min_dist*min_dist)
{ // Within min distance: No 3D panning.
level = 0;
}
else if (dist_sqr <= (min_dist + interp_range) * (min_dist + interp_range))
{ // Within interp_range units of min distance: Interpolate between none and full 3D panning.
level = float(1 - (min_dist + interp_range - sqrt(dist_sqr)) / interp_range);
// Are we inside the sector? If yes, the closest point is the one we're on.
if (P_PointInSector(players[consoleplayer].camera->x, players[consoleplayer].camera->y) == sec)
{
pos[0] = cpos[0];
pos[2] = cpos[2];
cx = players[consoleplayer].camera->x;
cy = players[consoleplayer].camera->y;
}
else
{ // Beyond 256 units of min distance: Normal 3D panning.
{
// Find the closest point on the sector's boundary lines and use
// that as the perceived origin of the sound.
sec->ClosestPoint(players[consoleplayer].camera->x, players[consoleplayer].camera->y, cx, cy);
pos[0] = FIXED2FLOAT(cx);
pos[2] = FIXED2FLOAT(cy);
}
// Set sound height based on channel.
if (channum == CHAN_FLOOR)
{
cz = MIN(sec->floorplane.ZatPoint(cx, cy), players[consoleplayer].camera->z);
}
else if (channum = CHAN_CEILING)
{
cz = MAX(sec->ceilingplane.ZatPoint(cx, cy), players[consoleplayer].camera->z);
}
else
{
cz = players[consoleplayer].camera->z;
}
pos[1] = FIXED2FLOAT(cz);
// How far are we from the perceived sound origin? Within a certain
// short distance, we interpolate between 2D panning and full 3D panning.
const double interp_range = 32.0;
double dx = cpos[0] - pos[0], dy = cpos[1] - pos[1], dz = cpos[2] - pos[2];
double dist_sqr = dx*dx + dy*dy + dz*dz;
if (dist_sqr == 0)
{
level = 0;
}
else if (dist_sqr <= interp_range * interp_range)
{ // Within interp_range: Interpolate between none and full 3D panning.
level = float(1 - (interp_range - sqrt(dist_sqr)) / interp_range);
}
else
{ // Beyond interp_range: Normal 3D panning.
level = 1;
}
if (chan->get3DPanLevel(&old_level) == FMOD_OK && old_level != level)
@ -1558,7 +1596,9 @@ FMOD_MODE FMODSoundRenderer::SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t
chan->set3DPanLevel(level);
if (level < 1)
{ // Let the noise come from all speakers, not just the front ones.
chan->setSpeakerMix(1,1,1,1,1,1,1,1);
// A centered 3D sound does not play at full volume, so neither should the 2D-panned one.
// This is sqrt(0.5), which is the result for a centered equal power panning.
chan->setSpeakerMix(0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f,0.70711f);
}
}
return oldmode;
@ -1657,7 +1697,7 @@ void FMODSoundRenderer::UpdateSoundParams3D(FSoundChan *chan, float pos[3], floa
{
oldmode = FMOD_3D | FMOD_SOFTWARE;
}
mode = SetChanHeadSettings(fchan, chan->SfxInfo, pos, chan->ChanFlags, oldmode);
mode = SetChanHeadSettings(fchan, chan->SfxInfo, pos, chan->EntChannel, chan->ChanFlags, chan->Sector, oldmode);
if (mode != oldmode)
{ // Only set the mode if it changed.
fchan->setMode(mode);

View file

@ -26,7 +26,7 @@ public:
// Starts a sound.
FSoundChan *StartSound (sfxinfo_t *sfx, float vol, int pitch, int chanflags);
FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, float pos[3], float vel[3], int chanflags);
FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, float pos[3], float vel[3], sector_t *sector, int channum, int chanflags);
// Stops a sound channel.
void StopSound (FSoundChan *chan);
@ -65,7 +65,7 @@ private:
static float F_CALLBACK RolloffCallback(FMOD_CHANNEL *channel, float distance);
FSoundChan *CommonChannelSetup(FMOD::Channel *chan) const;
FMOD_MODE SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t *sfx, float pos[3], int chanflags, FMOD_MODE oldmode) const;
FMOD_MODE SetChanHeadSettings(FMOD::Channel *chan, sfxinfo_t *sfx, float pos[3], int channum, int chanflags, sector_t *sec, FMOD_MODE oldmode) const;
void DoLoad (void **slot, sfxinfo_t *sfx);
void getsfx (sfxinfo_t *sfx);

View file

@ -90,7 +90,7 @@ public:
// Starts a sound.
virtual FSoundChan *StartSound (sfxinfo_t *sfx, float vol, int pitch, int chanflags) = 0;
virtual FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, float pos[3], float vel[3], int chanflags) = 0;
virtual FSoundChan *StartSound3D (sfxinfo_t *sfx, float vol, float distscale, int pitch, int priority, float pos[3], float vel[3], sector_t *sector, int channum, int chanflags) = 0;
// Stops a sound channel.
virtual void StopSound (FSoundChan *chan) = 0;

View file

@ -678,17 +678,17 @@ static void ParseInsideDecoration (FActorInfo *info, AActor *defaults,
sc.Compare ("DeathSound"))
{
sc.MustGetString ();
defaults->DeathSound = S_FindSound (sc.String);
defaults->DeathSound = sc.String;
}
else if (def == DEF_BreakableDecoration && sc.Compare ("BurnDeathSound"))
{
sc.MustGetString ();
defaults->ActiveSound = S_FindSound (sc.String);
defaults->ActiveSound = sc.String;
}
else if (def == DEF_Projectile && sc.Compare ("SpawnSound"))
{
sc.MustGetString ();
defaults->SeeSound = S_FindSound (sc.String);
defaults->SeeSound = sc.String;
}
else if (def == DEF_Projectile && sc.Compare ("DoomBounce"))
{
@ -705,7 +705,7 @@ static void ParseInsideDecoration (FActorInfo *info, AActor *defaults,
else if (def == DEF_Pickup && sc.Compare ("PickupSound"))
{
sc.MustGetString ();
inv->PickupSound = S_FindSound (sc.String);
inv->PickupSound = sc.String;
}
else if (def == DEF_Pickup && sc.Compare ("PickupMessage"))
{
@ -900,6 +900,6 @@ void A_ActiveSound (AActor *actor)
{
if (actor->ActiveSound)
{
S_SoundID (actor, CHAN_VOICE, actor->ActiveSound, 1, ATTN_NORM);
S_Sound (actor, CHAN_VOICE, actor->ActiveSound, 1, ATTN_NORM);
}
}

View file

@ -228,7 +228,7 @@ static void DoAttack (AActor *self, bool domelee, bool domissile)
if (domelee && MeleeDamage>0 && self->CheckMeleeRange ())
{
int damage = pr_camelee.HitDice(MeleeDamage);
if (MeleeSound) S_SoundID (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
P_TraceBleed (damage, self->target, self);
}
@ -288,7 +288,7 @@ static void DoPlaySound(AActor * self, int channel)
if (index<0) return;
int soundid = StateParameters[index];
S_SoundID (self, channel, soundid, 1, ATTN_NORM);
S_Sound (self, channel, soundid, 1, ATTN_NORM);
}
void A_PlaySound(AActor * self)
@ -333,13 +333,13 @@ void A_PlaySoundEx (AActor *self)
if (!looping)
{
S_SoundID (self, channel - NAME_Auto, soundid, 1, attenuation);
S_Sound (self, channel - NAME_Auto, soundid, 1, attenuation);
}
else
{
if (!S_IsActorPlayingSomething (self, channel - NAME_Auto, soundid))
{
S_SoundID (self, (channel - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation);
S_Sound (self, (channel - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation);
}
}
}
@ -390,7 +390,7 @@ void A_BulletAttack (AActor *self)
slope = P_AimLineAttack (self, bangle, MISSILERANGE);
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
for (i = self->GetMissileDamage (0, 1); i > 0; --i)
{
int angle = bangle + (pr_cabullet.Random2() << 20);
@ -858,7 +858,7 @@ void A_CustomBulletAttack (AActor *self)
bslope = P_AimLineAttack (self, bangle, MISSILERANGE);
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
for (i=0 ; i<NumBullets ; i++)
{
int angle = bangle + pr_cabullet.Random2() * (Spread_XY / 255);
@ -893,13 +893,13 @@ void A_CustomMeleeAttack (AActor *self)
A_FaceTarget (self);
if (self->CheckMeleeRange ())
{
if (MeleeSound) S_SoundID (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, DamageType);
if (bleed) P_TraceBleed (damage, self->target, self);
}
else
{
if (MissSound) S_SoundID (self, CHAN_WEAPON, MissSound, 1, ATTN_NORM);
if (MissSound) S_Sound (self, CHAN_WEAPON, MissSound, 1, ATTN_NORM);
}
}
@ -928,7 +928,7 @@ void A_CustomComboAttack (AActor *self)
if (self->CheckMeleeRange ())
{
if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type
if (MeleeSound) S_SoundID (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, damage, DamageType);
if (bleed) P_TraceBleed (damage, self->target, self);
}
@ -1021,7 +1021,7 @@ void A_FireBullets (AActor *self)
PuffType = PClass::FindClass(PuffTypeName);
if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff);
S_SoundID (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
if ((NumberOfBullets==1 && !player->refire) || NumberOfBullets==0)
{
@ -1150,7 +1150,7 @@ void A_CustomPunch (AActor *self)
// turn to face target
if (linetarget)
{
S_SoundID (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
self->angle = R_PointToAngle2 (self->x,
self->y,

View file

@ -1072,7 +1072,7 @@ static void ActorArgs (FScanner &sc, AActor *defaults, Baggage &bag)
static void ActorSeeSound (FScanner &sc, AActor *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->SeeSound=S_FindSound(sc.String);
defaults->SeeSound = sc.String;
}
//==========================================================================
@ -1081,7 +1081,7 @@ static void ActorSeeSound (FScanner &sc, AActor *defaults, Baggage &bag)
static void ActorAttackSound (FScanner &sc, AActor *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->AttackSound=S_FindSound(sc.String);
defaults->AttackSound = sc.String;
}
//==========================================================================
@ -1090,7 +1090,7 @@ static void ActorAttackSound (FScanner &sc, AActor *defaults, Baggage &bag)
static void ActorPainSound (FScanner &sc, AActor *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->PainSound=S_FindSound(sc.String);
defaults->PainSound = sc.String;
}
//==========================================================================
@ -1099,7 +1099,7 @@ static void ActorPainSound (FScanner &sc, AActor *defaults, Baggage &bag)
static void ActorDeathSound (FScanner &sc, AActor *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->DeathSound=S_FindSound(sc.String);
defaults->DeathSound = sc.String;
}
//==========================================================================
@ -1108,7 +1108,7 @@ static void ActorDeathSound (FScanner &sc, AActor *defaults, Baggage &bag)
static void ActorActiveSound (FScanner &sc, AActor *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->ActiveSound=S_FindSound(sc.String);
defaults->ActiveSound = sc.String;
}
//==========================================================================
@ -1935,7 +1935,7 @@ static void InventoryPickupmsg (FScanner &sc, AInventory *defaults, Baggage &bag
static void InventoryPickupsound (FScanner &sc, AInventory *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->PickupSound=S_FindSound(sc.String);
defaults->PickupSound = sc.String;
}
//==========================================================================
@ -1953,7 +1953,7 @@ static void InventoryRespawntics (FScanner &sc, AInventory *defaults, Baggage &b
static void InventoryUsesound (FScanner &sc, AInventory *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->UseSound=S_FindSound(sc.String);
defaults->UseSound = sc.String;
}
//==========================================================================
@ -2069,7 +2069,7 @@ static void WeaponKickback (FScanner &sc, AWeapon *defaults, Baggage &bag)
static void WeaponReadySound (FScanner &sc, AWeapon *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->ReadySound=S_FindSound(sc.String);
defaults->ReadySound = sc.String;
}
//==========================================================================
@ -2096,7 +2096,7 @@ static void WeaponSisterWeapon (FScanner &sc, AWeapon *defaults, Baggage &bag)
static void WeaponUpSound (FScanner &sc, AWeapon *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->UpSound=S_FindSound(sc.String);
defaults->UpSound = sc.String;
}
//==========================================================================

View file

@ -75,7 +75,7 @@
// SAVESIG should match SAVEVER.
// MINSAVEVER is the minimum level snapshot version that can be loaded.
#define MINSAVEVER 1033
#define MINSAVEVER 1034
#if SVN_REVISION_NUMBER < MINSAVEVER
// Never write a savegame with a version lower than what we need