mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Moved creature sounds to CCreature. Sound IDs are now stored as strings.
Creature parser is complete (untested).
This commit is contained in:
@@ -466,6 +466,8 @@ void CCreatureHandler::loadCreatures()
|
||||
|
||||
buildBonusTreeForTiers();
|
||||
loadAnimationInfo();
|
||||
loadSoundsInfo();
|
||||
|
||||
|
||||
//reading creature ability names
|
||||
const JsonNode config2(ResourceID("config/bonusnames.json"));
|
||||
@@ -691,6 +693,49 @@ void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int
|
||||
i+=2;
|
||||
}
|
||||
|
||||
void CCreatureHandler::loadSoundsInfo()
|
||||
{
|
||||
tlog5 << "\t\tReading config/cr_sounds.json" << std::endl;
|
||||
const JsonNode config(ResourceID("config/cr_sounds.json"));
|
||||
|
||||
if (!config["creature_sounds"].isNull())
|
||||
{
|
||||
|
||||
BOOST_FOREACH(const JsonNode &node, config["creature_sounds"].Vector())
|
||||
{
|
||||
const JsonNode *value;
|
||||
int id;
|
||||
|
||||
value = &node["name"];
|
||||
|
||||
bmap<std::string,int>::const_iterator i = nameToID.find(value->String());
|
||||
if (i != nameToID.end())
|
||||
id = i->second;
|
||||
else
|
||||
{
|
||||
tlog1 << "Sound info for an unknown creature: " << value->String() << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This is a bit ugly. Maybe we should use an array for
|
||||
* sound ids instead of separate variables and define
|
||||
* attack/defend/killed/... as indexes. */
|
||||
#define GET_SOUND_VALUE(value_name) do { value = &node[#value_name]; if (!value->isNull()) creatures[id]->sounds.value_name = value->String(); } while(0)
|
||||
GET_SOUND_VALUE(attack);
|
||||
GET_SOUND_VALUE(defend);
|
||||
GET_SOUND_VALUE(killed);
|
||||
GET_SOUND_VALUE(move);
|
||||
GET_SOUND_VALUE(shoot);
|
||||
GET_SOUND_VALUE(wince);
|
||||
GET_SOUND_VALUE(ext1);
|
||||
GET_SOUND_VALUE(ext2);
|
||||
GET_SOUND_VALUE(startMoving);
|
||||
GET_SOUND_VALUE(endMoving);
|
||||
#undef GET_SOUND_VALUE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigParser & parser) //help function for parsing CREXPBON.txt
|
||||
{
|
||||
bool enable = false; //some bonuses are activated with values 2 or 1
|
||||
|
||||
Reference in New Issue
Block a user