mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- moved a few bits of code around in Duke's sounds.cpp.
- refactored the only place in the entire code that used the return of S_PlaySound.
This commit is contained in:
parent
264a450bbe
commit
b5cc3ef883
3 changed files with 80 additions and 66 deletions
|
@ -568,7 +568,11 @@ void GameInterface::StartGame(FGameStartup& gs)
|
||||||
}
|
}
|
||||||
|
|
||||||
ud.m_player_skill = gs.Skill + 1;
|
ud.m_player_skill = gs.Skill + 1;
|
||||||
if (menu_sounds) ud.skill_voice = S_PlaySound(skillsound);
|
if (menu_sounds)
|
||||||
|
{
|
||||||
|
ud.skill_voice = skillsound;
|
||||||
|
S_PlaySound(skillsound);
|
||||||
|
}
|
||||||
ud.m_respawn_monsters = (gs.Skill == 3);
|
ud.m_respawn_monsters = (gs.Skill == 3);
|
||||||
ud.m_monsters_off = ud.monsters_off = 0;
|
ud.m_monsters_off = ud.monsters_off = 0;
|
||||||
ud.m_respawn_items = 0;
|
ud.m_respawn_items = 0;
|
||||||
|
|
|
@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
#include "mapinfo.h"
|
#include "mapinfo.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
static uint8_t precachehightile[2][(MAXTILES+7)>>3];
|
static uint8_t precachehightile[2][(MAXTILES+7)>>3];
|
||||||
|
@ -1321,9 +1322,10 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum)
|
||||||
|
|
||||||
if (ud.skill_voice > 0 && SoundEnabled())
|
if (ud.skill_voice > 0 && SoundEnabled())
|
||||||
{
|
{
|
||||||
while (FX_SoundActive(ud.skill_voice))
|
while (S_CheckSoundPlaying(ud.skill_voice))
|
||||||
gameHandleEvents();
|
gameHandleEvents();
|
||||||
}
|
}
|
||||||
|
ud.skill_voice = 0;
|
||||||
|
|
||||||
ready2send = 0;
|
ready2send = 0;
|
||||||
|
|
||||||
|
|
|
@ -118,70 +118,6 @@ void S_PauseSounds(bool paused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_MenuSound(void)
|
|
||||||
{
|
|
||||||
static int SoundNum;
|
|
||||||
int const menusnds[] = {
|
|
||||||
LASERTRIP_EXPLODE, DUKE_GRUNT, DUKE_LAND_HURT, CHAINGUN_FIRE, SQUISHED, KICK_HIT,
|
|
||||||
PISTOL_RICOCHET, PISTOL_BODYHIT, PISTOL_FIRE, SHOTGUN_FIRE, BOS1_WALK, RPG_EXPLODE,
|
|
||||||
PIPEBOMB_BOUNCE, PIPEBOMB_EXPLODE, NITEVISION_ONOFF, RPG_SHOOT, SELECT_WEAPON,
|
|
||||||
};
|
|
||||||
int s = VM_OnEventWithReturn(EVENT_OPENMENUSOUND, g_player[screenpeek].ps->i, screenpeek, FURY ? -1 : menusnds[SoundNum++ % ARRAY_SIZE(menusnds)]);
|
|
||||||
if (s != -1)
|
|
||||||
S_PlaySound(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void S_SetMusicIndex(unsigned int m)
|
|
||||||
{
|
|
||||||
ud.music_episode = m / MAXLEVELS;
|
|
||||||
ud.music_level = m % MAXLEVELS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void S_PlayLevelMusicOrNothing(unsigned int m)
|
|
||||||
{
|
|
||||||
ud.returnvar[0] = m / MAXLEVELS;
|
|
||||||
ud.returnvar[1] = m % MAXLEVELS;
|
|
||||||
|
|
||||||
int retval = VM_OnEvent(EVENT_PLAYLEVELMUSICSLOT, g_player[myconnectindex].ps->i, myconnectindex);
|
|
||||||
|
|
||||||
if (retval >= 0)
|
|
||||||
{
|
|
||||||
// Thanks to scripting that stupid slot hijack cannot be refactored - but we'll store the real data elsewhere anyway!
|
|
||||||
auto &mr = m == USERMAPMUSICFAKESLOT ? userMapRecord : mapList[m];
|
|
||||||
Mus_Play(mr.labelName, mr.music, true);
|
|
||||||
S_SetMusicIndex(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int S_TryPlaySpecialMusic(unsigned int m)
|
|
||||||
{
|
|
||||||
auto &musicfn = mapList[m].music;
|
|
||||||
if (musicfn.IsNotEmpty())
|
|
||||||
{
|
|
||||||
if (!Mus_Play(nullptr, musicfn, true))
|
|
||||||
{
|
|
||||||
S_SetMusicIndex(m);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void S_PlaySpecialMusicOrNothing(unsigned int m)
|
|
||||||
{
|
|
||||||
if (S_TryPlaySpecialMusic(m))
|
|
||||||
{
|
|
||||||
S_SetMusicIndex(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void S_ContinueLevelMusic(void)
|
|
||||||
{
|
|
||||||
VM_OnEvent(EVENT_CONTINUELEVELMUSICSLOT, g_player[myconnectindex].ps->i, myconnectindex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void S_Cleanup(void)
|
void S_Cleanup(void)
|
||||||
{
|
{
|
||||||
static uint32_t ldnum = 0;
|
static uint32_t ldnum = 0;
|
||||||
|
@ -717,4 +653,76 @@ int S_CheckSoundPlaying(int soundNum)
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)soundNum > (unsigned)g_highestSoundIdx)) return false;
|
if (EDUKE32_PREDICT_FALSE((unsigned)soundNum > (unsigned)g_highestSoundIdx)) return false;
|
||||||
return (g_sounds[soundNum].num != 0);
|
return (g_sounds[soundNum].num != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void S_MenuSound(void)
|
||||||
|
{
|
||||||
|
static int SoundNum;
|
||||||
|
int const menusnds[] = {
|
||||||
|
LASERTRIP_EXPLODE, DUKE_GRUNT, DUKE_LAND_HURT, CHAINGUN_FIRE, SQUISHED, KICK_HIT,
|
||||||
|
PISTOL_RICOCHET, PISTOL_BODYHIT, PISTOL_FIRE, SHOTGUN_FIRE, BOS1_WALK, RPG_EXPLODE,
|
||||||
|
PIPEBOMB_BOUNCE, PIPEBOMB_EXPLODE, NITEVISION_ONOFF, RPG_SHOOT, SELECT_WEAPON,
|
||||||
|
};
|
||||||
|
int s = VM_OnEventWithReturn(EVENT_OPENMENUSOUND, g_player[screenpeek].ps->i, screenpeek, FURY ? -1 : menusnds[SoundNum++ % ARRAY_SIZE(menusnds)]);
|
||||||
|
if (s != -1)
|
||||||
|
S_PlaySound(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void S_SetMusicIndex(unsigned int m)
|
||||||
|
{
|
||||||
|
ud.music_episode = m / MAXLEVELS;
|
||||||
|
ud.music_level = m % MAXLEVELS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void S_PlayLevelMusicOrNothing(unsigned int m)
|
||||||
|
{
|
||||||
|
ud.returnvar[0] = m / MAXLEVELS;
|
||||||
|
ud.returnvar[1] = m % MAXLEVELS;
|
||||||
|
|
||||||
|
int retval = VM_OnEvent(EVENT_PLAYLEVELMUSICSLOT, g_player[myconnectindex].ps->i, myconnectindex);
|
||||||
|
|
||||||
|
if (retval >= 0)
|
||||||
|
{
|
||||||
|
// Thanks to scripting that stupid slot hijack cannot be refactored - but we'll store the real data elsewhere anyway!
|
||||||
|
auto& mr = m == USERMAPMUSICFAKESLOT ? userMapRecord : mapList[m];
|
||||||
|
Mus_Play(mr.labelName, mr.music, true);
|
||||||
|
S_SetMusicIndex(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int S_TryPlaySpecialMusic(unsigned int m)
|
||||||
|
{
|
||||||
|
auto& musicfn = mapList[m].music;
|
||||||
|
if (musicfn.IsNotEmpty())
|
||||||
|
{
|
||||||
|
if (!Mus_Play(nullptr, musicfn, true))
|
||||||
|
{
|
||||||
|
S_SetMusicIndex(m);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void S_PlaySpecialMusicOrNothing(unsigned int m)
|
||||||
|
{
|
||||||
|
if (S_TryPlaySpecialMusic(m))
|
||||||
|
{
|
||||||
|
S_SetMusicIndex(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void S_ContinueLevelMusic(void)
|
||||||
|
{
|
||||||
|
VM_OnEvent(EVENT_CONTINUELEVELMUSICSLOT, g_player[myconnectindex].ps->i, myconnectindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
END_DUKE_NS
|
END_DUKE_NS
|
||||||
|
|
Loading…
Reference in a new issue