mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
- fixed crash on hovering indestructible walls
- fix for music player (no music after end of battle)
This commit is contained in:
@@ -1515,7 +1515,7 @@ bool CBattleInterface::isCatapultAttackable(BattleHex hex) const
|
||||
return false;
|
||||
|
||||
int wallUnder = curInt->cb->battleHexToWallPart(hex);
|
||||
if(wallUnder == -1)
|
||||
if(wallUnder < 0) //invalid or indestructible
|
||||
return false;
|
||||
|
||||
return curInt->cb->battleGetWallState(wallUnder) < EWallState::DESTROYED;
|
||||
|
@@ -426,11 +426,7 @@ void CMusicHandler::queueNext(MusicEntry *queued)
|
||||
|
||||
next.reset(queued);
|
||||
|
||||
if (current.get() != NULL)
|
||||
{
|
||||
current->stop(1000);
|
||||
}
|
||||
else
|
||||
if (current.get() == nullptr || !current->stop(1000))
|
||||
{
|
||||
current.reset(next.release());
|
||||
current->play();
|
||||
@@ -480,7 +476,7 @@ void CMusicHandler::musicFinishedCallback(void)
|
||||
MusicEntry::MusicEntry(CMusicHandler *owner, std::string setName, std::string musicURI, bool looped):
|
||||
owner(owner),
|
||||
music(nullptr),
|
||||
looped(looped),
|
||||
loop(looped ? -1 : 1),
|
||||
setName(setName)
|
||||
{
|
||||
if (!musicURI.empty())
|
||||
@@ -521,7 +517,7 @@ void MusicEntry::load(std::string musicURI)
|
||||
|
||||
bool MusicEntry::play()
|
||||
{
|
||||
if (!looped && music) //already played once - return
|
||||
if (!(loop--) && music) //already played once - return
|
||||
return false;
|
||||
|
||||
if (!setName.empty())
|
||||
@@ -542,11 +538,16 @@ bool MusicEntry::play()
|
||||
return true;
|
||||
}
|
||||
|
||||
void MusicEntry::stop(int fade_ms)
|
||||
bool MusicEntry::stop(int fade_ms)
|
||||
{
|
||||
tlog5<<"Stoping music file "<<currentName<<"\n";
|
||||
looped = false;
|
||||
Mix_FadeOutMusic(fade_ms);
|
||||
if (Mix_PlayingMusic())
|
||||
{
|
||||
tlog5<<"Stoping music file "<<currentName<<"\n";
|
||||
loop = 0;
|
||||
Mix_FadeOutMusic(fade_ms);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MusicEntry::isSet(std::string set)
|
||||
|
@@ -112,7 +112,7 @@ class MusicEntry
|
||||
{
|
||||
CMusicHandler *owner;
|
||||
Mix_Music *music;
|
||||
bool looped;
|
||||
int loop; // -1 = indefinite
|
||||
//if not null - set from which music will be randomly selected
|
||||
std::string setName;
|
||||
std::string currentName;
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
~MusicEntry();
|
||||
|
||||
bool play();
|
||||
void stop(int fade_ms=0);
|
||||
bool stop(int fade_ms=0);
|
||||
};
|
||||
|
||||
class CMusicHandler: public CAudioBase
|
||||
|
Reference in New Issue
Block a user