mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-21 19:19:26 +02:00
vcmi: remove TFaction
This is a huge change and will break save compatibility
This commit is contained in:
parent
452cebfdfd
commit
fedf7d377c
@ -96,14 +96,14 @@ public:
|
||||
std::vector<SlotInfo> ArmyManager::getBestArmy(const IBonusBearer * armyCarrier, const CCreatureSet * target, const CCreatureSet * source) const
|
||||
{
|
||||
auto sortedSlots = getSortedSlots(target, source);
|
||||
std::map<TFaction, uint64_t> alignmentMap;
|
||||
std::map<FactionID, uint64_t> alignmentMap;
|
||||
|
||||
for(auto & slot : sortedSlots)
|
||||
{
|
||||
alignmentMap[slot.creature->getFactionIndex()] += slot.power;
|
||||
alignmentMap[slot.creature->getFaction()] += slot.power;
|
||||
}
|
||||
|
||||
std::set<TFaction> allowedFactions;
|
||||
std::set<FactionID> allowedFactions;
|
||||
std::vector<SlotInfo> resultingArmy;
|
||||
uint64_t armyValue = 0;
|
||||
|
||||
@ -121,7 +121,7 @@ std::vector<SlotInfo> ArmyManager::getBestArmy(const IBonusBearer * armyCarrier,
|
||||
|
||||
while(allowedFactions.size() < alignmentMap.size())
|
||||
{
|
||||
auto strongestAlignment = vstd::maxElementByFun(alignmentMap, [&](std::pair<TFaction, uint64_t> pair) -> uint64_t
|
||||
auto strongestAlignment = vstd::maxElementByFun(alignmentMap, [&](std::pair<FactionID, uint64_t> pair) -> uint64_t
|
||||
{
|
||||
return vstd::contains(allowedFactions, pair.first) ? 0 : pair.second;
|
||||
});
|
||||
@ -134,7 +134,7 @@ std::vector<SlotInfo> ArmyManager::getBestArmy(const IBonusBearer * armyCarrier,
|
||||
|
||||
for(auto & slot : sortedSlots)
|
||||
{
|
||||
if(vstd::contains(allowedFactions, slot.creature->getFactionIndex()))
|
||||
if(vstd::contains(allowedFactions, slot.creature->getFaction()))
|
||||
{
|
||||
auto slotID = newArmyInstance.getSlotFor(slot.creature);
|
||||
|
||||
|
@ -94,7 +94,7 @@ TGoalVec GatherTroops::getAllPossibleSubgoals()
|
||||
}
|
||||
|
||||
auto creature = VLC->creatures()->getByIndex(objid);
|
||||
if(t->subID == creature->getFactionIndex()) //TODO: how to force AI to build unupgraded creatures? :O
|
||||
if(t->subID == creature->getFaction()) //TODO: how to force AI to build unupgraded creatures? :O
|
||||
{
|
||||
auto creatures = vstd::tryAt(t->town->creatures, creature->getLevel() - 1);
|
||||
if(!creatures)
|
||||
|
@ -448,7 +448,7 @@ CCreaturePic::CCreaturePic(int x, int y, const CCreature * cre, bool Big, bool A
|
||||
pos.x+=x;
|
||||
pos.y+=y;
|
||||
|
||||
TFaction faction = cre->getFactionIndex();
|
||||
auto faction = cre->getFaction();
|
||||
|
||||
assert(CGI->townh->size() > faction);
|
||||
|
||||
|
@ -892,7 +892,7 @@ void CCastleBuildings::enterFountain(const BuildingID & building, BuildingSubID:
|
||||
std::string hasNotProduced;
|
||||
std::string hasProduced;
|
||||
|
||||
if(this->town->town->faction->getIndex() == (TFaction)ETownType::RAMPART)
|
||||
if(this->town->town->faction->getIndex() == ETownType::RAMPART)
|
||||
{
|
||||
hasNotProduced = CGI->generaltexth->allTexts[677];
|
||||
hasProduced = CGI->generaltexth->allTexts[678];
|
||||
|
@ -41,7 +41,6 @@ public:
|
||||
virtual int32_t getLevel() const = 0;
|
||||
virtual int32_t getGrowth() const = 0;
|
||||
virtual int32_t getHorde() const = 0;
|
||||
virtual int32_t getFactionIndex() const = 0;
|
||||
|
||||
virtual int32_t getBaseAttack() const = 0;
|
||||
virtual int32_t getBaseDefense() const = 0;
|
||||
|
@ -109,11 +109,6 @@ int32_t CCreature::getHorde() const
|
||||
return hordeGrowth;
|
||||
}
|
||||
|
||||
int32_t CCreature::getFactionIndex() const
|
||||
{
|
||||
return faction;
|
||||
}
|
||||
|
||||
FactionID CCreature::getFaction() const
|
||||
{
|
||||
return FactionID(faction);
|
||||
@ -335,22 +330,16 @@ std::string CCreature::nodeName() const
|
||||
return "\"" + getNamePluralTextID() + "\"";
|
||||
}
|
||||
|
||||
bool CCreature::isItNativeTerrain(TerrainId terrain) const
|
||||
{
|
||||
auto native = getNativeTerrain();
|
||||
return native == terrain || native == ETerrainId::ANY_TERRAIN;
|
||||
}
|
||||
|
||||
TerrainId CCreature::getNativeTerrain() const
|
||||
{
|
||||
constexpr auto any = TerrainId(ETerrainId::ANY_TERRAIN);
|
||||
const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY_sANY";
|
||||
static const auto selectorNoTerrainPenalty = Selector::typeSubtype(Bonus::NO_TERRAIN_PENALTY, static_cast<int>(ETerrainId::ANY_TERRAIN));
|
||||
static const auto selectorNoTerrainPenalty = Selector::typeSubtype(Bonus::NO_TERRAIN_PENALTY, any);
|
||||
|
||||
//this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses
|
||||
//and in the CGHeroInstance::getNativeTerrain() to setup movement bonuses or/and penalties.
|
||||
return getBonusBearer()->hasBonus(selectorNoTerrainPenalty, cachingStringNoTerrainPenalty)
|
||||
? TerrainId(ETerrainId::ANY_TERRAIN)
|
||||
: VLC->factions()->getById(getFaction())->getNativeTerrain();
|
||||
? any : VLC->factions()->getById(getFaction())->getNativeTerrain();
|
||||
}
|
||||
|
||||
void CCreature::updateFrom(const JsonNode & data)
|
||||
@ -933,7 +922,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
|
||||
|
||||
VLC->modh->identifiers.requestIdentifier("faction", config["faction"], [=](si32 faction)
|
||||
{
|
||||
creature->faction = faction;
|
||||
creature->faction = FactionID(faction);
|
||||
});
|
||||
|
||||
for(const JsonNode &value : config["upgrades"].Vector())
|
||||
|
@ -39,7 +39,7 @@ class DLL_LINKAGE CCreature : public Creature, public CBonusSystemNode
|
||||
|
||||
CreatureID idNumber;
|
||||
|
||||
TFaction faction = 0;
|
||||
FactionID faction = FactionID::NEUTRAL;
|
||||
ui8 level = 0; // 0 - unknown; 1-7 for "usual" creatures
|
||||
|
||||
//stats that are not handled by bonus system
|
||||
@ -162,7 +162,6 @@ public:
|
||||
std::string getNamePluralTextID() const override;
|
||||
std::string getNameSingularTextID() const override;
|
||||
|
||||
bool isItNativeTerrain(TerrainId terrain) const;
|
||||
FactionID getFaction() const override;
|
||||
/**
|
||||
Returns creature native terrain considering some terrain bonuses.
|
||||
@ -183,7 +182,6 @@ public:
|
||||
int32_t getLevel() const override;
|
||||
int32_t getGrowth() const override;
|
||||
int32_t getHorde() const override;
|
||||
int32_t getFactionIndex() const override;
|
||||
|
||||
int32_t getBaseAttack() const override;
|
||||
int32_t getBaseDefense() const override;
|
||||
|
@ -359,7 +359,7 @@ bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero
|
||||
|
||||
for(auto creature : VLC->creh->objects)
|
||||
{
|
||||
if(static_cast<si16>(creature->getFactionIndex()) == factionIndex && static_cast<int>(creature->getAIValue()) > maxAIValue)
|
||||
if(creature->getFaction() == factionIndex && static_cast<int>(creature->getAIValue()) > maxAIValue)
|
||||
{
|
||||
maxAIValue = creature->getAIValue();
|
||||
mostStrong = creature;
|
||||
|
@ -372,7 +372,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native,
|
||||
( !bannedClass || elem.second->type->heroClass != bannedClass) ) // and his class is not same as other hero
|
||||
{
|
||||
pool.push_back(elem.second);
|
||||
sum += elem.second->type->heroClass->selectionProbability[town->faction->getIndex()]; //total weight
|
||||
sum += elem.second->type->heroClass->selectionProbability[town->faction->getId()]; //total weight
|
||||
}
|
||||
}
|
||||
if(pool.empty() || sum == 0)
|
||||
@ -384,7 +384,7 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native,
|
||||
r = rand.nextInt(sum - 1);
|
||||
for (auto & elem : pool)
|
||||
{
|
||||
r -= elem->type->heroClass->selectionProbability[town->faction->getIndex()];
|
||||
r -= elem->type->heroClass->selectionProbability[town->faction->getId()];
|
||||
if(r < 0)
|
||||
{
|
||||
ret = elem;
|
||||
@ -1747,8 +1747,8 @@ void CGameState::initTowns()
|
||||
}
|
||||
if(vti->getNameTranslated().empty())
|
||||
{
|
||||
size_t nameID = getRandomGenerator().nextInt(vti->town->getRandomNamesCount() - 1);
|
||||
vti->setNameTranslated(vti->town->getRandomNameTranslated(nameID));
|
||||
size_t nameID = getRandomGenerator().nextInt(vti->getTown()->getRandomNamesCount() - 1);
|
||||
vti->setNameTranslated(vti->getTown()->getRandomNameTranslated(nameID));
|
||||
}
|
||||
|
||||
//init buildings
|
||||
@ -1778,14 +1778,14 @@ void CGameState::initTowns()
|
||||
if (vstd::contains(vti->builtBuildings, (BuildingID::HORDE_PLACEHOLDER1 - i))) //if we have horde for this level
|
||||
{
|
||||
vti->builtBuildings.erase(BuildingID(BuildingID::HORDE_PLACEHOLDER1 - i));//remove old ID
|
||||
if (vti->town->hordeLvl.at(0) == i)//if town first horde is this one
|
||||
if (vti->getTown()->hordeLvl.at(0) == i)//if town first horde is this one
|
||||
{
|
||||
vti->builtBuildings.insert(BuildingID::HORDE_1);//add it
|
||||
//if we have upgraded dwelling as well
|
||||
if (vstd::contains(vti->builtBuildings, (BuildingID::DWELL_UP_FIRST + i)))
|
||||
vti->builtBuildings.insert(BuildingID::HORDE_1_UPGR);//add it as well
|
||||
}
|
||||
if (vti->town->hordeLvl.at(1) == i)//if town second horde is this one
|
||||
if (vti->getTown()->hordeLvl.at(1) == i)//if town second horde is this one
|
||||
{
|
||||
vti->builtBuildings.insert(BuildingID::HORDE_2);
|
||||
if (vstd::contains(vti->builtBuildings, (BuildingID::DWELL_UP_FIRST + i)))
|
||||
@ -1798,7 +1798,7 @@ void CGameState::initTowns()
|
||||
//But DO NOT remove horde placeholders before they are replaced
|
||||
vstd::erase_if(vti->builtBuildings, [vti](const BuildingID & bid)
|
||||
{
|
||||
return !vti->town->buildings.count(bid) || !vti->town->buildings.at(bid);
|
||||
return !vti->getTown()->buildings.count(bid) || !vti->getTown()->buildings.at(bid);
|
||||
});
|
||||
|
||||
if (vstd::contains(vti->builtBuildings, BuildingID::SHIPYARD) && vti->shipyardStatus()==IBoatGenerator::TILE_BLOCKED)
|
||||
@ -1807,7 +1807,7 @@ void CGameState::initTowns()
|
||||
//Early check for #1444-like problems
|
||||
for(const auto & building : vti->builtBuildings)
|
||||
{
|
||||
assert(vti->town->buildings.at(building) != nullptr);
|
||||
assert(vti->getTown()->buildings.at(building) != nullptr);
|
||||
MAYBE_UNUSED(building);
|
||||
}
|
||||
|
||||
@ -1818,9 +1818,9 @@ void CGameState::initTowns()
|
||||
if (vstd::contains(ev.buildings,(-31-i))) //if we have horde for this level
|
||||
{
|
||||
ev.buildings.erase(BuildingID(-31-i));
|
||||
if (vti->town->hordeLvl.at(0) == i)
|
||||
if (vti->getTown()->hordeLvl.at(0) == i)
|
||||
ev.buildings.insert(BuildingID::HORDE_1);
|
||||
if (vti->town->hordeLvl.at(1) == i)
|
||||
if (vti->getTown()->hordeLvl.at(1) == i)
|
||||
ev.buildings.insert(BuildingID::HORDE_2);
|
||||
}
|
||||
}
|
||||
@ -1839,7 +1839,7 @@ void CGameState::initTowns()
|
||||
int sel = -1;
|
||||
|
||||
for(ui32 ps=0;ps<vti->possibleSpells.size();ps++)
|
||||
total += vti->possibleSpells[ps].toSpell()->getProbability(vti->subID);
|
||||
total += vti->possibleSpells[ps].toSpell()->getProbability(vti->getFaction());
|
||||
|
||||
if (total == 0) // remaining spells have 0 probability
|
||||
break;
|
||||
@ -1847,7 +1847,7 @@ void CGameState::initTowns()
|
||||
auto r = getRandomGenerator().nextInt(total - 1);
|
||||
for(ui32 ps=0; ps<vti->possibleSpells.size();ps++)
|
||||
{
|
||||
r -= vti->possibleSpells[ps].toSpell()->getProbability(vti->subID);
|
||||
r -= vti->possibleSpells[ps].toSpell()->getProbability(vti->getFaction());
|
||||
if(r<0)
|
||||
{
|
||||
sel = ps;
|
||||
@ -3133,7 +3133,7 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed)
|
||||
built = t->builded;
|
||||
fortLevel = t->fortLevel();
|
||||
name = t->getNameTranslated();
|
||||
tType = t->town;
|
||||
tType = t->getTown();
|
||||
|
||||
vstd::clear_pointer(details);
|
||||
|
||||
|
@ -289,7 +289,7 @@ CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const Js
|
||||
VLC->modh->identifiers.requestIdentifier(tavern.second.meta, "faction", tavern.first,
|
||||
[=](si32 factionID)
|
||||
{
|
||||
heroClass->selectionProbability[factionID] = value;
|
||||
heroClass->selectionProbability[FactionID(factionID)] = value;
|
||||
});
|
||||
}
|
||||
|
||||
@ -361,11 +361,11 @@ void CHeroClassHandler::afterLoadFinalization()
|
||||
{
|
||||
if (!faction->town)
|
||||
continue;
|
||||
if (heroClass->selectionProbability.count(faction->getIndex()))
|
||||
if (heroClass->selectionProbability.count(faction->getId()))
|
||||
continue;
|
||||
|
||||
auto chance = static_cast<float>(heroClass->defaultTavernChance * faction->town->defaultTavernChance);
|
||||
heroClass->selectionProbability[faction->getIndex()] = static_cast<int>(sqrt(chance) + 0.5); //FIXME: replace with std::round once MVS supports it
|
||||
heroClass->selectionProbability[faction->getId()] = static_cast<int>(sqrt(chance) + 0.5); //FIXME: replace with std::round once MVS supports it
|
||||
}
|
||||
// set default probabilities for gaining secondary skills where not loaded previously
|
||||
heroClass->secSkillProbability.resize(VLC->skillh->size(), -1);
|
||||
|
@ -131,7 +131,7 @@ public:
|
||||
};
|
||||
|
||||
//double aggression; // not used in vcmi.
|
||||
TFaction faction;
|
||||
FactionID faction;
|
||||
ui8 affinity; // affinity, using EClassAffinity enum
|
||||
|
||||
// default chance for hero of specific class to appear in tavern, if field "tavern" was not set
|
||||
@ -146,7 +146,7 @@ public:
|
||||
|
||||
std::vector<int> secSkillProbability; //probabilities of gaining secondary skills (out of 112), in id order
|
||||
|
||||
std::map<TFaction, int> selectionProbability; //probability of selection in towns
|
||||
std::map<FactionID, int> selectionProbability; //probability of selection in towns
|
||||
|
||||
std::string imageBattleMale;
|
||||
std::string imageBattleFemale;
|
||||
|
@ -567,13 +567,7 @@ void CTownHandler::loadSpecialBuildingBonuses(const JsonNode & source, BonusList
|
||||
if(bonus == nullptr)
|
||||
continue;
|
||||
|
||||
if(bonus->limiter != nullptr)
|
||||
{
|
||||
auto * limPtr = dynamic_cast<FactionLimiter *>(bonus->limiter.get());
|
||||
|
||||
if(limPtr != nullptr && limPtr->faction == FactionID::DEFAULT)
|
||||
limPtr->faction = building->town->faction->getId();
|
||||
}
|
||||
bonus->sid = Bonus::getSid32(building->town->faction->getIndex(), building->bid);
|
||||
//JsonUtils::parseBuildingBonus produces UNKNOWN type propagator instead of empty.
|
||||
if(bonus->propagator != nullptr
|
||||
&& bonus->propagator->getPropagatorType() == CBonusSystemNode::ENodeTypes::UNKNOWN)
|
||||
@ -952,7 +946,7 @@ void CTownHandler::loadTown(CTown * town, const JsonNode & source)
|
||||
|
||||
VLC->modh->identifiers.requestIdentifier(node.second.meta, "heroClass",node.first, [=](si32 classID)
|
||||
{
|
||||
VLC->heroh->classes[HeroClassID(classID)]->selectionProbability[town->faction->getIndex()] = chance;
|
||||
VLC->heroh->classes[HeroClassID(classID)]->selectionProbability[town->faction->getId()] = chance;
|
||||
});
|
||||
}
|
||||
|
||||
@ -962,7 +956,7 @@ void CTownHandler::loadTown(CTown * town, const JsonNode & source)
|
||||
|
||||
VLC->modh->identifiers.requestIdentifier(node.second.meta, "spell", node.first, [=](si32 spellID)
|
||||
{
|
||||
VLC->spellh->objects.at(spellID)->probabilities[town->faction->getIndex()] = chance;
|
||||
VLC->spellh->objects.at(spellID)->probabilities[town->faction->getId()] = chance;
|
||||
});
|
||||
}
|
||||
|
||||
@ -1008,7 +1002,7 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode
|
||||
|
||||
auto * faction = new CFaction();
|
||||
|
||||
faction->index = static_cast<TFaction>(index);
|
||||
faction->index = static_cast<FactionID>(index);
|
||||
faction->modScope = scope;
|
||||
faction->identifier = identifier;
|
||||
|
||||
@ -1211,9 +1205,9 @@ std::vector<bool> CTownHandler::getDefaultAllowed() const
|
||||
return allowedFactions;
|
||||
}
|
||||
|
||||
std::set<TFaction> CTownHandler::getAllowedFactions(bool withTown) const
|
||||
std::set<FactionID> CTownHandler::getAllowedFactions(bool withTown) const
|
||||
{
|
||||
std::set<TFaction> allowedFactions;
|
||||
std::set<FactionID> allowedFactions;
|
||||
std::vector<bool> allowed;
|
||||
if (withTown)
|
||||
allowed = getDefaultAllowed();
|
||||
@ -1222,7 +1216,7 @@ std::set<TFaction> CTownHandler::getAllowedFactions(bool withTown) const
|
||||
|
||||
for (size_t i=0; i<allowed.size(); i++)
|
||||
if (allowed[i])
|
||||
allowedFactions.insert(static_cast<TFaction>(i));
|
||||
allowedFactions.insert(static_cast<FactionID>(i));
|
||||
|
||||
return allowedFactions;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ class DLL_LINKAGE CFaction : public Faction
|
||||
std::string modScope;
|
||||
std::string identifier;
|
||||
|
||||
TFaction index = 0;
|
||||
FactionID index = FactionID::NEUTRAL;
|
||||
|
||||
FactionID getFaction() const override; //This function should not be used
|
||||
|
||||
@ -423,7 +423,7 @@ public:
|
||||
void afterLoadFinalization() override;
|
||||
|
||||
std::vector<bool> getDefaultAllowed() const override;
|
||||
std::set<TFaction> getAllowedFactions(bool withTown = true) const;
|
||||
std::set<FactionID> getAllowedFactions(bool withTown = true) const;
|
||||
|
||||
static void loadSpecialBuildingBonuses(const JsonNode & source, BonusList & bonusList, CBuilding * building);
|
||||
|
||||
|
@ -1314,7 +1314,6 @@ enum class EHealPower : ui8
|
||||
};
|
||||
|
||||
// Typedef declarations
|
||||
typedef ui8 TFaction;
|
||||
typedef si64 TExpType;
|
||||
typedef si32 TBonusSubtype;
|
||||
typedef si32 TQuantity;
|
||||
|
@ -85,9 +85,9 @@ bool CBattleInfoEssentials::battleHasNativeStack(ui8 side) const
|
||||
{
|
||||
RETURN_IF_NOT_BATTLE(false);
|
||||
|
||||
for(const CStack * s : battleGetAllStacks())
|
||||
for(const auto * s : battleGetAllStacks())
|
||||
{
|
||||
if(s->side == side && s->getCreature()->isItNativeTerrain(getBattle()->getTerrainType()))
|
||||
if(s->side == side && s->isItNativeTerrain(getBattle()->getTerrainType()))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
}
|
||||
|
||||
//number of alignments and presence of undead
|
||||
std::set<TFaction> factions;
|
||||
std::set<FactionID> factions;
|
||||
bool hasUndead = false;
|
||||
|
||||
const std::string undeadCacheKey = "type_UNDEAD";
|
||||
@ -76,7 +76,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
const CStackInstance * inst = slot.second;
|
||||
const CCreature * creature = VLC->creh->objects[inst->getCreatureID()];
|
||||
|
||||
factions.insert(creature->getFactionIndex());
|
||||
factions.insert(creature->getFaction());
|
||||
// Check for undead flag instead of faction (undead mummies are neutral)
|
||||
if (!hasUndead)
|
||||
{
|
||||
@ -91,7 +91,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
{
|
||||
size_t mixableFactions = 0;
|
||||
|
||||
for(TFaction f : factions)
|
||||
for(auto f : factions)
|
||||
{
|
||||
if (VLC->factions()->getByIndex(f)->getAlignment() != EAlignment::EVIL)
|
||||
mixableFactions++;
|
||||
@ -156,4 +156,9 @@ CBonusSystemNode & CArmedInstance::whatShouldBeAttached()
|
||||
return *this;
|
||||
}
|
||||
|
||||
const IBonusBearer* CArmedInstance::getBonusBearer() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -17,7 +17,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class BattleInfo;
|
||||
class CGameState;
|
||||
|
||||
class DLL_LINKAGE CArmedInstance: public CGObjectInstance, public CBonusSystemNode, public CCreatureSet
|
||||
class DLL_LINKAGE CArmedInstance: public CGObjectInstance, public CBonusSystemNode, public CCreatureSet, public IConstBonusProvider
|
||||
{
|
||||
private:
|
||||
CCheckProxy nonEvilAlignmentMix;
|
||||
@ -32,6 +32,8 @@ public:
|
||||
void armyChanged() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//IConstBonusProvider
|
||||
const IBonusBearer* getBonusBearer() const override;
|
||||
// int valOfGlobalBonuses(CSelector selector) const; //used only for castle interface ???
|
||||
virtual CBonusSystemNode & whereShouldBeAttached(CGameState * gs);
|
||||
virtual CBonusSystemNode & whatShouldBeAttached();
|
||||
|
@ -938,7 +938,7 @@ void CGTownInstance::newTurn(CRandomGenerator & rand) const
|
||||
std::vector<SlotID> nativeCrits; //slots
|
||||
for(const auto & elem : Slots())
|
||||
{
|
||||
if (elem.second->type->getFactionIndex() == subID) //native
|
||||
if (elem.second->type->getFaction() == subID) //native
|
||||
{
|
||||
nativeCrits.push_back(elem.first); //collect matching slots
|
||||
}
|
||||
@ -1612,6 +1612,16 @@ void CGTownInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
}
|
||||
}
|
||||
|
||||
FactionID CGTownInstance::getFaction() const
|
||||
{
|
||||
return town->faction->getId();
|
||||
}
|
||||
|
||||
TerrainId CGTownInstance::getNativeTerrain() const
|
||||
{
|
||||
return town->faction->getNativeTerrain();
|
||||
}
|
||||
|
||||
PlayerColor CGTownBuilding::getOwner() const
|
||||
{
|
||||
return town->getOwner();
|
||||
@ -1759,7 +1769,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
|
||||
break;
|
||||
|
||||
case BuildingSubID::CUSTOM_VISITING_BONUS:
|
||||
const auto building = town->town->buildings.at(bID);
|
||||
const auto building = town->getTown()->buildings.at(bID);
|
||||
if(!h->hasBonusFrom(Bonus::TOWN_STRUCTURE, Bonus::getSid32(building->town->faction->getIndex(), building->bid)))
|
||||
{
|
||||
const auto & bonuses = building->onVisitBonuses;
|
||||
@ -1843,7 +1853,7 @@ int GrowthInfo::totalGrowth() const
|
||||
|
||||
std::string CGTownBuilding::getVisitingBonusGreeting() const
|
||||
{
|
||||
auto bonusGreeting = town->town->getGreeting(bType);
|
||||
auto bonusGreeting = town->getTown()->getGreeting(bType);
|
||||
|
||||
if(!bonusGreeting.empty())
|
||||
return bonusGreeting;
|
||||
@ -1869,15 +1879,15 @@ std::string CGTownBuilding::getVisitingBonusGreeting() const
|
||||
bonusGreeting = std::string(VLC->generaltexth->translate("vcmi.townHall.greetingDefence"));
|
||||
break;
|
||||
}
|
||||
auto buildingName = town->town->getSpecialBuilding(bType)->getNameTranslated();
|
||||
auto buildingName = town->getTown()->getSpecialBuilding(bType)->getNameTranslated();
|
||||
|
||||
if(bonusGreeting.empty())
|
||||
{
|
||||
bonusGreeting = "Error: Bonus greeting for '%s' is not localized.";
|
||||
logGlobal->error("'%s' building of '%s' faction has not localized bonus greeting.", buildingName, town->town->faction->getNameTranslated());
|
||||
logGlobal->error("'%s' building of '%s' faction has not localized bonus greeting.", buildingName, town->getTown()->faction->getNameTranslated());
|
||||
}
|
||||
boost::algorithm::replace_first(bonusGreeting, "%s", buildingName);
|
||||
town->town->setGreeting(bType, bonusGreeting);
|
||||
town->getTown()->setGreeting(bType, bonusGreeting);
|
||||
return bonusGreeting;
|
||||
}
|
||||
|
||||
@ -1886,7 +1896,7 @@ std::string CGTownBuilding::getCustomBonusGreeting(const Bonus & bonus) const
|
||||
if(bonus.type == Bonus::TOWN_MAGIC_WELL)
|
||||
{
|
||||
auto bonusGreeting = std::string(VLC->generaltexth->translate("vcmi.townHall.greetingInTownMagicWell"));
|
||||
auto buildingName = town->town->getSpecialBuilding(bType)->getNameTranslated();
|
||||
auto buildingName = town->getTown()->getSpecialBuilding(bType)->getNameTranslated();
|
||||
boost::algorithm::replace_first(bonusGreeting, "%s", buildingName);
|
||||
return bonusGreeting;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ struct DLL_LINKAGE GrowthInfo
|
||||
int totalGrowth() const;
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public IMarket
|
||||
class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public IMarket, public INativeTerrainProvider
|
||||
{
|
||||
std::string name; // name of town
|
||||
public:
|
||||
@ -341,7 +341,11 @@ public:
|
||||
/// Returns damage range for central tower(keep) of this town
|
||||
DamageRange getKeepDamageRange() const;
|
||||
|
||||
const CTown * getTown() const ;
|
||||
const CTown * getTown() const;
|
||||
|
||||
/// INativeTerrainProvider
|
||||
FactionID getFaction() const override;
|
||||
TerrainId getNativeTerrain() const override;
|
||||
|
||||
CGTownInstance();
|
||||
virtual ~CGTownInstance();
|
||||
|
@ -67,7 +67,7 @@ struct DLL_LINKAGE PlayerInfo
|
||||
bool canComputerPlay;
|
||||
EAiTactic::EAiTactic aiTactic; /// The default value is EAiTactic::RANDOM.
|
||||
|
||||
std::set<TFaction> allowedFactions;
|
||||
std::set<FactionID> allowedFactions;
|
||||
bool isFactionRandom;
|
||||
|
||||
///main hero instance (VCMI maps only)
|
||||
|
@ -251,10 +251,10 @@ void CMapLoaderH3M::readPlayerInfo()
|
||||
{
|
||||
mapHeader->players[i].allowedFactions.clear();
|
||||
|
||||
for(int fact = 0; fact < totalFactions; ++fact)
|
||||
for(auto fact = 0; fact < totalFactions; ++fact)
|
||||
{
|
||||
if(allowedFactions & (1 << fact))
|
||||
mapHeader->players[i].allowedFactions.insert(fact);
|
||||
mapHeader->players[i].allowedFactions.insert(FactionID(fact));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ RoadType * CMapFormatJson::getRoadByCode(const std::string & code)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CMapFormatJson::serializeAllowedFactions(JsonSerializeFormat & handler, std::set<TFaction> & value) const
|
||||
void CMapFormatJson::serializeAllowedFactions(JsonSerializeFormat & handler, std::set<FactionID> & value) const
|
||||
{
|
||||
//TODO: unify allowed factions with others - make them std::vector<bool>
|
||||
|
||||
@ -404,7 +404,7 @@ void CMapFormatJson::serializeAllowedFactions(JsonSerializeFormat & handler, std
|
||||
value.clear();
|
||||
for (std::size_t i=0; i<temp.size(); i++)
|
||||
if(temp[i])
|
||||
value.insert(static_cast<TFaction>(i));
|
||||
value.insert(static_cast<FactionID>(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ protected:
|
||||
static RiverType * getRiverByCode(const std::string & code);
|
||||
static RoadType * getRoadByCode(const std::string & code);
|
||||
|
||||
void serializeAllowedFactions(JsonSerializeFormat & handler, std::set<TFaction> & value) const;
|
||||
void serializeAllowedFactions(JsonSerializeFormat & handler, std::set<FactionID> & value) const;
|
||||
|
||||
///common part of header saving/loading
|
||||
void serializeHeader(JsonSerializeFormat & handler);
|
||||
|
@ -135,14 +135,14 @@ void CMapGenOptions::setMonsterStrength(EMonsterStrength::EMonsterStrength value
|
||||
void CMapGenOptions::resetPlayersMap()
|
||||
{
|
||||
|
||||
std::map<PlayerColor, TFaction> rememberTownTypes;
|
||||
std::map<PlayerColor, FactionID> rememberTownTypes;
|
||||
std::map<PlayerColor, TeamID> rememberTeam;
|
||||
|
||||
for(const auto & p : players)
|
||||
{
|
||||
auto town = p.second.getStartingTown();
|
||||
if (town != RANDOM_SIZE)
|
||||
rememberTownTypes[p.first] = town;
|
||||
rememberTownTypes[p.first] = FactionID(town);
|
||||
rememberTeam[p.first] = p.second.getTeam();
|
||||
}
|
||||
|
||||
|
@ -199,33 +199,33 @@ void ZoneOptions::setTerrainTypes(const std::set<TerrainId> & value)
|
||||
terrainTypes = value;
|
||||
}
|
||||
|
||||
std::set<TFaction> ZoneOptions::getDefaultTownTypes() const
|
||||
std::set<FactionID> ZoneOptions::getDefaultTownTypes() const
|
||||
{
|
||||
std::set<TFaction> defaultTowns;
|
||||
std::set<FactionID> defaultTowns;
|
||||
auto towns = VLC->townh->getDefaultAllowed();
|
||||
for(int i = 0; i < towns.size(); ++i)
|
||||
{
|
||||
if(towns[i]) defaultTowns.insert(i);
|
||||
if(towns[i]) defaultTowns.insert(FactionID(i));
|
||||
}
|
||||
return defaultTowns;
|
||||
}
|
||||
|
||||
const std::set<TFaction> & ZoneOptions::getTownTypes() const
|
||||
const std::set<FactionID> & ZoneOptions::getTownTypes() const
|
||||
{
|
||||
return townTypes;
|
||||
}
|
||||
|
||||
void ZoneOptions::setTownTypes(const std::set<TFaction> & value)
|
||||
void ZoneOptions::setTownTypes(const std::set<FactionID> & value)
|
||||
{
|
||||
townTypes = value;
|
||||
}
|
||||
|
||||
void ZoneOptions::setMonsterTypes(const std::set<TFaction> & value)
|
||||
void ZoneOptions::setMonsterTypes(const std::set<FactionID> & value)
|
||||
{
|
||||
monsterTypes = value;
|
||||
}
|
||||
|
||||
const std::set<TFaction> & ZoneOptions::getMonsterTypes() const
|
||||
const std::set<FactionID> & ZoneOptions::getMonsterTypes() const
|
||||
{
|
||||
return monsterTypes;
|
||||
}
|
||||
@ -373,8 +373,8 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
||||
}
|
||||
|
||||
handler.serializeBool("townsAreSameType", townsAreSameType, false);
|
||||
handler.serializeIdArray<TFaction, FactionID>("allowedMonsters", monsterTypes, VLC->townh->getAllowedFactions(false));
|
||||
handler.serializeIdArray<TFaction, FactionID>("allowedTowns", townTypes, VLC->townh->getAllowedFactions(true));
|
||||
handler.serializeIdArray<FactionID, FactionID>("allowedMonsters", monsterTypes, VLC->townh->getAllowedFactions(false));
|
||||
handler.serializeIdArray<FactionID, FactionID>("allowedTowns", townTypes, VLC->townh->getAllowedFactions(true));
|
||||
|
||||
{
|
||||
//TODO: add support for std::map to serializeEnum
|
||||
|
@ -131,12 +131,12 @@ public:
|
||||
|
||||
const CTownInfo & getPlayerTowns() const;
|
||||
const CTownInfo & getNeutralTowns() const;
|
||||
std::set<TFaction> getDefaultTownTypes() const;
|
||||
const std::set<TFaction> & getTownTypes() const;
|
||||
const std::set<TFaction> & getMonsterTypes() const;
|
||||
std::set<FactionID> getDefaultTownTypes() const;
|
||||
const std::set<FactionID> & getTownTypes() const;
|
||||
const std::set<FactionID> & getMonsterTypes() const;
|
||||
|
||||
void setTownTypes(const std::set<TFaction> & value);
|
||||
void setMonsterTypes(const std::set<TFaction> & value);
|
||||
void setTownTypes(const std::set<FactionID> & value);
|
||||
void setMonsterTypes(const std::set<FactionID> & value);
|
||||
|
||||
void setMinesInfo(const std::map<TResource, ui16> & value);
|
||||
std::map<TResource, ui16> getMinesInfo() const;
|
||||
@ -173,8 +173,8 @@ protected:
|
||||
std::set<TerrainId> terrainTypes;
|
||||
bool townsAreSameType;
|
||||
|
||||
std::set<TFaction> townTypes;
|
||||
std::set<TFaction> monsterTypes;
|
||||
std::set<FactionID> townTypes;
|
||||
std::set<FactionID> monsterTypes;
|
||||
|
||||
std::map<TResource, ui16> mines; //obligatory mines to spawn in this zone
|
||||
|
||||
|
@ -426,7 +426,7 @@ CGCreature * ObjectManager::chooseGuard(si32 strength, bool zoneGuard)
|
||||
continue;
|
||||
if(!cre->getAIValue()) //bug #2681
|
||||
continue;
|
||||
if(!vstd::contains(zone.getMonsterTypes(), cre->getFactionIndex()))
|
||||
if(!vstd::contains(zone.getMonsterTypes(), cre->getFaction()))
|
||||
continue;
|
||||
if((static_cast<si32>(cre->getAIValue() * (cre->ammMin + cre->ammMax) / 2) < strength) && (strength < static_cast<si32>(cre->getAIValue()) * 100)) //at least one full monster. size between average size of given stack and 100
|
||||
{
|
||||
|
@ -274,13 +274,13 @@ float RmgMap::getNearestObjectDistance(const int3 &tile) const
|
||||
return tiles[tile.x][tile.y][tile.z].getNearestObjectDistance();
|
||||
}
|
||||
|
||||
void RmgMap::registerZone(TFaction faction)
|
||||
void RmgMap::registerZone(FactionID faction)
|
||||
{
|
||||
zonesPerFaction[faction]++;
|
||||
zonesTotal++;
|
||||
}
|
||||
|
||||
ui32 RmgMap::getZoneCount(TFaction faction)
|
||||
ui32 RmgMap::getZoneCount(FactionID faction)
|
||||
{
|
||||
return zonesPerFaction[faction];
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ public:
|
||||
|
||||
Zones & getZones();
|
||||
|
||||
void registerZone(TFaction faction);
|
||||
ui32 getZoneCount(TFaction faction);
|
||||
void registerZone(FactionID faction);
|
||||
ui32 getZoneCount(FactionID faction);
|
||||
ui32 getTotalZoneCount() const;
|
||||
void initTiles(CMapGenerator & generator);
|
||||
void addModificators();
|
||||
@ -75,7 +75,7 @@ private:
|
||||
|
||||
private:
|
||||
Zones zones;
|
||||
std::map<TFaction, ui32> zonesPerFaction;
|
||||
std::map<FactionID, ui32> zonesPerFaction;
|
||||
ui32 zonesTotal; //zones that have their main town only
|
||||
const CMapGenOptions& mapGenOptions;
|
||||
boost::multi_array<TileInfo, 3> tiles; //[x][y][z]
|
||||
|
@ -85,7 +85,7 @@ void TownPlacer::placeTowns(ObjectManager & manager)
|
||||
|
||||
totalTowns++;
|
||||
//register MAIN town of zone only
|
||||
map.registerZone(town->subID);
|
||||
map.registerZone(town->getFaction());
|
||||
|
||||
if(playerInfo.canAnyonePlay()) //configure info for owning player
|
||||
{
|
||||
@ -201,7 +201,7 @@ void TownPlacer::addNewTowns(int count, bool hasFort, const PlayerColor & player
|
||||
{
|
||||
//FIXME: discovered bug with small zones - getPos is close to map boarder and we have outOfMap exception
|
||||
//register MAIN town of zone
|
||||
map.registerZone(town->subID);
|
||||
map.registerZone(town->getFaction());
|
||||
//first town in zone goes in the middle
|
||||
placeMainTown(manager, *town);
|
||||
}
|
||||
@ -216,8 +216,8 @@ si32 TownPlacer::getRandomTownType(bool matchUndergroundType)
|
||||
auto townTypesAllowed = (!zone.getTownTypes().empty() ? zone.getTownTypes() : zone.getDefaultTownTypes());
|
||||
if(matchUndergroundType)
|
||||
{
|
||||
std::set<TFaction> townTypesVerify;
|
||||
for(TFaction factionIdx : townTypesAllowed)
|
||||
std::set<FactionID> townTypesVerify;
|
||||
for(auto factionIdx : townTypesAllowed)
|
||||
{
|
||||
bool preferUnderground = (*VLC->townh)[factionIdx]->preferUndergroundPlacement;
|
||||
if(zone.isUnderground() ? preferUnderground : !preferUnderground)
|
||||
|
@ -135,7 +135,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
||||
std::vector<CCreature *> creatures; //native creatures for this zone
|
||||
for(auto cre : VLC->creh->objects)
|
||||
{
|
||||
if(!cre->special && cre->getFactionIndex() == zone.getTownType())
|
||||
if(!cre->special && cre->getFaction() == zone.getTownType())
|
||||
{
|
||||
creatures.push_back(cre);
|
||||
}
|
||||
@ -164,9 +164,9 @@ void TreasurePlacer::addAllPossibleObjects()
|
||||
continue;
|
||||
|
||||
const auto * cre = creatures.front();
|
||||
if(cre->getFactionIndex() == zone.getTownType())
|
||||
if(cre->getFaction() == zone.getTownType())
|
||||
{
|
||||
auto nativeZonesCount = static_cast<float>(map.getZoneCount(cre->getFactionIndex()));
|
||||
auto nativeZonesCount = static_cast<float>(map.getZoneCount(cre->getFaction()));
|
||||
oi.value = static_cast<ui32>(cre->getAIValue() * cre->getGrowth() * (1 + (nativeZonesCount / map.getTotalZoneCount()) + (nativeZonesCount / 2)));
|
||||
oi.probability = 40;
|
||||
|
||||
@ -294,7 +294,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
||||
return obj;
|
||||
};
|
||||
oi.setTemplate(Obj::PANDORAS_BOX, 0, zone.getTerrainType());
|
||||
oi.value = static_cast<ui32>((2 * (creature->getAIValue()) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->getFactionIndex())) / map.getTotalZoneCount())) / 3);
|
||||
oi.value = static_cast<ui32>((2 * (creature->getAIValue()) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->getFaction())) / map.getTotalZoneCount())) / 3);
|
||||
oi.probability = 3;
|
||||
addObjectToRandomPool(oi);
|
||||
}
|
||||
@ -453,7 +453,7 @@ void TreasurePlacer::addAllPossibleObjects()
|
||||
return obj;
|
||||
};
|
||||
oi.setTemplate(Obj::SEER_HUT, randomAppearance, zone.getTerrainType());
|
||||
oi.value = static_cast<ui32>(((2 * (creature->getAIValue()) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->getFactionIndex())) / map.getTotalZoneCount())) - 4000) / 3);
|
||||
oi.value = static_cast<ui32>(((2 * (creature->getAIValue()) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->getFaction())) / map.getTotalZoneCount())) - 4000) / 3);
|
||||
oi.probability = 3;
|
||||
addObjectToRandomPool(oi);
|
||||
}
|
||||
|
@ -123,9 +123,9 @@ rmg::Area & Zone::freePaths()
|
||||
return dAreaFree;
|
||||
}
|
||||
|
||||
si32 Zone::getTownType() const
|
||||
FactionID Zone::getTownType() const
|
||||
{
|
||||
return townType;
|
||||
return FactionID(townType);
|
||||
}
|
||||
|
||||
void Zone::setTownType(si32 town)
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
void clearTiles();
|
||||
void fractalize();
|
||||
|
||||
si32 getTownType() const;
|
||||
FactionID getTownType() const;
|
||||
void setTownType(si32 town);
|
||||
TerrainId getTerrainType() const;
|
||||
void setTerrainType(TerrainId terrain);
|
||||
|
@ -340,7 +340,7 @@ int32_t CSpell::getLevelPower(const int32_t skillLevel) const
|
||||
return getLevelInfo(skillLevel).power;
|
||||
}
|
||||
|
||||
si32 CSpell::getProbability(const TFaction factionId) const
|
||||
si32 CSpell::getProbability(const FactionID & factionId) const
|
||||
{
|
||||
if(!vstd::contains(probabilities,factionId))
|
||||
{
|
||||
@ -722,7 +722,7 @@ CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode &
|
||||
|
||||
VLC->modh->identifiers.requestIdentifier(node.second.meta, "faction", node.first, [=](si32 factionID)
|
||||
{
|
||||
spell->probabilities[factionID] = chance;
|
||||
spell->probabilities[FactionID(factionID)] = chance;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ public:
|
||||
|
||||
si32 power; //spell's power
|
||||
|
||||
std::map<TFaction, si32> probabilities; //% chance to gain for castles
|
||||
std::map<FactionID, si32> probabilities; //% chance to gain for castles
|
||||
|
||||
bool combat; //is this spell combat (true) or adventure (false)
|
||||
bool creatureAbility; //if true, only creatures can use this spell
|
||||
@ -223,7 +223,7 @@ public:
|
||||
|
||||
int32_t getCost(const int32_t skillLevel) const override;
|
||||
|
||||
si32 getProbability(const TFaction factionId) const;
|
||||
si32 getProbability(const FactionID & factionId) const;
|
||||
|
||||
int32_t getBasePower() const override;
|
||||
int32_t getLevelPower(const int32_t skillLevel) const override;
|
||||
|
@ -87,7 +87,7 @@ void Moat::convertBonus(const Mechanics * m, std::vector<Bonus> & converted) con
|
||||
|
||||
if(m->battle()->battleGetDefendedTown() && m->battle()->battleGetSiegeLevel() >= CGTownInstance::CITADEL)
|
||||
{
|
||||
nb.sid = Bonus::getSid32(m->battle()->battleGetDefendedTown()->town->faction->getIndex(), BuildingID::CITADEL);
|
||||
nb.sid = Bonus::getSid32(m->battle()->battleGetDefendedTown()->getFaction(), BuildingID::CITADEL);
|
||||
nb.source = Bonus::TOWN_STRUCTURE;
|
||||
}
|
||||
else
|
||||
|
@ -29,7 +29,7 @@ PlayerParams::PlayerParams(MapController & ctrl, int playerId, QWidget *parent)
|
||||
{
|
||||
CFaction * faction = VLC->townh->objects.at(idx);
|
||||
auto * item = new QListWidgetItem(QString::fromStdString(faction->getNameTranslated()));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(idx));
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(idx.getNum()));
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
ui->allowedFactions->addItem(item);
|
||||
if(playerInfo.allowedFactions.count(idx))
|
||||
@ -124,9 +124,9 @@ void PlayerParams::on_randomFaction_stateChanged(int arg1)
|
||||
void PlayerParams::allowedFactionsCheck(QListWidgetItem * item)
|
||||
{
|
||||
if(item->checkState() == Qt::Checked)
|
||||
playerInfo.allowedFactions.insert(item->data(Qt::UserRole).toInt());
|
||||
playerInfo.allowedFactions.insert(FactionID(item->data(Qt::UserRole).toInt()));
|
||||
else
|
||||
playerInfo.allowedFactions.erase(item->data(Qt::UserRole).toInt());
|
||||
playerInfo.allowedFactions.erase(FactionID(item->data(Qt::UserRole).toInt()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ const std::vector<CreatureProxy::CustomRegType> CreatureProxy::REGISTER_CUSTOM =
|
||||
{"getLevel", LuaMethodWrapper<Creature, decltype(&Creature::getLevel), &Creature::getLevel>::invoke, false},
|
||||
{"getGrowth", LuaMethodWrapper<Creature, decltype(&Creature::getGrowth), &Creature::getGrowth>::invoke, false},
|
||||
{"getHorde", LuaMethodWrapper<Creature, decltype(&Creature::getHorde), &Creature::getHorde>::invoke, false},
|
||||
{"getFactionIndex", LuaMethodWrapper<Creature, decltype(&Creature::getFactionIndex), &Creature::getFactionIndex>::invoke, false},
|
||||
{"getFaction", LuaMethodWrapper<Creature, decltype(&Creature::getFaction), &Creature::getFaction>::invoke, false},
|
||||
|
||||
{"getBaseAttack", LuaMethodWrapper<Creature, decltype(&Creature::getBaseAttack), &Creature::getBaseAttack>::invoke, false},
|
||||
{"getBaseDefense", LuaMethodWrapper<Creature, decltype(&Creature::getBaseDefense), &Creature::getBaseDefense>::invoke, false},
|
||||
|
@ -80,7 +80,7 @@ MA.I = createModifier({}, "aiValue" ,"getAIValue")
|
||||
MA.L = createModifier({}, "level" , "getLevel")
|
||||
MA.M = createModifier({"damage"}, "min", "getBaseDamageMin")
|
||||
MA.N = createModifier({}, "shots" , "getBaseShots")
|
||||
MA.O = createModifier({}, "faction" ,"getFactionIndex")
|
||||
MA.O = createModifier({}, "faction" ,"getFaction")
|
||||
MA.P = createModifier({}, "hitPoints" ,"getBaseHitPoints")
|
||||
MA.R = createModifier({}, "horde" , "getHorde")
|
||||
MA.S = createModifier({}, "speed" , "getBaseSpeed")
|
||||
|
@ -1732,7 +1732,7 @@ void CGameHandler::newTurn()
|
||||
{
|
||||
newMonster.second = VLC->creh->pickRandomMonster(getRandomGenerator());
|
||||
} while (VLC->creh->objects[newMonster.second] &&
|
||||
(*VLC->townh)[VLC->creatures()->getById(newMonster.second)->getFactionIndex()]->town == nullptr); // find first non neutral creature
|
||||
(*VLC->townh)[VLC->creatures()->getById(newMonster.second)->getFaction()]->town == nullptr); // find first non neutral creature
|
||||
n.creatureid = newMonster.second;
|
||||
}
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ void CVCMIServer::optionNextCastle(PlayerColor player, int dir)
|
||||
else
|
||||
{
|
||||
assert(dir >= -1 && dir <= 1); //othervice std::advance may go out of range
|
||||
auto iter = allowed.find((ui8)cur);
|
||||
auto iter = allowed.find(FactionID(cur));
|
||||
std::advance(iter, dir);
|
||||
cur = *iter;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ TEST_F(CCreatureTest, JsonUpdate)
|
||||
|
||||
EXPECT_EQ(subject->getFightValue(), 2420);
|
||||
EXPECT_EQ(subject->getLevel(), 6);
|
||||
EXPECT_EQ(subject->getFactionIndex(), 55);
|
||||
EXPECT_EQ(subject->getFaction(), 55);
|
||||
EXPECT_TRUE(subject->isDoubleWide());
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ TEST_F(ERM_MA, Example)
|
||||
EXPECT_CALL(oldCreature, getAIValue()).WillOnce(Return(AI_VALUE));
|
||||
EXPECT_CALL(oldCreature, getFightValue()).WillOnce(Return(FIGHT_VALUE));
|
||||
EXPECT_CALL(oldCreature, getLevel()).WillOnce(Return(LEVEL));
|
||||
EXPECT_CALL(oldCreature, getFactionIndex()).WillOnce(Return(FACTION));
|
||||
EXPECT_CALL(oldCreature, getFaction()).WillOnce(Return(FACTION));
|
||||
|
||||
EXPECT_CALL(oldCreature, isDoubleWide()).WillRepeatedly(Return(false));
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <vcmi/Creature.h>
|
||||
|
||||
class IBonusBearer;
|
||||
class FactionID;
|
||||
|
||||
class CreatureMock : public Creature
|
||||
{
|
||||
@ -36,7 +37,7 @@ public:
|
||||
MOCK_CONST_METHOD0(getLevel, int32_t());
|
||||
MOCK_CONST_METHOD0(getGrowth, int32_t());
|
||||
MOCK_CONST_METHOD0(getHorde, int32_t());
|
||||
MOCK_CONST_METHOD0(getFactionIndex, int32_t());
|
||||
MOCK_CONST_METHOD0(getFaction, FactionID());
|
||||
|
||||
MOCK_CONST_METHOD0(getBaseAttack, int32_t());
|
||||
MOCK_CONST_METHOD0(getBaseDefense, int32_t());
|
||||
|
Loading…
x
Reference in New Issue
Block a user