mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
Remove explicit convesion to int in operators
This commit is contained in:
parent
10e110320b
commit
abad4b01ce
@ -17,6 +17,7 @@ class MetaString;
|
|||||||
class ServerCallback;
|
class ServerCallback;
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
class Spell;
|
class Spell;
|
||||||
|
class SpellSchool;
|
||||||
|
|
||||||
namespace battle
|
namespace battle
|
||||||
{
|
{
|
||||||
@ -38,7 +39,7 @@ public:
|
|||||||
/// returns level on which given spell would be cast by this(0 - none, 1 - basic etc);
|
/// returns level on which given spell would be cast by this(0 - none, 1 - basic etc);
|
||||||
/// caster may not know this spell at all
|
/// caster may not know this spell at all
|
||||||
/// optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic
|
/// optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic
|
||||||
virtual int32_t getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool = nullptr) const = 0;
|
virtual int32_t getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool = nullptr) const = 0;
|
||||||
|
|
||||||
///default spell school level for effect calculation
|
///default spell school level for effect calculation
|
||||||
virtual int32_t getEffectLevel(const Spell * spell) const = 0;
|
virtual int32_t getEffectLevel(const Spell * spell) const = 0;
|
||||||
|
@ -216,7 +216,7 @@ DLL_LINKAGE CArtifactInstance * ArtifactUtils::createNewArtifactInstance(CArtifa
|
|||||||
|
|
||||||
DLL_LINKAGE CArtifactInstance * ArtifactUtils::createNewArtifactInstance(const ArtifactID & aid)
|
DLL_LINKAGE CArtifactInstance * ArtifactUtils::createNewArtifactInstance(const ArtifactID & aid)
|
||||||
{
|
{
|
||||||
return ArtifactUtils::createNewArtifactInstance(VLC->arth->objects[aid]);
|
return ArtifactUtils::createNewArtifactInstance((*VLC->arth)[aid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_LINKAGE CArtifactInstance * ArtifactUtils::createArtifact(CMap * map, const ArtifactID & aid, SpellID spellID)
|
DLL_LINKAGE CArtifactInstance * ArtifactUtils::createArtifact(CMap * map, const ArtifactID & aid, SpellID spellID)
|
||||||
|
@ -371,7 +371,7 @@ void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode
|
|||||||
|
|
||||||
objects.emplace_back(object);
|
objects.emplace_back(object);
|
||||||
|
|
||||||
registerObject(scope, "artifact", name, object->id);
|
registerObject(scope, "artifact", name, object->id.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
|
||||||
@ -383,7 +383,7 @@ void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode
|
|||||||
assert(objects[index] == nullptr); // ensure that this id was not loaded before
|
assert(objects[index] == nullptr); // ensure that this id was not loaded before
|
||||||
objects[index] = object;
|
objects[index] = object;
|
||||||
|
|
||||||
registerObject(scope, "artifact", name, object->id);
|
registerObject(scope, "artifact", name, object->id.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> & CArtHandler::getTypeNames() const
|
const std::vector<std::string> & CArtHandler::getTypeNames() const
|
||||||
@ -630,7 +630,7 @@ void CArtHandler::makeItCommanderArt(CArtifact * a, bool onlyCommander)
|
|||||||
|
|
||||||
bool CArtHandler::legalArtifact(const ArtifactID & id)
|
bool CArtHandler::legalArtifact(const ArtifactID & id)
|
||||||
{
|
{
|
||||||
auto art = objects[id];
|
auto art = id.toArtifact();
|
||||||
//assert ( (!art->constituents) || art->constituents->size() ); //artifacts is not combined or has some components
|
//assert ( (!art->constituents) || art->constituents->size() ); //artifacts is not combined or has some components
|
||||||
|
|
||||||
if(art->isCombined())
|
if(art->isCombined())
|
||||||
@ -639,13 +639,13 @@ bool CArtHandler::legalArtifact(const ArtifactID & id)
|
|||||||
if(art->aClass < CArtifact::ART_TREASURE || art->aClass > CArtifact::ART_RELIC)
|
if(art->aClass < CArtifact::ART_TREASURE || art->aClass > CArtifact::ART_RELIC)
|
||||||
return false; // invalid class
|
return false; // invalid class
|
||||||
|
|
||||||
if(!art->possibleSlots[ArtBearer::HERO].empty())
|
if(art->possibleSlots.count(ArtBearer::HERO) && !art->possibleSlots.at(ArtBearer::HERO).empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!art->possibleSlots[ArtBearer::CREATURE].empty() && VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_ARTIFACT))
|
if(art->possibleSlots.count(ArtBearer::CREATURE) && !art->possibleSlots.at(ArtBearer::CREATURE).empty() && VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_ARTIFACT))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!art->possibleSlots[ArtBearer::COMMANDER].empty() && VLC->settings()->getBoolean(EGameSettings::MODULE_COMMANDERS))
|
if(art->possibleSlots.count(ArtBearer::COMMANDER) && !art->possibleSlots.at(ArtBearer::COMMANDER).empty() && VLC->settings()->getBoolean(EGameSettings::MODULE_COMMANDERS))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -658,7 +658,7 @@ void CArtHandler::initAllowedArtifactsList(const std::set<ArtifactID> & allowed)
|
|||||||
for (ArtifactID i : allowed)
|
for (ArtifactID i : allowed)
|
||||||
{
|
{
|
||||||
if (legalArtifact(ArtifactID(i)))
|
if (legalArtifact(ArtifactID(i)))
|
||||||
allowedArtifacts.push_back(objects[i]);
|
allowedArtifacts.push_back(i.toArtifact());
|
||||||
//keep im mind that artifact can be worn by more than one type of bearer
|
//keep im mind that artifact can be worn by more than one type of bearer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -682,7 +682,6 @@ void CArtHandler::afterLoadFinalization()
|
|||||||
{
|
{
|
||||||
for(auto &bonus : art->getExportedBonusList())
|
for(auto &bonus : art->getExportedBonusList())
|
||||||
{
|
{
|
||||||
assert(art == objects[art->id]);
|
|
||||||
assert(bonus->source == BonusSource::ARTIFACT);
|
assert(bonus->source == BonusSource::ARTIFACT);
|
||||||
bonus->sid = BonusSourceID(art->id);
|
bonus->sid = BonusSourceID(art->id);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ class DLL_LINKAGE CArtHandler : public CHandlerBase<ArtifactID, Artifact, CArtif
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// List of artifacts allowed on the map
|
/// List of artifacts allowed on the map
|
||||||
std::vector<CArtifact *> allowedArtifacts;
|
std::vector<const CArtifact *> allowedArtifacts;
|
||||||
|
|
||||||
void addBonuses(CArtifact *art, const JsonNode &bonusList);
|
void addBonuses(CArtifact *art, const JsonNode &bonusList);
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ bool CCreature::isMyUpgrade(const CCreature *anotherCre) const
|
|||||||
|
|
||||||
bool CCreature::valid() const
|
bool CCreature::valid() const
|
||||||
{
|
{
|
||||||
return this == VLC->creh->objects[idNumber];
|
return this == (*VLC->creh)[idNumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CCreature::nodeName() const
|
std::string CCreature::nodeName() const
|
||||||
@ -778,15 +778,13 @@ void CCreatureHandler::loadCrExpBon(CBonusSystemNode & globalEffects)
|
|||||||
}
|
}
|
||||||
do //parse everything that's left
|
do //parse everything that's left
|
||||||
{
|
{
|
||||||
CreatureID sid = static_cast<ui32>(parser.readNumber()); //id = this particular creature ID
|
CreatureID sid = parser.readNumber(); //id = this particular creature ID
|
||||||
|
|
||||||
b.sid = BonusSourceID(sid);
|
b.sid = BonusSourceID(sid);
|
||||||
bl.clear();
|
bl.clear();
|
||||||
loadStackExp(b, bl, parser);
|
loadStackExp(b, bl, parser);
|
||||||
for(const auto & b : bl)
|
for(const auto & b : bl)
|
||||||
{
|
(*this)[sid]->addNewBonus(b); //add directly to CCreature Node
|
||||||
objects[sid]->addNewBonus(b); //add directly to CCreature Node
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while (parser.endLine());
|
while (parser.endLine());
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ bool CCreatureSet::setCreature(SlotID slot, CreatureID type, TQuantity quantity)
|
|||||||
|
|
||||||
SlotID CCreatureSet::getSlotFor(const CreatureID & creature, ui32 slotsAmount) const /*returns -1 if no slot available */
|
SlotID CCreatureSet::getSlotFor(const CreatureID & creature, ui32 slotsAmount) const /*returns -1 if no slot available */
|
||||||
{
|
{
|
||||||
return getSlotFor(VLC->creh->objects[creature], slotsAmount);
|
return getSlotFor(creature.toCreature(), slotsAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotID CCreatureSet::getSlotFor(const CCreature *c, ui32 slotsAmount) const
|
SlotID CCreatureSet::getSlotFor(const CCreature *c, ui32 slotsAmount) const
|
||||||
@ -304,7 +304,7 @@ void CCreatureSet::sweep()
|
|||||||
|
|
||||||
void CCreatureSet::addToSlot(const SlotID & slot, const CreatureID & cre, TQuantity count, bool allowMerging)
|
void CCreatureSet::addToSlot(const SlotID & slot, const CreatureID & cre, TQuantity count, bool allowMerging)
|
||||||
{
|
{
|
||||||
const CCreature *c = VLC->creh->objects[cre];
|
const CCreature *c = cre.toCreature();
|
||||||
|
|
||||||
if(!hasStackAtSlot(slot))
|
if(!hasStackAtSlot(slot))
|
||||||
{
|
{
|
||||||
@ -749,10 +749,10 @@ void CStackInstance::giveStackExp(TExpType exp)
|
|||||||
|
|
||||||
void CStackInstance::setType(const CreatureID & creID)
|
void CStackInstance::setType(const CreatureID & creID)
|
||||||
{
|
{
|
||||||
if(creID.getNum() >= 0 && creID.getNum() < VLC->creh->objects.size())
|
if (creID == CreatureID::NONE)
|
||||||
setType(VLC->creh->objects[creID]);
|
setType(nullptr);//FIXME: unused branch?
|
||||||
else
|
else
|
||||||
setType((const CCreature*)nullptr);
|
setType(creID.toCreature());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStackInstance::setType(const CCreature *c)
|
void CStackInstance::setType(const CCreature *c)
|
||||||
@ -809,7 +809,7 @@ bool CStackInstance::valid(bool allowUnrandomized) const
|
|||||||
{
|
{
|
||||||
if(!randomStack)
|
if(!randomStack)
|
||||||
{
|
{
|
||||||
return (type && type == VLC->creh->objects[type->getId()]);
|
return (type && type == type->getId().toEntity(VLC));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return allowUnrandomized;
|
return allowUnrandomized;
|
||||||
@ -999,7 +999,7 @@ bool CCommanderInstance::gainsLevel() const
|
|||||||
CStackBasicDescriptor::CStackBasicDescriptor() = default;
|
CStackBasicDescriptor::CStackBasicDescriptor() = default;
|
||||||
|
|
||||||
CStackBasicDescriptor::CStackBasicDescriptor(const CreatureID & id, TQuantity Count):
|
CStackBasicDescriptor::CStackBasicDescriptor(const CreatureID & id, TQuantity Count):
|
||||||
type(VLC->creh->objects[id]),
|
type(id.toCreature()),
|
||||||
count(Count)
|
count(Count)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -518,7 +518,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
|
|||||||
|
|
||||||
for (auto const & upgradeSourceID : oldTargets)
|
for (auto const & upgradeSourceID : oldTargets)
|
||||||
{
|
{
|
||||||
const CCreature * upgradeSource = VLC->creh->objects[upgradeSourceID];
|
const CCreature * upgradeSource = upgradeSourceID.toCreature();
|
||||||
targets.insert(upgradeSource->upgrades.begin(), upgradeSource->upgrades.end());
|
targets.insert(upgradeSource->upgrades.begin(), upgradeSource->upgrades.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
|
|||||||
|
|
||||||
for(CreatureID cid : targets)
|
for(CreatureID cid : targets)
|
||||||
{
|
{
|
||||||
const CCreature &specCreature = *VLC->creh->objects[cid];
|
auto const & specCreature = *cid.toCreature();
|
||||||
int stepSize = specCreature.getLevel() ? specCreature.getLevel() : 5;
|
int stepSize = specCreature.getLevel() ? specCreature.getLevel() : 5;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ namespace JsonRandom
|
|||||||
|
|
||||||
for (auto const & artID : valuesSet)
|
for (auto const & artID : valuesSet)
|
||||||
{
|
{
|
||||||
CArtifact * art = VLC->arth->objects[artID];
|
const CArtifact * art = artID.toArtifact();
|
||||||
|
|
||||||
if(!vstd::iswithin(art->getPrice(), minValue, maxValue))
|
if(!vstd::iswithin(art->getPrice(), minValue, maxValue))
|
||||||
continue;
|
continue;
|
||||||
@ -482,13 +482,13 @@ namespace JsonRandom
|
|||||||
else
|
else
|
||||||
logMod->warn("Failed to select suitable random creature!");
|
logMod->warn("Failed to select suitable random creature!");
|
||||||
|
|
||||||
stack.type = VLC->creh->objects[pickedCreature];
|
stack.type = pickedCreature.toCreature();
|
||||||
stack.count = loadValue(value, rng, variables);
|
stack.count = loadValue(value, rng, variables);
|
||||||
if (!value["upgradeChance"].isNull() && !stack.type->upgrades.empty())
|
if (!value["upgradeChance"].isNull() && !stack.type->upgrades.empty())
|
||||||
{
|
{
|
||||||
if (int(value["upgradeChance"].Float()) > rng.nextInt(99)) // select random upgrade
|
if (int(value["upgradeChance"].Float()) > rng.nextInt(99)) // select random upgrade
|
||||||
{
|
{
|
||||||
stack.type = VLC->creh->objects[*RandomGeneratorUtil::nextItem(stack.type->upgrades, rng)];
|
stack.type = RandomGeneratorUtil::nextItem(stack.type->upgrades, rng)->toCreature();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
@ -523,7 +523,7 @@ namespace JsonRandom
|
|||||||
if (node["upgradeChance"].Float() > 0)
|
if (node["upgradeChance"].Float() > 0)
|
||||||
{
|
{
|
||||||
for(const auto & creaID : crea->upgrades)
|
for(const auto & creaID : crea->upgrades)
|
||||||
info.allowedCreatures.push_back(VLC->creh->objects[creaID]);
|
info.allowedCreatures.push_back(creaID.toCreature());
|
||||||
}
|
}
|
||||||
ret.push_back(info);
|
ret.push_back(info);
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ const CGHeroInstance * CUnitState::getHeroCaster() const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CUnitState::getSpellSchoolLevel(const spells::Spell * spell, int32_t * outSelectedSchool) const
|
int32_t CUnitState::getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
int32_t skill = valOfBonuses(Selector::typeSubtype(BonusType::SPELLCASTER, BonusSubtypeID(spell->getId())));
|
int32_t skill = valOfBonuses(Selector::typeSubtype(BonusType::SPELLCASTER, BonusSubtypeID(spell->getId())));
|
||||||
vstd::abetween(skill, 0, 3);
|
vstd::abetween(skill, 0, 3);
|
||||||
|
@ -182,7 +182,7 @@ public:
|
|||||||
|
|
||||||
int32_t getCasterUnitId() const override;
|
int32_t getCasterUnitId() const override;
|
||||||
|
|
||||||
int32_t getSpellSchoolLevel(const spells::Spell * spell, int32_t * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int32_t getEffectLevel(const spells::Spell * spell) const override;
|
int32_t getEffectLevel(const spells::Spell * spell) const override;
|
||||||
|
|
||||||
int64_t getSpellBonus(const spells::Spell * spell, int64_t base, const Unit * affectedStack) const override;
|
int64_t getSpellBonus(const spells::Spell * spell, int64_t base, const Unit * affectedStack) const override;
|
||||||
|
@ -160,12 +160,12 @@ std::string CampaignScenarioID::encode(const si32 index)
|
|||||||
return std::to_string(index);
|
return std::to_string(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Obj::encode(int32_t index)
|
std::string MapObjectID::encode(int32_t index)
|
||||||
{
|
{
|
||||||
return VLC->objtypeh->getObjectHandlerName(index);
|
return VLC->objtypeh->getObjectHandlerName(MapObjectID(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
si32 Obj::decode(const std::string & identifier)
|
si32 MapObjectID::decode(const std::string & identifier)
|
||||||
{
|
{
|
||||||
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "objects", identifier);
|
auto rawId = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "objects", identifier);
|
||||||
if(rawId)
|
if(rawId)
|
||||||
|
@ -672,6 +672,12 @@ class ArtifactPosition : public IdentifierWithEnum<ArtifactPosition, ArtifactPos
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>::IdentifierWithEnum;
|
using IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>::IdentifierWithEnum;
|
||||||
|
|
||||||
|
// TODO: Remove
|
||||||
|
constexpr operator int32_t () const
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ArtifactIDBase : public IdentifierBase
|
class ArtifactIDBase : public IdentifierBase
|
||||||
@ -728,6 +734,7 @@ public:
|
|||||||
FIRE_ELEMENTAL = 114, // for tests
|
FIRE_ELEMENTAL = 114, // for tests
|
||||||
PSYCHIC_ELEMENTAL = 120, // for hardcoded ability
|
PSYCHIC_ELEMENTAL = 120, // for hardcoded ability
|
||||||
MAGIC_ELEMENTAL = 121, // for hardcoded ability
|
MAGIC_ELEMENTAL = 121, // for hardcoded ability
|
||||||
|
AZURE_DRAGON = 132,
|
||||||
CATAPULT = 145,
|
CATAPULT = 145,
|
||||||
BALLISTA = 146,
|
BALLISTA = 146,
|
||||||
FIRST_AID_TENT = 147,
|
FIRST_AID_TENT = 147,
|
||||||
|
@ -1860,8 +1860,7 @@ void CGameState::attachArmedObjects()
|
|||||||
|
|
||||||
bool CGameState::giveHeroArtifact(CGHeroInstance * h, const ArtifactID & aid)
|
bool CGameState::giveHeroArtifact(CGHeroInstance * h, const ArtifactID & aid)
|
||||||
{
|
{
|
||||||
CArtifact * const artifact = VLC->arth->objects[aid]; //pointer to constant object
|
CArtifactInstance * ai = ArtifactUtils::createNewArtifactInstance(aid);
|
||||||
CArtifactInstance * ai = ArtifactUtils::createNewArtifactInstance(artifact);
|
|
||||||
map->addNewArtifactInstance(ai);
|
map->addNewArtifactInstance(ai);
|
||||||
auto slot = ArtifactUtils::getArtAnyPosition(h, aid);
|
auto slot = ArtifactUtils::getArtAnyPosition(h, aid);
|
||||||
if(ArtifactUtils::isSlotEquipment(slot) || ArtifactUtils::isSlotBackpack(slot))
|
if(ArtifactUtils::isSlotEquipment(slot) || ArtifactUtils::isSlotBackpack(slot))
|
||||||
|
@ -288,27 +288,26 @@ void CObjectClassesHandler::loadObject(std::string scope, std::string name, cons
|
|||||||
void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNode config, MapObjectID ID, MapObjectSubID subID)
|
void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNode config, MapObjectID ID, MapObjectSubID subID)
|
||||||
{
|
{
|
||||||
config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not NULL
|
config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not NULL
|
||||||
assert(objects[ID]);
|
assert(objects[ID.getNum()]);
|
||||||
|
|
||||||
if ( subID >= objects[ID]->objects.size())
|
if ( subID.getNum() >= objects[ID.getNum()]->objects.size())
|
||||||
objects[ID]->objects.resize(subID+1);
|
objects[ID.getNum()]->objects.resize(subID.getNum()+1);
|
||||||
|
|
||||||
JsonUtils::inherit(config, objects.at(ID)->base);
|
JsonUtils::inherit(config, objects.at(ID.getNum())->base);
|
||||||
loadSubObject(config.meta, identifier, config, objects[ID], subID);
|
loadSubObject(config.meta, identifier, config, objects[ID.getNum()], subID.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CObjectClassesHandler::removeSubObject(MapObjectID ID, MapObjectSubID subID)
|
void CObjectClassesHandler::removeSubObject(MapObjectID ID, MapObjectSubID subID)
|
||||||
{
|
{
|
||||||
assert(objects[ID]);
|
assert(objects[ID.getNum()]);
|
||||||
assert(subID < objects[ID]->objects.size());
|
objects[ID.getNum()]->objects[subID.getNum()] = nullptr;
|
||||||
objects[ID]->objects[subID] = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(MapObjectID type, MapObjectSubID subtype) const
|
TObjectTypeHandler CObjectClassesHandler::getHandlerFor(MapObjectID type, MapObjectSubID subtype) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto result = objects.at(type)->objects.at(subtype);
|
auto result = objects.at(type.getNum())->objects.at(subtype.getNum());
|
||||||
|
|
||||||
if (result != nullptr)
|
if (result != nullptr)
|
||||||
return result;
|
return result;
|
||||||
@ -318,7 +317,7 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(MapObjectID type, MapObj
|
|||||||
// Leave catch block silently
|
// Leave catch block silently
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string errorString = "Failed to find object of type " + std::to_string(type) + "::" + std::to_string(subtype);
|
std::string errorString = "Failed to find object of type " + std::to_string(type.getNum()) + "::" + std::to_string(subtype.getNum());
|
||||||
logGlobal->error(errorString);
|
logGlobal->error(errorString);
|
||||||
throw std::runtime_error(errorString);
|
throw std::runtime_error(errorString);
|
||||||
}
|
}
|
||||||
@ -360,13 +359,13 @@ std::set<MapObjectSubID> CObjectClassesHandler::knownSubObjects(MapObjectID prim
|
|||||||
{
|
{
|
||||||
std::set<MapObjectSubID> ret;
|
std::set<MapObjectSubID> ret;
|
||||||
|
|
||||||
if (!objects.at(primaryID))
|
if (!objects.at(primaryID.getNum()))
|
||||||
{
|
{
|
||||||
logGlobal->error("Failed to find object %d", primaryID);
|
logGlobal->error("Failed to find object %d", primaryID);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto & entry : objects.at(primaryID)->objects)
|
for(const auto & entry : objects.at(primaryID.getNum())->objects)
|
||||||
if (entry)
|
if (entry)
|
||||||
ret.insert(entry->subtype);
|
ret.insert(entry->subtype);
|
||||||
|
|
||||||
@ -460,7 +459,7 @@ std::string CObjectClassesHandler::getObjectName(MapObjectID type, MapObjectSubI
|
|||||||
if (handler && handler->hasNameTextID())
|
if (handler && handler->hasNameTextID())
|
||||||
return handler->getNameTranslated();
|
return handler->getNameTranslated();
|
||||||
else
|
else
|
||||||
return objects[type]->getNameTranslated();
|
return objects[type.getNum()]->getNameTranslated();
|
||||||
}
|
}
|
||||||
|
|
||||||
SObjectSounds CObjectClassesHandler::getObjectSounds(MapObjectID type, MapObjectSubID subtype) const
|
SObjectSounds CObjectClassesHandler::getObjectSounds(MapObjectID type, MapObjectSubID subtype) const
|
||||||
@ -472,20 +471,19 @@ SObjectSounds CObjectClassesHandler::getObjectSounds(MapObjectID type, MapObject
|
|||||||
if(type == Obj::PRISON || type == Obj::HERO || type == Obj::SPELL_SCROLL)
|
if(type == Obj::PRISON || type == Obj::HERO || type == Obj::SPELL_SCROLL)
|
||||||
subtype = 0;
|
subtype = 0;
|
||||||
|
|
||||||
assert(objects[type]);
|
assert(objects[type.getNum()]);
|
||||||
assert(subtype < objects[type]->objects.size());
|
|
||||||
|
|
||||||
return getHandlerFor(type, subtype)->getSounds();
|
return getHandlerFor(type, subtype)->getSounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CObjectClassesHandler::getObjectHandlerName(MapObjectID type) const
|
std::string CObjectClassesHandler::getObjectHandlerName(MapObjectID type) const
|
||||||
{
|
{
|
||||||
return objects.at(type)->handlerName;
|
return objects.at(type.getNum())->handlerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CObjectClassesHandler::getJsonKey(MapObjectID type) const
|
std::string CObjectClassesHandler::getJsonKey(MapObjectID type) const
|
||||||
{
|
{
|
||||||
return objects.at(type)->getJsonKey();
|
return objects.at(type.getNum())->getJsonKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
void CArmedInstance::randomizeArmy(int type)
|
void CArmedInstance::randomizeArmy(FactionID type)
|
||||||
{
|
{
|
||||||
for (auto & elem : stacks)
|
for (auto & elem : stacks)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
BattleInfo *battle; //set to the current battle, if engaged
|
BattleInfo *battle; //set to the current battle, if engaged
|
||||||
|
|
||||||
void randomizeArmy(int type);
|
void randomizeArmy(FactionID type);
|
||||||
virtual void updateMoraleBonusFromArmy();
|
virtual void updateMoraleBonusFromArmy();
|
||||||
|
|
||||||
void armyChanged() override;
|
void armyChanged() override;
|
||||||
|
@ -578,11 +578,11 @@ void CGHeroInstance::pickRandomObject(CRandomGenerator & rand)
|
|||||||
{
|
{
|
||||||
ID = Obj::HERO;
|
ID = Obj::HERO;
|
||||||
subID = cb->gameState()->pickNextHeroType(getOwner());
|
subID = cb->gameState()->pickNextHeroType(getOwner());
|
||||||
type = VLC->heroh->objects[subID];
|
type = VLC->heroh->objects[getHeroType().getNum()];
|
||||||
randomizeArmy(type->heroClass->faction);
|
randomizeArmy(type->heroClass->faction);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
type = VLC->heroh->objects[subID];
|
type = VLC->heroh->objects[getHeroType().getNum()];
|
||||||
|
|
||||||
auto oldSubID = subID;
|
auto oldSubID = subID;
|
||||||
|
|
||||||
@ -657,7 +657,7 @@ int32_t CGHeroInstance::getCasterUnitId() const
|
|||||||
return id.getNum();
|
return id.getNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CGHeroInstance::getSpellSchoolLevel(const spells::Spell * spell, int32_t * outSelectedSchool) const
|
int32_t CGHeroInstance::getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
int32_t skill = -1; //skill level
|
int32_t skill = -1; //skill level
|
||||||
|
|
||||||
@ -909,7 +909,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
|
|||||||
// raise upgraded creature (at 2/3 rate) if no space available otherwise
|
// raise upgraded creature (at 2/3 rate) if no space available otherwise
|
||||||
if(getSlotFor(creatureTypeRaised) == SlotID())
|
if(getSlotFor(creatureTypeRaised) == SlotID())
|
||||||
{
|
{
|
||||||
for(const CreatureID & upgraded : VLC->creh->objects[creatureTypeRaised]->upgrades)
|
for(const CreatureID & upgraded : creatureTypeRaised.toCreature()->upgrades)
|
||||||
{
|
{
|
||||||
if(getSlotFor(upgraded) != SlotID())
|
if(getSlotFor(upgraded) != SlotID())
|
||||||
{
|
{
|
||||||
@ -920,7 +920,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// calculate number of creatures raised - low level units contribute at 50% rate
|
// calculate number of creatures raised - low level units contribute at 50% rate
|
||||||
const double raisedUnitHealth = VLC->creh->objects[creatureTypeRaised]->getMaxHealth();
|
const double raisedUnitHealth = creatureTypeRaised.toCreature()->getMaxHealth();
|
||||||
double raisedUnits = 0;
|
double raisedUnits = 0;
|
||||||
for(const auto & casualty : casualties)
|
for(const auto & casualty : casualties)
|
||||||
{
|
{
|
||||||
@ -1523,7 +1523,7 @@ std::string CGHeroInstance::getHeroTypeName() const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return VLC->heroh->objects[getHeroType()]->getJsonKey();
|
return getHeroType().toEntity(VLC)->getJsonKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@ -1657,15 +1657,11 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
|
|||||||
for(size_t skillIndex = 0; skillIndex < secondarySkills.size(); ++skillIndex)
|
for(size_t skillIndex = 0; skillIndex < secondarySkills.size(); ++skillIndex)
|
||||||
{
|
{
|
||||||
JsonArraySerializer inner = secondarySkills.enterArray(skillIndex);
|
JsonArraySerializer inner = secondarySkills.enterArray(skillIndex);
|
||||||
const si32 rawId = secSkills.at(skillIndex).first;
|
SecondarySkill skillId = secSkills.at(skillIndex).first;
|
||||||
|
|
||||||
if(rawId < 0 || rawId >= VLC->skillh->size())
|
handler.serializeId("skill", skillId);
|
||||||
logGlobal->error("Invalid secondary skill %d", rawId);
|
std::string skillLevel = NSecondarySkill::levels.at(secSkills.at(skillIndex).second);
|
||||||
|
handler.serializeString("level", skillLevel);
|
||||||
auto value = (*VLC->skillh)[SecondarySkill(rawId)]->getJsonKey();
|
|
||||||
handler.serializeString("skill", value);
|
|
||||||
value = NSecondarySkill::levels.at(secSkills.at(skillIndex).second);
|
|
||||||
handler.serializeString("level", value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1757,7 +1753,7 @@ void CGHeroInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
|||||||
if(!appearance)
|
if(!appearance)
|
||||||
{
|
{
|
||||||
// crossoverDeserialize
|
// crossoverDeserialize
|
||||||
type = VLC->heroh->objects[getHeroType()];
|
type = VLC->heroh->objects[getHeroType().getNum()];
|
||||||
appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, type->heroClass->getIndex())->getTemplates().front();
|
appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, type->heroClass->getIndex())->getTemplates().front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ public:
|
|||||||
|
|
||||||
///spells::Caster
|
///spells::Caster
|
||||||
int32_t getCasterUnitId() const override;
|
int32_t getCasterUnitId() const override;
|
||||||
int32_t getSpellSchoolLevel(const spells::Spell * spell, int32_t * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int64_t getSpellBonus(const spells::Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
int64_t getSpellBonus(const spells::Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
||||||
int64_t getSpecificSpellBonus(const spells::Spell * spell, int64_t base) const override;
|
int64_t getSpecificSpellBonus(const spells::Spell * spell, int64_t base) const override;
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
|
|||||||
if (creatures[level].second.empty())
|
if (creatures[level].second.empty())
|
||||||
return ret; //no dwelling
|
return ret; //no dwelling
|
||||||
|
|
||||||
const CCreature *creature = VLC->creh->objects[creatures[level].second.back()];
|
const Creature *creature = creatures[level].second.back().toEntity(VLC);
|
||||||
const int base = creature->getGrowth();
|
const int base = creature->getGrowth();
|
||||||
int castleBonus = 0;
|
int castleBonus = 0;
|
||||||
|
|
||||||
@ -489,8 +489,8 @@ void CGTownInstance::pickRandomObject(CRandomGenerator & rand)
|
|||||||
|
|
||||||
assert(ID == Obj::TOWN); // just in case
|
assert(ID == Obj::TOWN); // just in case
|
||||||
setType(ID, subID);
|
setType(ID, subID);
|
||||||
town = (*VLC->townh)[subID]->town;
|
town = (*VLC->townh)[getFaction()]->town;
|
||||||
randomizeArmy(subID);
|
randomizeArmy(getFaction());
|
||||||
updateAppearance();
|
updateAppearance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,7 +571,7 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const
|
|||||||
}
|
}
|
||||||
else //upgrade
|
else //upgrade
|
||||||
{
|
{
|
||||||
cb->changeStackType(sl, VLC->creh->objects[*c->upgrades.begin()]);
|
cb->changeStackType(sl, c->upgrades.begin()->toCreature());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((stacksCount() < GameConstants::ARMY_SIZE && rand.nextInt(99) < 25) || Slots().empty()) //add new stack
|
if ((stacksCount() < GameConstants::ARMY_SIZE && rand.nextInt(99) < 25) || Slots().empty()) //add new stack
|
||||||
@ -592,7 +592,7 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const
|
|||||||
{
|
{
|
||||||
StackLocation sl(this, n);
|
StackLocation sl(this, n);
|
||||||
if (slotEmpty(n))
|
if (slotEmpty(n))
|
||||||
cb->insertNewStack(sl, VLC->creh->objects[c], count);
|
cb->insertNewStack(sl, c.toCreature(), count);
|
||||||
else //add to existing
|
else //add to existing
|
||||||
cb->changeStackCount(sl, count);
|
cb->changeStackCount(sl, count);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
std::map <si32, std::vector<ObjectInstanceID> > CGMagi::eyelist;
|
std::map <MapObjectSubID, std::vector<ObjectInstanceID> > CGMagi::eyelist;
|
||||||
ui8 CGObelisk::obeliskCount = 0; //how many obelisks are on map
|
ui8 CGObelisk::obeliskCount = 0; //how many obelisks are on map
|
||||||
std::map<TeamID, ui8> CGObelisk::visited; //map: team_id => how many obelisks has been visited
|
std::map<TeamID, ui8> CGObelisk::visited; //map: team_id => how many obelisks has been visited
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ void CGMine::serializeJsonOptions(JsonSerializeFormat & handler)
|
|||||||
for(const auto & resID : abandonedMineResources)
|
for(const auto & resID : abandonedMineResources)
|
||||||
{
|
{
|
||||||
JsonNode one(JsonNode::JsonType::DATA_STRING);
|
JsonNode one(JsonNode::JsonType::DATA_STRING);
|
||||||
one.String() = GameConstants::RESOURCE_NAMES[resID];
|
one.String() = GameConstants::RESOURCE_NAMES[resID.getNum()];
|
||||||
node.Vector().push_back(one);
|
node.Vector().push_back(one);
|
||||||
}
|
}
|
||||||
handler.serializeRaw("possibleResources", node, std::nullopt);
|
handler.serializeRaw("possibleResources", node, std::nullopt);
|
||||||
|
@ -338,7 +338,7 @@ protected:
|
|||||||
class DLL_LINKAGE CGMagi : public CGObjectInstance
|
class DLL_LINKAGE CGMagi : public CGObjectInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::map <si32, std::vector<ObjectInstanceID> > eyelist; //[subID][id], supports multiple sets as in H5
|
static std::map <MapObjectSubID, std::vector<ObjectInstanceID> > eyelist; //[subID][id], supports multiple sets as in H5
|
||||||
|
|
||||||
static void reset();
|
static void reset();
|
||||||
|
|
||||||
|
@ -2095,7 +2095,7 @@ int CMapLoaderH3M::readQuest(IQuestObject * guard, const int3 & position)
|
|||||||
guard->quest->mission.creatures.resize(typeNumber);
|
guard->quest->mission.creatures.resize(typeNumber);
|
||||||
for(int hh = 0; hh < typeNumber; ++hh)
|
for(int hh = 0; hh < typeNumber; ++hh)
|
||||||
{
|
{
|
||||||
guard->quest->mission.creatures[hh].type = VLC->creh->objects[reader->readCreature()];
|
guard->quest->mission.creatures[hh].type = reader->readCreature().toCreature();
|
||||||
guard->quest->mission.creatures[hh].count = reader->readUInt16();
|
guard->quest->mission.creatures[hh].count = reader->readUInt16();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -528,13 +528,10 @@ void CMapFormatJson::serializePlayerInfo(JsonSerializeFormat & handler)
|
|||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
if(hero->type)
|
if(hero->type)
|
||||||
{
|
|
||||||
temp = hero->type->getJsonKey();
|
temp = hero->type->getJsonKey();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
temp = hero->getHeroType().toEntity(VLC)->getJsonKey();
|
||||||
temp = VLC->heroh->objects[hero->subID]->getJsonKey();
|
|
||||||
}
|
|
||||||
handler.serializeString("type", temp);
|
handler.serializeString("type", temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -753,7 +750,7 @@ void CMapFormatJson::writeDisposedHeroes(JsonSerializeFormat & handler)
|
|||||||
|
|
||||||
for(DisposedHero & hero : map->disposedHeroes)
|
for(DisposedHero & hero : map->disposedHeroes)
|
||||||
{
|
{
|
||||||
std::string type = HeroTypeID::encode(hero.heroId);
|
std::string type = HeroTypeID::encode(hero.heroId.getNum());
|
||||||
|
|
||||||
auto definition = definitions->enterStruct(type);
|
auto definition = definitions->enterStruct(type);
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void Rewardable::Interface::grantRewardAfterLevelup(IGameCallback * cb, const Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(const ArtifactID & art : info.reward.artifacts)
|
for(const ArtifactID & art : info.reward.artifacts)
|
||||||
cb->giveHeroNewArtifact(hero, VLC->arth->objects[art],ArtifactPosition::FIRST_AVAILABLE);
|
cb->giveHeroNewArtifact(hero, art.toArtifact(), ArtifactPosition::FIRST_AVAILABLE);
|
||||||
|
|
||||||
if(!info.reward.spells.empty())
|
if(!info.reward.spells.empty())
|
||||||
{
|
{
|
||||||
|
@ -98,12 +98,7 @@ const CMapGenOptions& CMapGenerator::getMapGenOptions() const
|
|||||||
|
|
||||||
void CMapGenerator::initPrisonsRemaining()
|
void CMapGenerator::initPrisonsRemaining()
|
||||||
{
|
{
|
||||||
allowedPrisons = 0;
|
allowedPrisons = map->getMap(this).allowedHeroes.size();
|
||||||
for (auto isAllowed : map->getMap(this).allowedHeroes)
|
|
||||||
{
|
|
||||||
if (isAllowed)
|
|
||||||
allowedPrisons++;
|
|
||||||
}
|
|
||||||
allowedPrisons = std::max<int> (0, allowedPrisons - 16 * mapGenOptions.getHumanOrCpuPlayerCount()); //so at least 16 heroes will be available for every player
|
allowedPrisons = std::max<int> (0, allowedPrisons - 16 * mapGenOptions.getHumanOrCpuPlayerCount()); //so at least 16 heroes will be available for every player
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,14 +638,14 @@ CGCreature * ObjectManager::chooseGuard(si32 strength, bool zoneGuard)
|
|||||||
if(!possibleCreatures.empty())
|
if(!possibleCreatures.empty())
|
||||||
{
|
{
|
||||||
creId = *RandomGeneratorUtil::nextItem(possibleCreatures, zone.getRand());
|
creId = *RandomGeneratorUtil::nextItem(possibleCreatures, zone.getRand());
|
||||||
amount = strength / VLC->creh->objects[creId]->getAIValue();
|
amount = strength / creId.toEntity(VLC)->getAIValue();
|
||||||
if (amount >= 4)
|
if (amount >= 4)
|
||||||
amount = static_cast<int>(amount * zone.getRand().nextDouble(0.75, 1.25));
|
amount = static_cast<int>(amount * zone.getRand().nextDouble(0.75, 1.25));
|
||||||
}
|
}
|
||||||
else //just pick any available creature
|
else //just pick any available creature
|
||||||
{
|
{
|
||||||
creId = CreatureID(132); //Azure Dragon
|
creId = CreatureID::AZURE_DRAGON; //Azure Dragon
|
||||||
amount = strength / VLC->creh->objects[creId]->getAIValue();
|
amount = strength / creId.toEntity(VLC)->getAIValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto guardFactory = VLC->objtypeh->getHandlerFor(Obj::MONSTER, creId);
|
auto guardFactory = VLC->objtypeh->getHandlerFor(Obj::MONSTER, creId);
|
||||||
|
@ -28,7 +28,7 @@ AbilityCaster::AbilityCaster(const battle::Unit * actualCaster_, int32_t baseSpe
|
|||||||
|
|
||||||
AbilityCaster::~AbilityCaster() = default;
|
AbilityCaster::~AbilityCaster() = default;
|
||||||
|
|
||||||
int32_t AbilityCaster::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
|
int32_t AbilityCaster::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
auto skill = baseSpellLevel;
|
auto skill = baseSpellLevel;
|
||||||
const auto * unit = dynamic_cast<const battle::Unit*>(actualCaster);
|
const auto * unit = dynamic_cast<const battle::Unit*>(actualCaster);
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
AbilityCaster(const battle::Unit * actualCaster_, int32_t baseSpellLevel_);
|
AbilityCaster(const battle::Unit * actualCaster_, int32_t baseSpellLevel_);
|
||||||
virtual ~AbilityCaster();
|
virtual ~AbilityCaster();
|
||||||
|
|
||||||
int32_t getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int32_t getEffectLevel(const Spell * spell) const override;
|
int32_t getEffectLevel(const Spell * spell) const override;
|
||||||
void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const override;
|
void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const override;
|
||||||
void spendMana(ServerCallback * server, const int32_t spellCost) const override;
|
void spendMana(ServerCallback * server, const int32_t spellCost) const override;
|
||||||
|
@ -154,7 +154,7 @@ void CSpell::forEachSchool(const std::function<void(const SpellSchool &, bool &)
|
|||||||
bool stop = false;
|
bool stop = false;
|
||||||
for(auto iter : SpellConfig::SCHOOL_ORDER)
|
for(auto iter : SpellConfig::SCHOOL_ORDER)
|
||||||
{
|
{
|
||||||
const spells::SchoolInfo & cnf = SpellConfig::SCHOOL[iter];
|
const spells::SchoolInfo & cnf = SpellConfig::SCHOOL[iter.getNum()];
|
||||||
if(school.at(cnf.id))
|
if(school.at(cnf.id))
|
||||||
{
|
{
|
||||||
cb(cnf.id, stop);
|
cb(cnf.id, stop);
|
||||||
|
@ -42,7 +42,7 @@ void ExternalCaster::spendMana(ServerCallback * server, const int32_t spellCost)
|
|||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ExternalCaster::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
|
int32_t ExternalCaster::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
return schoolLevel;
|
return schoolLevel;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
class SpellSchool;
|
||||||
|
|
||||||
namespace spells
|
namespace spells
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -27,7 +29,7 @@ public:
|
|||||||
void setActualCaster(const Caster * actualCaster);
|
void setActualCaster(const Caster * actualCaster);
|
||||||
void setSpellSchoolLevel(int level);
|
void setSpellSchoolLevel(int level);
|
||||||
|
|
||||||
int32_t getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
void spendMana(ServerCallback * server, const int32_t spellCost) const override;
|
void spendMana(ServerCallback * server, const int32_t spellCost) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ ObstacleCasterProxy::ObstacleCasterProxy(PlayerColor owner_, const Caster * hero
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ObstacleCasterProxy::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
|
int32_t ObstacleCasterProxy::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
return obs.spellLevel;
|
return obs.spellLevel;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class DLL_LINKAGE ObstacleCasterProxy : public SilentCaster
|
|||||||
public:
|
public:
|
||||||
ObstacleCasterProxy(PlayerColor owner_, const Caster * hero_, const SpellCreatedObstacle & obs_);
|
ObstacleCasterProxy(PlayerColor owner_, const Caster * hero_, const SpellCreatedObstacle & obs_);
|
||||||
|
|
||||||
int32_t getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int32_t getEffectLevel(const Spell * spell) const override;
|
int32_t getEffectLevel(const Spell * spell) const override;
|
||||||
int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
||||||
int32_t getEffectPower(const Spell * spell) const override;
|
int32_t getEffectPower(const Spell * spell) const override;
|
||||||
|
@ -36,7 +36,7 @@ int32_t ProxyCaster::getCasterUnitId() const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ProxyCaster::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
|
int32_t ProxyCaster::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
if(actualCaster)
|
if(actualCaster)
|
||||||
return actualCaster->getSpellSchoolLevel(spell, outSelectedSchool);
|
return actualCaster->getSpellSchoolLevel(spell, outSelectedSchool);
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
virtual ~ProxyCaster();
|
virtual ~ProxyCaster();
|
||||||
|
|
||||||
int32_t getCasterUnitId() const override;
|
int32_t getCasterUnitId() const override;
|
||||||
int32_t getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int32_t getEffectLevel(const Spell * spell) const override;
|
int32_t getEffectLevel(const Spell * spell) const override;
|
||||||
int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
||||||
int64_t getSpecificSpellBonus(const Spell * spell, int64_t base) const override;
|
int64_t getSpecificSpellBonus(const Spell * spell, int64_t base) const override;
|
||||||
|
Loading…
Reference in New Issue
Block a user