Merge branch 'develop' into ryzomclassic-develop

ryzomclassic-develop
kaetemi 5 years ago
commit 90e1297c1d

@ -108,7 +108,7 @@ public:
bool play(const std::string &filepath, uint xFadeTime = 0, bool async = true, bool loop = true);
/// Stop the music previously loaded and played (the Memory is also freed)
void stop(uint xFadeTime = 0);
bool stop(uint xFadeTime = 0);
/// Pause the music previously loaded and played (the Memory is not freed)
void pause();

@ -96,6 +96,8 @@ private:
IAudioDecoder *m_AudioDecoder;
std::string m_LookupPath;
bool m_Paused;
bool m_DecodingEnded;

@ -34,7 +34,7 @@ class CCurlHttpClient
public:
/// Constructor
CCurlHttpClient() {}
CCurlHttpClient() : _CurlStruct(NULL) {}
/// Connect to an http server (string by val is intended). If you specify a whole URL, an attempt will be made to determine the server.
bool connect(const std::string &server);

@ -3830,9 +3830,15 @@ void CDriverD3D::CLightState::apply(CDriverD3D *driver)
void CDriverD3D::CRenderTargetState::apply(CDriverD3D *driver)
{
H_AUTO_D3D(CDriverD3D_CRenderTargetState);
driver->_DeviceInterface->SetRenderTarget (0, Target);
nlassert(TargetOwned); // Can only apply once!
driver->_DeviceInterface->SetRenderTarget(0, Target);
driver->setupViewport(driver->_Viewport);
driver->setupScissor(driver->_Scissor);
if (TargetOwned)
{
Target->Release();
TargetOwned = false;
}
}
// ***************************************************************************

@ -1546,11 +1546,13 @@ public:
Texture = NULL;
Level = 0;
CubeFace = 0;
TargetOwned = false;
}
IDirect3DSurface9 *Target;
ITexture *Texture;
uint8 Level;
uint8 CubeFace;
bool TargetOwned;
virtual void apply(CDriverD3D *driver);
};
@ -2076,10 +2078,17 @@ public:
NL_D3D_CACHE_TEST(CacheTest_RenderTarget, _RenderTarget.Target != target)
#endif // NL_D3D_USE_RENDER_STATE_CACHE
{
if (_RenderTarget.TargetOwned)
{
nlassert(_RenderTarget.Target);
_RenderTarget.Target->Release();
}
_RenderTarget.Target = target;
_RenderTarget.Texture = texture;
_RenderTarget.Level = level;
_RenderTarget.CubeFace = cubeFace;
_RenderTarget.TargetOwned = target;
target->AddRef();
touchRenderVariable (&_RenderTarget);

@ -706,9 +706,13 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
// Set the texture states
if (text || (stage == 0))
{
// Doesn't use a pixel shader ? Set the textures stages
if (pShader->PixelShader == NULL)
if (matShader == CMaterial::Program)
{
// Do nothing for user pixel shader
}
else if (!pShader->PixelShader)
{
// Doesn't use a pixel shader ? Set the textures stages
if (pShader->RGBPipe[stage])
{
setTextureState (stage, D3DTSS_COLOROP, pShader->ColorOp[stage]);
@ -1145,7 +1149,7 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
}
break;
case CMaterial::Cloud:
case CMaterial::Cloud:
{
H_AUTO_D3D(CDriverD3D_setupMaterial_setupCloudShader)
activeShader (&_ShaderCloud);
@ -1167,7 +1171,7 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
return false;
}
break;
case CMaterial::Water:
case CMaterial::Water:
{
H_AUTO_D3D(CDriverD3D_setupMaterial_setupWaterShader)
activeShader(mat.getTexture(3) ? &_ShaderWaterDiffuse : &_ShaderWaterNoDiffuse);
@ -1296,7 +1300,14 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
}
}
}
// CMaterial::Water
break; // CMaterial::Water
case CMaterial::Program:
{
H_AUTO_D3D(CDriverD3D_setupMaterial_setupProgramshader)
// No material shader
activeShader(NULL);
}
break;
}
// New material setuped

