Skip to content

Commit

Permalink
Fixed section management in the new MusicChange calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Sep 12, 2018
1 parent 13cef26 commit efb84d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LunaDll/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ DEFMEM(GM_ORIG_LVL_BOUNDS, Bounds*, 0x00B2587C); // Same as above, but alwa
DEFMEM(GM_SEC_ISWARP, short*, 0x00B257F0);
DEFMEM(GM_SEC_OFFSCREEN, short*, 0x00B2580C);
DEFMEM(GM_SEC_NOTURNBACK, short*, 0x00B2C5EC);
DEFMEM(GM_SEC_CURRENT_MUSIC,short, 0x00B2C5D8);
DEFMEM(GM_SEC_ISUNDERWATER, short*, 0x00B2C608);
DEFMEM(GM_SEC_CURRENT_MUSIC_ID,short, 0x00B25888);

// Background objects
DEFMEM(GM_BGO_COUNT, WORD, 0x00B25958);
Expand Down
11 changes: 9 additions & 2 deletions LunaDll/LuaMain/LuaProxyComponent/LuaProxyAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../../Misc/MiscFuncs.h"
#include "../../GlobalFuncs.h"
#include "../../MciEmulator/mciEmulator.h"
#include "../../SMBXInternal/PlayerMOB.h"

#include "../../SMBXInternal/Level.h"

Expand Down Expand Up @@ -201,7 +202,10 @@ void LuaProxy::Audio::changeMusic(int section, const std::string &filename, int

// If the specified section's music is what's
// currently playing, force the change in config to be picked up
if(section == GM_SEC_CURRENT_MUSIC)
if(
(GM_SEC_CURRENT_MUSIC_ID >= 0) &&
(section == ::Player::Get(GM_MUSIC_RESTORE_PL > 0 ? GM_MUSIC_RESTORE_PL : 1)->CurrentSection)
)
{
playMusic(section);
if(fadeInDelayMs > 0)
Expand All @@ -221,7 +225,10 @@ void LuaProxy::Audio::changeMusic(int section, int musicId, int fadeInDelayMs)

// If the specified section's music is what's
// currently playing, force the change in config to be picked up
if(section == GM_SEC_CURRENT_MUSIC)
if(
(GM_SEC_CURRENT_MUSIC_ID >= 0) &&
(section == ::Player::Get(GM_MUSIC_RESTORE_PL > 0 ? GM_MUSIC_RESTORE_PL : 1)->CurrentSection)
)
{
if(fadeInDelayMs <= 0)
playMusic(section);
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
if "%1"=="" SET CONFIG=Release
if NOT "%1"=="" SET CONFIG=%1

"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" LunaDll.sln /nologo /p:Configuration="%CONFIG%" /p:Platfprm="Win32"
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" LunaDll.sln /m /nologo /p:Configuration="%CONFIG%" /p:Platfprm="Win32"

0 comments on commit efb84d5

Please sign in to comment.