code review

This commit is contained in:
Laserlicht
2024-07-29 22:54:42 +02:00
parent 6adc49b814
commit 3e5df61946
13 changed files with 49 additions and 45 deletions
+6 -7
View File
@@ -140,10 +140,10 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
if(tempOwner.isValidPlayer())
{
auto * playerSettings = cb->getPlayerSettings(tempOwner);
ret.percent = playerSettings->handicap.percentGrowth;
ret.handicapPercentage = playerSettings->handicap.percentGrowth;
}
else
ret.percent = 100;
ret.handicapPercentage = 100;
ret.entries.emplace_back(VLC->generaltexth->allTexts[590], base); // \n\nBasic growth %d"
@@ -226,7 +226,8 @@ TResources CGTownInstance::dailyIncome() const
auto playerSettings = cb->gameState()->scenarioOps->getIthPlayersSettings(getOwner());
for(TResources::nziterator it(ret); it.valid(); it++)
ret[it->resType] = ret[it->resType] * playerSettings.handicap.percentIncome / 100;
// always round up income - we don't want to always produce zero if handicap in use
ret[it->resType] = (ret[it->resType] * playerSettings.handicap.percentIncome + 99) / 100;
return ret;
}
@@ -1269,10 +1270,8 @@ int GrowthInfo::totalGrowth() const
for(const Entry &entry : entries)
ret += entry.count;
auto retCalc = ret * percent / 100;
if(retCalc == 0 && ret > 0) //generate at least one
retCalc = 1;
return retCalc;
// always round up income - we don't want buildings to always produce zero if handicap in use
return (ret * handicapPercentage + 99) / 100;
}
void CGTownInstance::fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &stack) const
+1 -1
View File
@@ -41,7 +41,7 @@ struct DLL_LINKAGE GrowthInfo
std::vector<Entry> entries;
int totalGrowth() const;
int percent;
int handicapPercentage;
};
class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public IMarket, public INativeTerrainProvider, public ICreatureUpgrader
+2 -4
View File
@@ -199,10 +199,8 @@ ui32 CGMine::defaultResProduction() const
ui32 CGMine::getProducedQuantity() const
{
auto * playerSettings = cb->getPlayerSettings(getOwner());
auto ret = producedQuantity * playerSettings->handicap.percentIncome / 100;
if(ret == 0 && producedQuantity > 0) // create at least 1 resource
ret = 1;
return ret;
// always round up income - we don't want mines to always produce zero if handicap in use
return (producedQuantity * playerSettings->handicap.percentIncome + 99) / 100;
}
void CGMine::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const