@ -1084,6 +1084,7 @@ void CDriverD3D::swapTextureHandle(ITexture &tex0, ITexture &tex1)
swap(t0->Height, t1->Height);
swap(t0->SrcCompressed, t1->SrcCompressed);
swap(t0->IsCube, t1->IsCube);
swap(t0->RenderTarget, t1->RenderTarget);
swap(t0->Levels, t1->Levels);
swap(t0->FirstMipMap, t1->FirstMipMap);
swap(t0->TextureMemory, t1->TextureMemory);

@ -246,6 +246,7 @@ void CFXAA::applyEffect()
// create render target
CTextureUser *otherRenderTarget = m_Driver->getRenderTargetManager().getRenderTarget(width, height, mode2D);
nlassert(otherRenderTarget);
// swap render target
CTextureUser texNull;

@ -56,18 +56,12 @@ IAudioDecoder::~IAudioDecoder()
IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &filepath, bool async, bool loop)
{
std::string lookup = CPath::lookup(filepath, false);
if (lookup.empty())
{
nlwarning("Music file %s does not exist!", filepath.c_str());
return NULL;
}
std::string type = CFile::getExtension(filepath);
CIFile *ifile = new CIFile();
ifile->setCacheFileOnOpen(!async);
ifile->allowBNPCacheFileOnOpen(!async);
ifile->open(lookup);
ifile->open(filepath);
IAudioDecoder *mb = createAudioDecoder(type, ifile, loop);

@ -147,7 +147,7 @@ void CMusicChannelFader::updateVolume()
*/
bool CMusicChannelFader::play(const std::string &filepath, uint xFadeTime, bool async, bool loop)
{
stop(xFadeTime);
bool stopped = stop(xFadeTime);
// Find the next best free music channel
uint nextFader = _MaxMusicFader;
@ -164,7 +164,7 @@ bool CMusicChannelFader::play(const std::string &filepath, uint xFadeTime, bool
// Play a song in it :)
_CMusicFader &fader = _MusicFader[_ActiveMusicFader];
if (xFadeTime) fader.fadeIn(xFadeTime);
if (xFadeTime && !stopped) fader.fadeIn(xFadeTime); // only fade in when fading out
else fader.XFadeVolume = 1.0f;
fader.Playing = true;
updateVolume(); // make sure at ok volume to start :)
@ -173,12 +173,17 @@ bool CMusicChannelFader::play(const std::string &filepath, uint xFadeTime, bool
}
/// Stop the music previously loaded and played (the Memory is also freed)
void CMusicChannelFader::stop(uint xFadeTime)
bool CMusicChannelFader::stop(uint xFadeTime)
{
if (xFadeTime)
{
bool stopped = true;
for (uint i = 0; i < _MaxMusicFader; ++i) if (_MusicFader[i].Playing)
{
_MusicFader[i].fadeOut(xFadeTime);
stopped = false; // fading
}
return stopped;
}
else
{
@ -188,6 +193,7 @@ void CMusicChannelFader::stop(uint xFadeTime)
_MusicFader[i].Fade = false;
_MusicFader[i].Playing = false;
}
return true;
}
}

@ -108,6 +108,13 @@ void CStreamFileSource::play()
//{
// nlwarning("Already waiting for play");
//}
std::string filepath = getStreamFileSound()->getFilePath();
m_LookupPath = NLMISC::CPath::lookup(filepath, false, false);
if (m_LookupPath.empty())
{
nlwarning("Music file %s does not exist!", filepath.c_str());
return;
}
if (!getStreamFileSound()->getAsync())
{
if (!prepareDecoder())
@ -272,7 +279,8 @@ bool CStreamFileSource::prepareDecoder()
if (!m_AudioDecoder)
{
// load the file
m_AudioDecoder = IAudioDecoder::createAudioDecoder(getStreamFileSound()->getFilePath(), getStreamFileSound()->getAsync(), getStreamFileSound()->getLooping());
nlassert(!m_LookupPath.empty());
m_AudioDecoder = IAudioDecoder::createAudioDecoder(m_LookupPath, getStreamFileSound()->getAsync(), getStreamFileSound()->getLooping());
if (!m_AudioDecoder)
{
nlwarning("Failed to create IAudioDecoder, likely invalid format");

@ -192,6 +192,7 @@ bool CCurlHttpClient::receive(string &res, bool verbose)
void CCurlHttpClient::disconnect()
{
curl_easy_cleanup(_Curl);
_Curl = NULL;
curl_global_cleanup();
}

@ -458,7 +458,13 @@ CClientConfig::CClientConfig()
SoundOn = true; // Default is with sound.
DriverSound = SoundDrvAuto;
SoundForceSoftwareBuffer = true;
SoundOutGameMusic = "main menu loop.ogg";
StartMusic = "main theme air.ogg"; // Use at game startup (originally no music)
EmptySlotMusic = "loading music loop.ogg"; // Use in character selection for empty slots
LoadingMusic = "main menu loop.ogg"; // Main loading used after leaving character selection, and when going back to character selection
KamiTeleportMusic = "kami teleport.ogg"; // Kami teleport
KaravanTeleportMusic = "karavan teleport.ogg"; // Karavan teleport
TeleportLoadingMusic = "loading music loop.ogg"; // Use for generic teleportations
DeathMusic = "death.ogg"; // Player death
SoundSFXVolume = 1.f;
SoundGameMusicVolume = 1.f;
SoundTPFade = 500;
@ -469,7 +475,7 @@ CClientConfig::CClientConfig()
UserEntitySoundLevel = 0.5f; // Default volume for sound in 1st person
UseEax = true; // Default to use EAX;
UseADPCM = false; // Defualt to PCM sample, NO ADPCM
MaxTrack = 32; // DEfault to 32 track
MaxTrack = 32; // Default to 32 track
ColorShout = CRGBA(150,0,0,255); // Default Shout color.
ColorTalk = CRGBA(255,255,255,255); // Default Talk color.
@ -1242,7 +1248,13 @@ void CClientConfig::setValues()
// SoundForceSoftwareBuffer
READ_BOOL_FV(SoundForceSoftwareBuffer);
// SoundOutGameMusic
READ_STRING_DEV(SoundOutGameMusic)
READ_STRING_DEV(StartMusic)
READ_STRING_DEV(EmptySlotMusic)
READ_STRING_DEV(LoadingMusic)
READ_STRING_DEV(KamiTeleportMusic)
READ_STRING_DEV(KaravanTeleportMusic)
READ_STRING_DEV(TeleportLoadingMusic)
READ_STRING_DEV(DeathMusic)
// SoundSFXVolume
READ_FLOAT_FV(SoundSFXVolume);
// SoundGameMusicVolume

@ -350,8 +350,14 @@ struct CClientConfig
/// SoundForceSoftwareBuffer
bool SoundForceSoftwareBuffer;
/// The outgame music file
string SoundOutGameMusic;
/// Music files
string StartMusic;
string EmptySlotMusic;
string LoadingMusic;
string KamiTeleportMusic;
string KaravanTeleportMusic;
string TeleportLoadingMusic;
string DeathMusic;
/// The Sound SFX Volume (0-1) (ie all but music)
float SoundSFXVolume;

@ -273,6 +273,73 @@ void setOutGameFullScreen()
CViewRenderer::getInstance()->setInterfaceScale(1.0f, 1024, 768);
}
// ------------------------------------------------------------------------------------------------
class CSoundGlobalMenu
{
public:
CSoundGlobalMenu()
{
_MusicWantedAsync= false;
_NbFrameBeforeChange= NbFrameBeforeChangeMax;
}
void reset();
void setMusic(const string &music, bool async);
void updateSound();
private:
string _MusicPlayed;
string _MusicWanted;
bool _MusicWantedAsync;
sint _NbFrameBeforeChange;
enum {NbFrameBeforeChangeMax= 10};
};
void CSoundGlobalMenu::reset()
{
_MusicPlayed.clear();
_MusicWanted.clear();
}
void CSoundGlobalMenu::updateSound()
{
// **** update the music played
// The first music played is the music played at loading, before select char
if (_MusicPlayed.empty())
_MusicPlayed = toLower(LoadingMusic.empty() ? ClientCfg.StartMusic : LoadingMusic);
if (_MusicWanted.empty())
_MusicWanted = toLower(LoadingMusic.empty() ? ClientCfg.StartMusic : LoadingMusic);
// because music is changed when the player select other race for instance,
// wait the 3D to load (stall some secs)
// if the wanted music is the same as the one currently playing, just continue playing
if(_MusicPlayed!=_MusicWanted)
{
// wait nbFrameBeforeChangeMax before actually changing the music
_NbFrameBeforeChange--;
if(_NbFrameBeforeChange<=0)
{
_MusicPlayed= _MusicWanted;
// play the music
if (SoundMngr != NULL)
SoundMngr->playMusic(_MusicPlayed, 500, _MusicWantedAsync, true, true);
}
}
// **** update mngr
if (SoundMngr != NULL)
SoundMngr->update();
}
void CSoundGlobalMenu::setMusic(const string &music, bool async)
{
_MusicWanted= toLower(music);
_MusicWantedAsync= async;
// reset the counter
_NbFrameBeforeChange= NbFrameBeforeChangeMax;
}
static CSoundGlobalMenu SoundGlobalMenu;
// New version of the menu after the server connection
//
@ -405,6 +472,8 @@ bool connection (const string &cookie, const string &fsaddr)
InterfaceState = GLOBAL_MENU;
}
// No loading music here, this is right before character selection, using the existing music
// Create the loading texture. We can't do that before because we need to add search path first.
beginLoading (LoadBackground);
UseEscapeDuringLoading = USE_ESCAPE_DURING_LOADING;
@ -506,6 +575,7 @@ bool reconnection()
ProgressBar.setFontFactor(1.0f);
// Init out game
SoundGlobalMenu.reset();
pIM->initOutGame();
// Hide cursor for interface
@ -521,6 +591,9 @@ bool reconnection()
FarTP.setOutgame();
if (SoundMngr)
SoundMngr->setupFadeSound(1.0f, 1.0f);
// these two globals sequence GlobalMenu to display the character select dialog
WaitServerAnswer = true;
userChar = true;
@ -555,6 +628,8 @@ bool reconnection()
// this also kicks the state machine to sendReady() so we stop spinning in farTPmainLoop
FarTP.setIngame();
// Not loading music here, this is before character selection, keep existing music
// Create the loading texture. We can't do that before because we need to add search path first.
beginLoading (LoadBackground);
UseEscapeDuringLoading = USE_ESCAPE_DURING_LOADING;
@ -729,66 +804,6 @@ std::string buildPlayerNameForSaveFile(const ucstring &playerNameIn)
return ret;
}
// ------------------------------------------------------------------------------------------------
class CSoundGlobalMenu
{
public:
CSoundGlobalMenu()
{
_MusicWantedAsync= false;
_NbFrameBeforeChange= NbFrameBeforeChangeMax;
}
void setMusic(const string &music, bool async);
void updateSound();
private:
string _MusicPlayed;
string _MusicWanted;
bool _MusicWantedAsync;
sint _NbFrameBeforeChange;
enum {NbFrameBeforeChangeMax= 10};
};
void CSoundGlobalMenu::updateSound()
{
// **** update the music played
// The first music played is the music played at loading, before select char
if(_MusicPlayed.empty())
_MusicPlayed= toLower(ClientCfg.SoundOutGameMusic);
if(_MusicWanted.empty())
_MusicWanted= toLower(ClientCfg.SoundOutGameMusic);
// because music is changed when the player select other race for instance,
// wait the 3D to load (stall some secs)
// if the wanted music is the same as the one currently playing, just continue playing
if(_MusicPlayed!=_MusicWanted)
{
// wait nbFrameBeforeChangeMax before actually changing the music
_NbFrameBeforeChange--;
if(_NbFrameBeforeChange<=0)
{
_MusicPlayed= _MusicWanted;
// play the music
if (SoundMngr != NULL)
SoundMngr->playMusic(_MusicPlayed, 500, _MusicWantedAsync, true, true);
}
}
// **** update mngr
if (SoundMngr != NULL)
SoundMngr->update();
}
void CSoundGlobalMenu::setMusic(const string &music, bool async)
{
_MusicWanted= toLower(music);
_MusicWantedAsync= async;
// reset the counter
_NbFrameBeforeChange= NbFrameBeforeChangeMax;
}
static CSoundGlobalMenu SoundGlobalMenu;
static bool LuaBGDSuccessFlag = true; // tmp, for debug
@ -2039,8 +2054,8 @@ public:
fromString(getParam(Params, "async"), async);
// if empty name, return to default mode
if(sName.empty())
sName= ClientCfg.SoundOutGameMusic;
if (sName.empty())
sName = ClientCfg.EmptySlotMusic;
// change the music
SoundGlobalMenu.setMusic(sName, async);

@ -1112,15 +1112,6 @@ void CFarTP::disconnectFromPreviousShard()
beginLoading (StartBackground);
UseEscapeDuringLoading = false;
// Play music and fade out the Game Sound
if (SoundMngr)
{
// Loading Music Loop.ogg
LoadingMusic = ClientCfg.SoundOutGameMusic;
SoundMngr->playEventMusic(LoadingMusic, CSoundManager::LoadingMusicXFade, true);
SoundMngr->fadeOutGameSound(ClientCfg.SoundTPFade);
}
// Change the tips
selectTipsOfTheDay (rand());
@ -1129,6 +1120,21 @@ void CFarTP::disconnectFromPreviousShard()
ucstring nmsg("Loading...");
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
ProgressBar.progress(0);
// Play music and fade out the Game Sound
if (SoundMngr)
{
SoundMngr->fadeOutGameSound(ClientCfg.SoundTPFade);
// Stop and enable music
SoundMngr->stopMusic(0);
SoundMngr->setupFadeSound(0.0f, 1.0f);
// Loading Music Loop.ogg
LoadingMusic = ClientCfg.LoadingMusic;
// SoundMngr->playEventMusic(LoadingMusic, CSoundManager::LoadingMusicXFade, true);
SoundMngr->playMusic(LoadingMusic, 0, false, true, true);
}
}
// Disconnect from the FS

@ -1411,6 +1411,42 @@ void prelogInit()
StereoDisplay->setDriver(Driver); // VR_DRIVER
}
{
H_AUTO(InitRZSound)
// Init the sound manager
nmsg = "Initializing sound manager...";
ProgressBar.newMessage(ClientCfg.buildLoadingString(nmsg));
if (ClientCfg.SoundOn)
{
nlassert(!SoundMngr);
SoundMngr = new CSoundManager(&ProgressBar);
try
{
SoundMngr->init(&ProgressBar);
}
catch(const Exception &e)
{
nlwarning("init : Error when creating 'SoundMngr' : %s", e.what());
delete SoundMngr;
SoundMngr = NULL;
}
// Play Music just after the SoundMngr is inited
if (SoundMngr)
{
// init the SoundMngr with backuped volume
SoundMngr->setSFXVolume(ClientCfg.SoundSFXVolume);
SoundMngr->setGameMusicVolume(ClientCfg.SoundGameMusicVolume);
// Play the login screen music
SoundMngr->playMusic(ClientCfg.StartMusic, 0, true, true, true);
}
}
CPath::memoryCompress(); // Because sound calls addSearchPath
}
nlinfo ("PROFILE: %d seconds for prelogInit", (uint32)(ryzomGetLocalTime ()-initStart)/1000);
FPU_CHECKER_ONCE
@ -1553,55 +1589,6 @@ void postlogInit()
// set the primitive context
CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig;
{
H_AUTO(InitRZSound)
// Init the sound manager
nmsg = "Initializing sound manager...";
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
if(ClientCfg.SoundOn)
{
SoundMngr = new CSoundManager(&ProgressBar);
try
{
SoundMngr->init(&ProgressBar);
}
catch(const Exception &e)
{
nlwarning("init : Error when creating 'SoundMngr' : %s", e.what());
delete SoundMngr;
SoundMngr = NULL;
}
// Play Music just after the SoundMngr is inited
if(SoundMngr)
{
// init the SoundMngr with backuped volume
SoundMngr->setSFXVolume(ClientCfg.SoundSFXVolume);
SoundMngr->setGameMusicVolume(ClientCfg.SoundGameMusicVolume);
// no fadein, and not async because don't work well because of loading in the main thread
// Force use GameMusic volume
const uint fadeInTime= 500;
SoundMngr->playMusic(ClientCfg.SoundOutGameMusic, fadeInTime, false, true, true);
// Because of blocking loading, force the fadeIn
TTime t0= ryzomGetLocalTime();
TTime t1;
while((t1=ryzomGetLocalTime())<t0+fadeInTime)
{
//ProgressBar.progress(1.f);
SoundMngr->updateAudioMixerOnly();
}
}
}
CPath::memoryCompress(); // Because sound call addSearchPath
initLast = initCurrent;
initCurrent = ryzomGetLocalTime();
//nlinfo ("PROFILE: %d seconds (%d total) for Initializing sound manager", (uint32)(initCurrent-initLast)/1000, (uint32)(initCurrent-initStart)/1000);
}
{
H_AUTO(InitRZShIdI)

@ -485,6 +485,27 @@ void initMainLoop()
FPU_CHECKER_ONCE
if (SoundMngr)
{
// Loading Music
LoadingMusic = ClientCfg.LoadingMusic;
// SoundMngr->playEventMusic(LoadingMusic, CSoundManager::LoadingMusicXFade, true);
// no fadein, and not async because don't work well because of loading in the main thread
// Force use GameMusic volume
const uint fadeInTime = 500;
SoundMngr->playMusic(LoadingMusic, fadeInTime, false, true, true);
// Because of blocking loading, force the fadeIn
TTime t0 = ryzomGetLocalTime();
TTime t1;
do
{
ProgressBar.progress(0);
SoundMngr->updateAudioMixerOnly();
nlSleep(10);
} while ((t1 = ryzomGetLocalTime()) < t0 + fadeInTime);
}
// Get the interface manager
CInterfaceManager *pIM = CInterfaceManager::getInstance();

@ -3279,6 +3279,7 @@ bool loginIntroSkip;
void loginIntro()
{
// Display of nevrax logo is done at init time (see init.cpp) just before addSearchPath (second one)
#if 0
for (uint i = 0; i < 1; i++) // previously display nevrax then nvidia
{
if (i != 0)
@ -3316,6 +3317,7 @@ void loginIntro()
NLGUI::CDBManager::getInstance()->flushObserverCalls();
}
}
#endif
beginLoading(StartBackground);
ProgressBar.finish();
}

