1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

vcmi: massive refactoring v1

This commit is contained in:
Konstantin
2023-04-05 03:26:29 +03:00
parent ee489f18d2
commit 11b237a23c
129 changed files with 803 additions and 762 deletions

View File

@ -325,7 +325,7 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
if (VLC->settings()->getBoolean(EGameSettings::MODULE_COMMANDERS) && !commander)
{
commander = new CCommanderInstance(type->heroClass->commander->idNumber);
commander = new CCommanderInstance(type->heroClass->commander->getId());
commander->setArmyObj (castToArmyObj()); //TODO: separate function for setting commanders
commander->giveStackExp (exp); //after our exp is set
}
@ -790,7 +790,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
};
int maxCasualtyLevel = 1;
for(const auto & casualty : casualties)
vstd::amax(maxCasualtyLevel, VLC->creh->objects[casualty.first]->level);
vstd::amax(maxCasualtyLevel, VLC->creatures()->getByIndex(casualty.first)->getLevel());
// pick best bonus available
std::shared_ptr<Bonus> topPick;
for(const std::shared_ptr<Bonus> & newPick : *improvedNecromancy)
@ -806,8 +806,8 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
{
auto quality = [getCreatureID](const std::shared_ptr<Bonus> & pick) -> std::tuple<int, int, int>
{
const CCreature * c = VLC->creh->objects[getCreatureID(pick)];
return std::tuple<int, int, int> {c->level, static_cast<int>(c->cost.marketValue()), -pick->additionalInfo[1]};
const auto * c = getCreatureID(pick).toCreature();
return std::tuple<int, int, int> {c->getLevel(), static_cast<int>(c->getFullRecruitCost().marketValue()), -pick->additionalInfo[1]};
};
if(quality(topPick) < quality(newPick))
topPick = newPick;
@ -840,7 +840,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
{
const CCreature * c = VLC->creh->objects[casualty.first];
double raisedFromCasualty = std::min(c->MaxHealth() / raisedUnitHealth, 1.0) * casualty.second * necromancySkill;
if(c->level < requiredCasualtyLevel)
if(c->getLevel() < requiredCasualtyLevel)
raisedFromCasualty *= 0.5;
raisedUnits += raisedFromCasualty;
}