mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-21 00:19:29 +02:00
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there. * Declared existing Entity APIs. * Added basic script context caching * Started Lua script module * Started Lua spell effect API * Started script state persistence * Started battle info callback binding * CommitPackage removed * Extracted spells::Caster to own header; Expanded Spell API. * implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C * !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented * Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key) * Re-enabled VERM macros. * !?GM0 added * !?TM implemented * Added !!MF:N * Started !?OB, !!BM, !!HE, !!OW, !!UN * Added basic support of w-variables * Added support for ERM indirect variables * Made !?FU regular trigger * !!re (ERA loop receiver) implemented * Fixed ERM receivers with zero args.
This commit is contained in:
101
lib/VCMI_Lib.cpp
101
lib/VCMI_Lib.cpp
@ -20,6 +20,7 @@
|
||||
#include "CTownHandler.h"
|
||||
#include "CBuildingHandler.h"
|
||||
#include "spells/CSpellHandler.h"
|
||||
#include "spells/effects/Registry.h"
|
||||
#include "CSkillHandler.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "CModHandler.h"
|
||||
@ -30,6 +31,7 @@
|
||||
#include "CConsoleHandler.h"
|
||||
#include "rmg/CRmgTemplateStorage.h"
|
||||
#include "mapping/CMapEditManager.h"
|
||||
#include "ScriptHandler.h"
|
||||
|
||||
LibClasses * VLC = nullptr;
|
||||
|
||||
@ -53,11 +55,92 @@ DLL_LINKAGE void loadDLLClasses(bool onlyEssential)
|
||||
VLC->init(onlyEssential);
|
||||
}
|
||||
|
||||
const ArtifactService * LibClasses::artifacts() const
|
||||
{
|
||||
return arth;
|
||||
}
|
||||
|
||||
const CreatureService * LibClasses::creatures() const
|
||||
{
|
||||
return creh;
|
||||
}
|
||||
|
||||
const FactionService * LibClasses::factions() const
|
||||
{
|
||||
return townh;
|
||||
}
|
||||
|
||||
const HeroClassService * LibClasses::heroClasses() const
|
||||
{
|
||||
return &heroh->classes;
|
||||
}
|
||||
|
||||
const HeroTypeService * LibClasses::heroTypes() const
|
||||
{
|
||||
return heroh;
|
||||
}
|
||||
|
||||
const scripting::Service * LibClasses::scripts() const
|
||||
{
|
||||
return scriptHandler;
|
||||
}
|
||||
|
||||
const spells::Service * LibClasses::spells() const
|
||||
{
|
||||
return spellh;
|
||||
}
|
||||
|
||||
const SkillService * LibClasses::skills() const
|
||||
{
|
||||
return skillh;
|
||||
}
|
||||
|
||||
const IBonusTypeHandler * LibClasses::getBth() const
|
||||
{
|
||||
return bth;
|
||||
}
|
||||
|
||||
const spells::effects::Registry * LibClasses::spellEffects() const
|
||||
{
|
||||
return spells::effects::GlobalRegistry::get();
|
||||
}
|
||||
|
||||
spells::effects::Registry * LibClasses::spellEffects()
|
||||
{
|
||||
return spells::effects::GlobalRegistry::get();
|
||||
}
|
||||
|
||||
void LibClasses::updateEntity(Metatype metatype, int32_t index, const JsonNode & data)
|
||||
{
|
||||
switch(metatype)
|
||||
{
|
||||
case Metatype::ARTIFACT:
|
||||
arth->updateEntity(index, data);
|
||||
break;
|
||||
case Metatype::CREATURE:
|
||||
creh->updateEntity(index, data);
|
||||
break;
|
||||
case Metatype::FACTION:
|
||||
townh->updateEntity(index, data);
|
||||
break;
|
||||
case Metatype::HERO_CLASS:
|
||||
heroh->classes.updateEntity(index, data);
|
||||
break;
|
||||
case Metatype::HERO_TYPE:
|
||||
heroh->updateEntity(index, data);
|
||||
break;
|
||||
case Metatype::SKILL:
|
||||
skillh->updateEntity(index, data);
|
||||
break;
|
||||
case Metatype::SPELL:
|
||||
spellh->updateEntity(index, data);
|
||||
break;
|
||||
default:
|
||||
logGlobal->error("Invalid Metatype id %d", static_cast<int32_t>(metatype));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LibClasses::loadFilesystem(bool onlyEssential)
|
||||
{
|
||||
CStopWatch totalTime;
|
||||
@ -81,7 +164,7 @@ void LibClasses::loadFilesystem(bool onlyEssential)
|
||||
|
||||
static void logHandlerLoaded(const std::string & name, CStopWatch & timer)
|
||||
{
|
||||
logGlobal->info("\t\t %s handler: %d ms", name, timer.getDiff());
|
||||
logGlobal->info("\t\t %s handler: %d ms", name, timer.getDiff());
|
||||
}
|
||||
|
||||
template <class Handler> void createHandler(Handler *&handler, const std::string &name, CStopWatch &timer)
|
||||
@ -120,6 +203,8 @@ void LibClasses::init(bool onlyEssential)
|
||||
|
||||
createHandler(tplh, "Template", pomtime); //templates need already resolved identifiers (refactor?)
|
||||
|
||||
createHandler(scriptHandler, "Script", pomtime);
|
||||
|
||||
logGlobal->info("\tInitializing handlers: %d ms", totalTime.getDiff());
|
||||
|
||||
modh->load();
|
||||
@ -145,6 +230,7 @@ void LibClasses::clear()
|
||||
delete bth;
|
||||
delete tplh;
|
||||
delete terviewh;
|
||||
delete scriptHandler;
|
||||
makeNull();
|
||||
}
|
||||
|
||||
@ -163,6 +249,7 @@ void LibClasses::makeNull()
|
||||
bth = nullptr;
|
||||
tplh = nullptr;
|
||||
terviewh = nullptr;
|
||||
scriptHandler = nullptr;
|
||||
}
|
||||
|
||||
LibClasses::LibClasses()
|
||||
@ -182,6 +269,11 @@ void LibClasses::callWhenDeserializing()
|
||||
//modh->loadConfigFromFile ("defaultMods"); //TODO: remember last saved config
|
||||
}
|
||||
|
||||
void LibClasses::scriptsLoaded()
|
||||
{
|
||||
scriptHandler->performRegistration(this);
|
||||
}
|
||||
|
||||
LibClasses::~LibClasses()
|
||||
{
|
||||
clear();
|
||||
@ -201,3 +293,10 @@ void LibClasses::restoreAllCreaturesNodeType794()
|
||||
{
|
||||
creh->restoreAllCreaturesNodeType794();
|
||||
}
|
||||
|
||||
void LibClasses::update800()
|
||||
{
|
||||
vstd::clear_pointer(scriptHandler);
|
||||
scriptHandler = new scripting::ScriptHandler();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user