mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Very simple loading and adding new creatures. Needs testing.
This commit is contained in:
parent
9438cfc7e2
commit
abd4a96bf1
@ -19,32 +19,6 @@ struct _Mix_Music;
|
|||||||
typedef struct _Mix_Music Mix_Music;
|
typedef struct _Mix_Music Mix_Music;
|
||||||
struct Mix_Chunk;
|
struct Mix_Chunk;
|
||||||
|
|
||||||
|
|
||||||
//// Sound infos for creatures in combat
|
|
||||||
//struct CreaturesBattleSounds {
|
|
||||||
// soundBase::soundID attack;
|
|
||||||
// soundBase::soundID defend;
|
|
||||||
// soundBase::soundID killed; // was killed or died
|
|
||||||
// soundBase::soundID move;
|
|
||||||
// soundBase::soundID shoot; // range attack
|
|
||||||
// soundBase::soundID wince; // attacked but did not die
|
|
||||||
// soundBase::soundID ext1; // creature specific extension
|
|
||||||
// soundBase::soundID ext2; // creature specific extension
|
|
||||||
// soundBase::soundID startMoving; // usually same as ext1
|
|
||||||
// soundBase::soundID endMoving; // usually same as ext2
|
|
||||||
//
|
|
||||||
// CreaturesBattleSounds(): attack(soundBase::invalid),
|
|
||||||
// defend(soundBase::invalid),
|
|
||||||
// killed(soundBase::invalid),
|
|
||||||
// move(soundBase::invalid),
|
|
||||||
// shoot(soundBase::invalid),
|
|
||||||
// wince(soundBase::invalid),
|
|
||||||
// ext1(soundBase::invalid),
|
|
||||||
// ext2(soundBase::invalid),
|
|
||||||
// startMoving(soundBase::invalid),
|
|
||||||
// endMoving(soundBase::invalid) {};
|
|
||||||
//};
|
|
||||||
|
|
||||||
class CAudioBase {
|
class CAudioBase {
|
||||||
protected:
|
protected:
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
@ -62,6 +62,43 @@ void CModHandler::loadConfigFromFile (std::string name)
|
|||||||
modules.STACK_ARTIFACT = gameModules["STACK_ARTIFACTS"].Bool();
|
modules.STACK_ARTIFACT = gameModules["STACK_ARTIFACTS"].Bool();
|
||||||
modules.COMMANDERS = gameModules["COMMANDERS"].Bool();
|
modules.COMMANDERS = gameModules["COMMANDERS"].Bool();
|
||||||
modules.MITHRIL = gameModules["MITHRIL"].Bool();
|
modules.MITHRIL = gameModules["MITHRIL"].Bool();
|
||||||
|
|
||||||
|
//auto mods = config["activeMods"]; //TODO: load only mods from the list
|
||||||
|
|
||||||
|
CResourceLoader * modLoader = new CResourceLoader;
|
||||||
|
|
||||||
|
auto iterator = modLoader->getIterator([](const ResourceID & ident) -> bool
|
||||||
|
{
|
||||||
|
std::string name = ident.getName();
|
||||||
|
|
||||||
|
return ident.getType() == EResType::TEXT
|
||||||
|
&& std::count(name.begin(), name.end(), '/') == 3
|
||||||
|
&& boost::algorithm::starts_with(name, "ALL/MODS/")
|
||||||
|
&& boost::algorithm::ends_with(name, "MOD"); //all mods have "mod.json" name - does it make sense?
|
||||||
|
});
|
||||||
|
|
||||||
|
std::set<std::string> foundMods;
|
||||||
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
foundMods.insert(iterator->getName());
|
||||||
|
++iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_FOREACH (auto mod, foundMods)
|
||||||
|
{
|
||||||
|
tlog3 << "\t\tFound mod file: " << mod << "\n";
|
||||||
|
|
||||||
|
const JsonNode config (ResourceID("mod"));
|
||||||
|
const JsonNode *value = &config["creatures"];
|
||||||
|
if (!value->isNull())
|
||||||
|
{
|
||||||
|
BOOST_FOREACH (auto creature, value->Vector())
|
||||||
|
{
|
||||||
|
auto cre = loadCreature (creature);
|
||||||
|
addNewCreature (cre);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void CModHandler::saveConfigToFile (std::string name)
|
void CModHandler::saveConfigToFile (std::string name)
|
||||||
{
|
{
|
||||||
@ -187,10 +224,15 @@ void CModHandler::recreateHandlers()
|
|||||||
{
|
{
|
||||||
//TODO: consider some template magic to unify all handlers?
|
//TODO: consider some template magic to unify all handlers?
|
||||||
|
|
||||||
VLC->arth->artifacts.clear();
|
//VLC->arth->artifacts.clear();
|
||||||
VLC->creh->creatures.clear(); //TODO: what about items from original game?
|
//VLC->creh->creatures.clear(); //TODO: what about items from original game?
|
||||||
|
|
||||||
BOOST_FOREACH (auto mod, activeMods)
|
BOOST_FOREACH (auto creature, creatures)
|
||||||
|
{
|
||||||
|
VLC->creh->creatures.push_back (creature);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_FOREACH (auto mod, activeMods) //inactive part
|
||||||
{
|
{
|
||||||
BOOST_FOREACH (auto art, allMods[mod].artifacts)
|
BOOST_FOREACH (auto art, allMods[mod].artifacts)
|
||||||
{
|
{
|
||||||
@ -201,6 +243,7 @@ void CModHandler::recreateHandlers()
|
|||||||
BOOST_FOREACH (auto creature, allMods[mod].creatures)
|
BOOST_FOREACH (auto creature, allMods[mod].creatures)
|
||||||
{
|
{
|
||||||
VLC->creh->creatures.push_back (creatures[creature]);
|
VLC->creh->creatures.push_back (creatures[creature]);
|
||||||
|
//TODO VLC->creh->notUsedMonster.push_back (creatures[creature]);
|
||||||
|
|
||||||
//TODO: recreate upgrades and other properties based on string id
|
//TODO: recreate upgrades and other properties based on string id
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ void CResourceHandler::loadModsFilesystems()
|
|||||||
|
|
||||||
BOOST_FOREACH(const std::string & entry, foundMods)
|
BOOST_FOREACH(const std::string & entry, foundMods)
|
||||||
{
|
{
|
||||||
tlog1 << "\t\tFound mod filesystem: " << entry << "\n";
|
tlog3 << "\t\tFound mod filesystem: " << entry << "\n";
|
||||||
loadFileSystem(entry);
|
loadFileSystem(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,9 @@ void LibClasses::init()
|
|||||||
spellh->loadSpells();
|
spellh->loadSpells();
|
||||||
tlog0<<"\tSpell handler: "<<pomtime.getDiff()<<std::endl;
|
tlog0<<"\tSpell handler: "<<pomtime.getDiff()<<std::endl;
|
||||||
|
|
||||||
|
modh->recreateHandlers(); //load all new creatures parsed in the meantime.
|
||||||
|
//TODO: This should be done every time mod config changes
|
||||||
|
|
||||||
IS_AI_ENABLED = false;
|
IS_AI_ENABLED = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user