mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Code cleanup
This commit is contained in:
parent
e50f586d8b
commit
d04241b10a
@ -236,7 +236,7 @@ int getDwellingArmyCost(const CGObjectInstance * target)
|
||||
return cost;
|
||||
}
|
||||
|
||||
uint64_t evaluateArtifactArmyValue(CArtifactInstance * art)
|
||||
static uint64_t evaluateArtifactArmyValue(const CArtifactInstance * art)
|
||||
{
|
||||
if(art->artType->getId() == ArtifactID::SPELL_SCROLL)
|
||||
return 1500;
|
||||
|
@ -373,7 +373,7 @@ HeroExchangeArmy * HeroExchangeMap::tryUpgrade(
|
||||
|
||||
for(auto & creatureToBuy : buyArmy)
|
||||
{
|
||||
auto targetSlot = target->getSlotFor(dynamic_cast<const CCreature*>(creatureToBuy.creID.toCreature()));
|
||||
auto targetSlot = target->getSlotFor(creatureToBuy.creID.toCreature());
|
||||
|
||||
target->addToSlot(targetSlot, creatureToBuy.creID, creatureToBuy.count);
|
||||
target->armyCost += creatureToBuy.creID.toCreature()->getFullRecruitCost() * creatureToBuy.count;
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
|
||||
const CGameInfo * CGI;
|
||||
CGameInfo * CGI;
|
||||
CClientState * CCS = nullptr;
|
||||
CServerHandler * CSH;
|
||||
|
||||
|
@ -99,4 +99,4 @@ public:
|
||||
private:
|
||||
const Services * globalServices;
|
||||
};
|
||||
extern const CGameInfo* CGI;
|
||||
extern CGameInfo* CGI;
|
||||
|
@ -72,7 +72,7 @@ void init()
|
||||
CStopWatch tmh;
|
||||
|
||||
loadDLLClasses();
|
||||
const_cast<CGameInfo*>(CGI)->setFromLib();
|
||||
CGI->setFromLib();
|
||||
|
||||
logGlobal->info("Initializing VCMI_Lib: %d ms", tmh.getDiff());
|
||||
|
||||
|
@ -367,7 +367,7 @@ void CClient::endGame()
|
||||
logNetwork->info("Ending current game!");
|
||||
removeGUI();
|
||||
|
||||
const_cast<CGameInfo *>(CGI)->mh.reset();
|
||||
CGI->mh.reset();
|
||||
vstd::clear_pointer(gs);
|
||||
|
||||
logNetwork->info("Deleted mapHandler and gameState.");
|
||||
@ -389,7 +389,7 @@ void CClient::initMapHandler()
|
||||
// During loading CPlayerInterface from serialized state it's depend on MH
|
||||
if(!settings["session"]["headless"].Bool())
|
||||
{
|
||||
const_cast<CGameInfo *>(CGI)->mh = std::make_shared<CMapHandler>(gs->map);
|
||||
CGI->mh = std::make_shared<CMapHandler>(gs->map);
|
||||
logNetwork->trace("Creating mapHandler: %d ms", CSH->th->getDiff());
|
||||
}
|
||||
|
||||
|
@ -155,9 +155,9 @@ bool CHeroClass::isMagicHero() const
|
||||
return affinity == MAGIC;
|
||||
}
|
||||
|
||||
int CHeroClass::tavernProbability(FactionID faction) const
|
||||
int CHeroClass::tavernProbability(FactionID targetFaction) const
|
||||
{
|
||||
auto it = selectionProbability.find(faction);
|
||||
auto it = selectionProbability.find(targetFaction);
|
||||
if (it != selectionProbability.end())
|
||||
return it->second;
|
||||
return 0;
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
si32 JsonRandom::loadVariable(std::string variableGroup, const std::string & value, const Variables & variables, si32 defaultValue)
|
||||
si32 JsonRandom::loadVariable(const std::string & variableGroup, const std::string & value, const Variables & variables, si32 defaultValue)
|
||||
{
|
||||
if (value.empty() || value[0] != '@')
|
||||
{
|
||||
@ -54,7 +54,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
if(value.isNull())
|
||||
return defaultValue;
|
||||
if(value.isNumber())
|
||||
return static_cast<si32>(value.Float());
|
||||
return value.Integer();
|
||||
if (value.isString())
|
||||
return loadVariable("number", value.String(), variables, defaultValue);
|
||||
|
||||
@ -68,9 +68,9 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
if(value.isStruct())
|
||||
{
|
||||
if (!value["amount"].isNull())
|
||||
return static_cast<si32>(loadValue(value["amount"], rng, variables, defaultValue));
|
||||
si32 min = static_cast<si32>(loadValue(value["min"], rng, variables, 0));
|
||||
si32 max = static_cast<si32>(loadValue(value["max"], rng, variables, 0));
|
||||
return loadValue(value["amount"], rng, variables, defaultValue);
|
||||
si32 min = loadValue(value["min"], rng, variables, 0);
|
||||
si32 max = loadValue(value["max"], rng, variables, 0);
|
||||
return rng.getIntRange(min, max)();
|
||||
}
|
||||
return defaultValue;
|
||||
|
@ -41,7 +41,7 @@ private:
|
||||
template<typename IdentifierType>
|
||||
IdentifierType decodeKey(const JsonNode & value, const Variables & variables);
|
||||
|
||||
si32 loadVariable(std::string variableGroup, const std::string & value, const Variables & variables, si32 defaultValue);
|
||||
si32 loadVariable(const std::string & variableGroup, const std::string & value, const Variables & variables, si32 defaultValue);
|
||||
|
||||
public:
|
||||
using GameCallbackHolder::GameCallbackHolder;
|
||||
|
@ -486,7 +486,7 @@ void CBonusSystemNode::getRedParents(TCNodes & out) const
|
||||
|
||||
if(!actsAsBonusSourceOnly())
|
||||
{
|
||||
for(CBonusSystemNode *child : children)
|
||||
for(const CBonusSystemNode *child : children)
|
||||
{
|
||||
out.insert(child);
|
||||
}
|
||||
|
@ -171,10 +171,10 @@ CGameState::~CGameState()
|
||||
initialOpts.dellNull();
|
||||
}
|
||||
|
||||
void CGameState::preInit(Services * services, IGameCallback * callback)
|
||||
void CGameState::preInit(Services * newServices, IGameCallback * newCallback)
|
||||
{
|
||||
this->services = services;
|
||||
this->callback = callback;
|
||||
services = newServices;
|
||||
callback = newCallback;
|
||||
}
|
||||
|
||||
void CGameState::init(const IMapService * mapService, StartInfo * si, Load::ProgressAccumulator & progressTracking, bool allowSavingRandomMap)
|
||||
@ -631,7 +631,7 @@ void CGameState::initHeroes()
|
||||
if (tile.terType->isWater())
|
||||
{
|
||||
auto handler = VLC->objtypeh->getHandlerFor(Obj::BOAT, hero->getBoatType().getNum());
|
||||
CGBoat * boat = dynamic_cast<CGBoat*>(handler->create(callback, nullptr));
|
||||
auto boat = dynamic_cast<CGBoat*>(handler->create(callback, nullptr));
|
||||
handler->configureObject(boat, gs->getRandomGenerator());
|
||||
|
||||
boat->pos = hero->pos;
|
||||
|
@ -247,7 +247,7 @@ std::vector<const CHeroClass *> HeroPoolProcessor::findAvailableClassesFor(const
|
||||
const auto & heroesPool = gameHandler->gameState()->heroesPool;
|
||||
FactionID factionID = gameHandler->getPlayerSettings(player)->castle;
|
||||
|
||||
for(auto & elem : heroesPool->unusedHeroesFromPool())
|
||||
for(const auto & elem : heroesPool->unusedHeroesFromPool())
|
||||
{
|
||||
if (vstd::contains(result, elem.second->type->heroClass))
|
||||
continue;
|
||||
@ -268,7 +268,7 @@ std::vector<CGHeroInstance *> HeroPoolProcessor::findAvailableHeroesFor(const Pl
|
||||
|
||||
const auto & heroesPool = gameHandler->gameState()->heroesPool;
|
||||
|
||||
for(auto & elem : heroesPool->unusedHeroesFromPool())
|
||||
for(const auto & elem : heroesPool->unusedHeroesFromPool())
|
||||
{
|
||||
assert(!vstd::contains(result, elem.second));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user