1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +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:
AlexVinS
2018-03-17 17:58:30 +03:00
committed by AlexVinS
parent 11bb46780a
commit ecaa9f5d0b
475 changed files with 22491 additions and 7123 deletions

View File

@ -15,16 +15,25 @@
#ifndef VCMI_NO_EXTRA_VERSION
#include "../Version.h"
#endif
#include <vcmi/Artifact.h>
#include <vcmi/ArtifactService.h>
#include <vcmi/Faction.h>
#include <vcmi/FactionService.h>
#include <vcmi/HeroType.h>
#include <vcmi/HeroTypeService.h>
#include <vcmi/spells/Spell.h>
#include <vcmi/spells/Service.h>
#include "VCMI_Lib.h"
#include "mapObjects/CObjectClassesHandler.h"
#include "CArtHandler.h"
#include "CCreatureHandler.h"
#include "spells/CSpellHandler.h"
#include "CSkillHandler.h"
#include "mapObjects/CObjectClassesHandler.h"//todo: remove
#include "CArtHandler.h"//todo: remove
#include "CCreatureHandler.h"//todo: remove
#include "spells/CSpellHandler.h" //todo: remove
#include "CSkillHandler.h"//todo: remove
#include "StringConstants.h"
#include "CGeneralTextHandler.h"
#include "CModHandler.h"
#include "CModHandler.h"//todo: remove
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER = SlotID(-2);
const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER = SlotID(-3);
@ -47,9 +56,28 @@ namespace GameConstants
#endif
}
si32 HeroTypeID::decode(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "hero", identifier);
if(rawId)
return rawId.get();
else
return -1;
}
std::string HeroTypeID::encode(const si32 index)
{
return VLC->heroTypes()->getByIndex(index)->getJsonKey();
}
const CArtifact * ArtifactID::toArtifact() const
{
return VLC->arth->artifacts.at(*this);
return VLC->arth->objects.at(*this);
}
const Artifact * ArtifactID::toArtifact(const ArtifactService * service) const
{
return service->getById(*this);
}
si32 ArtifactID::decode(const std::string & identifier)
@ -63,12 +91,17 @@ si32 ArtifactID::decode(const std::string & identifier)
std::string ArtifactID::encode(const si32 index)
{
return VLC->arth->artifacts.at(index)->identifier;
return VLC->artifacts()->getByIndex(index)->getJsonKey();
}
const CCreature * CreatureID::toCreature() const
{
return VLC->creh->creatures.at(*this);
return VLC->creh->objects.at(*this);
}
const Creature * CreatureID::toCreature(const CreatureService * creatures) const
{
return creatures->getById(*this);
}
si32 CreatureID::decode(const std::string & identifier)
@ -82,7 +115,7 @@ si32 CreatureID::decode(const std::string & identifier)
std::string CreatureID::encode(const si32 index)
{
return VLC->creh->creatures.at(index)->identifier;
return VLC->creatures()->getById(CreatureID(index))->getJsonKey();
}
const CSpell * SpellID::toSpell() const
@ -95,6 +128,11 @@ const CSpell * SpellID::toSpell() const
return VLC->spellh->objects[*this];
}
const spells::Spell * SpellID::toSpell(const spells::Service * service) const
{
return service->getById(*this);
}
si32 SpellID::decode(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "spell", identifier);
@ -106,17 +144,9 @@ si32 SpellID::decode(const std::string & identifier)
std::string SpellID::encode(const si32 index)
{
return VLC->spellh->objects.at(index)->identifier;
return VLC->spells()->getByIndex(index)->getJsonKey();
}
const CSkill * SecondarySkill::toSkill() const
{
return VLC->skillh->objects.at(*this);
}
//template std::ostream & operator << <ArtifactInstanceID>(std::ostream & os, BaseForID<ArtifactInstanceID> id);
//template std::ostream & operator << <ObjectInstanceID>(std::ostream & os, BaseForID<ObjectInstanceID> id);
bool PlayerColor::isValidPlayer() const
{
return num < PLAYER_LIMIT_I;
@ -153,6 +183,32 @@ std::string PlayerColor::getStrCap(bool L10n) const
return ret;
}
const FactionID FactionID::ANY = FactionID(-1);
const FactionID FactionID::CASTLE = FactionID(0);
const FactionID FactionID::RAMPART = FactionID(1);
const FactionID FactionID::TOWER = FactionID(2);
const FactionID FactionID::INFERNO = FactionID(3);
const FactionID FactionID::NECROPOLIS = FactionID(4);
const FactionID FactionID::DUNGEON = FactionID(5);
const FactionID FactionID::STRONGHOLD = FactionID(6);
const FactionID FactionID::FORTRESS = FactionID(7);
const FactionID FactionID::CONFLUX = FactionID(8);
const FactionID FactionID::NEUTRAL = FactionID(9);
si32 FactionID::decode(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "faction", identifier);
if(rawId)
return rawId.get();
else
return -1;
}
std::string FactionID::encode(const si32 index)
{
return VLC->factions()->getByIndex(index)->getJsonKey();
}
std::ostream & operator<<(std::ostream & os, const EActionType actionType)
{
static const std::map<EActionType, std::string> actionTypeToString =