code cleanup

* gave reverb functions the proper 'S_' prefix for consistency.
* Blood: fixed license of 4 files which do not contain any NBlood code anymore (sound code was completely rewritten, and all such code has long been moved out of d_menu.cpp)
* Blood: renamed VIEWPOS_* constants
This commit is contained in:
Christoph Oelckers 2023-09-26 21:09:35 +02:00
parent e0e459216d
commit 8a0f79141b
19 changed files with 60 additions and 76 deletions

View file

@ -189,7 +189,7 @@ static void GameTicker()
{
g_nextmap = currentLevel;
FX_StopAllSounds();
FX_SetReverb(0);
S_SetReverb(0);
NewGame(g_nextmap, -1);
BackupSaveGame = "";
}
@ -197,7 +197,7 @@ static void GameTicker()
case ga_completed:
FX_StopAllSounds();
FX_SetReverb(0);
S_SetReverb(0);
gi->LevelCompleted(g_nextmap, g_nextskill);
break;
@ -214,7 +214,7 @@ static void GameTicker()
[[fallthrough]];
case ga_newgamenostopsound:
DeleteScreenJob();
FX_SetReverb(0);
S_SetReverb(0);
C_FlushDisplay();
BackupSaveGame = "";
NewGame(g_nextmap, g_nextskill, ga == ga_newgamenostopsound);

View file

@ -52,16 +52,16 @@ static int LastReverb;
CUSTOM_CVAR(Bool, snd_reverb, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{
FX_SetReverb(-1);
S_SetReverb(-1);
}
// This is for testing reverb settings.
CUSTOM_CVAR(Int, snd_reverbtype, -1, 0)
{
FX_SetReverb(-1);
S_SetReverb(-1);
}
void FX_SetReverb(int strength)
void S_SetReverb(int strength)
{
if (strength == -1) strength = LastReverb;
if (snd_reverbtype > -1)

View file

@ -24,7 +24,7 @@ inline void FX_StopAllSounds(void)
soundEngine->StopAllChannels();
}
void FX_SetReverb(int strength);
void S_SetReverb(int strength);
inline void FX_SetReverbDelay(int delay)
{

View file

@ -126,11 +126,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, SoundEnabled, SoundEnabled)
ACTION_RETURN_INT(SoundEnabled());
}
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, SetReverb, FX_SetReverb)
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, SetReverb, S_SetReverb)
{
PARAM_PROLOGUE;
PARAM_INT(i);
FX_SetReverb(i);
S_SetReverb(i);
return 0;
}

View file

