1
0
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:
DjWarmonger
2012-09-17 19:00:26 +00:00
parent 061ed69c63
commit 9438cfc7e2
5 changed files with 153 additions and 81 deletions

View File

@@ -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