@ -2233,19 +2233,21 @@ bool mainLoop()
{
StartPlayTime = NLMISC::CTime::getLocalTime();
}
// Start background sound play now ! (nb: restarted if load just ended, or if sound re-enabled)
if (SoundMngr)
{
H_AUTO_USE ( RZ_Client_Main_Loop_Sound )
SoundMngr->playBackgroundSound();
}
// Fade in Game Sound now (before endLoading)
if(SoundMngr)
{
// fade out loading music
if(LoadingMusic==SoundMngr->getEventMusicPlayed())
if (SoundMngr->getEventMusicPlayed() == LoadingMusic)
{
SoundMngr->stopEventMusic(LoadingMusic, CSoundManager::LoadingMusicXFade);
}
SoundMngr->playBackgroundSound();
// Fade in Game Sound now (before endLoading)
// fade in game sound
SoundMngr->fadeInGameSound(ClientCfg.SoundTPFade);
}
@ -2509,7 +2511,7 @@ bool mainLoop()
EditActions.enable(true);
// For stoping the outgame music, start after 30 frames, and duration of 3 seconds
// CMusicFader outgameFader(60, 3);
outgameFader = CMusicFader(60, 3);
// check for banned player
if (testPermanentBanMarkers())

@ -1483,32 +1483,33 @@ void impulseTPCommon(NLMISC::CBitMemStream &impulse, bool hasSeason)
void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason)
{
// choose a default screen if not setuped
if( LoadingBackground!=ResurectKamiBackground && LoadingBackground!=ResurectKaravanBackground &&
LoadingBackground!=TeleportKamiBackground && LoadingBackground!=TeleportKaravanBackground)
LoadingBackground= TeleportKaravanBackground;
if (LoadingBackground != ResurectKamiBackground && LoadingBackground != ResurectKaravanBackground
&& LoadingBackground != TeleportKamiBackground && LoadingBackground != TeleportKaravanBackground)
LoadingBackground = ElevatorBackground;
// if resurect but user not dead, choose default. NB: this is a bug, the tp impulse should tell
// which background to choose. \todo yoyo: this is a temp fix
if( UserEntity && !UserEntity->isDead() &&
(LoadingBackground==ResurectKamiBackground || LoadingBackground==ResurectKaravanBackground) )
LoadingBackground= TeleportKaravanBackground;
if (UserEntity && !UserEntity->isDead() && (LoadingBackground == ResurectKamiBackground || LoadingBackground == ResurectKaravanBackground))
LoadingBackground = ElevatorBackground;
// Play music according to the background
if(SoundMngr)
if (SoundMngr)
{
LoadingMusic.clear();
if(LoadingBackground==TeleportKamiBackground)
LoadingMusic= "Kami Teleport.ogg";
else if(LoadingBackground==TeleportKaravanBackground)
LoadingMusic= "Karavan Teleport.ogg";
// if resurection, continue to play death music
else if(LoadingBackground==ResurectKamiBackground || LoadingBackground==ResurectKaravanBackground)
{
// noop
}
// default: loading music
else
switch (LoadingBackground)
{
LoadingMusic= "Loading Music Loop.ogg";
case TeleportKamiBackground:
LoadingMusic = ClientCfg.KamiTeleportMusic;
break;
case TeleportKaravanBackground:
LoadingMusic = ClientCfg.KaravanTeleportMusic;
break;
case ResurectKamiBackground:
case ResurectKaravanBackground:
// TODO: Resurrect music
break;
default:
LoadingMusic = ClientCfg.TeleportLoadingMusic;
break;
}
// start to play

@ -4309,20 +4309,19 @@ void CUserEntity::updatePreCollision(const NLMISC::TTime &time, CEntityCL *targe
// test each frame if the mode has changed
if(SoundMngr)
{
string deadMusic= "death.ogg";
// Play/stop music if comes from or goes to dead
bool isDead= _Mode==MBEHAV::DEATH || _Mode==MBEHAV::SWIM_DEATH;
bool isDead = _Mode == MBEHAV::DEATH || _Mode == MBEHAV::SWIM_DEATH;
// must start music?
if( isDead && SoundMngr->getEventMusicPlayed()!=deadMusic )
if (isDead && SoundMngr->getEventMusicPlayed() != ClientCfg.DeathMusic)
{
SoundMngr->playEventMusic(deadMusic, 0, true);
SoundMngr->playEventMusic(ClientCfg.DeathMusic, 0, true);
}
// must end music?
if( !isDead && SoundMngr->getEventMusicPlayed()==deadMusic )
if (!isDead && SoundMngr->getEventMusicPlayed() == ClientCfg.DeathMusic)
{
SoundMngr->stopEventMusic(deadMusic, CSoundManager::LoadingMusicXFade);
SoundMngr->stopEventMusic(ClientCfg.DeathMusic, CSoundManager::LoadingMusicXFade);
}
}
}

Loading…
Cancel
Save