diff --git a/src/bbannouncer.cpp b/src/bbannouncer.cpp index f0533cac17..a54ccd88f1 100644 --- a/src/bbannouncer.cpp +++ b/src/bbannouncer.cpp @@ -185,7 +185,7 @@ void DoVoiceAnnounce (const char *sound) if (LastAnnounceTime == 0 || LastAnnounceTime <= primaryLevel->time-5) { LastAnnounceTime = primaryLevel->time; - S_Sound (CHAN_VOICE, sound, 1, ATTN_NONE); + S_Sound (CHAN_VOICE, 0, sound, 1, ATTN_NONE); } } diff --git a/src/d_main.cpp b/src/d_main.cpp index 881825a202..36b74f033f 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1214,7 +1214,7 @@ void D_DoStrifeAdvanceDemo () pagetic = 10 * TICRATE/35; pagename = ""; // PANEL0, but strife0.wad doesn't have it, so don't use it. PageBlank = true; - S_Sound (CHAN_VOICE | CHAN_UI, "bishop/active", 1, ATTN_NORM); + S_Sound (CHAN_VOICE, CHANF_UI, "bishop/active", 1, ATTN_NORM); break; case 2: @@ -1226,7 +1226,7 @@ void D_DoStrifeAdvanceDemo () pagetic = 7 * TICRATE; pagename = "PANEL1"; subtitle = "TXT_SUB_INTRO1"; - S_Sound (CHAN_VOICE | CHAN_UI, voices[0], 1, ATTN_NORM); + S_Sound (CHAN_VOICE, CHANF_UI, voices[0], 1, ATTN_NORM); // The new Strife teaser has D_FMINTR. // The full retail Strife has D_INTRO. // And the old Strife teaser has both. (I do not know which one it actually uses, nor do I care.) @@ -1237,35 +1237,35 @@ void D_DoStrifeAdvanceDemo () pagetic = 9 * TICRATE; pagename = "PANEL2"; subtitle = "TXT_SUB_INTRO2"; - S_Sound (CHAN_VOICE | CHAN_UI, voices[1], 1, ATTN_NORM); + S_Sound (CHAN_VOICE, CHANF_UI, voices[1], 1, ATTN_NORM); break; case 5: pagetic = 12 * TICRATE; pagename = "PANEL3"; subtitle = "TXT_SUB_INTRO3"; - S_Sound (CHAN_VOICE | CHAN_UI, voices[2], 1, ATTN_NORM); + S_Sound (CHAN_VOICE, CHANF_UI, voices[2], 1, ATTN_NORM); break; case 6: pagetic = 11 * TICRATE; pagename = "PANEL4"; subtitle = "TXT_SUB_INTRO4"; - S_Sound (CHAN_VOICE | CHAN_UI, voices[3], 1, ATTN_NORM); + S_Sound (CHAN_VOICE, CHANF_UI, voices[3], 1, ATTN_NORM); break; case 7: pagetic = 10 * TICRATE; pagename = "PANEL5"; subtitle = "TXT_SUB_INTRO5"; - S_Sound (CHAN_VOICE | CHAN_UI, voices[4], 1, ATTN_NORM); + S_Sound (CHAN_VOICE, CHANF_UI, voices[4], 1, ATTN_NORM); break; case 8: pagetic = 16 * TICRATE; pagename = "PANEL6"; subtitle = "TXT_SUB_INTRO6"; - S_Sound (CHAN_VOICE | CHAN_UI, voices[5], 1, ATTN_NORM); + S_Sound (CHAN_VOICE, CHANF_UI, voices[5], 1, ATTN_NORM); break; case 9: @@ -2770,7 +2770,7 @@ static int D_DoomMain_Internal (void) delete StartScreen; StartScreen = NULL; - S_Sound (CHAN_BODY, "misc/startupdone", 1, ATTN_NONE); + S_Sound (CHAN_BODY, 0, "misc/startupdone", 1, ATTN_NONE); if (Args->CheckParm("-norun") || batchrun) { diff --git a/src/d_net.cpp b/src/d_net.cpp index 3e92c410cc..3b8222b3cc 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2186,7 +2186,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player) { Printf (PRINT_CHAT, "%s" TEXTCOLOR_CHAT ": %s" TEXTCOLOR_CHAT "\n", name, s); } - S_Sound (CHAN_VOICE | CHAN_UI, gameinfo.chatSound, 1, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, gameinfo.chatSound, 1, ATTN_NONE); } else if (players[player].userinfo.GetTeam() == players[consoleplayer].userinfo.GetTeam()) { // Said only to members of the player's team @@ -2198,7 +2198,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player) { Printf (PRINT_TEAMCHAT, "(%s" TEXTCOLOR_TEAMCHAT "): %s" TEXTCOLOR_TEAMCHAT "\n", name, s); } - S_Sound (CHAN_VOICE | CHAN_UI, gameinfo.chatSound, 1, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, gameinfo.chatSound, 1, ATTN_NONE); } } break; diff --git a/src/g_game.cpp b/src/g_game.cpp index 6c6a1ef102..389d861552 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -363,7 +363,7 @@ CCMD (weapnext) } if (SendItemUse != players[consoleplayer].ReadyWeapon) { - S_Sound(CHAN_AUTO, "misc/weaponchange", 1.0, ATTN_NONE); + S_Sound(CHAN_AUTO, 0, "misc/weaponchange", 1.0, ATTN_NONE); } } @@ -389,7 +389,7 @@ CCMD (weapprev) } if (SendItemUse != players[consoleplayer].ReadyWeapon) { - S_Sound(CHAN_AUTO, "misc/weaponchange", 1.0, ATTN_NONE); + S_Sound(CHAN_AUTO, 0, "misc/weaponchange", 1.0, ATTN_NONE); } } diff --git a/src/gamedata/a_keys.cpp b/src/gamedata/a_keys.cpp index 7362cb3e67..d331d319e8 100644 --- a/src/gamedata/a_keys.cpp +++ b/src/gamedata/a_keys.cpp @@ -506,7 +506,7 @@ int P_CheckKeys (AActor *owner, int keynum, bool remote, bool quiet) int snd = S_FindSkinnedSound(owner, failsound[i]); if (snd != 0) { - S_Sound (owner, CHAN_VOICE, snd, 1, ATTN_NORM); + S_Sound (owner, CHAN_VOICE, 0, snd, 1, ATTN_NORM); break; } } diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index fa09541317..5a0e962584 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -170,7 +170,7 @@ void DIntermissionScreen::Init(FIntermissionAction *desc, bool first) mBackground = TexMan.CheckForTexture(texname, ETextureType::MiscPatch); mFlatfill = desc->mFlatfill; } - S_Sound (CHAN_VOICE | CHAN_UI, desc->mSound, 1.0f, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, desc->mSound, 1.0f, ATTN_NONE); mOverlays.Resize(desc->mOverlays.Size()); for (unsigned i=0; i < mOverlays.Size(); i++) { @@ -500,7 +500,7 @@ void DIntermissionScreenCast::Init(FIntermissionAction *desc, bool first) castattacking = false; if (mDefaults->SeeSound) { - S_Sound (CHAN_VOICE | CHAN_UI, mDefaults->SeeSound, 1, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, mDefaults->SeeSound, 1, ATTN_NONE); } } @@ -526,11 +526,11 @@ int DIntermissionScreenCast::Responder (event_t *ev) if (mClass->IsDescendantOf(NAME_PlayerPawn)) { int snd = S_FindSkinnedSound(players[consoleplayer].mo, "*death"); - if (snd != 0) S_Sound (CHAN_VOICE | CHAN_UI, snd, 1, ATTN_NONE); + if (snd != 0) S_Sound (CHAN_VOICE, CHANF_UI, snd, 1, ATTN_NONE); } else if (mDefaults->DeathSound) { - S_Sound (CHAN_VOICE | CHAN_UI, mDefaults->DeathSound, 1, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, mDefaults->DeathSound, 1, ATTN_NONE); } } return true; @@ -547,7 +547,7 @@ void DIntermissionScreenCast::PlayAttackSound() (caststate == basestate + mCastSounds[i].mIndex)) { S_StopAllChannels (); - S_Sound (CHAN_WEAPON | CHAN_UI, mCastSounds[i].mSound, 1, ATTN_NONE); + S_Sound (CHAN_WEAPON, CHANF_UI, mCastSounds[i].mSound, 1, ATTN_NONE); return; } } diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index a7863a864d..2c94cffb09 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -373,7 +373,7 @@ void M_StartControlPanel (bool makeSound, bool scaleoverride) if (makeSound) { - S_Sound (CHAN_VOICE | CHAN_UI, "menu/activate", snd_menuvolume, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE); } BackbuttonTime = 0; BackbuttonAlpha = 0; @@ -1149,13 +1149,13 @@ EXTERN_CVAR (Int, screenblocks) CCMD (sizedown) { screenblocks = screenblocks - 1; - S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, "menu/change", snd_menuvolume, ATTN_NONE); } CCMD (sizeup) { screenblocks = screenblocks + 1; - S_Sound (CHAN_VOICE | CHAN_UI, "menu/change", snd_menuvolume, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, "menu/change", snd_menuvolume, ATTN_NONE); } CCMD(menuconsole) diff --git a/src/menu/messagebox.cpp b/src/menu/messagebox.cpp index 59a32ccb20..75685678b8 100644 --- a/src/menu/messagebox.cpp +++ b/src/menu/messagebox.cpp @@ -116,7 +116,7 @@ CCMD (menu_quit) { if (gameinfo.quitSound.IsNotEmpty()) { - S_Sound(CHAN_VOICE | CHAN_UI, gameinfo.quitSound, snd_menuvolume, ATTN_NONE); + S_Sound(CHAN_VOICE, CHANF_UI, gameinfo.quitSound, snd_menuvolume, ATTN_NONE); I_WaitVBL(105); } } @@ -156,12 +156,12 @@ CCMD (menu_endgame) { // F7 if (!usergame) { - S_Sound (CHAN_VOICE | CHAN_UI, "menu/invalid", snd_menuvolume, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, "menu/invalid", snd_menuvolume, ATTN_NONE); return; } //M_StartControlPanel (true); - S_Sound (CHAN_VOICE | CHAN_UI, "menu/activate", snd_menuvolume, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE); ActivateEndGameMenu(); } @@ -176,7 +176,7 @@ CCMD (quicksave) { // F6 if (!usergame || (players[consoleplayer].health <= 0 && !multiplayer)) { - S_Sound (CHAN_VOICE | CHAN_UI, "menu/invalid", snd_menuvolume, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, "menu/invalid", snd_menuvolume, ATTN_NONE); return; } @@ -192,7 +192,7 @@ CCMD (quicksave) if (savegameManager.quickSaveSlot == NULL || savegameManager.quickSaveSlot == (FSaveGameNode*)1) { - S_Sound(CHAN_VOICE | CHAN_UI, "menu/activate", snd_menuvolume, ATTN_NONE); + S_Sound(CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE); M_StartControlPanel(false); M_SetMenu(NAME_Savegamemenu); return; @@ -205,7 +205,7 @@ CCMD (quicksave) return; } - S_Sound(CHAN_VOICE | CHAN_UI, "menu/activate", snd_menuvolume, ATTN_NONE); + S_Sound(CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE); FString tempstring = GStrings("QSPROMPT"); tempstring.Substitute("%s", savegameManager.quickSaveSlot->SaveTitle.GetChars()); @@ -213,7 +213,7 @@ CCMD (quicksave) DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, false, NAME_None, []() { G_SaveGame(savegameManager.quickSaveSlot->Filename.GetChars(), savegameManager.quickSaveSlot->SaveTitle.GetChars()); - S_Sound(CHAN_VOICE | CHAN_UI, "menu/dismiss", snd_menuvolume, ATTN_NONE); + S_Sound(CHAN_VOICE, CHANF_UI, "menu/dismiss", snd_menuvolume, ATTN_NONE); M_ClearMenus(); }); @@ -258,7 +258,7 @@ CCMD (quickload) DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, false, NAME_None, []() { G_LoadGame(savegameManager.quickSaveSlot->Filename.GetChars()); - S_Sound(CHAN_VOICE | CHAN_UI, "menu/dismiss", snd_menuvolume, ATTN_NONE); + S_Sound(CHAN_VOICE, CHANF_UI, "menu/dismiss", snd_menuvolume, ATTN_NONE); M_ClearMenus(); }); M_ActivateMenu(newmenu); diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 4a0a77e46e..4ae7352bda 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -329,7 +329,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang if (pc->player == Level->GetConsolePlayer()) { - S_Sound (CHAN_VOICE | CHAN_UI, gameinfo.chatSound, 1, ATTN_NONE); + S_Sound (CHAN_VOICE, CHANF_UI, gameinfo.chatSound, 1, ATTN_NONE); } npc->reactiontime = 2; @@ -380,7 +380,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang if (CurNode->SpeakerVoice != 0) { I_SetMusicVolume (dlg_musicvolume); - S_Sound (npc, CHAN_VOICE|CHAN_NOPAUSE, CurNode->SpeakerVoice, 1, ATTN_NORM); + S_Sound (npc, CHAN_VOICE, CHANF_NOPAUSE, CurNode->SpeakerVoice, 1, ATTN_NORM); } M_StartControlPanel(false, true); diff --git a/src/playsim/fragglescript/t_func.cpp b/src/playsim/fragglescript/t_func.cpp index 5d3917b31e..69b819202b 100644 --- a/src/playsim/fragglescript/t_func.cpp +++ b/src/playsim/fragglescript/t_func.cpp @@ -585,7 +585,7 @@ void FParser::SF_Input(void) void FParser::SF_Beep(void) { - S_Sound(CHAN_AUTO, "misc/chat", 1.0f, ATTN_IDLE); + S_Sound(CHAN_AUTO, 0, "misc/chat", 1.0f, ATTN_IDLE); } //========================================================================== @@ -1471,7 +1471,7 @@ void FParser::SF_StartSound(void) if (mo) { - S_Sound(mo, CHAN_BODY, T_FindSound(stringvalue(t_argv[1])), 1, ATTN_NORM); + S_Sound(mo, CHAN_BODY, 0, T_FindSound(stringvalue(t_argv[1])), 1, ATTN_NORM); } } } @@ -1497,7 +1497,7 @@ void FParser::SF_StartSectorSound(void) while ((i = itr.Next()) >= 0) { sector = &Level->sectors[i]; - S_Sound(sector, CHAN_BODY, T_FindSound(stringvalue(t_argv[1])), 1.0f, ATTN_NORM); + S_Sound(sector, CHAN_BODY, 0, T_FindSound(stringvalue(t_argv[1])), 1.0f, ATTN_NORM); } } } @@ -2812,7 +2812,7 @@ void FParser::SF_AmbientSound(void) { if (CheckArgs(1)) { - S_Sound(CHAN_AUTO, T_FindSound(stringvalue(t_argv[0])), 1, ATTN_NORM); + S_Sound(CHAN_AUTO, 0, T_FindSound(stringvalue(t_argv[0])), 1, ATTN_NORM); } } @@ -2911,7 +2911,7 @@ void FParser::SF_SpawnExplosion() { spawn->ClearCounters(); t_return.value.i = spawn->SetState(spawn->FindState(NAME_Death)); - if(spawn->DeathSound) S_Sound (spawn, CHAN_BODY, spawn->DeathSound, 1, ATTN_NORM); + if(spawn->DeathSound) S_Sound (spawn, CHAN_BODY, 0, spawn->DeathSound, 1, ATTN_NORM); } } } @@ -3738,7 +3738,7 @@ void FParser::SF_SpawnShot2(void) AActor *mo = Spawn(Level, pclass, source->PosPlusZ(z), ALLOW_REPLACE); if (mo) { - S_Sound(mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); + S_Sound(mo, CHAN_VOICE, 0, mo->SeeSound, 1, ATTN_NORM); mo->target = source; mo->Angles.Yaw = source->Angles.Yaw; mo->Thrust(); diff --git a/src/playsim/mapthinkers/a_doors.cpp b/src/playsim/mapthinkers/a_doors.cpp index 664b0096ee..f517d20db5 100644 --- a/src/playsim/mapthinkers/a_doors.cpp +++ b/src/playsim/mapthinkers/a_doors.cpp @@ -437,7 +437,7 @@ bool FLevelLocals::EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, // if the wrong side of door is pushed, give oof sound if (line->sidedef[1] == NULL) // killough { - S_Sound (thing, CHAN_VOICE, "*usefail", 1, ATTN_NORM); + S_Sound (thing, CHAN_VOICE, 0, "*usefail", 1, ATTN_NORM); return false; } diff --git a/src/playsim/mapthinkers/a_lightning.cpp b/src/playsim/mapthinkers/a_lightning.cpp index 7c27218ec2..541df51a57 100644 --- a/src/playsim/mapthinkers/a_lightning.cpp +++ b/src/playsim/mapthinkers/a_lightning.cpp @@ -176,7 +176,7 @@ void DLightningThinker::LightningFlash () } Level->flags |= LEVEL_SWAPSKIES; // set alternate sky - S_Sound (CHAN_AUTO, "world/thunder", 1.0, ATTN_NONE); + S_Sound (CHAN_AUTO, 0, "world/thunder", 1.0, ATTN_NONE); // [ZZ] just in case Level->localEventManager->WorldLightning(); // start LIGHTNING scripts diff --git a/src/playsim/mapthinkers/a_quake.cpp b/src/playsim/mapthinkers/a_quake.cpp index 4eff8a4376..e21c3c313d 100644 --- a/src/playsim/mapthinkers/a_quake.cpp +++ b/src/playsim/mapthinkers/a_quake.cpp @@ -115,7 +115,7 @@ void DEarthquake::Tick () if (!S_IsActorPlayingSomething (m_Spot, CHAN_BODY, m_QuakeSFX)) { - S_Sound (m_Spot, CHAN_BODY | CHAN_LOOP, m_QuakeSFX, 1, ATTN_NORM); + S_Sound (m_Spot, CHAN_BODY, CHANF_LOOP, m_QuakeSFX, 1, ATTN_NORM); } if (m_DamageRadius > 0) diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index cbcfb0fc63..df54741ff2 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -5910,13 +5910,14 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) } if (sid != 0) { + // What a mess. I think it's a given that this was used with sound flags so it will forever be restricted to the original 8 channels. if (!looping) { - S_PlaySound(spot, chan, sid, vol, atten, !!local); + S_PlaySound(spot, chan&7, EChanFlags::FromInt(chan&~7), sid, vol, atten, !!local); } else if (!S_IsActorPlayingSomething(spot, chan & 7, sid)) { - S_PlaySound(spot, chan | CHAN_LOOP, sid, vol, atten, !!local); + S_PlaySound(spot, chan&7, EChanFlags::FromInt(chan & ~7)|CHANF_LOOP, sid, vol, atten, !!local); } } } @@ -8821,7 +8822,7 @@ scriptwait: { S_Sound ( activationline->frontsector, - CHAN_AUTO, // Not CHAN_AREA, because that'd probably break existing scripts. + CHAN_AUTO, 0, // Not CHAN_AREA, because that'd probably break existing scripts. lookup, (float)(STACK(1)) / 127.f, ATTN_NORM); @@ -8829,7 +8830,7 @@ scriptwait: else { S_Sound ( - CHAN_AUTO, + CHAN_AUTO, 0, lookup, (float)(STACK(1)) / 127.f, ATTN_NORM); @@ -8842,7 +8843,7 @@ scriptwait: lookup = Level->Behaviors.LookupString (STACK(2)); if (lookup != NULL) { - S_Sound (CHAN_AUTO, + S_Sound (CHAN_AUTO, 0, lookup, (float)(STACK(1)) / 127.f, ATTN_NONE); } @@ -8853,7 +8854,7 @@ scriptwait: lookup = Level->Behaviors.LookupString (STACK(2)); if (lookup != NULL && activator && activator->CheckLocalView()) { - S_Sound (CHAN_AUTO, + S_Sound (CHAN_AUTO, 0, lookup, (float)(STACK(1)) / 127.f, ATTN_NONE); } @@ -8866,13 +8867,13 @@ scriptwait: { if (activator != NULL) { - S_Sound (activator, CHAN_AUTO, + S_Sound (activator, CHAN_AUTO, 0, lookup, (float)(STACK(1)) / 127.f, ATTN_NORM); } else { - S_Sound (CHAN_AUTO, + S_Sound (CHAN_AUTO, 0, lookup, (float)(STACK(1)) / 127.f, ATTN_NONE); } @@ -9040,7 +9041,7 @@ scriptwait: while ( (spot = iterator.Next ()) ) { - S_Sound (spot, CHAN_AUTO, + S_Sound (spot, CHAN_AUTO, 0, lookup, (float)(STACK(1))/127.f, ATTN_NORM); } diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index d47053198c..b8b3ab7dac 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -715,13 +715,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlaySoundEx) if (!looping) { - S_Sound (self, int(channel) - NAME_Auto, soundid, 1, attenuation); + S_Sound (self, int(channel) - NAME_Auto, 0, soundid, 1, attenuation); } else { if (!S_IsActorPlayingSomething (self, int(channel) - NAME_Auto, soundid)) { - S_Sound (self, (int(channel) - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation); + S_Sound (self, (int(channel) - NAME_Auto), CHANF_LOOP, soundid, 1, attenuation); } } return 0; @@ -791,7 +791,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack) DAngle slope = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE); - S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); + S_Sound (self, CHAN_WEAPON, 0, self->AttackSound, 1, ATTN_NORM); for (i = self->GetMissileDamage (0, 1); i > 0; --i) { DAngle angle = self->Angles.Yaw + pr_cabullet.Random2() * (5.625 / 256.); @@ -1075,7 +1075,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomMeleeAttack) if (self->CheckMeleeRange ()) { if (meleesound) - S_Sound (self, CHAN_WEAPON, meleesound, 1, ATTN_NORM); + S_Sound (self, CHAN_WEAPON, 0, meleesound, 1, ATTN_NORM); int newdam = P_DamageMobj (self->target, self, self, damage, damagetype); if (bleed) P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); @@ -1083,7 +1083,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomMeleeAttack) else { if (misssound) - S_Sound (self, CHAN_WEAPON, misssound, 1, ATTN_NORM); + S_Sound (self, CHAN_WEAPON, 0, misssound, 1, ATTN_NORM); } return 0; } @@ -1112,7 +1112,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CustomComboAttack) if (damagetype == NAME_None) damagetype = NAME_Melee; // Melee is the default type if (meleesound) - S_Sound (self, CHAN_WEAPON, meleesound, 1, ATTN_NORM); + S_Sound (self, CHAN_WEAPON, 0, meleesound, 1, ATTN_NORM); int newdam = P_DamageMobj (self->target, self, self, damage, damagetype); if (bleed) P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); @@ -3419,7 +3419,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WolfAttack) } // And finally, let's play the sound - S_Sound (self, CHAN_WEAPON, sound, 1, ATTN_NORM); + S_Sound (self, CHAN_WEAPON, 0, sound, 1, ATTN_NORM); return 0; } diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index 1e9d8e1d1a..58e2daf716 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -656,7 +656,7 @@ void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, if (fabs(mo->X() - trail[0].start.X) < 20 && fabs(mo->Y() - trail[0].start.Y) < 20) { // This player (probably) fired the railgun - S_Sound (mo, CHAN_WEAPON, sound, 1, ATTN_NORM); + S_Sound (mo, CHAN_WEAPON, 0, sound, 1, ATTN_NORM); } else { @@ -665,7 +665,7 @@ void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, { if (shortest == NULL || shortest->sounddist > seg.sounddist) shortest = &seg; } - S_Sound (source->Level, DVector3(shortest->soundpos, r_viewpoint.Pos.Z), CHAN_WEAPON, sound, 1, ATTN_NORM); + S_Sound (source->Level, DVector3(shortest->soundpos, r_viewpoint.Pos.Z), CHAN_WEAPON, 0, sound, 1, ATTN_NORM); } } } diff --git a/src/playsim/p_enemy.cpp b/src/playsim/p_enemy.cpp index 51dbd5ccf3..5d9191900e 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -1848,11 +1848,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) { if (self->flags2 & MF2_BOSS) { // full volume - S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NONE); + S_Sound (self, CHAN_VOICE, 0, self->SeeSound, 1, ATTN_NONE); } else { - S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM); + S_Sound (self, CHAN_VOICE, 0, self->SeeSound, 1, ATTN_NORM); } } @@ -2030,11 +2030,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_LookEx) { if (flags & LOF_FULLVOLSEESOUND) { // full volume - S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NONE); + S_Sound (self, CHAN_VOICE, 0, self->SeeSound, 1, ATTN_NONE); } else { - S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM); + S_Sound (self, CHAN_VOICE, 0, self->SeeSound, 1, ATTN_NORM); } } @@ -2456,7 +2456,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (meleestate && actor->CheckMeleeRange ()) { if (actor->AttackSound) - S_Sound (actor, CHAN_WEAPON, actor->AttackSound, 1, ATTN_NORM); + S_Sound (actor, CHAN_WEAPON, 0, actor->AttackSound, 1, ATTN_NORM); actor->SetState (meleestate); actor->flags &= ~MF_INCHASE; @@ -2717,7 +2717,7 @@ bool P_CheckForResurrection(AActor *self, bool usevilestates) self->SetState(archvile->FindState(NAME_Heal)); } } - S_Sound(corpsehit, CHAN_BODY, "vile/raise", 1, ATTN_IDLE); + S_Sound(corpsehit, CHAN_BODY, 0, "vile/raise", 1, ATTN_IDLE); info = corpsehit->GetDefault(); if (GetTranslationType(corpsehit->Translation) == TRANSLATION_Blood) @@ -3025,11 +3025,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Pain) sfx_id = pain_amount; } - S_Sound (self, CHAN_VOICE, sfx_id, 1, ATTN_NORM); + S_Sound (self, CHAN_VOICE, 0, sfx_id, 1, ATTN_NORM); } else if (self->PainSound) { - S_Sound (self, CHAN_VOICE, self->PainSound, 1, ATTN_NORM); + S_Sound (self, CHAN_VOICE, 0, self->PainSound, 1, ATTN_NORM); } return 0; } diff --git a/src/playsim/p_interaction.cpp b/src/playsim/p_interaction.cpp index 7454210597..7d16b46fb4 100644 --- a/src/playsim/p_interaction.cpp +++ b/src/playsim/p_interaction.cpp @@ -1415,7 +1415,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da } if (P_GiveBody(source, draindmg)) { - S_Sound(source, CHAN_ITEM, "*drainhealth", 1, ATTN_NORM); + S_Sound(source, CHAN_ITEM, 0, "*drainhealth", 1, ATTN_NORM); } } } diff --git a/src/playsim/p_lnspec.cpp b/src/playsim/p_lnspec.cpp index 33b8d4b9e1..5a3a67996e 100644 --- a/src/playsim/p_lnspec.cpp +++ b/src/playsim/p_lnspec.cpp @@ -2173,7 +2173,7 @@ FUNC(LS_UsePuzzleItem) } // [RH] Say "hmm" if you don't have the puzzle item - S_Sound (it, CHAN_VOICE, "*puzzfail", 1, ATTN_IDLE); + S_Sound (it, CHAN_VOICE, 0, "*puzzfail", 1, ATTN_IDLE); return false; } @@ -3197,7 +3197,7 @@ FUNC(LS_SendToCommunicator) { S_StopSound (CHAN_VOICE); it->player->SetSubtitle(arg0, name); - S_Sound (CHAN_VOICE, name, 1, ATTN_NORM); + S_Sound (CHAN_VOICE, 0, name, 1, ATTN_NORM); // Get the message from the LANGUAGE lump. FString msg; diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index ad04adafcd..08525e6d6c 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -1526,7 +1526,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Ok to spawn blood P_RipperBlood(tm.thing, thing); } - S_Sound(tm.thing, CHAN_BODY, "misc/ripslop", 1, ATTN_IDLE); + S_Sound(tm.thing, CHAN_BODY, 0, "misc/ripslop", 1, ATTN_IDLE); // Do poisoning (if using new style poison) if (tm.thing->PoisonDamage > 0 && tm.thing->PoisonDuration != INT_MIN) @@ -2841,7 +2841,7 @@ void FSlide::HitSlideLine(line_t* ld) tmmove.Y /= 2; // absorb half the velocity if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!// ^ + S_Sound(slidemo, CHAN_VOICE, 0, "*grunt", 1, ATTN_IDLE); // oooff!// ^ } } // | else // phares @@ -2857,7 +2857,7 @@ void FSlide::HitSlideLine(line_t* ld) tmmove.Y = -tmmove.Y / 2; if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! + S_Sound(slidemo, CHAN_VOICE, 0, "*grunt", 1, ATTN_IDLE); // oooff! } } else @@ -2889,7 +2889,7 @@ void FSlide::HitSlideLine(line_t* ld) movelen /= 2; // absorb if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { - S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! + S_Sound(slidemo, CHAN_VOICE, 0, "*grunt", 1, ATTN_IDLE); // oooff! } tmmove = moveangle.ToVector(movelen); } @@ -4517,7 +4517,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, { // hit nothing if (!nointeract && puffDefaults && puffDefaults->ActiveSound) { // Play miss sound - S_Sound(t1, CHAN_WEAPON, puffDefaults->ActiveSound, 1, ATTN_NORM); + S_Sound(t1, CHAN_WEAPON, 0, puffDefaults->ActiveSound, 1, ATTN_NORM); } // [MC] LAF_NOINTERACT guarantees puff spawning and returns it directly to the calling function. @@ -5466,7 +5466,7 @@ bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, if (usething->player) { - S_Sound(usething, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); + S_Sound(usething, CHAN_VOICE, 0, "*usefail", 1, ATTN_IDLE); } return true; // can't use through a wall } @@ -5583,7 +5583,7 @@ void P_UseLines(player_t *player) if ((!sec->SecActTarget || !sec->TriggerSectorActions(player->mo, spac)) && P_NoWayTraverse(player->mo, start, end)) { - S_Sound(player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); + S_Sound(player->mo, CHAN_VOICE, 0, "*usefail", 1, ATTN_IDLE); } } } @@ -6233,7 +6233,7 @@ void P_DoCrunch(AActor *thing, FChangePosition *cpos) } if (thing->CrushPainSound != 0 && !S_GetSoundPlayingInfo(thing, thing->CrushPainSound)) { - S_Sound(thing, CHAN_VOICE, thing->CrushPainSound, 1.f, ATTN_NORM); + S_Sound(thing, CHAN_VOICE, 0, thing->CrushPainSound, 1.f, ATTN_NORM); } } } diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 00f1feb645..cd26319938 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -1194,7 +1194,7 @@ bool AActor::Grind(bool items) SetState (state); if (isgeneric) // Not a custom crush state, so colorize it appropriately. { - S_Sound (this, CHAN_BODY, "misc/fallingsplat", 1, ATTN_IDLE); + S_Sound (this, CHAN_BODY, 0, "misc/fallingsplat", 1, ATTN_IDLE); Translation = BloodTranslation; } return false; @@ -1238,7 +1238,7 @@ bool AActor::Grind(bool items) gib->radius = 0; gib->Translation = BloodTranslation; } - S_Sound (this, CHAN_BODY, "misc/fallingsplat", 1, ATTN_IDLE); + S_Sound (this, CHAN_BODY, 0, "misc/fallingsplat", 1, ATTN_IDLE); } if (flags & MF_ICECORPSE) { @@ -1437,7 +1437,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target, bool onsky, FNa // play the sound before changing the state, so that AActor::OnDestroy can call S_RelinkSounds on it and the death state can override it. if (mo->DeathSound) { - S_Sound (mo, CHAN_VOICE, mo->DeathSound, 1, + S_Sound (mo, CHAN_VOICE, 0, mo->DeathSound, 1, (mo->flags3 & MF3_FULLVOLDEATH) ? ATTN_NONE : ATTN_NORM); } @@ -1501,15 +1501,15 @@ void AActor::PlayBounceSound(bool onfloor) { if (BounceFlags & BOUNCE_UseSeeSound) { - S_Sound (this, CHAN_VOICE, SeeSound, 1, ATTN_IDLE); + S_Sound (this, CHAN_VOICE, 0, SeeSound, 1, ATTN_IDLE); } else if (onfloor || WallBounceSound <= 0) { - S_Sound (this, CHAN_VOICE, BounceSound, 1, ATTN_IDLE); + S_Sound (this, CHAN_VOICE, 0, BounceSound, 1, ATTN_IDLE); } else { - S_Sound (this, CHAN_VOICE, WallBounceSound, 1, ATTN_IDLE); + S_Sound (this, CHAN_VOICE, 0, WallBounceSound, 1, ATTN_IDLE); } } } @@ -2786,14 +2786,14 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj) // Why should this number vary by gravity? if (mo->Vel.Z < -mo->player->mo->FloatVar(NAME_GruntSpeed)) { - S_Sound (mo, CHAN_VOICE, "*grunt", 1, ATTN_NORM); + S_Sound (mo, CHAN_VOICE, 0, "*grunt", 1, ATTN_NORM); grunted = true; } if (onmobj != NULL || !Terrains[P_GetThingFloorType (mo)].IsLiquid) { if (!grunted || !S_AreSoundsEquivalent (mo, "*grunt", "*land")) { - S_Sound (mo, CHAN_AUTO, "*land", 1, ATTN_NORM); + S_Sound (mo, CHAN_AUTO, 0, "*land", 1, ATTN_NORM); } } } @@ -3107,7 +3107,7 @@ void AActor::Howl () FSoundID howl = SoundVar(NAME_HowlSound); if (!S_IsActorPlayingSomething(this, CHAN_BODY, howl)) { - S_Sound (this, CHAN_BODY, howl, 1, ATTN_NORM); + S_Sound (this, CHAN_BODY, 0, howl, 1, ATTN_NORM); } } @@ -3267,7 +3267,7 @@ void AActor::PlayActiveSound () { if (ActiveSound && !S_IsActorPlayingSomething (this, CHAN_VOICE, -1)) { - S_Sound (this, CHAN_VOICE, ActiveSound, 1, + S_Sound (this, CHAN_VOICE, 0, ActiveSound, 1, (flags3 & MF3_FULLVOLACTIVE) ? ATTN_NONE : ATTN_IDLE); } } @@ -4353,7 +4353,7 @@ bool AActor::UpdateWaterLevel(bool dosplash) if (oldlevel < 3 && waterlevel == 3) { // Our head just went under. - S_Sound(this, CHAN_VOICE, "*dive", 1, ATTN_NORM); + S_Sound(this, CHAN_VOICE, 0, "*dive", 1, ATTN_NORM); } else if (oldlevel == 3 && waterlevel < 3) { @@ -4361,7 +4361,7 @@ bool AActor::UpdateWaterLevel(bool dosplash) if (player->air_finished > Level->maptime) { // We hadn't run out of air yet. - S_Sound(this, CHAN_VOICE, "*surface", 1, ATTN_NORM); + S_Sound(this, CHAN_VOICE, 0, "*surface", 1, ATTN_NORM); } // If we were running out of air, then ResetAirSupply() will play *gasp. } @@ -5669,11 +5669,11 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, const DVector3 &pos1 if ((flags & PF_HITTHING) && puff->SeeSound) { // Hit thing sound - S_Sound (puff, CHAN_BODY, puff->SeeSound, 1, ATTN_NORM); + S_Sound (puff, CHAN_BODY, 0, puff->SeeSound, 1, ATTN_NORM); } else if (puff->AttackSound) { - S_Sound (puff, CHAN_BODY, puff->AttackSound, 1, ATTN_NORM); + S_Sound (puff, CHAN_BODY, 0, puff->AttackSound, 1, ATTN_NORM); } } @@ -6100,13 +6100,13 @@ foundone: } if (mo) { - S_Sound(mo, CHAN_ITEM, smallsplash ? + S_Sound(mo, CHAN_ITEM, 0, smallsplash ? splash->SmallSplashSound : splash->NormalSplashSound, 1, ATTN_IDLE); } else { - S_Sound(thing->Level, pos, CHAN_ITEM, smallsplash ? + S_Sound(thing->Level, pos, CHAN_ITEM, 0, smallsplash ? splash->SmallSplashSound : splash->NormalSplashSound, 1, ATTN_IDLE); } @@ -6303,18 +6303,18 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner) { if (!(missile->flags & MF_SPAWNSOUNDSOURCE)) { - S_Sound (missile, CHAN_VOICE, missile->SeeSound, 1, ATTN_NORM); + S_Sound (missile, CHAN_VOICE, 0, missile->SeeSound, 1, ATTN_NORM); } else if (spawner != NULL) { - S_Sound (spawner, CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM); + S_Sound (spawner, CHAN_WEAPON, 0, 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_Sound (missile->Level, missile->Pos(), CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM); + S_Sound (missile->Level, missile->Pos(), CHAN_WEAPON, 0, missile->SeeSound, 1, ATTN_NORM); } } } diff --git a/src/playsim/p_spec.cpp b/src/playsim/p_spec.cpp index c1b99b4df3..80a506f257 100644 --- a/src/playsim/p_spec.cpp +++ b/src/playsim/p_spec.cpp @@ -598,7 +598,7 @@ void P_GiveSecret(FLevelLocals *Level, AActor *actor, bool printmessage, bool pl Printf(PRINT_NONOTIFY, "Secret found in sector %d\n", sectornum); } } - if (playsound) S_Sound (CHAN_AUTO | CHAN_UI, "misc/secret", 1, ATTN_NORM); + if (playsound) S_Sound (CHAN_AUTO, CHANF_UI, "misc/secret", 1, ATTN_NORM); } } Level->found_secrets++; @@ -647,7 +647,7 @@ void P_PlayerOnSpecialFlat (player_t *player, int floorType) } if (damage > 0 && Terrains[floorType].Splash != -1) { - S_Sound (player->mo, CHAN_AUTO, + S_Sound (player->mo, CHAN_AUTO, 0, Splashes[Terrains[floorType].Splash].NormalSplashSound, 1, ATTN_IDLE); } diff --git a/src/playsim/p_switch.cpp b/src/playsim/p_switch.cpp index 81ce5b58bb..51248e6b5b 100644 --- a/src/playsim/p_switch.cpp +++ b/src/playsim/p_switch.cpp @@ -306,7 +306,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, uint8_t special, bool *q } if (playsound) { - S_Sound (side->GetLevel(), DVector3(pt, 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC); + S_Sound (side->GetLevel(), DVector3(pt, 0), CHAN_VOICE, CHANF_LISTENERZ, sound, 1, ATTN_STATIC); } if (quest != NULL) { @@ -402,7 +402,7 @@ void DActiveButton::Tick () if (def != NULL) { m_Frame = -1; - S_Sound (Level, DVector3(m_Pos, 0), CHAN_VOICE|CHAN_LISTENERZ, + S_Sound (Level, DVector3(m_Pos, 0), CHAN_VOICE, CHANF_LISTENERZ, def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"), 1, ATTN_STATIC); bFlippable = false; diff --git a/src/playsim/p_things.cpp b/src/playsim/p_things.cpp index 0874f07747..7e000a74a0 100644 --- a/src/playsim/p_things.cpp +++ b/src/playsim/p_things.cpp @@ -470,7 +470,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser, int flags) if (!P_CanResurrect(raiser, thing)) return false; - S_Sound (thing, CHAN_BODY, "vile/raise", 1, ATTN_IDLE); + S_Sound (thing, CHAN_BODY, 0, "vile/raise", 1, ATTN_IDLE); thing->Revive(); diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 1ad68b098d..bfc59d9bef 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -892,11 +892,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) { if (self->DeathSound != 0) { - S_Sound (self, CHAN_VOICE, self->DeathSound, 1, ATTN_NORM); + S_Sound (self, CHAN_VOICE, 0, self->DeathSound, 1, ATTN_NORM); } else { - S_Sound (self, CHAN_VOICE, "*death", 1, ATTN_NORM); + S_Sound (self, CHAN_VOICE, 0, "*death", 1, ATTN_NORM); } return 0; } @@ -946,7 +946,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream) } } } - S_Sound (self, chan, sound, 1, ATTN_NORM); + S_Sound (self, chan, 0, sound, 1, ATTN_NORM); return 0; } @@ -1094,7 +1094,7 @@ void P_FallingDamage (AActor *actor) if (actor->player) { - S_Sound (actor, CHAN_AUTO, "*land", 1, ATTN_NORM); + S_Sound (actor, CHAN_AUTO, 0, "*land", 1, ATTN_NORM); P_NoiseAlert (actor, actor, true); if (damage >= TELEFRAG_DAMAGE && ((actor->player->cheats & (CF_GODMODE | CF_BUDDHA) || (actor->FindInventory(PClass::FindActor(NAME_PowerBuddha), true) != nullptr)))) @@ -1170,7 +1170,7 @@ void P_CheckEnvironment(player_t *player) int id = S_FindSkinnedSound(player->mo, "*falling"); if (id != 0 && !S_IsActorPlayingSomething(player->mo, CHAN_VOICE, id)) { - S_Sound(player->mo, CHAN_VOICE, id, 1, ATTN_NORM); + S_Sound(player->mo, CHAN_VOICE, 0, id, 1, ATTN_NORM); } } } diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 7ad73c7e84..fe749755b2 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -174,6 +174,29 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_PlaySound, A_PlaySound) return 0; } +DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StartSound, A_StartSound) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_SOUND(soundid); + PARAM_INT(channel); + PARAM_INT(flags); + PARAM_FLOAT(volume); + PARAM_BOOL(looping); + PARAM_FLOAT(attenuation); + PARAM_BOOL(local); + PARAM_FLOAT(pitch); + A_StartSound(self, soundid, channel, flags, volume, looping, attenuation, local, pitch); + return 0; +} + +DEFINE_ACTION_FUNCTION_NATIVE(AActor, IsActorPlayingSomething, S_IsActorPlayingSomething) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(channel); + PARAM_SOUND(soundid); + ACTION_RETURN_BOOL(S_IsActorPlayingSomething(self, channel, soundid)); +} + DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckKeys, P_CheckKeys) { PARAM_SELF_PROLOGUE(AActor); diff --git a/src/sound/backend/i_soundinternal.h b/src/sound/backend/i_soundinternal.h index 99dc1badbb..8ee722086c 100644 --- a/src/sound/backend/i_soundinternal.h +++ b/src/sound/backend/i_soundinternal.h @@ -7,6 +7,32 @@ #include "tarray.h" #include "zmusic/sounddecoder.h" #include "../../libraries/music_common/fileio.h" +#include "tflags.h" + +enum EChanFlag +{ + // modifier flags + CHANF_LISTENERZ = 8, + CHANF_MAYBE_LOCAL = 16, + CHANF_UI = 32, // Do not record sound in savegames. + CHANF_NOPAUSE = 64, // Do not pause this sound in menus. + CHANF_AREA = 128, // Sound plays from all around. Only valid with sector sounds. + CHANF_LOOP = 256, + + CHANF_PICKUP = CHANF_MAYBE_LOCAL, + + CHANF_IS3D = 1, // internal: Sound is 3D. + CHANF_EVICTED = 2, // internal: Sound was evicted. + CHANF_FORGETTABLE = 4, // internal: Forget channel data when sound stops. + CHANF_JUSTSTARTED = 512, // internal: Sound has not been updated yet. + CHANF_ABSTIME = 1024, // internal: Start time is absolute and does not depend on current time. + CHANF_VIRTUAL = 2048, // internal: Channel is currently virtual + CHANF_NOSTOP = 4096, // only for A_PlaySound. Does not start if channel is playing something. + CHANF_OVERLAP = 8192, // [MK] Does not stop any sounds in the channel and instead plays over them. +}; + +typedef TFlags EChanFlags; +DEFINE_TFLAGS_OPERATORS(EChanFlags) class FileReader; @@ -111,7 +137,7 @@ struct FISoundChannel float DistanceScale; float DistanceSqr; bool ManualRolloff; - int ChanFlags; + EChanFlags ChanFlags; }; diff --git a/src/sound/backend/oalsound.cpp b/src/sound/backend/oalsound.cpp index 3f3ede72f5..b2357fc36b 100644 --- a/src/sound/backend/oalsound.cpp +++ b/src/sound/backend/oalsound.cpp @@ -1669,7 +1669,7 @@ void OpenALSoundRenderer::ChannelPitch(FISoundChannel *chan, float pitch) alDeferUpdatesSOFT(); ALuint source = GET_PTRID(chan->SysChannel); - if (WasInWater && !(chan->ChanFlags & CHAN_UI)) + if (WasInWater && !(chan->ChanFlags & CHANF_UI)) alSourcef(source, AL_PITCH, MAX(pitch, 0.0001f)*PITCH_MULT); else alSourcef(source, AL_PITCH, MAX(pitch, 0.0001f)); @@ -1947,7 +1947,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) while (schan) { ALuint source = GET_PTRID(schan->SysChannel); - if (source && !(schan->ChanFlags & CHAN_UI)) + if (source && !(schan->ChanFlags & CHANF_UI)) { alSourcei(source, AL_DIRECT_FILTER, EnvFilters[0]); alSource3i(source, AL_AUXILIARY_SEND_FILTER, EnvSlot, 0, EnvFilters[1]); @@ -1960,7 +1960,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) while (schan) { ALuint source = GET_PTRID(schan->SysChannel); - if (source && !(schan->ChanFlags & CHAN_UI)) + if (source && !(schan->ChanFlags & CHANF_UI)) alSourcef(source, AL_PITCH, schan->Pitch / 128.0f * PITCH_MULT); schan = schan->NextChan; } @@ -1985,7 +1985,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) while (schan) { ALuint source = GET_PTRID(schan->SysChannel); - if (source && !(schan->ChanFlags & CHAN_UI)) + if (source && !(schan->ChanFlags & CHANF_UI)) { alSourcei(source, AL_DIRECT_FILTER, EnvFilters[0]); alSource3i(source, AL_AUXILIARY_SEND_FILTER, EnvSlot, 0, EnvFilters[1]); @@ -1998,7 +1998,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) while (schan) { ALuint source = GET_PTRID(schan->SysChannel); - if (source && !(schan->ChanFlags & CHAN_UI)) + if (source && !(schan->ChanFlags & CHANF_UI)) alSourcef(source, AL_PITCH, schan->Pitch / 128.0f); schan = schan->NextChan; } diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index d2f7ba0f55..1ae59a8862 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -1910,7 +1910,7 @@ DEFINE_ACTION_FUNCTION(AAmbientSound, Tick) return 0; FAmbientSound *ambient; - int loop = 0; + EChanFlags loop = 0; ambient = Ambients.CheckKey(self->args[0]); if (ambient == NULL) @@ -1920,7 +1920,7 @@ DEFINE_ACTION_FUNCTION(AAmbientSound, Tick) if ((ambient->type & CONTINUOUS) == CONTINUOUS) { - loop = CHAN_LOOP; + loop = CHANF_LOOP; } if (ambient->sound != FSoundID(0)) @@ -1937,7 +1937,7 @@ DEFINE_ACTION_FUNCTION(AAmbientSound, Tick) // use the standard rolloff. if ((self->args[2] | self->args[3]) == 0 || self->args[2] > self->args[3]) { - S_Sound(self, CHAN_BODY | loop, ambient->sound, usevol, ambient->attenuation); + S_Sound(self, CHAN_BODY, loop, ambient->sound, usevol, ambient->attenuation); } else { @@ -1948,7 +1948,7 @@ DEFINE_ACTION_FUNCTION(AAmbientSound, Tick) min *= self->args[4]; max *= self->args[4]; } - S_SoundMinMaxDist(self, CHAN_BODY | loop, ambient->sound, usevol, min, max); + S_SoundMinMaxDist(self, CHAN_BODY, loop, ambient->sound, usevol, min, max); } if (!loop) { diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index efe414c9d6..45df5e6ba8 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -278,14 +278,14 @@ void S_InitData() // //========================================================================== -void S_SoundPitch(int channel, FSoundID sound_id, float volume, float attenuation, float pitch) +void S_SoundPitch(int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation, float pitch) { - soundEngine->StartSound(SOURCE_None, nullptr, nullptr, channel, sound_id, volume, attenuation, 0, pitch); + soundEngine->StartSound(SOURCE_None, nullptr, nullptr, channel, flags, sound_id, volume, attenuation, 0, pitch); } -void S_Sound(int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound(int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation) { - soundEngine->StartSound (SOURCE_None, nullptr, nullptr, channel, sound_id, volume, attenuation, 0, 0.f); + soundEngine->StartSound (SOURCE_None, nullptr, nullptr, channel, flags, sound_id, volume, attenuation, 0, 0.f); } DEFINE_ACTION_FUNCTION(DObject, S_Sound) @@ -296,10 +296,24 @@ DEFINE_ACTION_FUNCTION(DObject, S_Sound) PARAM_FLOAT(volume); PARAM_FLOAT(attn); PARAM_FLOAT(pitch); - S_SoundPitch(channel, id, static_cast(volume), static_cast(attn), static_cast(pitch)); + S_SoundPitch(channel & 7, EChanFlags::FromInt(channel & ~7), id, static_cast(volume), static_cast(attn), static_cast(pitch)); return 0; } +DEFINE_ACTION_FUNCTION(DObject, S_StartSound) +{ + PARAM_PROLOGUE; + PARAM_SOUND(id); + PARAM_INT(channel); + PARAM_INT(flags); + PARAM_FLOAT(volume); + PARAM_FLOAT(attn); + PARAM_FLOAT(pitch); + S_SoundPitch(channel, EChanFlags::FromInt(flags), id, static_cast(volume), static_cast(attn), static_cast(pitch)); + return 0; +} + + //========================================================================== // // @@ -324,12 +338,12 @@ FSoundID DoomSoundEngine::ResolveSound(const void * ent, int type, FSoundID soun // //========================================================================== -static bool VerifyActorSound(AActor* ent, FSoundID& sound_id, int& channel) +static bool VerifyActorSound(AActor* ent, FSoundID& sound_id, int& channel, EChanFlags flags) { if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != primaryLevel) return false; - if ((channel & CHAN_MAYBE_LOCAL) && (compatflags & COMPATF_SILENTPICKUP)) + if ((flags & CHANF_MAYBE_LOCAL) && (compatflags & COMPATF_SILENTPICKUP)) { if (soundEngine->isListener(ent)) { @@ -351,15 +365,15 @@ static bool VerifyActorSound(AActor* ent, FSoundID& sound_id, int& channel) // //========================================================================== -void S_SoundPitchActor(AActor *ent, int channel, FSoundID sound_id, float volume, float attenuation, float pitch) +void S_SoundPitchActor(AActor *ent, int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation, float pitch) { - if (VerifyActorSound(ent, sound_id, channel)) - soundEngine->StartSound (SOURCE_Actor, ent, nullptr, channel, sound_id, volume, attenuation, 0, pitch); + if (VerifyActorSound(ent, sound_id, channel, flags)) + soundEngine->StartSound (SOURCE_Actor, ent, nullptr, channel, flags, sound_id, volume, attenuation, 0, pitch); } -void S_Sound(AActor *ent, int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound(AActor *ent, int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation) { - S_SoundPitchActor(ent, channel, sound_id, volume, attenuation, 0.f); + S_SoundPitchActor(ent, channel, flags, sound_id, volume, attenuation, 0.f); } //========================================================================== @@ -370,16 +384,16 @@ void S_Sound(AActor *ent, int channel, FSoundID sound_id, float volume, float at // //========================================================================== -void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume, float mindist, float maxdist) +void S_SoundMinMaxDist(AActor *ent, int channel, EChanFlags flags, FSoundID sound_id, float volume, float mindist, float maxdist) { - if (VerifyActorSound(ent, sound_id, channel)) + if (VerifyActorSound(ent, sound_id, channel, flags)) { FRolloffInfo rolloff; rolloff.RolloffType = ROLLOFF_Linear; rolloff.MinDistance = mindist; rolloff.MaxDistance = maxdist; - soundEngine->StartSound(SOURCE_Actor, ent, nullptr, channel, sound_id, volume, 1, &rolloff); + soundEngine->StartSound(SOURCE_Actor, ent, nullptr, channel, flags, sound_id, volume, 1, &rolloff); } } @@ -389,10 +403,10 @@ void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume // //========================================================================== -void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound (const FPolyObj *poly, int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation) { if (poly->Level != primaryLevel) return; - soundEngine->StartSound (SOURCE_Polyobj, poly, nullptr, channel, sound_id, volume, attenuation); + soundEngine->StartSound (SOURCE_Polyobj, poly, nullptr, channel, flags, sound_id, volume, attenuation); } //========================================================================== @@ -401,12 +415,12 @@ void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume // //========================================================================== -void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation) { if (Level != primaryLevel) return; // The sound system switches Y and Z around. FVector3 p((float)pos.X, (float)pos.Z, (float)pos.Y); - soundEngine->StartSound (SOURCE_Unattached, nullptr, &p, channel, sound_id, volume, attenuation); + soundEngine->StartSound (SOURCE_Unattached, nullptr, &p, channel, flags, sound_id, volume, attenuation); } //========================================================================== @@ -415,10 +429,10 @@ void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, FSoundID sou // //========================================================================== -void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation) +void S_Sound (const sector_t *sec, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation) { if (sec->Level != primaryLevel) return; - soundEngine->StartSound (SOURCE_Sector, sec, nullptr, channel, sfxid, volume, attenuation); + soundEngine->StartSound (SOURCE_Sector, sec, nullptr, channel, flags, sfxid, volume, attenuation); } //========================================================================== @@ -429,47 +443,52 @@ void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, fl // //========================================================================== -void S_PlaySoundPitch(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local, float pitch) +void S_PlaySoundPitch(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local, float pitch) { if (a == nullptr || a->Sector->Flags & SECF_SILENT || a->Level != primaryLevel) return; if (!local) { - S_SoundPitchActor(a, chan, sid, vol, atten, pitch); + S_SoundPitchActor(a, chan, flags, sid, vol, atten, pitch); } else { if (a->CheckLocalView()) { - S_SoundPitch(chan, sid, vol, ATTN_NONE, pitch); + S_SoundPitch(chan, flags, sid, vol, ATTN_NONE, pitch); } } } -void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local) +void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local) { - S_PlaySoundPitch(a, chan, sid, vol, atten, local, 0.f); + S_PlaySoundPitch(a, chan, flags, sid, vol, atten, local, 0.f); } -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, int looping, double attenuation, int local, double pitch) { if (!looping) { - if (!(channel & CHAN_NOSTOP) || !S_IsActorPlayingSomething(self, channel & 7, soundid)) + if (!(flags & CHANF_NOSTOP) || !S_IsActorPlayingSomething(self, channel & 7, soundid)) { - S_PlaySoundPitch(self, channel, soundid, (float)volume, (float)attenuation, local, (float)pitch); + S_PlaySoundPitch(self, channel, EChanFlags::FromInt(flags), soundid, (float)volume, (float)attenuation, local, (float)pitch); } } else { if (!S_IsActorPlayingSomething(self, channel & 7, soundid)) { - S_PlaySoundPitch(self, channel | CHAN_LOOP, soundid, (float)volume, (float)attenuation, local, (float)pitch); + S_PlaySoundPitch(self, channel, EChanFlags::FromInt(flags) | CHANF_LOOP, soundid, (float)volume, (float)attenuation, local, (float)pitch); } } } +void A_PlaySound(AActor* self, int soundid, int channel, double volume, int looping, double attenuation, int local, double pitch) +{ + A_StartSound(self, soundid, channel & 7, channel & ~7, volume, looping, attenuation, local, pitch); +} + //========================================================================== // @@ -576,7 +595,7 @@ bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id) // //========================================================================== -bool S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id) +int S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id) { if (compatflags & COMPATF_MAGICSILENCE) { @@ -728,7 +747,7 @@ void S_SerializeSounds(FSerializer &arc) chan = (FSoundChan*)soundEngine->GetChannel(nullptr); arc(nullptr, *chan); // Sounds always start out evicted when restored from a save. - chan->ChanFlags |= CHAN_EVICTED | CHAN_ABSTIME; + chan->ChanFlags |= CHANF_EVICTED | CHANF_ABSTIME; } arc.EndArray(); } @@ -902,7 +921,7 @@ void DoomSoundEngine::CalcPosVel(int type, const void* source, const float pt[3] sector_t* sec = primaryLevel->PointInSector(pt[0], pt[2]); DVector2 disp = primaryLevel->Displacements.getOffset(pgroup, sec->PortalGroup); pos->X = pt[0] - (float)disp.X; - pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : (float)listenpos.Z; + pos->Y = !(chanflags & CHANF_LISTENERZ) ? pt[1] : (float)listenpos.Z; pos->Z = pt[2] - (float)disp.Y; } else @@ -939,7 +958,7 @@ void DoomSoundEngine::CalcPosVel(int type, const void* source, const float pt[3] if (sector != nullptr) { DVector2 disp = primaryLevel->Displacements.getOffset(pgroup, sector->PortalGroup); - if (chanflags & CHAN_AREA) + if (chanflags & CHANF_AREA) { // listener must be reversely offset to calculate the proper sound origin. CalcSectorSoundOrg(listenpos + disp, sector, channum, *pos); @@ -951,7 +970,7 @@ void DoomSoundEngine::CalcPosVel(int type, const void* source, const float pt[3] pos->X = (float)(sector->centerspot.X - disp.X); pos->Z = (float)(sector->centerspot.Y - disp.Y); - chanflags |= CHAN_LISTENERZ; + chanflags |= CHANF_LISTENERZ; } } break; @@ -972,7 +991,7 @@ void DoomSoundEngine::CalcPosVel(int type, const void* source, const float pt[3] } } - if ((chanflags & CHAN_LISTENERZ) && players[consoleplayer].camera != nullptr) + if ((chanflags & CHANF_LISTENERZ) && players[consoleplayer].camera != nullptr) { pos->Y = (float)listenpos.Z; } @@ -1108,14 +1127,14 @@ void DoomSoundEngine::NoiseDebug() char temp[32]; SoundEngine::CalcPosVel(chan, &origin, nullptr); - color = (chan->ChanFlags & CHAN_LOOP) ? CR_BROWN : CR_GREY; + color = (chan->ChanFlags & CHANF_LOOP) ? CR_BROWN : CR_GREY; // Name Wads.GetLumpName(temp, S_sfx[chan->SoundID].lumpnum); temp[8] = 0; screen->DrawText(NewConsoleFont, color, 0, y, temp, TAG_DONE); - if (!(chan->ChanFlags & CHAN_IS3D)) + if (!(chan->ChanFlags & CHANF_IS3D)) { screen->DrawText(NewConsoleFont, color, 70, y, "---", TAG_DONE); // X screen->DrawText(NewConsoleFont, color, 120, y, "---", TAG_DONE); // Y @@ -1162,15 +1181,15 @@ void DoomSoundEngine::NoiseDebug() // Flags mysnprintf(temp, countof(temp), "%s3%sZ%sU%sM%sN%sA%sL%sE%sV", - (chan->ChanFlags & CHAN_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_MAYBE_LOCAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_NOPAUSE) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_AREA) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_LOOP) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, - (chan->ChanFlags & CHAN_VIRTUAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK); + (chan->ChanFlags & CHANF_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_MAYBE_LOCAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_NOPAUSE) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_AREA) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_LOOP) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK, + (chan->ChanFlags & CHANF_VIRTUAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK); screen->DrawText(NewConsoleFont, color, 380, y, temp, TAG_DONE); // Audibility @@ -1266,7 +1285,7 @@ CCMD (playsound) } else { - S_Sound (CHAN_AUTO | CHAN_UI, id, 1.f, ATTN_NONE); + S_Sound (CHAN_AUTO, CHANF_UI, id, 1.f, ATTN_NONE); } } } @@ -1291,7 +1310,7 @@ CCMD (loopsound) AActor *icon = Spawn(primaryLevel, "SpeakerIcon", players[consoleplayer].mo->PosPlusZ(32.), ALLOW_REPLACE); if (icon != nullptr) { - S_Sound(icon, CHAN_BODY | CHAN_LOOP, id, 1.f, ATTN_IDLE); + S_Sound(icon, CHAN_BODY, CHANF_LOOP, id, 1.f, ATTN_IDLE); } } } diff --git a/src/sound/s_doomsound.h b/src/sound/s_doomsound.h index e36cf6030c..d1b3e197d6 100644 --- a/src/sound/s_doomsound.h +++ b/src/sound/s_doomsound.h @@ -16,21 +16,21 @@ void S_SetSoundPaused(int state); void S_PrecacheLevel(FLevelLocals* l); // Start sound for thing at -void S_Sound(int channel, FSoundID sfxid, float volume, float attenuation); -void S_SoundPitch(int channel, FSoundID sfxid, float volume, float attenuation, float pitch); +void S_Sound(int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); +void S_SoundPitch(int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation, float pitch); -void S_Sound (AActor *ent, int channel, FSoundID sfxid, float volume, float attenuation); -void S_SoundMinMaxDist (AActor *ent, int channel, FSoundID sfxid, float volume, float mindist, float maxdist); -void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, float attenuation); -void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation); -void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, FSoundID sfxid, float volume, float attenuation); +void S_Sound (AActor *ent, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); +void S_SoundMinMaxDist (AActor *ent, int channel, EChanFlags flags, FSoundID sfxid, float volume, float mindist, float maxdist); +void S_Sound (const FPolyObj *poly, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); +void S_Sound (const sector_t *sec, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); +void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation); -void S_SoundPitchActor (AActor *ent, int channel, FSoundID sfxid, float volume, float attenuation, float pitch); +void S_SoundPitchActor (AActor *ent, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation, float pitch); // [Nash] Used by ACS and DECORATE -void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local); -void S_PlaySoundPitch(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local, float pitch); +void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local); +void S_PlaySoundPitch(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local, float pitch); // Stops a sound emanating from one of an emitter's channels. void S_StopSound (AActor *ent, int channel); @@ -45,7 +45,7 @@ bool S_GetSoundPlayingInfo (const AActor *actor, int sound_id); bool S_GetSoundPlayingInfo (const sector_t *sector, int sound_id); bool S_GetSoundPlayingInfo (const FPolyObj *poly, int sound_id); -bool S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id); +int S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id); // Change a playing sound's volume void S_ChangeActorSoundVolume(AActor *actor, int channel, double volume); @@ -57,6 +57,7 @@ void S_ChangeActorSoundPitch(AActor *actor, int channel, double pitch); void S_SerializeSounds(FSerializer &arc); 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 flags, int channel, double volume, int looping, double attenuation, int local, double pitch); static void S_SetListener(AActor *listenactor); void S_SoundReset(); void S_ResumeSound(bool state); diff --git a/src/sound/s_sndseq.cpp b/src/sound/s_sndseq.cpp index 9bdbfb9239..4ed82903ab 100644 --- a/src/sound/s_sndseq.cpp +++ b/src/sound/s_sndseq.cpp @@ -118,7 +118,7 @@ public: void Serialize(FSerializer &arc); void MakeSound(int loop, FSoundID id) { - S_Sound(m_Actor, CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten); + S_Sound(m_Actor, CHAN_BODY, EChanFlags::FromInt(loop), id, clamp(m_Volume, 0.f, 1.f), m_Atten); } bool IsPlaying() { @@ -146,7 +146,7 @@ public: void Serialize(FSerializer &arc); void MakeSound(int loop, FSoundID id) { - S_Sound (m_Poly, CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten); + S_Sound (m_Poly, CHAN_BODY, EChanFlags::FromInt(loop), id, clamp(m_Volume, 0.f, 1.f), m_Atten); } bool IsPlaying() { @@ -174,8 +174,8 @@ public: void Serialize(FSerializer &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); + // The Channel here may have CHANF_LOOP encoded into it. + S_Sound(m_Sector, Channel & 7, CHANF_AREA | EChanFlags::FromInt(loop| (Channel & ~7)), id, clamp(m_Volume, 0.f, 1.f), m_Atten); } bool IsPlaying() { @@ -1162,7 +1162,7 @@ bool SN_IsMakingLoopingSound (sector_t *sector) DSeqNode *next = node->NextSequence(); if (node->Source() == (void *)sector) { - return !!(static_cast(node)->Channel & CHAN_LOOP); + return !!(static_cast(node)->Channel & CHANF_LOOP); } node = next; } @@ -1222,7 +1222,7 @@ void DSeqNode::Tick () { // Does not advance sequencePtr, so it will repeat as necessary. m_CurrentSoundID = FSoundID(GetData(*m_SequencePtr)); - MakeSound (CHAN_LOOP, m_CurrentSoundID); + MakeSound (CHANF_LOOP, m_CurrentSoundID); } return; diff --git a/src/sound/s_sndseq.h b/src/sound/s_sndseq.h index 17e4284d26..094bf5f6a4 100644 --- a/src/sound/s_sndseq.h +++ b/src/sound/s_sndseq.h @@ -5,6 +5,15 @@ #include "dobject.h" #include "s_sound.h" +enum +{ + // Sound channel aliases for sound sequences. + CHAN_CEILING = CHAN_WEAPON, + CHAN_FLOOR = CHAN_VOICE, + CHAN_INTERIOR = CHAN_ITEM, + CHAN_FULLHEIGHT = CHAN_BODY, +}; + typedef enum { SEQ_PLATFORM, SEQ_DOOR, diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index 5a957cd4b8..bcb84d18bb 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -285,7 +285,7 @@ TArray SoundEngine::AllActiveChannels() // If the sound is forgettable, this is as good a time as // any to forget about it. And if it's a UI sound, it shouldn't // be stored in the savegame. - if (!(chan->ChanFlags & (CHAN_FORGETTABLE | CHAN_UI))) + if (!(chan->ChanFlags & (CHANF_FORGETTABLE | CHANF_UI))) { chans.Push(chan); } @@ -306,7 +306,7 @@ FString SoundEngine::ListSoundChannels() int count = 0; for (chan = Channels; chan != nullptr; chan = chan->NextChan) { - if (!(chan->ChanFlags & CHAN_EVICTED)) + if (!(chan->ChanFlags & CHANF_EVICTED)) { FVector3 chanorigin; @@ -376,11 +376,11 @@ FSoundID SoundEngine::ResolveSound(const void *, int, FSoundID soundid, float &a //========================================================================== FSoundChan *SoundEngine::StartSound(int type, const void *source, - const FVector3 *pt, int channel, FSoundID sound_id, float volume, float attenuation, + const FVector3 *pt, int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation, FRolloffInfo *forcedrolloff, float spitch) { sfxinfo_t *sfx; - int chanflags; + EChanFlags chanflags = flags; int basepriority; int org_id; int pitch; @@ -396,7 +396,6 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, if (type == SOURCE_Unattached && pt == nullptr) type = SOURCE_None; org_id = sound_id; - chanflags = channel & ~7; channel &= 7; CalcPosVel(type, source, &pt->X, channel, chanflags, sound_id, &pos, &vel); @@ -461,7 +460,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, // If this is a singular sound, don't play it if it's already playing. if (sfx->bSingular && CheckSingular(sound_id)) { - chanflags |= CHAN_EVICTED; + chanflags |= CHANF_EVICTED; } // If the sound is unpositioned or comes from the listener, it is @@ -475,13 +474,13 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, // that's what would happen. (Does this really need the SOURCE_Actor restriction?) if (near_limit > 0 && CheckSoundLimit(sfx, pos, near_limit, limit_range, type, type == SOURCE_Actor? source : nullptr, channel)) { - chanflags |= CHAN_EVICTED; + chanflags |= CHANF_EVICTED; } // If the sound is blocked and not looped, return now. If the sound // is blocked and looped, pretend to play it so that it can // eventually play for real. - if ((chanflags & (CHAN_EVICTED | CHAN_LOOP)) == CHAN_EVICTED) + if ((chanflags & (CHANF_EVICTED | CHANF_LOOP)) == CHANF_EVICTED) { return NULL; } @@ -531,7 +530,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, } // If this actor is already playing something on the selected channel, stop it. - if (type != SOURCE_None && ((source == NULL && channel != CHAN_AUTO) || (source != NULL && IsChannelUsed(type, source, channel, &seen)))) + if (!(chanflags & CHANF_OVERLAP) && type != SOURCE_None && ((source == NULL && channel != CHAN_AUTO) || (source != NULL && IsChannelUsed(type, source, channel, &seen)))) { for (chan = Channels; chan != NULL; chan = chan->NextChan) { @@ -552,7 +551,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, // sound is paused and a non-looped sound is being started. // Such a sound would play right after unpausing which wouldn't sound right. - if (!(chanflags & CHAN_LOOP) && !(chanflags & (CHAN_UI|CHAN_NOPAUSE)) && SoundPaused) + if (!(chanflags & CHANF_LOOP) && !(chanflags & (CHANF_UI|CHANF_NOPAUSE)) && SoundPaused) { return NULL; } @@ -567,17 +566,17 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, pitch = DEFAULT_PITCH; } - if (chanflags & CHAN_EVICTED) + if (chanflags & CHANF_EVICTED) { chan = NULL; } else { int startflags = 0; - if (chanflags & CHAN_LOOP) startflags |= SNDF_LOOP; - if (chanflags & CHAN_AREA) startflags |= SNDF_AREA; - if (chanflags & (CHAN_UI|CHAN_NOPAUSE)) startflags |= SNDF_NOPAUSE; - if (chanflags & CHAN_UI) startflags |= SNDF_NOREVERB; + if (chanflags & CHANF_LOOP) startflags |= SNDF_LOOP; + if (chanflags & CHANF_AREA) startflags |= SNDF_AREA; + if (chanflags & (CHANF_UI|CHANF_NOPAUSE)) startflags |= SNDF_NOPAUSE; + if (chanflags & CHANF_UI) startflags |= SNDF_NOREVERB; if (attenuation > 0) { @@ -589,19 +588,19 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, chan = (FSoundChan*)GSnd->StartSound (sfx->data, float(volume), pitch, startflags, NULL); } } - if (chan == NULL && (chanflags & CHAN_LOOP)) + if (chan == NULL && (chanflags & CHANF_LOOP)) { chan = (FSoundChan*)GetChannel(NULL); GSnd->MarkStartTime(chan); - chanflags |= CHAN_EVICTED; + chanflags |= CHANF_EVICTED; } if (attenuation > 0) { - chanflags |= CHAN_IS3D | CHAN_JUSTSTARTED; + chanflags |= CHANF_IS3D | CHANF_JUSTSTARTED; } else { - chanflags |= CHAN_LISTENERZ | CHAN_JUSTSTARTED; + chanflags |= CHANF_LISTENERZ | CHANF_JUSTSTARTED; } if (chan != NULL) { @@ -642,7 +641,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, void SoundEngine::RestartChannel(FSoundChan *chan) { - assert(chan->ChanFlags & CHAN_EVICTED); + assert(chan->ChanFlags & CHANF_EVICTED); FSoundChan *ochan; sfxinfo_t *sfx = &S_sfx[chan->SoundID]; @@ -660,15 +659,15 @@ void SoundEngine::RestartChannel(FSoundChan *chan) return; } - int oldflags = chan->ChanFlags; + EChanFlags oldflags = chan->ChanFlags; int startflags = 0; - if (chan->ChanFlags & CHAN_LOOP) startflags |= SNDF_LOOP; - if (chan->ChanFlags & CHAN_AREA) startflags |= SNDF_AREA; - if (chan->ChanFlags & (CHAN_UI|CHAN_NOPAUSE)) startflags |= SNDF_NOPAUSE; - if (chan->ChanFlags & CHAN_ABSTIME) startflags |= SNDF_ABSTIME; + if (chan->ChanFlags & CHANF_LOOP) startflags |= SNDF_LOOP; + if (chan->ChanFlags & CHANF_AREA) startflags |= SNDF_AREA; + if (chan->ChanFlags & (CHANF_UI|CHANF_NOPAUSE)) startflags |= SNDF_NOPAUSE; + if (chan->ChanFlags & CHANF_ABSTIME) startflags |= SNDF_ABSTIME; - if (chan->ChanFlags & CHAN_IS3D) + if (chan->ChanFlags & CHANF_IS3D) { FVector3 pos, vel; @@ -687,13 +686,13 @@ void SoundEngine::RestartChannel(FSoundChan *chan) } LoadSound3D(sfx, &SoundBuffer); - chan->ChanFlags &= ~(CHAN_EVICTED|CHAN_ABSTIME); + chan->ChanFlags &= ~(CHANF_EVICTED|CHANF_ABSTIME); ochan = (FSoundChan*)GSnd->StartSound3D(sfx->data3d, &listener, chan->Volume, &chan->Rolloff, chan->DistanceScale, chan->Pitch, chan->Priority, pos, vel, chan->EntChannel, startflags, chan); } else { - chan->ChanFlags &= ~(CHAN_EVICTED|CHAN_ABSTIME); + chan->ChanFlags &= ~(CHANF_EVICTED|CHANF_ABSTIME); ochan = (FSoundChan*)GSnd->StartSound(sfx->data, chan->Volume, chan->Pitch, startflags, chan); } assert(ochan == NULL || ochan == chan); @@ -884,7 +883,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_ for (chan = Channels, count = 0; chan != NULL && count < near_limit; chan = chan->NextChan) { - if (!(chan->ChanFlags & CHAN_EVICTED) && &S_sfx[chan->SoundID] == sfx) + if (!(chan->ChanFlags & CHANF_EVICTED) && &S_sfx[chan->SoundID] == sfx) { FVector3 chanorigin; @@ -1015,7 +1014,7 @@ void SoundEngine::RelinkSound (int sourcetype, const void *from, const void *to, { chan->Source = to; } - else if (!(chan->ChanFlags & CHAN_LOOP) && optpos) + else if (!(chan->ChanFlags & CHANF_LOOP) && optpos) { chan->Source = NULL; chan->SourceType = SOURCE_Unattached; @@ -1183,15 +1182,15 @@ void SoundEngine::EvictAllChannels() { next = chan->NextChan; - if (!(chan->ChanFlags & CHAN_EVICTED)) + if (!(chan->ChanFlags & CHANF_EVICTED)) { - chan->ChanFlags |= CHAN_EVICTED; + chan->ChanFlags |= CHANF_EVICTED; if (chan->SysChannel != NULL) { - if (!(chan->ChanFlags & CHAN_ABSTIME)) + if (!(chan->ChanFlags & CHANF_ABSTIME)) { chan->StartTime = GSnd ? GSnd->GetPosition(chan) : 0; - chan->ChanFlags |= CHAN_ABSTIME; + chan->ChanFlags |= CHANF_ABSTIME; } StopChannel(chan); } @@ -1215,22 +1214,22 @@ void SoundEngine::RestoreEvictedChannel(FSoundChan *chan) return; } RestoreEvictedChannel(chan->NextChan); - if (chan->ChanFlags & CHAN_EVICTED) + if (chan->ChanFlags & CHANF_EVICTED) { RestartChannel(chan); - if (!(chan->ChanFlags & CHAN_LOOP)) + if (!(chan->ChanFlags & CHANF_LOOP)) { - if (chan->ChanFlags & CHAN_EVICTED) + if (chan->ChanFlags & CHANF_EVICTED) { // Still evicted and not looping? Forget about it. ReturnChannel(chan); } - else if (!(chan->ChanFlags & CHAN_JUSTSTARTED)) + else if (!(chan->ChanFlags & CHANF_JUSTSTARTED)) { // Should this sound become evicted again, it's okay to forget about it. - chan->ChanFlags |= CHAN_FORGETTABLE; + chan->ChanFlags |= CHANF_FORGETTABLE; } } } - else if (chan->SysChannel == NULL && (chan->ChanFlags & (CHAN_FORGETTABLE | CHAN_LOOP)) == CHAN_FORGETTABLE) + else if (chan->SysChannel == NULL && (chan->ChanFlags & (CHANF_FORGETTABLE | CHANF_LOOP)) == CHANF_FORGETTABLE) { ReturnChannel(chan); } @@ -1264,16 +1263,16 @@ void SoundEngine::UpdateSounds(int time) for (FSoundChan* chan = Channels; chan != NULL; chan = chan->NextChan) { - if ((chan->ChanFlags & (CHAN_EVICTED | CHAN_IS3D)) == CHAN_IS3D) + if ((chan->ChanFlags & (CHANF_EVICTED | CHANF_IS3D)) == CHANF_IS3D) { CalcPosVel(chan, &pos, &vel); if (ValidatePosVel(chan, pos, vel)) { - GSnd->UpdateSoundParams3D(&listener, chan, !!(chan->ChanFlags & CHAN_AREA), pos, vel); + GSnd->UpdateSoundParams3D(&listener, chan, !!(chan->ChanFlags & CHANF_AREA), pos, vel); } } - chan->ChanFlags &= ~CHAN_JUSTSTARTED; + chan->ChanFlags &= ~CHANF_JUSTSTARTED; } GSnd->UpdateListener(&listener); @@ -1342,11 +1341,11 @@ void SoundEngine::ChannelEnded(FISoundChannel *ichan) // it wasn't evicted. Otherwise, if it's looping, it must have // been evicted. If it's not looping, then it was evicted if it // didn't reach the end of its playback. - if (schan->ChanFlags & CHAN_FORGETTABLE) + if (schan->ChanFlags & CHANF_FORGETTABLE) { evicted = false; } - else if (schan->ChanFlags & (CHAN_LOOP | CHAN_EVICTED)) + else if (schan->ChanFlags & (CHANF_LOOP | CHANF_EVICTED)) { evicted = true; } @@ -1356,7 +1355,7 @@ void SoundEngine::ChannelEnded(FISoundChannel *ichan) unsigned int len = GSnd->GetSampleLength(S_sfx[schan->SoundID].data); if (pos == 0) { - evicted = !!(schan->ChanFlags & CHAN_JUSTSTARTED); + evicted = !!(schan->ChanFlags & CHANF_JUSTSTARTED); } else { @@ -1369,7 +1368,7 @@ void SoundEngine::ChannelEnded(FISoundChannel *ichan) } else { - schan->ChanFlags |= CHAN_EVICTED; + schan->ChanFlags |= CHANF_EVICTED; schan->SysChannel = NULL; } } @@ -1386,11 +1385,11 @@ void SoundEngine::ChannelVirtualChanged(FISoundChannel *ichan, bool is_virtual) FSoundChan *schan = static_cast(ichan); if (is_virtual) { - schan->ChanFlags |= CHAN_VIRTUAL; + schan->ChanFlags |= CHANF_VIRTUAL; } else { - schan->ChanFlags &= ~CHAN_VIRTUAL; + schan->ChanFlags &= ~CHANF_VIRTUAL; } } @@ -1409,9 +1408,9 @@ void SoundEngine::StopChannel(FSoundChan *chan) { // S_EvictAllChannels() will set the CHAN_EVICTED flag to indicate // that it wants to keep all the channel information around. - if (!(chan->ChanFlags & CHAN_EVICTED)) + if (!(chan->ChanFlags & CHANF_EVICTED)) { - chan->ChanFlags |= CHAN_FORGETTABLE; + chan->ChanFlags |= CHANF_FORGETTABLE; if (chan->SourceType == SOURCE_Actor) { chan->Source = NULL; diff --git a/src/sound/s_soundinternal.h b/src/sound/s_soundinternal.h index 9983eb4940..183232c391 100644 --- a/src/sound/s_soundinternal.h +++ b/src/sound/s_soundinternal.h @@ -194,43 +194,20 @@ struct FSoundChan : public FISoundChannel // CHAN_BODY is for generic body sounds // CHAN_PICKUP can optionally be set as a local sound only for "compatibility" -enum +enum EChannel { - CHAN_AUTO = 0, - CHAN_WEAPON = 1, - CHAN_VOICE = 2, - CHAN_ITEM = 3, - CHAN_BODY = 4, - CHAN_5 = 5, - CHAN_6 = 6, - CHAN_7 = 7, - - // Channel alias for sector sounds. These define how listener height is - // used when calculating 3D sound volume. - CHAN_FLOOR = 1, // Sound comes from the floor. - CHAN_CEILING = 2, // Sound comes from the ceiling. - CHAN_FULLHEIGHT = 3, // Sound comes entire height of the sector. - CHAN_INTERIOR = 4, // Sound comes height between floor and ceiling. - - // modifier flags - CHAN_LISTENERZ = 8, - CHAN_MAYBE_LOCAL = 16, - CHAN_UI = 32, // Do not record sound in savegames. - CHAN_NOPAUSE = 64, // Do not pause this sound in menus. - CHAN_AREA = 128, // Sound plays from all around. Only valid with sector sounds. - CHAN_LOOP = 256, - - CHAN_PICKUP = (CHAN_ITEM|CHAN_MAYBE_LOCAL), - - CHAN_IS3D = 1, // internal: Sound is 3D. - CHAN_EVICTED = 2, // internal: Sound was evicted. - CHAN_FORGETTABLE = 4, // internal: Forget channel data when sound stops. - CHAN_JUSTSTARTED = 512, // internal: Sound has not been updated yet. - CHAN_ABSTIME = 1024, // internal: Start time is absolute and does not depend on current time. - CHAN_VIRTUAL = 2048, // internal: Channel is currently virtual - CHAN_NOSTOP = 4096, // only for A_PlaySound. Does not start if channel is playing something. + CHAN_AUTO = 0, + CHAN_WEAPON = 1, + CHAN_VOICE = 2, + CHAN_ITEM = 3, + CHAN_BODY = 4, + CHAN_5 = 5, + CHAN_6 = 6, + CHAN_7 = 7, }; + + // sound attenuation values #define ATTN_NONE 0.f // full volume the entire level #define ATTN_NORM 1.f @@ -329,7 +306,7 @@ public: void UpdateSounds(int time); FSoundChan* StartSound(int sourcetype, const void* source, - const FVector3* pt, int channel, FSoundID sound_id, float volume, float attenuation, FRolloffInfo* rolloff = nullptr, float spitch = 0.0f); + const FVector3* pt, int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation, FRolloffInfo* rolloff = nullptr, float spitch = 0.0f); // Stops an origin-less sound from playing from this channel. void StopSoundID(int sound_id); diff --git a/src/win32/st_start_util.cpp b/src/win32/st_start_util.cpp index 7a0593b73b..b347a3439f 100644 --- a/src/win32/st_start_util.cpp +++ b/src/win32/st_start_util.cpp @@ -511,7 +511,7 @@ void FHexenStartupScreen::Progress() y = ST_PROGRESS_Y; ST_Util_DrawBlock(StartupBitmap, NotchBits, x, y, ST_NOTCH_WIDTH / 2, ST_NOTCH_HEIGHT); } - S_Sound(CHAN_BODY, "StartupTick", 1, ATTN_NONE); + S_Sound(CHAN_BODY, 0, "StartupTick", 1, ATTN_NONE); } } I_GetEvent(); @@ -539,7 +539,7 @@ void FHexenStartupScreen::NetProgress(int count) y = ST_NETPROGRESS_Y; ST_Util_DrawBlock(StartupBitmap, NetNotchBits, x, y, ST_NETNOTCH_WIDTH / 2, ST_NETNOTCH_HEIGHT); } - S_Sound(CHAN_BODY, "misc/netnotch", 1, ATTN_NONE); + S_Sound(CHAN_BODY, 0, "misc/netnotch", 1, ATTN_NONE); I_GetEvent(); } } @@ -554,7 +554,7 @@ void FHexenStartupScreen::NetProgress(int count) void FHexenStartupScreen::NetDone() { - S_Sound(CHAN_BODY, "PickupWeapon", 1, ATTN_NORM); + S_Sound(CHAN_BODY, 0, "PickupWeapon", 1, ATTN_NORM); FGraphicalStartupScreen::NetDone(); } diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index dc52b342cc..d5bc371484 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -1054,13 +1054,15 @@ class Actor : Thinker native deprecated("2.3") native void A_BulletAttack(); native void A_WolfAttack(int flags = 0, sound whattoplay = "weapons/pistol", double snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, double runspeed = 160.0, class pufftype = "BulletPuff"); - native clearscope void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false, double pitch = 0.0); + /*deprecated("4.3")*/ native clearscope void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false, double pitch = 0.0); + native clearscope void A_StartSound(sound whattoplay, int slot, int flags = 0, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false, double pitch = 0.0); native void A_SoundVolume(int slot, double volume); native void A_SoundPitch(int slot, double pitch); - deprecated("2.3") void A_PlayWeaponSound(sound whattoplay) { A_PlaySound(whattoplay, CHAN_WEAPON); } + deprecated("2.3") void A_PlayWeaponSound(sound whattoplay) { A_StartSound(whattoplay, CHAN_WEAPON); } native void A_StopSound(int slot = CHAN_VOICE); // Bad default but that's what is originally was... deprecated("2.3") native void A_PlaySoundEx(sound whattoplay, name slot, bool looping = false, int attenuation = 0); deprecated("2.3") native void A_StopSoundEx(name slot); + native bool IsActorPlayingSomething(int channel, Sound snd = 0); native void A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); native action state A_Jump(int chance, statelabel label, ...); native Actor A_SpawnProjectile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET); diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 48e66b05eb..ee233dc1d5 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -444,7 +444,8 @@ class Object native { return level.PickPlayerStart(pnum, flags); } - native static void S_Sound (Sound sound_id, int channel, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0); + deprecated("4.3") native static void S_Sound (Sound sound_id, int channel, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0); + native static void S_StartSound (Sound sound_id, int flags, int channel, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0); native static void S_PauseSound (bool notmusic, bool notsfx); native static void S_ResumeSound (bool notsfx); native static bool S_ChangeMusic(String music_name, int order = 0, bool looping = true, bool force = false); diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index 13266602dc..2b299e7778 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -419,7 +419,8 @@ enum ESoundFlags CHAN_NOPAUSE = 64, CHAN_LOOP = 256, CHAN_PICKUP = (CHAN_ITEM|CHAN_MAYBE_LOCAL), - CHAN_NOSTOP = 4096 + CHAN_NOSTOP = 4096, + CHAN_OVERLAP = 8192, }; diff --git a/wadsrc/static/zscript/ui/menu/colorpickermenu.zs b/wadsrc/static/zscript/ui/menu/colorpickermenu.zs index 8cc23babf5..188d9f2722 100644 --- a/wadsrc/static/zscript/ui/menu/colorpickermenu.zs +++ b/wadsrc/static/zscript/ui/menu/colorpickermenu.zs @@ -241,7 +241,7 @@ class ColorpickerMenu : OptionMenu { mGridPosX = cell_x; mGridPosY = cell_y; - //S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); + //S_Sound (CHAN_VOICE, CHANF_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); } mDesc.mSelectedItem = mStartItem+7; if (type == MOUSE_Release) diff --git a/wadsrc/static/zscript/ui/menu/conversationmenu.zs b/wadsrc/static/zscript/ui/menu/conversationmenu.zs index ac16eeab33..eb60fa650d 100644 --- a/wadsrc/static/zscript/ui/menu/conversationmenu.zs +++ b/wadsrc/static/zscript/ui/menu/conversationmenu.zs @@ -383,7 +383,7 @@ class ConversationMenu : Menu } if (sel != -1 && sel != mSelection) { - //S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); + //S_Sound (CHAN_VOICE, CHANF_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); } mSelection = sel; if (type == MOUSE_Release) diff --git a/wadsrc/static/zscript/ui/menu/messagebox.zs b/wadsrc/static/zscript/ui/menu/messagebox.zs index 3f9669e162..68e8119253 100644 --- a/wadsrc/static/zscript/ui/menu/messagebox.zs +++ b/wadsrc/static/zscript/ui/menu/messagebox.zs @@ -304,7 +304,7 @@ class MessageBoxMenu : Menu } if (sel != -1 && sel != messageSelection) { - //S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); + //S_Sound (CHAN_VOICE, CHANF_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); } messageSelection = sel; if (type == MOUSE_Release) diff --git a/wadsrc/static/zscript/ui/menu/optionmenu.zs b/wadsrc/static/zscript/ui/menu/optionmenu.zs index a08355eb01..1a27b82651 100644 --- a/wadsrc/static/zscript/ui/menu/optionmenu.zs +++ b/wadsrc/static/zscript/ui/menu/optionmenu.zs @@ -393,7 +393,7 @@ class OptionMenu : Menu if (yline != mDesc.mSelectedItem) { mDesc.mSelectedItem = yline; - //S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); + //S_Sound (CHAN_VOICE, CHANF_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); } mDesc.mItems[yline].MouseEvent(type, x, y); return true;