diff --git a/client/CMusicHandler.cpp b/client/CMusicHandler.cpp index 955318be7..376994bbf 100644 --- a/client/CMusicHandler.cpp +++ b/client/CMusicHandler.cpp @@ -115,17 +115,21 @@ CSoundHandler::CSoundHandler(): {Terrain::WATER, soundBase::horseWater}, {Terrain::ROCK, soundBase::horseRock} }; +} + +void CSoundHandler::loadHorseSounds() +{ auto terrains = CGI->terrainTypeHandler->terrains(); for(const auto * terrain : terrains) { //since all sounds are hardcoded, let's keep it if(vstd::contains(horseSounds, terrain->id)) continue; - + //Use already existing horse sound horseSounds[terrain->id] = horseSounds.at(terrains[terrain->id]->horseSoundId); } -}; +} void CSoundHandler::init() { @@ -368,7 +372,11 @@ CMusicHandler::CMusicHandler(): addEntryToSet("enemy-turn", file.getName(), file.getName()); } - for(const auto * terrain : CGI->terrainTypeHandler->terrains()) +} + +void CMusicHandler::loadTerrainSounds() +{ + for (const auto* terrain : CGI->terrainTypeHandler->terrains()) { addEntryToSet("terrain", terrain->name, "Music/" + terrain->musicFilename); } diff --git a/client/CMusicHandler.h b/client/CMusicHandler.h index 03255f01a..d71005790 100644 --- a/client/CMusicHandler.h +++ b/client/CMusicHandler.h @@ -61,6 +61,7 @@ public: CSoundHandler(); void init() override; + void loadHorseSounds(); void release() override; void setVolume(ui32 percent) override; @@ -139,6 +140,7 @@ public: void addEntryToSet(const std::string & set, const std::string & entryID, const std::string & musicURI); void init() override; + void loadTerrainSounds(); void release() override; void setVolume(ui32 percent) override; diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 5c8555e17..1b935c6ed 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -152,6 +152,10 @@ void CPlayerInterface::init(std::shared_ptr ENV, std::shared_ptrsoundh->loadHorseSounds(); + CCS->musich->loadTerrainSounds(); + initializeHeroTownList(); // always recreate advmap interface to avoid possible memory-corruption bugs diff --git a/lib/Terrain.cpp b/lib/Terrain.cpp index 42011a3dc..7666f7b6a 100644 --- a/lib/Terrain.cpp +++ b/lib/Terrain.cpp @@ -96,7 +96,7 @@ TerrainTypeHandler::TerrainTypeHandler() } else { - info->horseSoundId = terr.second["horseSoundId"].Integer(); + info->horseSoundId = terr.second["horseSoundId"].Float(); } if(!terr.second["text"].isNull())