1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-19 21:10:12 +02:00

Don't play new building sound twice on auto-built buildings

This commit is contained in:
Ivan Savenko 2025-01-26 15:50:26 +00:00
parent 029a5699c3
commit d54d498d5f
2 changed files with 4 additions and 2 deletions

View File

@ -628,7 +628,6 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID build
switch(what) switch(what)
{ {
case 1: case 1:
CCS->soundh->playSound(soundBase::newBuilding);
castleInt->addBuilding(buildingID); castleInt->addBuilding(buildingID);
break; break;
case 2: case 2:
@ -1415,7 +1414,6 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj )
&& LOCPLINT->castleInt && LOCPLINT->castleInt
&& obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation()) && obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation())
{ {
CCS->soundh->playSound(soundBase::newBuilding);
LOCPLINT->castleInt->addBuilding(BuildingID::SHIP); LOCPLINT->castleInt->addBuilding(BuildingID::SHIP);
} }
} }

View File

@ -24,6 +24,7 @@
#include "../gui/Shortcut.h" #include "../gui/Shortcut.h"
#include "../gui/WindowHandler.h" #include "../gui/WindowHandler.h"
#include "../media/IMusicPlayer.h" #include "../media/IMusicPlayer.h"
#include "../media/ISoundPlayer.h"
#include "../widgets/MiscWidgets.h" #include "../widgets/MiscWidgets.h"
#include "../widgets/CComponent.h" #include "../widgets/CComponent.h"
#include "../widgets/CGarrisonInt.h" #include "../widgets/CGarrisonInt.h"
@ -1435,6 +1436,9 @@ void CCastleInterface::townChange()
void CCastleInterface::addBuilding(BuildingID bid) void CCastleInterface::addBuilding(BuildingID bid)
{ {
if (town->getTown()->buildings.at(bid)->mode != CBuilding::BUILD_AUTO)
CCS->soundh->playSound(soundBase::newBuilding);
deactivate(); deactivate();
builds->addBuilding(bid); builds->addBuilding(bid);
recreateIcons(); recreateIcons();