mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Do not play movement sound on non-movement actions
This commit is contained in:
@ -1977,8 +1977,17 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
|||||||
int soundChannel = -1;
|
int soundChannel = -1;
|
||||||
std::string soundName;
|
std::string soundName;
|
||||||
|
|
||||||
auto getMovementSoundFor = [&](const CGHeroInstance * hero, int3 posPrev, int3 posNext) -> std::string
|
auto getMovementSoundFor = [&](const CGHeroInstance * hero, int3 posPrev, int3 posNext, EPathNodeAction moveType) -> std::string
|
||||||
{
|
{
|
||||||
|
if (moveType == EPathNodeAction::TELEPORT_BATTLE || moveType == EPathNodeAction::TELEPORT_BLOCKING_VISIT || moveType == EPathNodeAction::TELEPORT_NORMAL)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (moveType == EPathNodeAction::EMBARK || moveType == EPathNodeAction::DISEMBARK)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (moveType == EPathNodeAction::BLOCKING_VISIT)
|
||||||
|
return "";
|
||||||
|
|
||||||
// flying movement sound
|
// flying movement sound
|
||||||
if (hero->hasBonusOfType(BonusType::FLYING_MOVEMENT))
|
if (hero->hasBonusOfType(BonusType::FLYING_MOVEMENT))
|
||||||
return "HORSE10.wav";
|
return "HORSE10.wav";
|
||||||
@ -2030,8 +2039,11 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
|||||||
}
|
}
|
||||||
if(i != path.nodes.size() - 1)
|
if(i != path.nodes.size() - 1)
|
||||||
{
|
{
|
||||||
soundName = getMovementSoundFor(h, prevCoord, nextCoord);
|
soundName = getMovementSoundFor(h, prevCoord, nextCoord, path.nodes[i-1].action);
|
||||||
|
if (!soundName.empty())
|
||||||
soundChannel = CCS->soundh->playSound(soundName, -1);
|
soundChannel = CCS->soundh->playSound(soundName, -1);
|
||||||
|
else
|
||||||
|
soundChannel = -1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2044,14 +2056,17 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Start a new sound for the hero movement or let the existing one carry on.
|
// Start a new sound for the hero movement or let the existing one carry on.
|
||||||
std::string newSoundName = getMovementSoundFor(h, prevCoord, nextCoord);
|
std::string newSoundName = getMovementSoundFor(h, prevCoord, nextCoord, path.nodes[i-1].action);
|
||||||
|
|
||||||
if(newSoundName != soundName)
|
if(newSoundName != soundName)
|
||||||
{
|
{
|
||||||
soundName = newSoundName;
|
soundName = newSoundName;
|
||||||
|
|
||||||
CCS->soundh->stopSound(soundChannel);
|
CCS->soundh->stopSound(soundChannel);
|
||||||
|
if (!soundName.empty())
|
||||||
soundChannel = CCS->soundh->playSound(soundName, -1);
|
soundChannel = CCS->soundh->playSound(soundName, -1);
|
||||||
|
else
|
||||||
|
soundChannel = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user