@ -253,7 +253,7 @@ void genDudeAttack1(int, DBloodActor* actor)
gKillMgr.AddKillCount(spawned);
pExtra->slave[pExtra->slaveCount++] = spawned;
if (!playGenDudeSound(actor, kGenDudeSndAttackNormal))
sfxPlay3DSoundCP(actor, 379, 1, 0, 0x10000 - Random3(0x3000));
sfxPlay3DSoundVolume(actor, 379, 1, 0, 0x10000 - Random3(0x3000));
}
}
}
@ -1391,7 +1391,7 @@ void removeLeech(DBloodActor* actLeech, bool delSprite)
effectactor->spr.scale = DVector2(repeat, repeat);
}
sfxPlay3DSoundCP(actLeech, 490, -1, 0, 60000);
sfxPlay3DSoundVolume(actLeech, 490, -1, 0, 60000);
if (actLeech->GetOwner())
actLeech->GetOwner()->genDudeExtra.pLifeLeech = nullptr;
@ -1412,7 +1412,7 @@ void killDudeLeech(DBloodActor* actLeech)
if (actLeech != NULL)
{
actDamageSprite(actLeech->GetOwner(), actLeech, kDamageExplode, 65535);
sfxPlay3DSoundCP(actLeech, 522, -1, 0, 60000);
sfxPlay3DSoundVolume(actLeech, 522, -1, 0, 60000);
if (actLeech->GetOwner() != nullptr)
actLeech->GetOwner()->genDudeExtra.pLifeLeech = nullptr;

View file

@ -837,7 +837,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
viewAddEffect(tsprites, nTSprite, kViewEffectShowWeapon);
}
if (thisPlayer->flashEffect && (pPlayer != thisPlayer || gViewPos != VIEWPOS_0)) {
if (thisPlayer->flashEffect && (pPlayer != thisPlayer || gViewPos != viewFirstPerson)) {
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectShoot);
if (pNTSprite) {
POSTURE* pPosture = &thisPlayer->pPosture[thisPlayer->lifeMode][thisPlayer->posture];
@ -866,7 +866,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
}
if (pTSprite->ownerActor != pPlayer->actor || gViewPos != VIEWPOS_0) {
if (pTSprite->ownerActor != pPlayer->actor || gViewPos != viewFirstPerson) {
if (getflorzofslopeptr(pTSprite->sectp, pTSprite->pos) >= cPos.Z)
{
viewAddEffect(tsprites, nTSprite, kViewEffectShadow);

View file

@ -1,13 +1,12 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
Copyright (C) 2020-2022 Christoph Oelckers
This file is part of NBlood.
This file is part of Raze
NBlood is free software; you can redistribute it and/or
Raze is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -15,9 +14,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
@ -128,18 +124,20 @@ void ambInit(void)
for (i = 0; i < nAmbChannels; i++, pChannel++)
if (actor->xspr.data3 == pChannel->check) break;
if (i == nAmbChannels) {
if (i == nAmbChannels)
{
if (i >= kMaxAmbChannel) {
if (i >= kMaxAmbChannel)
{
actor->spr.intowner = -1;
continue;
}
int nSFX = actor->xspr.data3;
auto snd = soundEngine->FindSoundByResID(nSFX);
if (!snd.isvalid()) {
//I_Error("Missing sound #%d used in ambient sound generator %d\n", nSFX);
viewSetSystemMessage("Missing sound #%d used in ambient sound generator #%d\n", nSFX, actor->GetIndex());
if (!snd.isvalid())
{
Printf(PRINT_HIGH | PRINT_NOTIFY, "Missing sound #%d used in ambient sound generator #%d\n", nSFX, actor->GetIndex());
actPostSprite(actor, kStatDecoration);
continue;
}

View file

@ -1,14 +1,12 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
Copyright (C) 2020 Christoph Oelckers
Copyright (C) 2020-2022 Christoph Oelckers
This file is part of Raze.
This file is part of Raze
NBlood is free software; you can redistribute it and/or
Raze is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -16,9 +14,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------

View file

@ -1,6 +1,6 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2020 - Christoph Oelckers
Copyright (C) 2020-2022 Christoph Oelckers
This file is part of Raze
@ -14,9 +14,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------

View file

@ -1735,7 +1735,7 @@ void debrisMove(int listIndex)
case kMarkerUpWater:
case kMarkerUpGoo:
int pitch = (150000 - (actor->spriteMass.mass << 9)) + Random3(8192);
sfxPlay3DSoundCP(actor, 720, -1, 0, pitch, 75 - Random(40));
sfxPlay3DSoundVolume(actor, 720, -1, 0, pitch, 75 - Random(40));
if (!spriteIsUnderwater(actor))
{
evKillActor(actor, kCallbackEnemeyBubble);
@ -6562,7 +6562,7 @@ void useSoundGen(DBloodActor* sourceactor, DBloodActor* actor)
{
int pitch = sourceactor->xspr.data4 << 1;
if (pitch < 2000) pitch = 0;
sfxPlay3DSoundCP(actor, sourceactor->xspr.data2, -1, 0, pitch, sourceactor->xspr.data3);
sfxPlay3DSoundVolume(actor, sourceactor->xspr.data2, -1, 0, pitch, sourceactor->xspr.data3);
}
//---------------------------------------------------------------------------

View file

@ -4,7 +4,7 @@ Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
Copyright (C) 2020 Raze developers and contributors
This file was part of NBlood.
This file is part of Raze.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
@ -34,13 +34,13 @@ BEGIN_BLD_NS
void GameInterface::ToggleThirdPerson()
{
if (gamestate != GS_LEVEL) return;
if (gViewPos > VIEWPOS_0)
if (gViewPos > viewFirstPerson)
{
gViewPos = VIEWPOS_0;
gViewPos = viewFirstPerson;
}
else
{
gViewPos = VIEWPOS_1;
gViewPos = viewThirdPerson;
cameradist = 0;
cameraclock = INT_MIN;
}

View file

@ -387,7 +387,7 @@ void SEQINST::Update()
{
auto udata = soundEngine->GetSfx(snd);
int relVol = udata ? udata->UserVal : 80;
sfxPlay3DSoundCP(actor, sndId, -1, 0, 0, (surfSfxMove[surf][2] != relVol) ? relVol : surfSfxMove[surf][3]);
sfxPlay3DSoundVolume(actor, sndId, -1, 0, 0, (surfSfxMove[surf][2] != relVol) ? relVol : surfSfxMove[surf][3]);
}
}
break;

View file

@ -1,13 +1,12 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
Copyright (C) 2020-2022 Christoph Oelckers
This file is part of NBlood.
This file is part of Raze
NBlood is free software; you can redistribute it and/or
Raze is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -15,11 +14,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include <string.h>
@ -184,7 +181,7 @@ void sfxPlay3DSound(const DVector3& pos, int soundId, sectortype* pSector)
//
//---------------------------------------------------------------------------
void sfxPlay3DSoundCP(DBloodActor* pActor, int soundId, int playchannel, int playflags, int pitch, int volume)
void sfxPlay3DSoundVolume(DBloodActor* pActor, int soundId, int playchannel, int playflags, int pitch, int volume)
{
if (!SoundEnabled() || soundId <= 0 || !pActor) return;
auto sid = soundEngine->FindSoundByResID(soundId);
@ -229,7 +226,7 @@ void sfxPlay3DSoundCP(DBloodActor* pActor, int soundId, int playchannel, int pla
void sfxPlay3DSound(DBloodActor* pActor, int soundId, int a3, int a4)
{
sfxPlay3DSoundCP(pActor, soundId, a3, a4, -1);
sfxPlay3DSoundVolume(pActor, soundId, a3, a4, -1);
}
@ -276,22 +273,22 @@ void sfxSetReverb(bool toggle)
{
if (toggle)
{
FX_SetReverb(128);
S_SetReverb(128);
FX_SetReverbDelay(10);
}
else
FX_SetReverb(0);
S_SetReverb(0);
}
void sfxSetReverb2(bool toggle)
{
if (toggle)
{
FX_SetReverb(128);
S_SetReverb(128);
FX_SetReverbDelay(20);
}
else
FX_SetReverb(0);
S_SetReverb(0);
}
END_BLD_NS

View file

@ -1,13 +1,12 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
Copyright (C) 2020-2022 Christoph Oelckers
This file is part of NBlood.
This file is part of Raze
NBlood is free software; you can redistribute it and/or
Raze is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -15,11 +14,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "build.h"

View file

@ -52,7 +52,7 @@ void sndInit(void);
void sfxPlay3DSound(const DVector3& pos, int soundId, sectortype* pSector);
void sfxPlay3DSound(DBloodActor* pSprite, int soundId, int a3 = -1, int a4 = 0);
void sfxPlay3DSoundCP(DBloodActor* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0);
void sfxPlay3DSoundVolume(DBloodActor* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0);
void sfxKill3DSound(DBloodActor* pSprite, int a2 = -1, int a3 = -1);
void sfxKillAllSounds(void);
void sfxSetReverb(bool toggle);

View file

@ -57,8 +57,8 @@ enum VIEW_EFFECT {
};
enum VIEWPOS {
VIEWPOS_0 = 0,
VIEWPOS_1
viewFirstPerson = 0,
viewThirdPerson
};
enum { kFontNum = 5 };

View file

@ -1148,7 +1148,7 @@ void enterlevel(MapRecord *mi, int gamemode)
// Stop all sounds
FX_StopAllSounds();
FX_SetReverb(0);
S_SetReverb(0);
auto p = &ps[0];

View file

@ -503,10 +503,10 @@ void GameInterface::SerializeGameState(FSerializer& arc)
Mus_ResumeSaved();
Mus_SetPaused(false);
FX_SetReverb(0);
S_SetReverb(0);
show_shareware = 0;
FX_SetReverb(0);
S_SetReverb(0);
resetlanepics();
}

View file

@ -631,7 +631,7 @@ void PlaySoundRTS(int rts_num)
void COVER_SetReverb(int amt)
{
FX_SetReverb(amt);
S_SetReverb(amt);
}
//==========================================================================