mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +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;
|
return false;
|
||||||
|
|
||||||
int wallUnder = curInt->cb->battleHexToWallPart(hex);
|
int wallUnder = curInt->cb->battleHexToWallPart(hex);
|
||||||
if(wallUnder == -1)
|
if(wallUnder < 0) //invalid or indestructible
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return curInt->cb->battleGetWallState(wallUnder) < EWallState::DESTROYED;
|
return curInt->cb->battleGetWallState(wallUnder) < EWallState::DESTROYED;
|
||||||
|
@@ -426,11 +426,7 @@ void CMusicHandler::queueNext(MusicEntry *queued)
|
|||||||
|
|
||||||
next.reset(queued);
|
next.reset(queued);
|
||||||
|
|
||||||
if (current.get() != NULL)
|
if (current.get() == nullptr || !current->stop(1000))
|
||||||
{
|
|
||||||
current->stop(1000);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
current.reset(next.release());
|
current.reset(next.release());
|
||||||
current->play();
|
current->play();
|
||||||
@@ -480,7 +476,7 @@ void CMusicHandler::musicFinishedCallback(void)
|
|||||||
MusicEntry::MusicEntry(CMusicHandler *owner, std::string setName, std::string musicURI, bool looped):
|
MusicEntry::MusicEntry(CMusicHandler *owner, std::string setName, std::string musicURI, bool looped):
|
||||||
owner(owner),
|
owner(owner),
|
||||||
music(nullptr),
|
music(nullptr),
|
||||||
looped(looped),
|
loop(looped ? -1 : 1),
|
||||||
setName(setName)
|
setName(setName)
|
||||||
{
|
{
|
||||||
if (!musicURI.empty())
|
if (!musicURI.empty())
|
||||||
@@ -521,7 +517,7 @@ void MusicEntry::load(std::string musicURI)
|
|||||||
|
|
||||||
bool MusicEntry::play()
|
bool MusicEntry::play()
|
||||||
{
|
{
|
||||||
if (!looped && music) //already played once - return
|
if (!(loop--) && music) //already played once - return
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!setName.empty())
|
if (!setName.empty())
|
||||||
@@ -542,11 +538,16 @@ bool MusicEntry::play()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MusicEntry::stop(int fade_ms)
|
bool MusicEntry::stop(int fade_ms)
|
||||||
{
|
{
|
||||||
tlog5<<"Stoping music file "<<currentName<<"\n";
|
if (Mix_PlayingMusic())
|
||||||
looped = false;
|
{
|
||||||
Mix_FadeOutMusic(fade_ms);
|
tlog5<<"Stoping music file "<<currentName<<"\n";
|
||||||
|
loop = 0;
|
||||||
|
Mix_FadeOutMusic(fade_ms);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MusicEntry::isSet(std::string set)
|
bool MusicEntry::isSet(std::string set)
|
||||||
|
@@ -112,7 +112,7 @@ class MusicEntry
|
|||||||
{
|
{
|
||||||
CMusicHandler *owner;
|
CMusicHandler *owner;
|
||||||
Mix_Music *music;
|
Mix_Music *music;
|
||||||
bool looped;
|
int loop; // -1 = indefinite
|
||||||
//if not null - set from which music will be randomly selected
|
//if not null - set from which music will be randomly selected
|
||||||
std::string setName;
|
std::string setName;
|
||||||
std::string currentName;
|
std::string currentName;
|
||||||
@@ -128,7 +128,7 @@ public:
|
|||||||
~MusicEntry();
|
~MusicEntry();
|
||||||
|
|
||||||
bool play();
|
bool play();
|
||||||
void stop(int fade_ms=0);
|
bool stop(int fade_ms=0);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMusicHandler: public CAudioBase
|
class CMusicHandler: public CAudioBase
|
||||||
|
Reference in New Issue
Block a user