[planetblupi] 01/13: Move the code to retrieve the music in a dedicated method
Didier Raboud
odyx at moszumanska.debian.org
Tue Feb 6 19:50:09 UTC 2018
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository planetblupi.
commit daa3dbf22bfb64d14e199b1eb70c158d9266a1fa
Author: Mathieu Schroeter <mathieu at schroetersa.ch>
Date: Wed Jan 31 06:50:56 2018 +0100
Move the code to retrieve the music in a dedicated method
---
src/event.cxx | 46 ++++++++++++++++++++++++++--------------------
src/event.h | 21 +++++++++++----------
2 files changed, 37 insertions(+), 30 deletions(-)
diff --git a/src/event.cxx b/src/event.cxx
index 31429a9..9854f0c 100644
--- a/src/event.cxx
+++ b/src/event.cxx
@@ -3065,6 +3065,31 @@ CEvent::IsHelpHide ()
return bHide;
}
+std::string
+CEvent::GetMusicLocation (Sint32 music)
+{
+ static const std::string exts[] = {"ogg", "mid"};
+ static const Location locs[] = {LOCATION_USER, LOCATION_BASE};
+ std::string absolute;
+
+ // Look for music in the user directory, then in the game directory.
+ for (size_t i = 0; i < countof (locs); ++i)
+ {
+ auto filename = string_format (
+ "music/music%.3d.%s", music - 1, exts[g_restoreMidi ? 1 : 0].c_str ());
+ if (!FileExists (filename, absolute, locs[i]))
+ filename = string_format (
+ "music/music%.3d.%s", music - 1, exts[g_restoreMidi ? 0 : 1].c_str ());
+
+ if (FileExists (filename, absolute, locs[i]))
+ break;
+
+ absolute = "";
+ }
+
+ return absolute;
+}
+
/**
* \brief Change the phase.
*
@@ -3374,26 +3399,7 @@ CEvent::ChangePhase (Uint32 phase)
music = m_pDecor->GetMusic ();
if (music > 0)
{
- static const std::string exts[] = {"ogg", "mid"};
- static const Location locs[] = {LOCATION_USER, LOCATION_BASE};
- std::string absolute;
-
- // Look for music in the user directory, then in the game directory.
- for (size_t i = 0; i < countof (locs); ++i)
- {
- filename = string_format (
- "music/music%.3d.%s", music - 1,
- exts[g_restoreMidi ? 1 : 0].c_str ());
- if (!FileExists (filename, absolute, locs[i]))
- filename = string_format (
- "music/music%.3d.%s", music - 1,
- exts[g_restoreMidi ? 0 : 1].c_str ());
-
- if (FileExists (filename, absolute, locs[i]))
- break;
-
- absolute = "";
- }
+ auto absolute = this->GetMusicLocation (music);
m_pSound->StopMusic ();
m_pSound->PlayMusic (absolute);
diff --git a/src/event.h b/src/event.h
index 4f16e91..73fe2d5 100644
--- a/src/event.h
+++ b/src/event.h
@@ -94,16 +94,17 @@ public:
Point GetMousePos ();
void
- Create (CPixmap * pPixmap, CDecor * pDecor, CSound * pSound, CMovie * pMovie);
- void SetFullScreen (bool bFullScreen);
- Sint32 GetWorld ();
- Sint32 GetPhysicalWorld ();
- Sint32 GetImageWorld ();
- bool IsHelpHide ();
- bool ChangePhase (Uint32 phase);
- bool MovieToStart ();
- Uint32 GetPhase ();
- void TryInsert ();
+ Create (CPixmap * pPixmap, CDecor * pDecor, CSound * pSound, CMovie * pMovie);
+ void SetFullScreen (bool bFullScreen);
+ Sint32 GetWorld ();
+ Sint32 GetPhysicalWorld ();
+ Sint32 GetImageWorld ();
+ bool IsHelpHide ();
+ std::string GetMusicLocation (Sint32 music);
+ bool ChangePhase (Uint32 phase);
+ bool MovieToStart ();
+ Uint32 GetPhase ();
+ void TryInsert ();
Sint32 GetButtonIndex (Sint32 button);
Sint32 GetState (Sint32 button);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/planetblupi.git
More information about the Pkg-games-commits
mailing list