2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* VCMI_Lib.h, 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
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
2009-04-16 14:14:13 +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
|
|
|
#include <vcmi/Services.h>
|
|
|
|
|
2017-08-11 19:03:05 +02:00
|
|
|
class CConsoleHandler;
|
2009-04-16 14:14:13 +03:00
|
|
|
class CArtHandler;
|
|
|
|
class CHeroHandler;
|
|
|
|
class CCreatureHandler;
|
|
|
|
class CSpellHandler;
|
2017-08-20 09:18:07 +02:00
|
|
|
class CSkillHandler;
|
2009-04-16 14:14:13 +03:00
|
|
|
class CBuildingHandler;
|
|
|
|
class CObjectHandler;
|
2014-05-24 01:56:51 +03:00
|
|
|
class CObjectClassesHandler;
|
2009-04-16 14:14:13 +03:00
|
|
|
class CTownHandler;
|
|
|
|
class CGeneralTextHandler;
|
2012-08-10 16:07:53 +03:00
|
|
|
class CModHandler;
|
2020-10-09 23:31:23 +02:00
|
|
|
class CContentHandler;
|
2013-03-06 21:49:56 +03:00
|
|
|
class IBonusTypeHandler;
|
|
|
|
class CBonusTypeHandler;
|
2013-08-17 15:46:48 +03:00
|
|
|
class CTerrainViewPatternConfig;
|
|
|
|
class CRmgTemplateStorage;
|
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
|
|
|
class IHandlerBase;
|
|
|
|
|
|
|
|
namespace scripting
|
|
|
|
{
|
|
|
|
class ScriptHandler;
|
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Loads and constructs several handlers
|
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
|
|
|
class DLL_LINKAGE LibClasses : public Services
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2013-03-06 21:49:56 +03:00
|
|
|
CBonusTypeHandler * bth;
|
2013-04-21 15:49:26 +03:00
|
|
|
|
2013-01-03 15:19:20 +03:00
|
|
|
void callWhenDeserializing(); //should be called only by serialize !!!
|
|
|
|
void makeNull(); //sets all handler pointers to null
|
2020-10-09 23:31:23 +02:00
|
|
|
std::shared_ptr<CContentHandler> getContent() const;
|
|
|
|
void setContent(std::shared_ptr<CContentHandler> content);
|
2021-01-14 00:02:13 +02:00
|
|
|
void restoreAllCreaturesNodeType794();
|
2020-10-09 23:31:23 +02:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
public:
|
2016-11-27 21:07:01 +02:00
|
|
|
bool IS_AI_ENABLED; //unused?
|
|
|
|
|
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 * artifacts() const override;
|
|
|
|
const CreatureService * creatures() const override;
|
|
|
|
const FactionService * factions() const override;
|
|
|
|
const HeroClassService * heroClasses() const override;
|
|
|
|
const HeroTypeService * heroTypes() const override;
|
|
|
|
const scripting::Service * scripts() const override;
|
|
|
|
const spells::Service * spells() const override;
|
|
|
|
const SkillService * skills() const override;
|
|
|
|
|
|
|
|
void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) override;
|
|
|
|
|
|
|
|
const spells::effects::Registry * spellEffects() const override;
|
|
|
|
spells::effects::Registry * spellEffects() override;
|
|
|
|
|
|
|
|
const IBonusTypeHandler * getBth() const; //deprecated
|
2013-04-21 15:49:26 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
CArtHandler * arth;
|
|
|
|
CHeroHandler * heroh;
|
|
|
|
CCreatureHandler * creh;
|
|
|
|
CSpellHandler * spellh;
|
2017-08-20 09:18:07 +02:00
|
|
|
CSkillHandler * skillh;
|
2009-04-16 14:14:13 +03:00
|
|
|
CObjectHandler * objh;
|
2014-05-24 01:56:51 +03:00
|
|
|
CObjectClassesHandler * objtypeh;
|
2009-04-16 14:14:13 +03:00
|
|
|
CTownHandler * townh;
|
|
|
|
CGeneralTextHandler * generaltexth;
|
2012-08-10 16:07:53 +03:00
|
|
|
CModHandler * modh;
|
2013-08-17 15:46:48 +03:00
|
|
|
CTerrainViewPatternConfig * terviewh;
|
|
|
|
CRmgTemplateStorage * tplh;
|
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
|
|
|
scripting::ScriptHandler * scriptHandler;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-06-23 11:14:49 +03:00
|
|
|
LibClasses(); //c-tor, loads .lods and NULLs handlers
|
2012-04-08 04:15:18 +03:00
|
|
|
~LibClasses();
|
2017-07-20 06:08:49 +02:00
|
|
|
void init(bool onlyEssential); //uses standard config file
|
2009-04-16 14:14:13 +03:00
|
|
|
void clear(); //deletes all handlers and its data
|
2013-01-03 15:19:20 +03:00
|
|
|
|
2012-08-02 14:03:26 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
void loadFilesystem(bool onlyEssential);// basic initialization. should be called before init()
|
2009-04-16 14:14:13 +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
|
|
|
void scriptsLoaded();
|
2013-01-03 15:19:20 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
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
|
|
|
if(version >= 800)
|
|
|
|
{
|
|
|
|
h & scriptHandler;//must be first (or second after modh), it can modify factories other handlers depends on
|
|
|
|
if(!h.saving)
|
|
|
|
{
|
|
|
|
scriptsLoaded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!h.saving)
|
|
|
|
{
|
|
|
|
update800();
|
|
|
|
}
|
|
|
|
|
2017-07-31 15:35:42 +02:00
|
|
|
h & heroh;
|
|
|
|
h & arth;
|
|
|
|
h & creh;
|
2021-01-14 00:02:13 +02:00
|
|
|
if(!h.saving && version < 794)
|
|
|
|
restoreAllCreaturesNodeType794();
|
|
|
|
|
2017-07-31 15:35:42 +02:00
|
|
|
h & townh;
|
|
|
|
h & objh;
|
|
|
|
h & objtypeh;
|
|
|
|
h & spellh;
|
2017-08-28 03:56:00 +02:00
|
|
|
if(version >= 777)
|
|
|
|
{
|
|
|
|
h & skillh;
|
|
|
|
}
|
2020-10-09 23:31:23 +02:00
|
|
|
if(!h.saving)
|
|
|
|
{
|
|
|
|
//modh will be changed and modh->content will be empty after deserialization
|
|
|
|
auto content = getContent();
|
|
|
|
h & modh;
|
|
|
|
setContent(content);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
h & modh;
|
|
|
|
|
2017-07-31 15:35:42 +02:00
|
|
|
h & IS_AI_ENABLED;
|
2013-03-06 21:49:56 +03:00
|
|
|
h & 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
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
if(!h.saving)
|
|
|
|
{
|
2010-02-12 17:04:01 +02:00
|
|
|
callWhenDeserializing();
|
2009-04-16 14:14:13 +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
|
|
|
|
|
|
|
private:
|
|
|
|
void update800();
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
extern DLL_LINKAGE LibClasses * VLC;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
DLL_LINKAGE void preinitDLL(CConsoleHandler * Console, bool onlyEssential = false);
|
|
|
|
DLL_LINKAGE void loadDLLClasses(bool onlyEssential = false);
|
2012-12-12 14:13:57 +03:00
|
|
|
|