mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge pull request #3512 from Alexander-Wilms/use-auto-with-template-factory-functions-for-smart-pointers
Use auto with template factory functions for smart pointers
This commit is contained in:
commit
b698b6e79d
@ -134,7 +134,7 @@ SlotID StackWithBonuses::unitSlot() const
|
||||
TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, const CSelector & limit,
|
||||
const CBonusSystemNode * root, const std::string & cachingStr) const
|
||||
{
|
||||
TBonusListPtr ret = std::make_shared<BonusList>();
|
||||
auto ret = std::make_shared<BonusList>();
|
||||
TConstBonusListPtr originalList = origBearer->getAllBonuses(selector, limit, root, cachingStr);
|
||||
|
||||
vstd::copy_if(*originalList, std::back_inserter(*ret), [this](const std::shared_ptr<Bonus> & b)
|
||||
@ -356,7 +356,7 @@ void HypotheticBattle::addUnit(uint32_t id, const JsonNode & data)
|
||||
{
|
||||
battle::UnitInfo info;
|
||||
info.load(id, data);
|
||||
std::shared_ptr<StackWithBonuses> newUnit = std::make_shared<StackWithBonuses>(this, info);
|
||||
auto newUnit = std::make_shared<StackWithBonuses>(this, info);
|
||||
stackStates[newUnit->unitId()] = newUnit;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ void CStupidAI::activeStack(const BattleID & battleID, const CStack * stack)
|
||||
{
|
||||
if(CStack::isMeleeAttackPossible(stack, s, hex))
|
||||
{
|
||||
std::vector<EnemyInfo>::iterator i = std::find(enemiesReachable.begin(), enemiesReachable.end(), s);
|
||||
auto i = std::find(enemiesReachable.begin(), enemiesReachable.end(), s);
|
||||
if(i == enemiesReachable.end())
|
||||
{
|
||||
enemiesReachable.push_back(s);
|
||||
|
@ -1089,7 +1089,7 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component
|
||||
std::shared_ptr<CIntObject> localIcon = localIconC.image;
|
||||
localIconC.removeChild(localIcon.get(), false);
|
||||
|
||||
std::shared_ptr<CObjectListWindow> wnd = std::make_shared<CObjectListWindow>(tempList, localIcon, localTitle, localDescription, selectCallback);
|
||||
auto wnd = std::make_shared<CObjectListWindow>(tempList, localIcon, localTitle, localDescription, selectCallback);
|
||||
wnd->onExit = cancelCallback;
|
||||
GH.windows().pushWindow(wnd);
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ std::shared_ptr<const CPathsInfo> CClient::getPathsInfo(const CGHeroInstance * h
|
||||
|
||||
if(iter == std::end(pathCache))
|
||||
{
|
||||
std::shared_ptr<CPathsInfo> paths = std::make_shared<CPathsInfo>(getMapSize(), h);
|
||||
auto paths = std::make_shared<CPathsInfo>(getMapSize(), h);
|
||||
|
||||
gs->calculatePaths(h, *paths.get());
|
||||
|
||||
|
@ -420,7 +420,7 @@ void BattleWindow::bFleef()
|
||||
|
||||
if ( owner.getBattle()->battleCanFlee() )
|
||||
{
|
||||
CFunctionList<void()> ony = std::bind(&BattleWindow::reallyFlee,this);
|
||||
auto ony = std::bind(&BattleWindow::reallyFlee,this);
|
||||
owner.curInt->showYesNoDialog(CGI->generaltexth->allTexts[28], ony, nullptr); //Are you sure you want to retreat?
|
||||
}
|
||||
else
|
||||
|
@ -481,7 +481,7 @@ void OptionsTab::SelectionWindow::setSelection()
|
||||
|
||||
void OptionsTab::SelectionWindow::reopen()
|
||||
{
|
||||
std::shared_ptr<SelectionWindow> window = std::shared_ptr<SelectionWindow>(new SelectionWindow(color, type));
|
||||
auto window = std::shared_ptr<SelectionWindow>(new SelectionWindow(color, type));
|
||||
close();
|
||||
GH.windows().pushWindow(window);
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ void SelectionTab::filter(int size, bool selectFirst)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<ElementInfo> folder = std::make_shared<ElementInfo>();
|
||||
auto folder = std::make_shared<ElementInfo>();
|
||||
folder->isFolder = true;
|
||||
folder->folderName = folderName;
|
||||
auto itemIt = boost::range::find_if(curItems, [folder](std::shared_ptr<ElementInfo> e) { return e->folderName == folder->folderName; });
|
||||
|
@ -38,8 +38,8 @@ void CreatureCostBox::createItems(TResources res)
|
||||
TResources::nziterator iter(res);
|
||||
while(iter.valid())
|
||||
{
|
||||
ImagePtr image = std::make_shared<CAnimImage>(AnimationPath::builtin("RESOURCE"), iter->resType);
|
||||
LabelPtr text = std::make_shared<CLabel>(15, 43, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, "0");
|
||||
auto image = std::make_shared<CAnimImage>(AnimationPath::builtin("RESOURCE"), iter->resType);
|
||||
auto text = std::make_shared<CLabel>(15, 43, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, "0");
|
||||
|
||||
resources.insert(std::make_pair(iter->resType, std::make_pair(text, image)));
|
||||
iter++;
|
||||
|
@ -98,7 +98,7 @@ Canvas CMapOverviewWidget::createMinimapForLayer(std::unique_ptr<CMap> & map, in
|
||||
|
||||
std::vector<Canvas> CMapOverviewWidget::createMinimaps(ResourcePath resource) const
|
||||
{
|
||||
std::vector<Canvas> ret = std::vector<Canvas>();
|
||||
auto ret = std::vector<Canvas>();
|
||||
|
||||
CMapService mapService;
|
||||
std::unique_ptr<CMap> map;
|
||||
@ -117,7 +117,7 @@ std::vector<Canvas> CMapOverviewWidget::createMinimaps(ResourcePath resource) co
|
||||
|
||||
std::vector<Canvas> CMapOverviewWidget::createMinimaps(std::unique_ptr<CMap> & map) const
|
||||
{
|
||||
std::vector<Canvas> ret = std::vector<Canvas>();
|
||||
auto ret = std::vector<Canvas>();
|
||||
|
||||
for(int i = 0; i < (map->twoLevel ? 2 : 1); i++)
|
||||
ret.push_back(createMinimapForLayer(map, i));
|
||||
@ -164,7 +164,7 @@ CMapOverviewWidget::CMapOverviewWidget(CMapOverview& parent):
|
||||
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(p.resource.getName(), EResType::SAVEGAME)), MINIMAL_SERIALIZATION_VERSION);
|
||||
lf.checkMagicBytes(SAVEGAME_MAGIC);
|
||||
|
||||
std::unique_ptr<CMapHeader> mapHeader = std::make_unique<CMapHeader>();
|
||||
auto mapHeader = std::make_unique<CMapHeader>();
|
||||
StartInfo * startInfo;
|
||||
lf >> *(mapHeader) >> startInfo;
|
||||
|
||||
|
@ -49,7 +49,7 @@ std::vector<JsonNode> BattleFieldHandler::loadLegacyData()
|
||||
|
||||
const std::vector<std::string> & BattleFieldHandler::getTypeNames() const
|
||||
{
|
||||
static const std::vector<std::string> types = std::vector<std::string> { "battlefield" };
|
||||
static const auto types = std::vector<std::string> { "battlefield" };
|
||||
|
||||
return types;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ bool CCreatureSet::isCreatureBalanced(const CCreature * c, TQuantity ignoreAmoun
|
||||
{
|
||||
assert(c && c->valid());
|
||||
TQuantity max = 0;
|
||||
TQuantity min = std::numeric_limits<TQuantity>::max();
|
||||
auto min = std::numeric_limits<TQuantity>::max();
|
||||
|
||||
for(const auto & elem : stacks)
|
||||
{
|
||||
|
@ -741,7 +741,7 @@ int CPlayerSpecificInfoCallback::howManyTowns() const
|
||||
std::vector < const CGTownInstance *> CPlayerSpecificInfoCallback::getTownsInfo(bool onlyOur) const
|
||||
{
|
||||
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
|
||||
std::vector < const CGTownInstance *> ret = std::vector < const CGTownInstance *>();
|
||||
auto ret = std::vector < const CGTownInstance *>();
|
||||
for(const auto & i : gs->players)
|
||||
{
|
||||
for(const auto & town : i.second.towns)
|
||||
|
@ -536,7 +536,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
|
||||
int stepSize = specCreature.getLevel() ? specCreature.getLevel() : 5;
|
||||
|
||||
{
|
||||
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>();
|
||||
auto bonus = std::make_shared<Bonus>();
|
||||
bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false));
|
||||
bonus->type = BonusType::STACKS_SPEED;
|
||||
bonus->val = 1;
|
||||
@ -544,7 +544,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
|
||||
}
|
||||
|
||||
{
|
||||
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>();
|
||||
auto bonus = std::make_shared<Bonus>();
|
||||
bonus->type = BonusType::PRIMARY_SKILL;
|
||||
bonus->subtype = BonusSubtypeID(PrimarySkill::ATTACK);
|
||||
bonus->val = 0;
|
||||
@ -554,7 +554,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
|
||||
}
|
||||
|
||||
{
|
||||
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>();
|
||||
auto bonus = std::make_shared<Bonus>();
|
||||
bonus->type = BonusType::PRIMARY_SKILL;
|
||||
bonus->subtype = BonusSubtypeID(PrimarySkill::DEFENSE);
|
||||
bonus->val = 0;
|
||||
|
@ -818,7 +818,7 @@ std::shared_ptr<ILimiter> JsonUtils::parseLimiter(const JsonNode & limiter)
|
||||
const JsonVector & parameters = limiter["parameters"].Vector();
|
||||
if(limiterType == "CREATURE_TYPE_LIMITER")
|
||||
{
|
||||
std::shared_ptr<CCreatureTypeLimiter> creatureLimiter = std::make_shared<CCreatureTypeLimiter>();
|
||||
auto creatureLimiter = std::make_shared<CCreatureTypeLimiter>();
|
||||
VLC->identifiers()->requestIdentifier("creature", parameters[0], [=](si32 creature)
|
||||
{
|
||||
creatureLimiter->setCreature(CreatureID(creature));
|
||||
@ -846,7 +846,7 @@ std::shared_ptr<ILimiter> JsonUtils::parseLimiter(const JsonNode & limiter)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<HasAnotherBonusLimiter> bonusLimiter = std::make_shared<HasAnotherBonusLimiter>();
|
||||
auto bonusLimiter = std::make_shared<HasAnotherBonusLimiter>();
|
||||
bonusLimiter->type = it->second;
|
||||
auto findSource = [&](const JsonNode & parameter)
|
||||
{
|
||||
@ -890,7 +890,7 @@ std::shared_ptr<ILimiter> JsonUtils::parseLimiter(const JsonNode & limiter)
|
||||
}
|
||||
else if(limiterType == "FACTION_LIMITER" || limiterType == "CREATURE_FACTION_LIMITER") //Second name is deprecated, 1.2 compat
|
||||
{
|
||||
std::shared_ptr<FactionLimiter> factionLimiter = std::make_shared<FactionLimiter>();
|
||||
auto factionLimiter = std::make_shared<FactionLimiter>();
|
||||
VLC->identifiers()->requestIdentifier("faction", parameters[0], [=](si32 faction)
|
||||
{
|
||||
factionLimiter->faction = FactionID(faction);
|
||||
@ -910,7 +910,7 @@ std::shared_ptr<ILimiter> JsonUtils::parseLimiter(const JsonNode & limiter)
|
||||
}
|
||||
else if(limiterType == "CREATURE_TERRAIN_LIMITER")
|
||||
{
|
||||
std::shared_ptr<CreatureTerrainLimiter> terrainLimiter = std::make_shared<CreatureTerrainLimiter>();
|
||||
auto terrainLimiter = std::make_shared<CreatureTerrainLimiter>();
|
||||
if(!parameters.empty())
|
||||
{
|
||||
VLC->identifiers()->requestIdentifier("terrain", parameters[0], [=](si32 terrain)
|
||||
@ -1007,7 +1007,7 @@ static TUpdaterPtr parseUpdater(const JsonNode & updaterJson)
|
||||
case JsonNode::JsonType::DATA_STRUCT:
|
||||
if(updaterJson["type"].String() == "GROWS_WITH_LEVEL")
|
||||
{
|
||||
std::shared_ptr<GrowsWithLevelUpdater> updater = std::make_shared<GrowsWithLevelUpdater>();
|
||||
auto updater = std::make_shared<GrowsWithLevelUpdater>();
|
||||
const JsonVector param = updaterJson["parameters"].Vector();
|
||||
updater->valPer20 = static_cast<int>(param[0].Integer());
|
||||
if(param.size() > 1)
|
||||
@ -1016,7 +1016,7 @@ static TUpdaterPtr parseUpdater(const JsonNode & updaterJson)
|
||||
}
|
||||
else if (updaterJson["type"].String() == "ARMY_MOVEMENT")
|
||||
{
|
||||
std::shared_ptr<ArmyMovementUpdater> updater = std::make_shared<ArmyMovementUpdater>();
|
||||
auto updater = std::make_shared<ArmyMovementUpdater>();
|
||||
if(updaterJson["parameters"].isVector())
|
||||
{
|
||||
const auto & param = updaterJson["parameters"].Vector();
|
||||
|
@ -225,7 +225,7 @@ std::vector<JsonNode> ScriptHandler::loadLegacyData()
|
||||
ScriptPtr ScriptHandler::loadFromJson(vstd::CLoggerBase * logger, const std::string & scope,
|
||||
const JsonNode & json, const std::string & identifier) const
|
||||
{
|
||||
ScriptPtr ret = std::make_shared<ScriptImpl>(this);
|
||||
auto ret = std::make_shared<ScriptImpl>(this);
|
||||
|
||||
JsonDeserializer handler(nullptr, json);
|
||||
ret->identifier = identifier;
|
||||
@ -279,7 +279,7 @@ void ScriptHandler::loadState(const JsonNode & state)
|
||||
|
||||
const JsonNode & scriptData = keyValue.second;
|
||||
|
||||
ScriptPtr script = std::make_shared<ScriptImpl>(this);
|
||||
auto script = std::make_shared<ScriptImpl>(this);
|
||||
|
||||
JsonDeserializer handler(nullptr, scriptData);
|
||||
script->serializeJsonState(handler);
|
||||
|
@ -957,14 +957,14 @@ void BattleInfo::setWallState(EWallPart partOfWall, EWallState state)
|
||||
|
||||
void BattleInfo::addObstacle(const ObstacleChanges & changes)
|
||||
{
|
||||
std::shared_ptr<SpellCreatedObstacle> obstacle = std::make_shared<SpellCreatedObstacle>();
|
||||
auto obstacle = std::make_shared<SpellCreatedObstacle>();
|
||||
obstacle->fromInfo(changes);
|
||||
obstacles.push_back(obstacle);
|
||||
}
|
||||
|
||||
void BattleInfo::updateObstacle(const ObstacleChanges& changes)
|
||||
{
|
||||
std::shared_ptr<SpellCreatedObstacle> changedObstacle = std::make_shared<SpellCreatedObstacle>();
|
||||
auto changedObstacle = std::make_shared<SpellCreatedObstacle>();
|
||||
changedObstacle->fromInfo(changes);
|
||||
|
||||
for(auto & obstacle : obstacles)
|
||||
|
@ -796,7 +796,7 @@ DamageEstimation CBattleInfoCallback::battleEstimateDamage(const BattleAttackInf
|
||||
|
||||
std::vector<std::shared_ptr<const CObstacleInstance>> CBattleInfoCallback::battleGetAllObstaclesOnPos(BattleHex tile, bool onlyBlocking) const
|
||||
{
|
||||
std::vector<std::shared_ptr<const CObstacleInstance>> obstacles = std::vector<std::shared_ptr<const CObstacleInstance>>();
|
||||
auto obstacles = std::vector<std::shared_ptr<const CObstacleInstance>>();
|
||||
RETURN_IF_NOT_BATTLE(obstacles);
|
||||
for(auto & obs : battleGetAllObstacles())
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
BattleField battleGetBattlefieldType() const override;
|
||||
int32_t battleGetEnchanterCounter(ui8 side) const;
|
||||
|
||||
std::vector<std::shared_ptr<const CObstacleInstance> > battleGetAllObstacles(std::optional<BattlePerspective::BattlePerspective> perspective = std::nullopt) const; //returns all obstacles on the battlefield
|
||||
std::vector<std::shared_ptr<const CObstacleInstance>> battleGetAllObstacles(std::optional<BattlePerspective::BattlePerspective> perspective = std::nullopt) const; //returns all obstacles on the battlefield
|
||||
|
||||
std::shared_ptr<const CObstacleInstance> battleGetObstacleByID(uint32_t ID) const;
|
||||
|
||||
|
@ -54,7 +54,7 @@ std::shared_ptr<Bonus> GrowsWithLevelUpdater::createUpdatedBonus(const std::shar
|
||||
//rounding follows format for HMM3 creature specialty bonus
|
||||
int newVal = (valPer20 * steps + 19) / 20;
|
||||
//return copy of bonus with updated val
|
||||
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*b);
|
||||
auto newBonus = std::make_shared<Bonus>(*b);
|
||||
newBonus->val = newVal;
|
||||
return newBonus;
|
||||
}
|
||||
@ -83,7 +83,7 @@ std::shared_ptr<Bonus> TimesHeroLevelUpdater::createUpdatedBonus(const std::shar
|
||||
if(context.getNodeType() == CBonusSystemNode::HERO)
|
||||
{
|
||||
int level = dynamic_cast<const CGHeroInstance &>(context).level;
|
||||
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*b);
|
||||
auto newBonus = std::make_shared<Bonus>(*b);
|
||||
newBonus->val *= level;
|
||||
return newBonus;
|
||||
}
|
||||
@ -155,7 +155,7 @@ std::shared_ptr<Bonus> TimesStackLevelUpdater::createUpdatedBonus(const std::sha
|
||||
if(context.getNodeType() == CBonusSystemNode::STACK_INSTANCE)
|
||||
{
|
||||
int level = dynamic_cast<const CStackInstance &>(context).getLevel();
|
||||
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*b);
|
||||
auto newBonus = std::make_shared<Bonus>(*b);
|
||||
newBonus->val *= level;
|
||||
return newBonus;
|
||||
}
|
||||
@ -167,7 +167,7 @@ std::shared_ptr<Bonus> TimesStackLevelUpdater::createUpdatedBonus(const std::sha
|
||||
if(stack.base == nullptr)
|
||||
{
|
||||
int level = stack.unitType()->getLevel();
|
||||
std::shared_ptr<Bonus> newBonus = std::make_shared<Bonus>(*b);
|
||||
auto newBonus = std::make_shared<Bonus>(*b);
|
||||
newBonus->val *= level;
|
||||
return newBonus;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace events
|
||||
|
||||
SubscriptionRegistry<ApplyDamage> * ApplyDamage::getRegistry()
|
||||
{
|
||||
static std::unique_ptr<SubscriptionRegistry<ApplyDamage>> Instance = std::make_unique<SubscriptionRegistry<ApplyDamage>>();
|
||||
static auto Instance = std::make_unique<SubscriptionRegistry<ApplyDamage>>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace events
|
||||
|
||||
SubscriptionRegistry<GameResumed> * GameResumed::getRegistry()
|
||||
{
|
||||
static std::unique_ptr<SubscriptionRegistry<GameResumed>> Instance = std::make_unique<SubscriptionRegistry<GameResumed>>();
|
||||
static auto Instance = std::make_unique<SubscriptionRegistry<GameResumed>>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace events
|
||||
|
||||
SubscriptionRegistry<ObjectVisitEnded> * ObjectVisitEnded::getRegistry()
|
||||
{
|
||||
static std::unique_ptr<Sub> Instance = std::make_unique<Sub>();
|
||||
static auto Instance = std::make_unique<Sub>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace events
|
||||
|
||||
SubscriptionRegistry<ObjectVisitStarted> * ObjectVisitStarted::getRegistry()
|
||||
{
|
||||
static std::unique_ptr<Sub> Instance = std::make_unique<Sub>();
|
||||
static auto Instance = std::make_unique<Sub>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace events
|
||||
|
||||
SubscriptionRegistry<PlayerGotTurn> * PlayerGotTurn::getRegistry()
|
||||
{
|
||||
static std::unique_ptr<SubscriptionRegistry<PlayerGotTurn>> Instance = std::make_unique<SubscriptionRegistry<PlayerGotTurn>>();
|
||||
static auto Instance = std::make_unique<SubscriptionRegistry<PlayerGotTurn>>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace events
|
||||
|
||||
SubscriptionRegistry<TurnStarted> * TurnStarted::getRegistry()
|
||||
{
|
||||
static std::unique_ptr<SubscriptionRegistry<TurnStarted>> Instance = std::make_unique<SubscriptionRegistry<TurnStarted>>();
|
||||
static auto Instance = std::make_unique<SubscriptionRegistry<TurnStarted>>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
|
||||
static constexpr si32 UNINITIALIZED_MANA = -1;
|
||||
static constexpr ui32 UNINITIALIZED_MOVEMENT = -1;
|
||||
static constexpr TExpType UNINITIALIZED_EXPERIENCE = std::numeric_limits<TExpType>::max();
|
||||
static constexpr auto UNINITIALIZED_EXPERIENCE = std::numeric_limits<TExpType>::max();
|
||||
|
||||
//std::vector<const CArtifact*> artifacts; //hero's artifacts from bag
|
||||
//std::map<ui16, const CArtifact*> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
|
||||
|
@ -780,7 +780,7 @@ CMapLoaderJson::CMapLoaderJson(CInputStream * stream)
|
||||
std::unique_ptr<CMap> CMapLoaderJson::loadMap()
|
||||
{
|
||||
LOG_TRACE(logGlobal);
|
||||
std::unique_ptr<CMap> result = std::make_unique<CMap>();
|
||||
auto result = std::make_unique<CMap>();
|
||||
map = result.get();
|
||||
mapHeader = map;
|
||||
readMap();
|
||||
@ -791,7 +791,7 @@ std::unique_ptr<CMapHeader> CMapLoaderJson::loadMapHeader()
|
||||
{
|
||||
LOG_TRACE(logGlobal);
|
||||
map = nullptr;
|
||||
std::unique_ptr<CMapHeader> result = std::make_unique<CMapHeader>();
|
||||
auto result = std::make_unique<CMapHeader>();
|
||||
mapHeader = result.get();
|
||||
readHeader(false);
|
||||
return result;
|
||||
|
@ -179,7 +179,7 @@ auto ThreadPool::async(std::function<void()>&& f) const -> boost::future<void>
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<TaskT> task = std::make_shared<TaskT>(f);
|
||||
auto task = std::make_shared<TaskT>(f);
|
||||
boost::future<void> fut = task->get_future();
|
||||
tasks.emplace([task]() -> void
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ namespace spells
|
||||
|
||||
static std::shared_ptr<TargetCondition> makeCondition(const CSpell * s)
|
||||
{
|
||||
std::shared_ptr<TargetCondition> res = std::make_shared<TargetCondition>();
|
||||
auto res = std::make_shared<TargetCondition>();
|
||||
|
||||
JsonDeserializer deser(nullptr, s->targetCondition);
|
||||
res->serializeJson(deser, TargetConditionItemFactory::getDefault());
|
||||
|
@ -318,19 +318,19 @@ class DefaultTargetConditionItemFactory : public TargetConditionItemFactory
|
||||
public:
|
||||
Object createAbsoluteLevel() const override
|
||||
{
|
||||
static std::shared_ptr<TargetConditionItem> antimagicCondition = std::make_shared<AbsoluteLevelCondition>();
|
||||
static auto antimagicCondition = std::make_shared<AbsoluteLevelCondition>();
|
||||
return antimagicCondition;
|
||||
}
|
||||
|
||||
Object createAbsoluteSpell() const override
|
||||
{
|
||||
static std::shared_ptr<TargetConditionItem> alCondition = std::make_shared<AbsoluteSpellCondition>();
|
||||
static auto alCondition = std::make_shared<AbsoluteSpellCondition>();
|
||||
return alCondition;
|
||||
}
|
||||
|
||||
Object createElemental() const override
|
||||
{
|
||||
static std::shared_ptr<TargetConditionItem> elementalCondition = std::make_shared<ElementalCondition>();
|
||||
static auto elementalCondition = std::make_shared<ElementalCondition>();
|
||||
return elementalCondition;
|
||||
}
|
||||
|
||||
@ -342,13 +342,13 @@ public:
|
||||
|
||||
Object createNormalLevel() const override
|
||||
{
|
||||
static std::shared_ptr<TargetConditionItem> nlCondition = std::make_shared<NormalLevelCondition>();
|
||||
static auto nlCondition = std::make_shared<NormalLevelCondition>();
|
||||
return nlCondition;
|
||||
}
|
||||
|
||||
Object createNormalSpell() const override
|
||||
{
|
||||
static std::shared_ptr<TargetConditionItem> nsCondition = std::make_shared<NormalSpellCondition>();
|
||||
static auto nsCondition = std::make_shared<NormalSpellCondition>();
|
||||
return nsCondition;
|
||||
}
|
||||
|
||||
@ -424,13 +424,13 @@ public:
|
||||
|
||||
Object createReceptiveFeature() const override
|
||||
{
|
||||
static std::shared_ptr<TargetConditionItem> condition = std::make_shared<ReceptiveFeatureCondition>();
|
||||
static auto condition = std::make_shared<ReceptiveFeatureCondition>();
|
||||
return condition;
|
||||
}
|
||||
|
||||
Object createImmunityNegation() const override
|
||||
{
|
||||
static std::shared_ptr<TargetConditionItem> condition = std::make_shared<ImmunityNegationCondition>();
|
||||
static auto condition = std::make_shared<ImmunityNegationCondition>();
|
||||
return condition;
|
||||
}
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ private:
|
||||
|
||||
Registry * GlobalRegistry::get()
|
||||
{
|
||||
static std::unique_ptr<Registry> Instance = std::make_unique<detail::RegistryImpl>();
|
||||
static auto Instance = std::make_unique<detail::RegistryImpl>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ std::shared_ptr<QImage> DefFile::loadFrame(size_t frame, size_t group) const
|
||||
const ui32 BaseOffset = currentOffset;
|
||||
|
||||
|
||||
std::shared_ptr<QImage> img = std::make_shared<QImage>(sprite.fullWidth, sprite.fullHeight, QImage::Format_Indexed8);
|
||||
auto img = std::make_shared<QImage>(sprite.fullWidth, sprite.fullHeight, QImage::Format_Indexed8);
|
||||
if(!img)
|
||||
throw std::runtime_error("Image memory cannot be allocated");
|
||||
|
||||
|
@ -184,7 +184,7 @@ std::shared_ptr<Animation> Graphics::loadHeroFlagAnimation(const std::string & n
|
||||
{2,14}, {3,15}
|
||||
};
|
||||
|
||||
std::shared_ptr<Animation> anim = std::make_shared<Animation>(name);
|
||||
auto anim = std::make_shared<Animation>(name);
|
||||
anim->preload();
|
||||
|
||||
for(const auto & rotation : rotations)
|
||||
@ -207,7 +207,7 @@ std::shared_ptr<Animation> Graphics::loadHeroAnimation(const std::string &name)
|
||||
{2,14}, {3,15}
|
||||
};
|
||||
|
||||
std::shared_ptr<Animation> anim = std::make_shared<Animation>(name);
|
||||
auto anim = std::make_shared<Animation>(name);
|
||||
anim->preload();
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ void ResourceConverter::splitDefFile(const std::string & fileName, const boost::
|
||||
{
|
||||
if(CResourceHandler::get()->existsResource(ResourcePath("SPRITES/" + fileName)))
|
||||
{
|
||||
std::unique_ptr<Animation> anim = std::make_unique<Animation>(fileName);
|
||||
auto anim = std::make_unique<Animation>(fileName);
|
||||
anim->preload();
|
||||
anim->exportBitmaps(pathToQString(sourceFolder));
|
||||
|
||||
|
@ -1377,7 +1377,7 @@ struct ScriptScanner
|
||||
{
|
||||
if(std::holds_alternative<Tcommand>(cmd)) //TCommand
|
||||
{
|
||||
Tcommand tcmd = std::get<Tcommand>(cmd);
|
||||
auto tcmd = std::get<Tcommand>(cmd);
|
||||
struct Visitor
|
||||
{
|
||||
void operator()(const ERM::Ttrigger& t) const
|
||||
@ -1423,7 +1423,7 @@ bool ERMInterpreter::isATrigger( const ERM::TLine & line )
|
||||
{
|
||||
if(std::holds_alternative<ERM::TVExp>(line))
|
||||
{
|
||||
TVExp vexp = std::get<TVExp>(line);
|
||||
auto vexp = std::get<TVExp>(line);
|
||||
if(vexp.children.empty())
|
||||
return false;
|
||||
|
||||
@ -1442,7 +1442,7 @@ bool ERMInterpreter::isATrigger( const ERM::TLine & line )
|
||||
}
|
||||
else if(std::holds_alternative<TERMline>(line))
|
||||
{
|
||||
TERMline ermline = std::get<TERMline>(line);
|
||||
auto ermline = std::get<TERMline>(line);
|
||||
return std::holds_alternative<ERM::Tcommand>(ermline) && isCMDATrigger( std::get<ERM::Tcommand>(ermline) );
|
||||
}
|
||||
else
|
||||
@ -1511,10 +1511,10 @@ ERM::TTriggerBase & ERMInterpreter::retrieveTrigger(ERM::TLine & line)
|
||||
{
|
||||
if(std::holds_alternative<ERM::TERMline>(line))
|
||||
{
|
||||
ERM::TERMline &tl = std::get<ERM::TERMline>(line);
|
||||
auto &tl = std::get<ERM::TERMline>(line);
|
||||
if(std::holds_alternative<ERM::Tcommand>(tl))
|
||||
{
|
||||
ERM::Tcommand &tcm = std::get<ERM::Tcommand>(tl);
|
||||
auto &tcm = std::get<ERM::Tcommand>(tl);
|
||||
if(std::holds_alternative<ERM::Ttrigger>(tcm.cmd))
|
||||
{
|
||||
return std::get<ERM::Ttrigger>(tcm.cmd);
|
||||
|
@ -22,7 +22,7 @@ Registry::Registry() = default;
|
||||
|
||||
Registry * Registry::get()
|
||||
{
|
||||
static std::unique_ptr<Registry> Instance = std::unique_ptr<Registry>(new Registry());
|
||||
static auto Instance = std::unique_ptr<Registry>(new Registry());
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ TypeRegistry::TypeRegistry()
|
||||
|
||||
TypeRegistry * TypeRegistry::get()
|
||||
{
|
||||
static std::unique_ptr<TypeRegistry> Instance = std::unique_ptr<TypeRegistry>(new TypeRegistry());
|
||||
static auto Instance = std::unique_ptr<TypeRegistry>(new TypeRegistry());
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ bool CVCMIServer::prepareToStartGame()
|
||||
Load::ProgressAccumulator progressTracking;
|
||||
Load::Progress current(1);
|
||||
progressTracking.include(current);
|
||||
Load::Type currentProgress = std::numeric_limits<Load::Type>::max();
|
||||
auto currentProgress = std::numeric_limits<Load::Type>::max();
|
||||
|
||||
auto progressTrackingThread = boost::thread([this, &progressTracking, ¤tProgress]()
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ TEST_F(CCreatureTest, DISABLED_JsonAddBonus)
|
||||
{
|
||||
JsonNode data(JsonNode::JsonType::DATA_STRUCT);
|
||||
|
||||
std::shared_ptr<Bonus> b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
auto b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
|
||||
JsonNode & toAdd = data["bonuses"]["toAdd"];
|
||||
|
||||
@ -133,10 +133,10 @@ TEST_F(CCreatureTest, DISABLED_JsonRemoveBonus)
|
||||
{
|
||||
JsonNode data(JsonNode::JsonType::DATA_STRUCT);
|
||||
|
||||
std::shared_ptr<Bonus> b1 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
auto b1 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
subject->addNewBonus(b1);
|
||||
|
||||
std::shared_ptr<Bonus> b2 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 18, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
auto b2 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 18, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
subject->addNewBonus(b2);
|
||||
|
||||
|
||||
|
@ -87,13 +87,13 @@ TEST_F(ERM_MA, Example)
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::FLYING, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::KING, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
|
||||
std::shared_ptr<Bonus> removed = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::MIND_IMMUNITY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
auto removed = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::MIND_IMMUNITY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
|
||||
creatureBonuses.addNewBonus(removed);
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::NO_MORALE, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::UNDEAD, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
|
||||
std::shared_ptr<Bonus> added = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::NO_MELEE_PENALTY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
auto added = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::NO_MELEE_PENALTY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
|
||||
|
||||
EXPECT_CALL(oldCreature, getRecruitCost(Eq(6))).WillOnce(Return(COST));
|
||||
@ -206,13 +206,13 @@ TEST_F(ERM_MA, Bonuses)
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::FLYING, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::KING, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
|
||||
std::shared_ptr<Bonus> removed = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::MIND_IMMUNITY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
auto removed = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::MIND_IMMUNITY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
|
||||
creatureBonuses.addNewBonus(removed);
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::NO_MORALE, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::UNDEAD, BonusSource::CREATURE_ABILITY, 0, 0));
|
||||
|
||||
std::shared_ptr<Bonus> added = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::NO_MELEE_PENALTY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
auto added = std::make_shared<Bonus>(BonusDuration::PERMANENT, Bonus::NO_MELEE_PENALTY, BonusSource::CREATURE_ABILITY, 0, 0);
|
||||
|
||||
EXPECT_CALL(oldCreature, isDoubleWide()).WillRepeatedly(Return(false));
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
public:
|
||||
static SubscriptionRegistry<EventExample> * getRegistry()
|
||||
{
|
||||
static std::unique_ptr<SubscriptionRegistry<EventExample>> Instance = std::make_unique<SubscriptionRegistry<EventExample>>();
|
||||
static auto Instance = std::make_unique<SubscriptionRegistry<EventExample>>();
|
||||
return Instance.get();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ TEST(MapFormat, DISABLED_Random)
|
||||
|
||||
CMapGenOptions opt;
|
||||
CRmgTemplate tmpl;
|
||||
std::shared_ptr<ZoneOptionsFake> zoneOptions = std::make_shared<ZoneOptionsFake>();
|
||||
auto zoneOptions = std::make_shared<ZoneOptionsFake>();
|
||||
|
||||
const_cast<CRmgTemplate::CPlayerCountRange &>(tmpl.getHumanPlayers()).addRange(1, 4);
|
||||
const_cast<CRmgTemplate::Zones &>(tmpl.getZones())[0] = zoneOptions;
|
||||
|
@ -34,7 +34,7 @@ protected:
|
||||
|
||||
void testLoadSave(const std::string & id, const JsonNode & config)
|
||||
{
|
||||
std::shared_ptr<CRmgTemplate> subject = std::make_shared<CRmgTemplate>();
|
||||
auto subject = std::make_shared<CRmgTemplate>();
|
||||
subject->setId(id);
|
||||
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ TEST_F(CatapultTest, NotApplicableWithoutTown)
|
||||
|
||||
TEST_F(CatapultTest, NotApplicableInVillage)
|
||||
{
|
||||
std::shared_ptr<CGTownInstance> fakeTown = std::make_shared<CGTownInstance>();
|
||||
auto fakeTown = std::make_shared<CGTownInstance>();
|
||||
|
||||
EXPECT_CALL(*battleFake, getDefendedTown()).WillRepeatedly(Return(fakeTown.get()));
|
||||
EXPECT_CALL(mechanicsMock, adaptProblem(_, _)).WillOnce(Return(false));
|
||||
@ -62,7 +62,7 @@ TEST_F(CatapultTest, NotApplicableInVillage)
|
||||
|
||||
TEST_F(CatapultTest, NotApplicableForDefenderIfSmart)
|
||||
{
|
||||
std::shared_ptr<CGTownInstance> fakeTown = std::make_shared<CGTownInstance>();
|
||||
auto fakeTown = std::make_shared<CGTownInstance>();
|
||||
fakeTown->builtBuildings.insert(BuildingID::FORT);
|
||||
mechanicsMock.casterSide = BattleSide::DEFENDER;
|
||||
|
||||
@ -76,7 +76,7 @@ TEST_F(CatapultTest, NotApplicableForDefenderIfSmart)
|
||||
|
||||
TEST_F(CatapultTest, DISABLED_ApplicableInTown)
|
||||
{
|
||||
std::shared_ptr<CGTownInstance> fakeTown = std::make_shared<CGTownInstance>();
|
||||
auto fakeTown = std::make_shared<CGTownInstance>();
|
||||
fakeTown->builtBuildings.insert(BuildingID::FORT);
|
||||
|
||||
EXPECT_CALL(*battleFake, getDefendedTown()).WillRepeatedly(Return(fakeTown.get()));
|
||||
|
@ -104,7 +104,7 @@ TEST_F(DamageApplyTest, DISABLED_DoesDamageToAliveUnit)
|
||||
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
std::shared_ptr<CUnitState> targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
auto targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
targetUnitState->localInit(&unitEnvironmentMock);
|
||||
EXPECT_CALL(targetUnit, acquireState()).WillOnce(Return(targetUnitState));
|
||||
EXPECT_CALL(*battleFake, setUnitState(Eq(unitId),_, Lt(0))).Times(1);
|
||||
@ -168,7 +168,7 @@ TEST_F(DamageApplyTest, DISABLED_DoesDamageByPercent)
|
||||
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
std::shared_ptr<CUnitState> targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
auto targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
targetUnitState->localInit(&unitEnvironmentMock);
|
||||
EXPECT_CALL(targetUnit, acquireState()).WillOnce(Return(targetUnitState));
|
||||
|
||||
@ -212,7 +212,7 @@ TEST_F(DamageApplyTest, DISABLED_DoesDamageByCount)
|
||||
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
std::shared_ptr<CUnitState> targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
auto targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
targetUnitState->localInit(&unitEnvironmentMock);
|
||||
EXPECT_CALL(targetUnit, acquireState()).WillOnce(Return(targetUnitState));
|
||||
|
||||
|
@ -352,7 +352,7 @@ TEST_P(HealApplyTest, DISABLED_Heals)
|
||||
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
std::shared_ptr<CUnitState> targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
auto targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
targetUnitState->localInit(&unitEnvironmentMock);
|
||||
{
|
||||
int64_t initialDmg = unitAmount * unitHP / 2 - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user