2013-03-06 21:49:56 +03:00
|
|
|
/*
|
|
|
|
* VCMI_Lib.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2014-03-15 13:57:34 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2008-06-14 13:20:18 +03:00
|
|
|
#include "VCMI_Lib.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CArtHandler.h"
|
2013-03-06 21:49:56 +03:00
|
|
|
#include "CBonusTypeHandler.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CCreatureHandler.h"
|
2014-06-05 14:19:47 +03:00
|
|
|
#include "mapObjects/CObjectClassesHandler.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CHeroHandler.h"
|
2014-06-05 14:19:47 +03:00
|
|
|
#include "mapObjects/CObjectHandler.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CTownHandler.h"
|
|
|
|
#include "CBuildingHandler.h"
|
2015-02-02 10:25:26 +02:00
|
|
|
#include "spells/CSpellHandler.h"
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
#include "spells/effects/Registry.h"
|
2017-08-20 09:18:07 +02:00
|
|
|
#include "CSkillHandler.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CGeneralTextHandler.h"
|
2012-08-10 16:07:53 +03:00
|
|
|
#include "CModHandler.h"
|
2011-06-20 14:41:04 +03:00
|
|
|
#include "IGameEventsReceiver.h"
|
2011-12-17 21:59:59 +03:00
|
|
|
#include "CStopWatch.h"
|
2012-05-25 14:49:56 +03:00
|
|
|
#include "VCMIDirs.h"
|
2013-07-28 17:49:50 +03:00
|
|
|
#include "filesystem/Filesystem.h"
|
2013-04-11 18:58:01 +03:00
|
|
|
#include "CConsoleHandler.h"
|
2013-08-17 15:46:48 +03:00
|
|
|
#include "rmg/CRmgTemplateStorage.h"
|
|
|
|
#include "mapping/CMapEditManager.h"
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
#include "ScriptHandler.h"
|
2022-06-28 10:05:30 +02:00
|
|
|
#include "BattleFieldHandler.h"
|
2022-09-15 10:06:54 +02:00
|
|
|
#include "ObstacleHandler.h"
|
2009-04-15 17:03:31 +03:00
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
LibClasses * VLC = nullptr;
|
2009-05-09 19:18:27 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
DLL_LINKAGE void preinitDLL(CConsoleHandler * Console, bool onlyEssential)
|
2008-06-14 13:20:18 +03:00
|
|
|
{
|
2008-09-17 13:18:22 +03:00
|
|
|
console = Console;
|
2017-07-16 11:58:05 +02:00
|
|
|
VLC = new LibClasses();
|
2013-07-30 18:02:55 +03:00
|
|
|
try
|
2012-12-12 14:13:57 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
VLC->loadFilesystem(onlyEssential);
|
2012-12-12 14:13:57 +03:00
|
|
|
}
|
2015-02-14 21:42:47 +02:00
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
handleException();
|
|
|
|
throw;
|
|
|
|
}
|
2012-12-12 14:13:57 +03:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
DLL_LINKAGE void loadDLLClasses(bool onlyEssential)
|
2012-12-12 14:13:57 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
VLC->init(onlyEssential);
|
2008-06-14 13:20:18 +03: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.
2018-03-17 16:58:30 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-09-21 18:31:14 +02:00
|
|
|
#if SCRIPTING_ENABLED
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
const scripting::Service * LibClasses::scripts() const
|
|
|
|
{
|
|
|
|
return scriptHandler;
|
|
|
|
}
|
2022-09-21 18:31:14 +02:00
|
|
|
#endif
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
|
|
|
|
const spells::Service * LibClasses::spells() const
|
|
|
|
{
|
|
|
|
return spellh;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkillService * LibClasses::skills() const
|
|
|
|
{
|
|
|
|
return skillh;
|
|
|
|
}
|
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
const IBonusTypeHandler * LibClasses::getBth() const
|
|
|
|
{
|
|
|
|
return bth;
|
|
|
|
}
|
|
|
|
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
const spells::effects::Registry * LibClasses::spellEffects() const
|
|
|
|
{
|
|
|
|
return spells::effects::GlobalRegistry::get();
|
|
|
|
}
|
|
|
|
|
|
|
|
spells::effects::Registry * LibClasses::spellEffects()
|
|
|
|
{
|
|
|
|
return spells::effects::GlobalRegistry::get();
|
|
|
|
}
|
|
|
|
|
2022-06-28 10:05:30 +02:00
|
|
|
const BattleFieldService * LibClasses::battlefields() const
|
|
|
|
{
|
|
|
|
return battlefieldsHandler;
|
|
|
|
}
|
|
|
|
|
2022-09-15 10:06:54 +02:00
|
|
|
const ObstacleService * LibClasses::obstacles() const
|
|
|
|
{
|
|
|
|
return obstacleHandler;
|
|
|
|
}
|
|
|
|
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
void LibClasses::loadFilesystem(bool onlyEssential)
|
2009-01-11 00:08:18 +02:00
|
|
|
{
|
2012-08-07 14:28:52 +03:00
|
|
|
CStopWatch totalTime;
|
|
|
|
CStopWatch loadTime;
|
|
|
|
|
2012-08-01 15:02:54 +03:00
|
|
|
CResourceHandler::initialize();
|
2017-08-10 20:59:55 +02:00
|
|
|
logGlobal->info("\tInitialization: %d ms", loadTime.getDiff());
|
2012-08-07 14:28:52 +03:00
|
|
|
|
2013-11-08 23:36:26 +03:00
|
|
|
CResourceHandler::load("config/filesystem.json");
|
2017-08-10 20:59:55 +02:00
|
|
|
logGlobal->info("\tData loading: %d ms", loadTime.getDiff());
|
2012-08-07 14:28:52 +03:00
|
|
|
|
2016-08-30 10:45:05 +02:00
|
|
|
modh = new CModHandler();
|
2017-08-10 20:59:55 +02:00
|
|
|
logGlobal->info("\tMod handler: %d ms", loadTime.getDiff());
|
2012-12-12 14:13:57 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
modh->loadMods(onlyEssential);
|
2014-03-15 13:57:34 +03:00
|
|
|
modh->loadModFilesystems();
|
2017-08-10 20:59:55 +02:00
|
|
|
logGlobal->info("\tMod filesystems: %d ms", loadTime.getDiff());
|
2012-08-01 15:02:54 +03:00
|
|
|
|
2017-08-10 20:59:55 +02:00
|
|
|
logGlobal->info("Basic initialization: %d ms", totalTime.getDiff());
|
2012-08-02 14:03:26 +03:00
|
|
|
}
|
|
|
|
|
2017-08-10 20:59:55 +02:00
|
|
|
static void logHandlerLoaded(const std::string & name, CStopWatch & timer)
|
2012-08-02 14:03:26 +03: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.
2018-03-17 16:58:30 +02:00
|
|
|
logGlobal->info("\t\t %s handler: %d ms", name, timer.getDiff());
|
2017-07-12 21:01:10 +02:00
|
|
|
}
|
2012-08-01 15:02:54 +03:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
template <class Handler> void createHandler(Handler *&handler, const std::string &name, CStopWatch &timer)
|
|
|
|
{
|
|
|
|
handler = new Handler();
|
|
|
|
logHandlerLoaded(name, timer);
|
2014-03-15 13:57:34 +03:00
|
|
|
}
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
void LibClasses::init(bool onlyEssential)
|
2013-03-06 21:49:56 +03:00
|
|
|
{
|
2013-04-21 15:49:26 +03:00
|
|
|
CStopWatch pomtime, totalTime;
|
2013-04-02 20:06:43 +03:00
|
|
|
|
2013-11-09 22:10:16 +03:00
|
|
|
modh->initializeConfig();
|
2013-04-28 18:06:14 +03:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(bth, "Bonus type", pomtime);
|
2014-03-15 13:57:34 +03:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(generaltexth, "General text", pomtime);
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(heroh, "Hero", pomtime);
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(arth, "Artifact", pomtime);
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(creh, "Creature", pomtime);
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(townh, "Town", pomtime);
|
2014-03-15 13:57:34 +03:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(objh, "Object", pomtime);
|
2014-03-15 13:57:34 +03:00
|
|
|
|
2014-05-16 23:50:02 +03:00
|
|
|
createHandler(objtypeh, "Object types information", pomtime);
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2013-03-06 21:49:56 +03:00
|
|
|
createHandler(spellh, "Spell", pomtime);
|
2009-01-11 00:08:18 +02:00
|
|
|
|
2017-08-20 09:18:07 +02:00
|
|
|
createHandler(skillh, "Skill", pomtime);
|
|
|
|
|
2013-08-17 15:46:48 +03:00
|
|
|
createHandler(terviewh, "Terrain view pattern", pomtime);
|
|
|
|
|
2015-05-26 18:19:41 +02:00
|
|
|
createHandler(tplh, "Template", pomtime); //templates need already resolved identifiers (refactor?)
|
|
|
|
|
2022-09-21 18:31:14 +02:00
|
|
|
#if SCRIPTING_ENABLED
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
createHandler(scriptHandler, "Script", pomtime);
|
2022-09-21 18:31:14 +02:00
|
|
|
#endif
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
|
2022-06-28 10:05:30 +02:00
|
|
|
createHandler(battlefieldsHandler, "Battlefields", pomtime);
|
2022-09-15 10:06:54 +02:00
|
|
|
|
|
|
|
createHandler(obstacleHandler, "Obstacles", pomtime);
|
2022-06-28 10:05:30 +02:00
|
|
|
|
2017-08-10 20:59:55 +02:00
|
|
|
logGlobal->info("\tInitializing handlers: %d ms", totalTime.getDiff());
|
2013-04-21 15:49:26 +03:00
|
|
|
|
2013-11-09 22:10:16 +03:00
|
|
|
modh->load();
|
2014-10-30 11:00:29 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
modh->afterLoad(onlyEssential);
|
2014-10-30 11:00:29 +02:00
|
|
|
|
2012-09-21 22:49:35 +03:00
|
|
|
//FIXME: make sure that everything is ok after game restart
|
2012-09-18 10:36:07 +03:00
|
|
|
//TODO: This should be done every time mod config changes
|
2009-01-11 00:08:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LibClasses::clear()
|
|
|
|
{
|
|
|
|
delete generaltexth;
|
|
|
|
delete heroh;
|
|
|
|
delete arth;
|
|
|
|
delete creh;
|
|
|
|
delete townh;
|
|
|
|
delete objh;
|
2014-05-16 23:50:02 +03:00
|
|
|
delete objtypeh;
|
2009-01-11 00:08:18 +02:00
|
|
|
delete spellh;
|
2017-08-20 09:18:07 +02:00
|
|
|
delete skillh;
|
2012-08-10 16:07:53 +03:00
|
|
|
delete modh;
|
2013-03-06 21:49:56 +03:00
|
|
|
delete bth;
|
2013-08-17 15:46:48 +03:00
|
|
|
delete tplh;
|
|
|
|
delete terviewh;
|
2022-09-21 18:31:14 +02:00
|
|
|
#if SCRIPTING_ENABLED
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
delete scriptHandler;
|
2022-09-21 18:31:14 +02:00
|
|
|
#endif
|
2022-06-28 10:05:30 +02:00
|
|
|
delete battlefieldsHandler;
|
2009-06-23 11:14:49 +03:00
|
|
|
makeNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LibClasses::makeNull()
|
|
|
|
{
|
2013-03-06 21:49:56 +03:00
|
|
|
generaltexth = nullptr;
|
|
|
|
heroh = nullptr;
|
|
|
|
arth = nullptr;
|
|
|
|
creh = nullptr;
|
|
|
|
townh = nullptr;
|
|
|
|
objh = nullptr;
|
2014-05-16 23:50:02 +03:00
|
|
|
objtypeh = nullptr;
|
2013-03-06 21:49:56 +03:00
|
|
|
spellh = nullptr;
|
2017-08-20 09:18:07 +02:00
|
|
|
skillh = nullptr;
|
2013-03-06 21:49:56 +03:00
|
|
|
modh = nullptr;
|
|
|
|
bth = nullptr;
|
2013-08-17 15:46:48 +03:00
|
|
|
tplh = nullptr;
|
|
|
|
terviewh = nullptr;
|
2022-09-21 18:31:14 +02:00
|
|
|
#if SCRIPTING_ENABLED
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
scriptHandler = nullptr;
|
2022-09-21 18:31:14 +02:00
|
|
|
#endif
|
2022-06-28 10:05:30 +02:00
|
|
|
battlefieldsHandler = nullptr;
|
2009-01-30 20:36:00 +02:00
|
|
|
}
|
2009-06-23 11:14:49 +03:00
|
|
|
|
|
|
|
LibClasses::LibClasses()
|
|
|
|
{
|
2016-11-27 21:07:01 +02:00
|
|
|
IS_AI_ENABLED = false;
|
2009-06-23 11:14:49 +03:00
|
|
|
//init pointers to handlers
|
|
|
|
makeNull();
|
2009-10-04 05:02:45 +03:00
|
|
|
}
|
2010-02-12 17:04:01 +02:00
|
|
|
|
|
|
|
void LibClasses::callWhenDeserializing()
|
|
|
|
{
|
2017-07-16 11:58:05 +02:00
|
|
|
//FIXME: check if any of these are needed
|
|
|
|
//generaltexth = new CGeneralTextHandler();
|
2013-04-21 15:49:26 +03:00
|
|
|
//generaltexth->load();
|
|
|
|
//arth->load(true);
|
2012-09-21 22:49:35 +03:00
|
|
|
//modh->recreateHandlers();
|
2012-08-24 12:37:52 +03:00
|
|
|
//modh->loadConfigFromFile ("defaultMods"); //TODO: remember last saved config
|
2011-03-29 20:16:10 +03:00
|
|
|
}
|
2012-04-08 04:15:18 +03:00
|
|
|
|
2022-09-21 18:31:14 +02:00
|
|
|
#if SCRIPTING_ENABLED
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
void LibClasses::scriptsLoaded()
|
|
|
|
{
|
|
|
|
scriptHandler->performRegistration(this);
|
|
|
|
}
|
2022-09-21 18:31:14 +02:00
|
|
|
#endif
|
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.
2018-03-17 16:58:30 +02:00
|
|
|
|
2012-04-08 04:15:18 +03:00
|
|
|
LibClasses::~LibClasses()
|
|
|
|
{
|
|
|
|
clear();
|
2013-04-09 17:31:36 +03:00
|
|
|
}
|
2020-10-09 23:31:23 +02:00
|
|
|
|
|
|
|
std::shared_ptr<CContentHandler> LibClasses::getContent() const
|
|
|
|
{
|
|
|
|
return modh->content;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LibClasses::setContent(std::shared_ptr<CContentHandler> content)
|
|
|
|
{
|
|
|
|
modh->content = content;
|
|
|
|
}
|