mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Load sounds for new terrains later
This commit is contained in:
parent
494b0f0226
commit
11e1bb44a2
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -152,6 +152,10 @@ void CPlayerInterface::init(std::shared_ptr<Environment> ENV, std::shared_ptr<CC
|
||||
{
|
||||
cb = CB;
|
||||
env = ENV;
|
||||
|
||||
CCS->soundh->loadHorseSounds();
|
||||
CCS->musich->loadTerrainSounds();
|
||||
|
||||
initializeHeroTownList();
|
||||
|
||||
// always recreate advmap interface to avoid possible memory-corruption bugs
|
||||
|
@ -96,7 +96,7 @@ TerrainTypeHandler::TerrainTypeHandler()
|
||||
}
|
||||
else
|
||||
{
|
||||
info->horseSoundId = terr.second["horseSoundId"].Integer();
|
||||
info->horseSoundId = terr.second["horseSoundId"].Float();
|
||||
}
|
||||
|
||||
if(!terr.second["text"].isNull())
|
||||
|
Loading…
Reference in New Issue
Block a user