1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #1991 from rilian-la-te/modernization-rule-ver1

vcmi: rule-based modernization part1
This commit is contained in:
Ivan Savenko 2023-04-30 15:06:14 +03:00 committed by GitHub
commit 3378a3c740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
75 changed files with 234 additions and 273 deletions

View File

@ -56,10 +56,7 @@ struct EvaluationResult
class BattleExchangeVariant
{
public:
BattleExchangeVariant()
:dpsScore(0), attackerValue()
{
}
BattleExchangeVariant(): dpsScore(0) {}
int64_t trackAttack(const AttackPossibility & ap, HypotheticBattle & state);
@ -92,10 +89,7 @@ private:
std::vector<battle::Units> turnOrder;
public:
BattleExchangeEvaluator(std::shared_ptr<CBattleInfoCallback> cb, std::shared_ptr<Environment> env)
:cb(cb), reachabilityMap(), env(env), turnOrder()
{
}
BattleExchangeEvaluator(std::shared_ptr<CBattleInfoCallback> cb, std::shared_ptr<Environment> env): cb(cb), env(env) {}
EvaluationResult findBestTarget(const battle::Unit * activeStack, PotentialTargets & targets, HypotheticBattle & hb);
int64_t calculateExchange(const AttackPossibility & ap, PotentialTargets & targets, HypotheticBattle & hb);

View File

@ -54,7 +54,7 @@
using namespace tbb;
typedef std::pair<ui32, std::vector<CreatureID>> dwellingContent;
using dwellingContent = std::pair<ui32, std::vector<CreatureID>>;
namespace NKAI
{
@ -305,10 +305,10 @@ public:
public:
using ptr_type = std::unique_ptr<T, External_Deleter>;
SharedPool(std::function<std::unique_ptr<T>()> elementFactory)
: elementFactory(elementFactory), pool(), sync(), instance_tracker(new SharedPool<T>*(this))
SharedPool(std::function<std::unique_ptr<T>()> elementFactory):
elementFactory(elementFactory), pool(), instance_tracker(new SharedPool<T> *(this))
{}
void add(std::unique_ptr<T> t)
{
boost::lock_guard<boost::mutex> lock(sync);

View File

@ -32,13 +32,8 @@ struct SlotInfo
struct ArmyUpgradeInfo
{
std::vector<SlotInfo> resultingArmy;
uint64_t upgradeValue;
uint64_t upgradeValue = 0;
TResources upgradeCost;
ArmyUpgradeInfo()
: resultingArmy(), upgradeValue(0), upgradeCost()
{
}
};
class DLL_EXPORT IArmyManager //: public: IAbstractManager

View File

@ -62,8 +62,11 @@ public:
HeroRole townRole;
bool hasSomethingToBuild;
TownDevelopmentInfo(const CGTownInstance* town)
:town(town), armyStrength(0), toBuild(), townDevelopmentCost(), requiredResources(), townRole(HeroRole::SCOUT), hasSomethingToBuild(false)
TownDevelopmentInfo(const CGTownInstance * town):
town(town),
armyStrength(0),
townRole(HeroRole::SCOUT),
hasSomethingToBuild(false)
{
}

View File

@ -22,7 +22,7 @@ struct ClusterObjectInfo
uint8_t turn;
};
typedef tbb::concurrent_hash_map<const CGObjectInstance *, ClusterObjectInfo> ClusterObjects;
using ClusterObjects = tbb::concurrent_hash_map<const CGObjectInstance *, ClusterObjectInfo>;
struct ObjectCluster
{
@ -36,11 +36,8 @@ public:
}
void addObject(const CGObjectInstance * object, const AIPath & path, float priority);
ObjectCluster(const CGObjectInstance * blocker)
:objects(), blocker(blocker)
{
}
ObjectCluster(const CGObjectInstance * blocker): blocker(blocker) {}
ObjectCluster() : ObjectCluster(nullptr)
{
@ -50,7 +47,7 @@ public:
const CGObjectInstance * calculateCenter() const;
};
typedef tbb::concurrent_hash_map<const CGObjectInstance *, std::shared_ptr<ObjectCluster>> ClusterMap;
using ClusterMap = tbb::concurrent_hash_map<const CGObjectInstance *, std::shared_ptr<ObjectCluster>>;
class ObjectClusterizer
{
@ -67,10 +64,7 @@ public:
std::vector<std::shared_ptr<ObjectCluster>> getLockedClusters() const;
const CGObjectInstance * getBlocker(const AIPath & path) const;
ObjectClusterizer(const Nullkiller * ai)
:nearObjects(), farObjects(), blockedObjects(), ai(ai)
{
}
ObjectClusterizer(const Nullkiller * ai): ai(ai) {}
private:
bool shouldVisitObject(const CGObjectInstance * obj) const;

View File

@ -22,7 +22,7 @@ struct GoalHash
}
};
typedef std::unordered_map<Goals::TSubgoal, Goals::TGoalVec, GoalHash> TGoalHashSet;
using TGoalHashSet = std::unordered_map<Goals::TSubgoal, Goals::TGoalVec, GoalHash>;
class DeepDecomposer
{

View File

@ -28,7 +28,7 @@ private:
TacticalAdvantageEngine tacticalAdvantageEngine;
public:
FuzzyHelper(const Nullkiller * ai) : ai(ai), tacticalAdvantageEngine() {}
FuzzyHelper(const Nullkiller * ai): ai(ai) {}
ui64 estimateBankDanger(const CBank * bank); //TODO: move to another class?

View File

@ -81,9 +81,9 @@ namespace Goals
bool operator<(const TSubgoal & rhs) const;
};
typedef std::shared_ptr<ITask> TTask;
typedef std::vector<TTask> TTaskVec;
typedef std::vector<TSubgoal> TGoalVec;
using TTask = std::shared_ptr<ITask>;
using TTaskVec = std::vector<TTask>;
using TGoalVec = std::vector<TSubgoal>;
//method chaining + clone pattern
#define SETTER(type, field) AbstractGoal & set ## field(const type &rhs) {field = rhs; return *this;};
@ -107,8 +107,7 @@ namespace Goals
const CGTownInstance *town; SETTER(CGTownInstance *, town)
int bid; SETTER(int, bid)
AbstractGoal(EGoals goal = EGoals::INVALID)
: goalType(goal), hero()
AbstractGoal(EGoals goal = EGoals::INVALID): goalType(goal)
{
isAbstract = false;
value = 0;

View File

@ -205,14 +205,14 @@ public:
inline void updateAINode(CGPathNode * node, std::function<void (AIPathNode *)> updater)
{
auto aiNode = static_cast<AIPathNode *>(node);
auto * aiNode = static_cast<AIPathNode *>(node);
updater(aiNode);
}
inline const CGHeroInstance * getHero(const CGPathNode * node) const
{
auto aiNode = getAINode(node);
const auto * aiNode = getAINode(node);
return aiNode->actor->hero;
}

View File

@ -32,9 +32,7 @@ public:
virtual bool needsLastStack() const override;
std::shared_ptr<SpecialAction> getActorAction() const;
HeroExchangeArmy() : CArmedInstance(true), armyCost(), requireBuyArmy(false)
{
}
HeroExchangeArmy(): CArmedInstance(true), requireBuyArmy(false) {}
};
struct ExchangeResult

View File

@ -23,9 +23,9 @@
class CCallback;
struct creInfo;
typedef const int3 & crint3;
typedef const std::string & crstring;
typedef std::pair<ui32, std::vector<CreatureID>> dwellingContent;
using crint3 = const int3 &;
using crstring = const std::string &;
using dwellingContent = std::pair<ui32, std::vector<CreatureID>>;
const int GOLD_MINE_PRODUCTION = 1000, WOOD_ORE_MINE_PRODUCTION = 2, RESOURCE_MINE_PRODUCTION = 1;
const int ACTUAL_RESOURCE_COUNT = 7;

View File

@ -76,7 +76,7 @@ namespace Goals
//TODO: serialize?
};
typedef std::vector<TSubgoal> TGoalVec;
using TGoalVec = std::vector<TSubgoal>;
//method chaining + clone pattern
#define VSETTER(type, field) virtual AbstractGoal & set ## field(const type &rhs) {field = rhs; return *this;};
@ -121,8 +121,7 @@ namespace Goals
TSubgoal parent; VSETTER(TSubgoal, parent)
EvaluationContext evaluationContext; VSETTER(EvaluationContext, evaluationContext)
AbstractGoal(EGoals goal = EGoals::INVALID)
: goalType(goal), evaluationContext()
AbstractGoal(EGoals goal = EGoals::INVALID): goalType(goal)
{
priority = 0;
isElementar = false;

View File

@ -19,8 +19,6 @@
class CCallback;
extern boost::thread_specific_ptr<CCallback> cb; //for templates
struct AIPathNode : public CGPathNode
{
uint32_t chainMask;

View File

@ -14,7 +14,7 @@
struct _Mix_Music;
struct SDL_RWops;
typedef struct _Mix_Music Mix_Music;
using Mix_Music = struct _Mix_Music;
struct Mix_Chunk;
class CAudioBase {

View File

@ -61,8 +61,8 @@ namespace boost { class thread; }
template<typename T>
class ThreadSafeVector
{
typedef std::vector<T> TVector;
typedef boost::unique_lock<boost::mutex> TLock;
using TVector = std::vector<T>;
using TLock = boost::unique_lock<boost::mutex>;
TVector items;
boost::mutex mx;
boost::condition_variable cond;

View File

@ -68,7 +68,7 @@ namespace AnimationControls
class CreatureAnimation : public CIntObject
{
public:
typedef std::function<float(CreatureAnimation *, ECreatureAnimType)> TSpeedController;
using TSpeedController = std::function<float(CreatureAnimation *, ECreatureAnimType)>;
private:
std::string name;

View File

@ -80,7 +80,7 @@ private:
std::vector<std::shared_ptr<IShowActivatable>> disposed;
std::atomic<bool> continueEventHandling;
typedef std::list<CIntObject*> CIntObjectList;
using CIntObjectList = std::list<CIntObject *>;
//active GUI elements (listening for events
CIntObjectList lclickable;
@ -107,11 +107,9 @@ private:
public:
void handleElementActivate(CIntObject * elem, ui16 activityFlag);
void handleElementDeActivate(CIntObject * elem, ui16 activityFlag);
public:
//objs to blit
std::vector<std::shared_ptr<IShowActivatable>> objsToBlit;
/// returns current position of mouse cursor, relative to vcmi window
const Point & getCursorPosition() const;

View File

@ -17,7 +17,7 @@ struct SDL_Surface;
class CGuiHandler;
class CPicture;
typedef int32_t SDL_Keycode;
using SDL_Keycode = int32_t;
using boost::logic::tribool;

View File

@ -17,7 +17,7 @@ VCMI_LIB_NAMESPACE_END
class CBitmapFont;
typedef struct _TTF_Font TTF_Font;
using TTF_Font = struct _TTF_Font;
class CTrueTypeFont : public IFont
{

View File

@ -45,8 +45,8 @@ SDL_Color toSDL(const ColorRGBA & color);
void setColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
void setAlpha(SDL_Surface * bg, int value);
typedef void (*TColorPutter)(uint8_t *&ptr, const uint8_t & R, const uint8_t & G, const uint8_t & B);
typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_t & G, const uint8_t & B, const uint8_t & A);
using TColorPutter = void (*)(uint8_t *&, const uint8_t &, const uint8_t &, const uint8_t &);
using TColorPutterAlpha = void (*)(uint8_t *&, const uint8_t &, const uint8_t &, const uint8_t &, const uint8_t &);
void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst);
void blitAt(SDL_Surface * src, const Rect & pos, SDL_Surface * dst);
@ -57,23 +57,23 @@ typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_
void blitSurface(SDL_Surface * src, const Rect & srcRect, SDL_Surface * dst, const Point & dest);
void blitSurface(SDL_Surface * src, SDL_Surface * dst, const Point & dest);
void fillSurface(SDL_Surface *dst, const SDL_Color & color);
void fillRect(SDL_Surface *dst, const Rect & dstrect, const SDL_Color & color);
void fillSurface(SDL_Surface * dst, const SDL_Color & color);
void fillRect(SDL_Surface * dst, const Rect & dstrect, const SDL_Color & color);
void updateRect(SDL_Surface *surface, const Rect & rect);
void updateRect(SDL_Surface * surface, const Rect & rect);
void putPixelWithoutRefresh(SDL_Surface *ekran, const int & x, const int & y, const uint8_t & R, const uint8_t & G, const uint8_t & B, uint8_t A = 255);
void putPixelWithoutRefresh(SDL_Surface * ekran, const int & x, const int & y, const uint8_t & R, const uint8_t & G, const uint8_t & B, uint8_t A = 255);
void putPixelWithoutRefreshIfInSurf(SDL_Surface *ekran, const int & x, const int & y, const uint8_t & R, const uint8_t & G, const uint8_t & B, uint8_t A = 255);
SDL_Surface * verticalFlip(SDL_Surface * toRot); //vertical flip
SDL_Surface * horizontalFlip(SDL_Surface * toRot); //horizontal flip
uint32_t getPixel(SDL_Surface *surface, const int & x, const int & y, bool colorByte = false);
uint32_t getPixel(SDL_Surface * surface, const int & x, const int & y, bool colorByte = false);
bool isTransparent(SDL_Surface * srf, int x, int y); //checks if surface is transparent at given position
bool isTransparent(SDL_Surface * srf, const Point & position); //checks if surface is transparent at given position
bool isTransparent(SDL_Surface * srf, const Point & position); //checks if surface is transparent at given position
uint8_t *getPxPtr(const SDL_Surface * const &srf, const int x, const int y);
TColorPutter getPutterFor(SDL_Surface * const &dest, int incrementing); //incrementing: -1, 0, 1
TColorPutterAlpha getPutterAlphaFor(SDL_Surface * const &dest, int incrementing); //incrementing: -1, 0, 1
uint8_t * getPxPtr(const SDL_Surface * const & srf, const int x, const int y);
TColorPutter getPutterFor(SDL_Surface * const & dest, int incrementing); //incrementing: -1, 0, 1
TColorPutterAlpha getPutterAlphaFor(SDL_Surface * const & dest, int incrementing); //incrementing: -1, 0, 1
template<int bpp>
int blit8bppAlphaTo24bppT(const SDL_Surface * src, const Rect & srcRect, SDL_Surface * dst, const Point & dstPoint); //blits 8 bpp surface with alpha channel to 24 bpp surface
@ -84,8 +84,8 @@ typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_
void drawLine(SDL_Surface * sur, const Point & from, const Point & dest, const SDL_Color & color1, const SDL_Color & color2);
void drawLineDashed(SDL_Surface * sur, const Point & from, const Point & dest, const SDL_Color & color);
void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const SDL_Color &color, int depth = 1);
void drawBorder(SDL_Surface * sur, const Rect &r, const SDL_Color &color, int depth = 1);
void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const SDL_Color & color, int depth = 1);
void drawBorder(SDL_Surface * sur, const Rect & r, const SDL_Color & color, int depth = 1);
void setPlayerColor(SDL_Surface * sur, PlayerColor player); //sets correct color of flags; -1 for neutral
SDL_Surface * newSurface(int w, int h, SDL_Surface * mod); //creates new surface, with flags/format same as in surface given
@ -97,18 +97,18 @@ typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_
//scale surface to required size.
//nearest neighbour algorithm
SDL_Surface * scaleSurfaceFast(SDL_Surface *surf, int width, int height);
SDL_Surface * scaleSurfaceFast(SDL_Surface * surf, int width, int height);
// bilinear filtering. Uses fallback to scaleSurfaceFast in case of indexed surfaces
SDL_Surface * scaleSurface(SDL_Surface *surf, int width, int height);
SDL_Surface * scaleSurface(SDL_Surface * surf, int width, int height);
template<int bpp>
void convertToGrayscaleBpp( SDL_Surface * surf, const Rect & rect );
void convertToGrayscaleBpp(SDL_Surface * surf, const Rect & rect);
void convertToGrayscale(SDL_Surface * surf, const Rect & rect);
bool isResolutionSupported(const std::vector<Point> & resolutions, const Point toTest );
bool isResolutionSupported(const std::vector<Point> & resolutions, const Point toTest);
std::vector<Point> getSupportedResolutions();
std::vector<Point> getSupportedResolutions( int displayIndex);
std::vector<Point> getSupportedResolutions(int displayIndex);
void setColorKey(SDL_Surface * surface, SDL_Color color);
@ -118,13 +118,13 @@ typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_
void setDefaultColorKeyPresize(SDL_Surface * surface);
/// helper that will safely set and un-set ClipRect for SDL_Surface
class CClipRectGuard : boost::noncopyable
class CClipRectGuard: boost::noncopyable
{
SDL_Surface * surf;
Rect oldRect;
public:
CClipRectGuard(SDL_Surface * surface, const Rect & rect):
surf(surface)
CClipRectGuard(SDL_Surface * surface, const Rect & rect): surf(surface)
{
CSDL_Ext::getClipRect(surf, oldRect);
CSDL_Ext::setClipRect(surf, rect);

View File

@ -47,7 +47,7 @@ namespace Channels
static void STRONG_INLINE set(uint8_t *ptr, uint8_t value)
{
uint16_t * const pixel = (uint16_t*)ptr;
auto * const pixel = (uint16_t *)ptr;
uint8_t subpx = value >> (8 - bits);
*pixel = (*pixel & ~mask) | ((subpx << shift) & mask );
}
@ -226,7 +226,7 @@ STRONG_INLINE void ColorPutter<2, incrementPtr>::PutColor(uint8_t *&ptr, const u
if(incrementPtr == -1)
ptr -= 2;
uint16_t * const px = (uint16_t*)ptr;
auto * const px = (uint16_t *)ptr;
*px = (B>>3) + ((G>>2) << 5) + ((R>>3) << 11); //drop least significant bits of 24 bpp encoded color
if(incrementPtr == 1)

View File

@ -25,7 +25,7 @@ class CAnimation;
class CObjectList : public CIntObject
{
public:
typedef std::function<std::shared_ptr<CIntObject>(size_t)> CreateFunc;
using CreateFunc = std::function<std::shared_ptr<CIntObject>(size_t)>;
private:
CreateFunc createObject;

View File

@ -45,8 +45,8 @@ public:
class CInfoWindow : public CSimpleWindow
{
public:
typedef std::vector<std::pair<std::string, CFunctionList<void()> > > TButtonsInfo;
typedef std::vector<std::shared_ptr<CComponent>> TCompsInfo;
using TButtonsInfo = std::vector<std::pair<std::string, CFunctionList<void()>>>;
using TCompsInfo = std::vector<std::shared_ptr<CComponent>>;
QueryID ID; //for identification
std::shared_ptr<CTextBox> text;
std::vector<std::shared_ptr<CButton>> buttons;

View File

@ -52,7 +52,7 @@ enum class AimType
class DLL_LINKAGE Problem
{
public:
typedef int Severity;
using Severity = int;
enum ESeverity
{

View File

@ -15,8 +15,8 @@ VCMI_LIB_NAMESPACE_BEGIN
namespace vstd
{
typedef std::function<int64_t()> TRandI64;
typedef std::function<double()> TRand;
using TRandI64 = std::function<int64_t()>;
using TRand = std::function<double()>;
class DLL_LINKAGE RNG
{

View File

@ -36,8 +36,12 @@ public:
{
}
BattleFieldInfo(BattleField battlefield, std::string identifier)
:bonuses(), isSpecial(false), battlefield(battlefield), identifier(identifier), graphics(), icon(), iconIndex(battlefield.getNum()), impassableHexes(), name(identifier)
BattleFieldInfo(BattleField battlefield, std::string identifier):
isSpecial(false),
battlefield(battlefield),
identifier(identifier),
iconIndex(battlefield.getNum()),
name(identifier)
{
}

View File

@ -19,7 +19,7 @@ VCMI_LIB_NAMESPACE_BEGIN
class JsonNode;
typedef Bonus::BonusType BonusTypeID;
using BonusTypeID = Bonus::BonusType;
class DLL_LINKAGE CBonusType
{

View File

@ -171,7 +171,7 @@ namespace config
GUIOptions *current; // pointer to current gui options
public:
typedef std::map<std::pair<int,int>, GUIOptions > GuiOptionsMap;
using GuiOptionsMap = std::map<std::pair<int, int>, GUIOptions>;
GuiOptionsMap guiOptions;
void init();
CConfigHandler();

View File

@ -163,22 +163,18 @@ public:
}
};
typedef std::map<SlotID, CStackInstance*> TSlots;
typedef std::map<SlotID, std::pair<CreatureID, TQuantity>> TSimpleSlots;
using TSlots = std::map<SlotID, CStackInstance *>;
using TSimpleSlots = std::map<SlotID, std::pair<CreatureID, TQuantity>>;
typedef std::pair<const CCreature*, SlotID> TPairCreatureSlot;
typedef std::map<const CCreature*, SlotID> TMapCreatureSlot;
using TPairCreatureSlot = std::pair<const CCreature *, SlotID>;
using TMapCreatureSlot = std::map<const CCreature *, SlotID>;
struct DLL_LINKAGE CreatureSlotComparer
{
bool operator()(const TPairCreatureSlot & lhs, const TPairCreatureSlot & rhs);
};
typedef std::priority_queue<
TPairCreatureSlot,
std::vector<TPairCreatureSlot>,
CreatureSlotComparer
> TCreatureQueue;
using TCreatureQueue = std::priority_queue<TPairCreatureSlot, std::vector<TPairCreatureSlot>, CreatureSlotComparer>;
class IArmyDescriptor
{

View File

@ -198,10 +198,9 @@ public:
if(!h.saving)
{
for(auto i = 0; i < secSkillProbability.size(); i++)
if(secSkillProbability[i] < 0)
secSkillProbability[i] = 0;
}
for(int & i : secSkillProbability)
vstd::amax(i, 0);
}
}
EAlignment getAlignment() const;
};

View File

@ -310,7 +310,7 @@ public:
missingMods(std::move(_missingMods))
{
std::ostringstream _ss;
for(auto & m : missingMods)
for(const auto & m : missingMods)
_ss << m.first << ' ' << m.second << std::endl;
message = _ss.str();
}

View File

@ -42,7 +42,7 @@ struct DLL_LINKAGE NodeComparer
struct DLL_LINKAGE CGPathNode
{
typedef EPathfindingLayer ELayer;
using ELayer = EPathfindingLayer;
enum ENodeAction : ui8
{
@ -151,10 +151,7 @@ struct DLL_LINKAGE CGPathNode
return turns < 255;
}
typedef boost::heap::fibonacci_heap<
CGPathNode *,
boost::heap::compare<NodeComparer<CGPathNode>>
> TFibHeap;
using TFibHeap = boost::heap::fibonacci_heap<CGPathNode *, boost::heap::compare<NodeComparer<CGPathNode>>>;
TFibHeap::handle_type pqHandle;
TFibHeap* pq;
@ -173,7 +170,7 @@ struct DLL_LINKAGE CGPath
struct DLL_LINKAGE CPathsInfo
{
typedef EPathfindingLayer ELayer;
using ELayer = EPathfindingLayer;
const CGHeroInstance * hero;
int3 hpos;
@ -484,7 +481,7 @@ public:
private:
CGameState * gamestate;
typedef EPathfindingLayer ELayer;
using ELayer = EPathfindingLayer;
std::shared_ptr<PathfinderConfig> config;

View File

@ -14,11 +14,11 @@
VCMI_LIB_NAMESPACE_BEGIN
typedef std::mt19937 TGenerator;
typedef std::uniform_int_distribution<int> TIntDist;
typedef std::uniform_int_distribution<int64_t> TInt64Dist;
typedef std::uniform_real_distribution<double> TRealDist;
typedef std::function<int()> TRandI;
using TGenerator = std::mt19937;
using TIntDist = std::uniform_int_distribution<int>;
using TInt64Dist = std::uniform_int_distribution<int64_t>;
using TRealDist = std::uniform_real_distribution<double>;
using TRandI = std::function<int()>;
/// The random generator randomly generates integers and real numbers("doubles") between
/// a given range. This is a header only class and mainly a wrapper for

View File

@ -121,7 +121,7 @@ public:
if(extSlot == SlotID::COMMANDER_SLOT_PLACEHOLDER)
{
auto hero = dynamic_cast<const CGHeroInstance *>(army);
const auto * hero = dynamic_cast<const CGHeroInstance *>(army);
assert(hero);
base = hero->commander;
}

View File

@ -17,7 +17,7 @@ VCMI_LIB_NAMESPACE_BEGIN
class DLL_LINKAGE CThreadHelper
{
public:
typedef std::function<void()> Task;
using Task = std::function<void()>;
CThreadHelper(std::vector<std::function<void()> > *Tasks, int Threads);
void run();
private:

View File

@ -43,7 +43,7 @@ class DLL_LINKAGE CBuilding
std::string identifier;
public:
typedef LogicalExpression<BuildingID> TRequired;
using TRequired = LogicalExpression<BuildingID>;
CTown * town; // town this building belongs to
TResources resources;

View File

@ -1325,11 +1325,11 @@ enum class EHealPower : ui8
};
// Typedef declarations
typedef si64 TExpType;
typedef si32 TBonusSubtype;
typedef si32 TQuantity;
using TExpType = si64;
using TBonusSubtype = si32;
using TQuantity = si32;
typedef int TRmgTemplateZoneId;
using TRmgTemplateZoneId = int;
#undef ID_LIKE_CLASS_COMMON
#undef ID_LIKE_OPERATORS

View File

@ -25,14 +25,14 @@ class IPropagator;
class IUpdater;
class BonusList;
typedef std::shared_ptr<BonusList> TBonusListPtr;
typedef std::shared_ptr<const BonusList> TConstBonusListPtr;
typedef std::shared_ptr<ILimiter> TLimiterPtr;
typedef std::shared_ptr<IPropagator> TPropagatorPtr;
typedef std::shared_ptr<IUpdater> TUpdaterPtr;
typedef std::set<CBonusSystemNode*> TNodes;
typedef std::set<const CBonusSystemNode*> TCNodes;
typedef std::vector<CBonusSystemNode *> TNodesVector;
using TBonusListPtr = std::shared_ptr<BonusList>;
using TConstBonusListPtr = std::shared_ptr<const BonusList>;
using TLimiterPtr = std::shared_ptr<ILimiter>;
using TPropagatorPtr = std::shared_ptr<IPropagator>;
using TUpdaterPtr = std::shared_ptr<IUpdater>;
using TNodes = std::set<CBonusSystemNode *>;
using TCNodes = std::set<const CBonusSystemNode *>;
using TNodesVector = std::vector<CBonusSystemNode *>;
class CSelector : std::function<bool(const Bonus*)>
{
@ -548,7 +548,7 @@ struct DLL_LINKAGE BonusParams {
bool isConverted;
Bonus::BonusType type = Bonus::NONE;
TBonusSubtype subtype = -1;
std::string subtypeStr = "";
std::string subtypeStr;
bool subtypeRelevant = false;
Bonus::ValueType valueType = Bonus::BASE_NUMBER;
bool valueTypeRelevant = false;
@ -569,7 +569,7 @@ private:
class DLL_LINKAGE BonusList
{
public:
typedef std::vector<std::shared_ptr<Bonus>> TInternalContainer;
using TInternalContainer = std::vector<std::shared_ptr<Bonus>>;
private:
TInternalContainer bonuses;
@ -577,11 +577,11 @@ private:
void changed() const;
public:
typedef TInternalContainer::const_reference const_reference;
typedef TInternalContainer::value_type value_type;
using const_reference = TInternalContainer::const_reference;
using value_type = TInternalContainer::value_type;
typedef TInternalContainer::const_iterator const_iterator;
typedef TInternalContainer::iterator iterator;
using const_iterator = TInternalContainer::const_iterator;
using iterator = TInternalContainer::iterator;
BonusList(bool BelongsToTree = false);
BonusList(const BonusList &bonusList);
@ -628,9 +628,8 @@ public:
void remove_if(Predicate pred)
{
BonusList newList;
for (ui32 i = 0; i < bonuses.size(); i++)
for(const auto & b : bonuses)
{
auto b = bonuses[i];
if (!pred(b.get()))
newList.push_back(b);
}

View File

@ -97,7 +97,7 @@ public:
objects.push_back(object);
for(auto type_name : getTypeNames())
for(const auto & type_name : getTypeNames())
registerObject(scope, type_name, name, object->getIndex());
}
@ -108,7 +108,7 @@ public:
assert(objects[index] == nullptr); // ensure that this id was not loaded before
objects[index] = object;
for(auto type_name : getTypeNames())
for(const auto & type_name : getTypeNames())
registerObject(scope, type_name, name, object->getIndex());
}

View File

@ -116,10 +116,10 @@ namespace Validation
std::string makeErrorMessage(const std::string &message);
};
typedef std::function<std::string(const JsonNode &)> TFormatValidator;
typedef std::unordered_map<std::string, TFormatValidator> TFormatMap;
typedef std::function<std::string(ValidationData &, const JsonNode &, const JsonNode &, const JsonNode &)> TFieldValidator;
typedef std::unordered_map<std::string, TFieldValidator> TValidatorMap;
using TFormatValidator = std::function<std::string(const JsonNode &)>;
using TFormatMap = std::unordered_map<std::string, TFormatValidator>;
using TFieldValidator = std::function<std::string(ValidationData &, const JsonNode &, const JsonNode &, const JsonNode &)>;
using TValidatorMap = std::unordered_map<std::string, TFieldValidator>;
/// map of known fields in schema
const TValidatorMap & getKnownFieldsFor(JsonNode::JsonType type);

View File

@ -13,8 +13,8 @@
VCMI_LIB_NAMESPACE_BEGIN
class JsonNode;
typedef std::map <std::string, JsonNode> JsonMap;
typedef std::vector <JsonNode> JsonVector;
using JsonMap = std::map<std::string, JsonNode>;
using JsonVector = std::vector<JsonNode>;
struct Bonus;
class CSelector;

View File

@ -30,19 +30,14 @@ namespace LogicalExpressionDetail
};
template<EOperations tag> class Element;
typedef Element<ANY_OF> OperatorAny;
typedef Element<ALL_OF> OperatorAll;
typedef Element<NONE_OF> OperatorNone;
using OperatorAny = Element<ANY_OF>;
using OperatorAll = Element<ALL_OF>;
using OperatorNone = Element<NONE_OF>;
typedef ContainedClass Value;
using Value = ContainedClass;
/// Variant that contains all possible elements from logical expression
typedef std::variant<
OperatorAll,
OperatorAny,
OperatorNone,
Value
> Variant;
using Variant = std::variant<OperatorAll, OperatorAny, OperatorNone, Value>;
/// Variant element, contains list of expressions to which operation "tag" should be applied
template<EOperations tag>
@ -73,7 +68,7 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class TestVisitor
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
std::function<bool(const typename Base::Value &)> classTest;
@ -119,7 +114,7 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class PossibilityVisitor
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
protected:
std::function<bool(const typename Base::Value &)> satisfiabilityTest;
@ -167,7 +162,7 @@ namespace LogicalExpressionDetail
template <typename ContainedClass>
class SatisfiabilityVisitor : public PossibilityVisitor<ContainedClass>
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
public:
SatisfiabilityVisitor(std::function<bool (const typename Base::Value &)> satisfiabilityTest,
@ -202,7 +197,7 @@ namespace LogicalExpressionDetail
template <typename ContainedClass>
class FalsifiabilityVisitor : public PossibilityVisitor<ContainedClass>
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
public:
FalsifiabilityVisitor(std::function<bool (const typename Base::Value &)> satisfiabilityTest,
@ -238,8 +233,8 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class CandidatesVisitor
{
typedef ExpressionBase<ContainedClass> Base;
typedef std::vector<typename Base::Value> TValueList;
using Base = ExpressionBase<ContainedClass>;
using TValueList = std::vector<typename Base::Value>;
TestVisitor<ContainedClass> classTest;
@ -288,7 +283,7 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class ForEachVisitor
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
std::function<typename Base::Variant(const typename Base::Value &)> visitor;
@ -315,7 +310,7 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class MinimizingVisitor
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
public:
typename Base::Variant operator()(const typename Base::Value & element) const
@ -360,7 +355,7 @@ namespace LogicalExpressionDetail
template <typename ContainedClass>
class Reader
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
std::function<typename Base::Value(const JsonNode &)> classParser;
@ -400,7 +395,7 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class Writer
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
std::function<JsonNode(const typename Base::Value &)> classPrinter;
@ -445,7 +440,7 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class Printer
{
typedef ExpressionBase<ContainedClass> Base;
using Base = ExpressionBase<ContainedClass>;
std::function<std::string(const typename Base::Value &)> classPrinter;
std::unique_ptr<TestVisitor<ContainedClass>> statusTest;
@ -510,30 +505,27 @@ namespace LogicalExpressionDetail
template<typename ContainedClass>
class LogicalExpression
{
typedef LogicalExpressionDetail::ExpressionBase<ContainedClass> Base;
using Base = LogicalExpressionDetail::ExpressionBase<ContainedClass>;
public:
/// Type of values used in expressions, same as ContainedClass
typedef typename Base::Value Value;
using Value = typename Base::Value;
/// Operators for use in expressions, all include vectors with operands
typedef typename Base::OperatorAny OperatorAny;
typedef typename Base::OperatorAll OperatorAll;
typedef typename Base::OperatorNone OperatorNone;
using OperatorAny = typename Base::OperatorAny;
using OperatorAll = typename Base::OperatorAll;
using OperatorNone = typename Base::OperatorNone;
/// one expression entry
typedef typename Base::Variant Variant;
using Variant = typename Base::Variant;
private:
Variant data;
public:
/// Base constructor
LogicalExpression()
{}
LogicalExpression() = default;
/// Constructor from variant or (implicitly) from Operator* types
LogicalExpression(const Variant & data):
data(data)
{
}
LogicalExpression(const Variant & data): data(data) {}
/// Constructor that receives JsonNode as input and function that can parse Value instances
LogicalExpression(const JsonNode & input, std::function<Value(const JsonNode &)> parser)

View File

@ -161,8 +161,8 @@ public:
ResourceSet & operator=(const TResource &rhs)
{
for(int i = 0; i < container.size(); i++)
container.at(i) = rhs;
for(int & i : container)
i = rhs;
return *this;
}

View File

@ -76,7 +76,7 @@ struct DLL_LINKAGE StartInfo
EMode mode;
ui8 difficulty; //0=easy; 4=impossible
typedef std::map<PlayerColor, PlayerSettings> TPlayerInfos;
using TPlayerInfos = std::map<PlayerColor, PlayerSettings>;
TPlayerInfos playerInfos; //color indexed
ui32 seedToBeUsed; //0 if not sure (client requests server to decide, will be send in reply pack)
@ -84,7 +84,7 @@ struct DLL_LINKAGE StartInfo
ui32 mapfileChecksum; //0 if not relevant
ui8 turnTime; //in minutes, 0=unlimited
std::string mapname; // empty for random map, otherwise name of the map or savegame
bool createRandomMap() const { return mapGenOptions.get() != nullptr; }
bool createRandomMap() const { return mapGenOptions != nullptr; }
std::shared_ptr<CMapGenOptions> mapGenOptions;
std::shared_ptr<CCampaignState> campState;

View File

@ -114,7 +114,7 @@ namespace vstd
: unlock_guard<Mutex, detail::unlock_shared_policy<Mutex> >();
}
typedef unlock_guard<boost::shared_mutex, detail::unlock_shared_policy<boost::shared_mutex> > unlock_shared_guard;
using unlock_shared_guard = unlock_guard<boost::shared_mutex, detail::unlock_shared_policy<boost::shared_mutex>>;
}
VCMI_LIB_NAMESPACE_END

View File

@ -21,8 +21,8 @@ class JsonNode;
/// Helper class that allows generation of a ISimpleResourceLoader entry out of Json config(s)
class DLL_LINKAGE CFilesystemGenerator
{
typedef std::function<void(const std::string &, const JsonNode &)> TLoadFunctor;
typedef std::map<std::string, TLoadFunctor> TLoadFunctorMap;
using TLoadFunctor = std::function<void(const std::string &, const JsonNode &)>;
using TLoadFunctorMap = std::map<std::string, TLoadFunctor>;
CFilesystemList * filesystem;
std::string prefix;

View File

@ -241,7 +241,7 @@ public:
}
};
typedef std::shared_ptr<AObjectTypeHandler> TObjectTypeHandler;
using TObjectTypeHandler = std::shared_ptr<AObjectTypeHandler>;
/// Class responsible for creation of adventure map objects of specific type
class DLL_LINKAGE ObjectClass
@ -283,7 +283,7 @@ class DLL_LINKAGE CObjectClassesHandler : public IHandlerBase
std::map<std::string, std::function<TObjectTypeHandler()> > handlerConstructors;
/// container with H3 templates, used only during loading, no need to serialize it
typedef std::multimap<std::pair<si32, si32>, std::shared_ptr<const ObjectTemplate>> TTemplatesContainer;
using TTemplatesContainer = std::multimap<std::pair<si32, si32>, std::shared_ptr<const ObjectTemplate>>;
TTemplatesContainer legacyTemplates;
TObjectTypeHandler loadSubObjectFromJson(const std::string & scope, const std::string & identifier, const JsonNode & entry, ObjectClass * obj, size_t index);

View File

@ -197,7 +197,7 @@ struct BankConfig
}
};
typedef std::vector<std::pair<ui8, IObjectInfo::CArmyStructure>> TPossibleGuards;
using TPossibleGuards = std::vector<std::pair<ui8, IObjectInfo::CArmyStructure>>;
template <typename T>
struct DLL_LINKAGE PossibleReward

View File

@ -189,11 +189,9 @@ protected:
class DLL_LINKAGE CGArtifact : public CArmedInstance
{
public:
CArtifactInstance *storedArtifact;
CArtifactInstance * storedArtifact = nullptr;
std::string message;
CGArtifact() : CArmedInstance() {storedArtifact = nullptr;};
void onHeroVisit(const CGHeroInstance * h) const override;
void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;

View File

@ -160,7 +160,7 @@ struct DLL_LINKAGE EventCondition
}
};
typedef LogicalExpression<EventCondition> EventExpression;
using EventExpression = LogicalExpression<EventCondition>;
struct DLL_LINKAGE EventEffect
{

View File

@ -46,7 +46,7 @@ public:
void setUndoCallback(std::function<void(bool, bool)> functor);
private:
typedef std::list<std::unique_ptr<CMapOperation> > TStack;
using TStack = std::list<std::unique_ptr<CMapOperation>>;
void doOperation(TStack & fromStack, TStack & toStack, bool doUndo);
const CMapOperation * peek(const TStack & stack) const;

View File

@ -212,7 +212,7 @@ struct DLL_LINKAGE TerrainViewPattern
class DLL_LINKAGE CTerrainViewPatternConfig : public boost::noncopyable
{
public:
typedef std::vector<TerrainViewPattern> TVPVector;
using TVPVector = std::vector<TerrainViewPattern>;
CTerrainViewPatternConfig();

View File

@ -26,7 +26,7 @@ class RmgMap;
class CMap;
class Zone;
typedef std::vector<JsonNode> JsonVector;
using JsonVector = std::vector<JsonNode>;
/// The map generator creates a map randomly.
class DLL_LINKAGE CMapGenerator: public Load::Progress

View File

@ -22,10 +22,10 @@ class CRandomGenerator;
class RmgMap;
class Zone;
typedef std::vector<std::pair<TRmgTemplateZoneId, std::shared_ptr<Zone>>> TZoneVector;
typedef std::map<TRmgTemplateZoneId, std::shared_ptr<Zone>> TZoneMap;
typedef std::map<std::shared_ptr<Zone>, float3> TForceVector;
typedef std::map<std::shared_ptr<Zone>, float> TDistanceVector;
using TZoneVector = std::vector<std::pair<TRmgTemplateZoneId, std::shared_ptr<Zone>>>;
using TZoneMap = std::map<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
using TForceVector = std::map<std::shared_ptr<Zone>, float3>;
using TDistanceVector = std::map<std::shared_ptr<Zone>, float>;
class CZonePlacer
{

View File

@ -30,7 +30,7 @@ public:
protected:
void collectNeighbourZones();
protected:
std::vector<rmg::ZoneConnection> dConnections, dCompleted;
std::map<TRmgTemplateZoneId, rmg::Tileset> dNeighbourZones;

View File

@ -20,7 +20,7 @@ class CGObjectInstance;
class ObjectTemplate;
class CGCreature;
typedef std::pair<int3, float> TDistance;
using TDistance = std::pair<int3, float>;
struct DistanceMaximizeFunctor
{
bool operator()(const TDistance & lhs, const TDistance & rhs) const
@ -38,11 +38,10 @@ public:
WEIGHT = 0x00000001,
DISTANCE = 0x00000010
};
public:
MODIFICATOR(ObjectManager);
void process() override;
void init() override;

View File

@ -43,9 +43,9 @@ public:
protected:
int getWeightedObjects(const int3 & tile, const CMap * map, CRandomGenerator & rand, std::list<rmg::Object> & allObjects, std::vector<std::pair<rmg::Object*, int3>> & weightedObjects);
typedef std::vector<std::shared_ptr<const ObjectTemplate>> ObstacleVector;
using ObstacleVector = std::vector<std::shared_ptr<const ObjectTemplate>>;
std::map<int, ObstacleVector> obstaclesBySize;
typedef std::pair<int, ObstacleVector> ObstaclePair;
using ObstaclePair = std::pair<int, ObstacleVector>;
std::vector<ObstaclePair> possibleObstacles;
};

View File

@ -72,7 +72,7 @@ public:
private:
void assertOnMap(const int3 &tile) const; //throws
private:
Zones zones;
std::map<FactionID, ui32> zonesPerFaction;

View File

@ -31,7 +31,7 @@ public:
protected:
bool createRoad(const int3 & dst);
void drawRoads(bool secondary = false); //actually updates tiles
protected:
rmg::Tileset roadNodes; //tiles to be connected with roads
rmg::Area roads; //all tiles with roads

View File

@ -32,9 +32,8 @@ protected:
void placeTowns(ObjectManager & manager);
bool placeMines(ObjectManager & manager);
int3 placeMainTown(ObjectManager & manager, CGTownInstance & town);
protected:
int totalTowns = 0;
};

View File

@ -56,9 +56,8 @@ protected:
ObjectInfo * getRandomObject(ui32 desiredValue, ui32 currentValue, ui32 maxValue, bool allowLargeObjects);
std::vector<ObjectInfo*> prepareTreasurePile(const CTreasureInfo & treasureInfo);
rmg::Object constructTreasurePile(const std::vector<ObjectInfo*> & treasureInfos, bool densePlacement = false);
protected:
protected:
std::vector<ObjectInfo> possibleObjects;
int minGuardedValue = 0;

View File

@ -29,7 +29,7 @@ public:
protected:
void createWater(EWaterContent::EWaterContent waterContent);
protected:
rmg::Area noWaterArea, waterArea;
TRmgTemplateZoneId waterZoneId;

View File

@ -49,8 +49,8 @@ protected:
bool placeShipyard(Zone & land, const Lake & lake, si32 guard, RouteInfo & info);
bool placeBoat(Zone & land, const Lake & lake, RouteInfo & info);
protected:
protected:
std::vector<Lake> lakes; //disconnected parts of zone. Used to work with water zones
std::map<int3, int> lakeMap; //map tile on lakeId which is position of lake in lakes array +1
};

View File

@ -98,7 +98,7 @@ class DLL_LINKAGE BinaryDeserializer : public CLoaderBase
}
else
{
auto hero = dynamic_cast<CGHeroInstance *>(armedObj);
auto * hero = dynamic_cast<CGHeroInstance *>(armedObj);
assert(hero);
assert(hero->commander);
data = hero->commander;
@ -158,7 +158,7 @@ class DLL_LINKAGE BinaryDeserializer : public CLoaderBase
public:
const std::type_info * loadPtr(CLoaderBase &ar, void *data, ui32 pid) const override //data is pointer to the ACTUAL POINTER
{
BinaryDeserializer &s = static_cast<BinaryDeserializer&>(ar);
auto & s = static_cast<BinaryDeserializer &>(ar);
T *&ptr = *static_cast<T**>(data);
//create new object under pointer
@ -217,7 +217,7 @@ public:
assert( fileVersion != 0 );
////that const cast is evil because it allows to implicitly overwrite const objects when deserializing
typedef typename std::remove_const<T>::type nonConstT;
nonConstT &hlp = const_cast<nonConstT&>(data);
auto & hlp = const_cast<nonConstT &>(data);
hlp.serialize(*this,fileVersion);
}
template < typename T, typename std::enable_if < std::is_array<T>::value, int >::type = 0 >
@ -301,7 +301,7 @@ public:
if(smartPointerSerialization)
{
load( pid ); //get the id
std::map<ui32, void*>::iterator i = loadedPointers.find(pid); //lookup
auto i = loadedPointers.find(pid); //lookup
if(i != loadedPointers.end())
{
@ -327,7 +327,7 @@ public:
}
else
{
auto app = applier.getApplier(tid);
auto * app = applier.getApplier(tid);
if(app == nullptr)
{
logGlobal->error("load %d %d - no loader exists", tid, pid);

View File

@ -100,7 +100,7 @@ class DLL_LINKAGE BinarySerializer : public CSaverBase
public:
void savePtr(CSaverBase &ar, const void *data) const override
{
BinarySerializer &s = static_cast<BinarySerializer&>(ar);
auto & s = static_cast<BinarySerializer &>(ar);
const T *ptr = static_cast<const T*>(data);
//T is most derived known type, it's time to call actual serialize
@ -210,7 +210,7 @@ public:
// We might have an object that has multiple inheritance and store it via the non-first base pointer.
// Therefore, all pointers need to be normalized to the actual object address.
auto actualPointer = typeList.castToMostDerived(data);
std::map<const void*,ui32>::iterator i = savedPointers.find(actualPointer);
auto i = savedPointers.find(actualPointer);
if(i != savedPointers.end())
{
//this pointer has been already serialized - write only it's id
@ -275,28 +275,28 @@ public:
template <typename T>
void save(const std::set<T> &data)
{
std::set<T> &d = const_cast<std::set<T> &>(data);
auto & d = const_cast<std::set<T> &>(data);
ui32 length = (ui32)d.size();
save(length);
for(typename std::set<T>::iterator i=d.begin();i!=d.end();i++)
for(auto i = d.begin(); i != d.end(); i++)
save(*i);
}
template <typename T, typename U>
void save(const std::unordered_set<T, U> &data)
{
std::unordered_set<T, U> &d = const_cast<std::unordered_set<T, U> &>(data);
auto & d = const_cast<std::unordered_set<T, U> &>(data);
ui32 length = (ui32)d.size();
*this & length;
for(typename std::unordered_set<T, U>::iterator i=d.begin();i!=d.end();i++)
for(auto i = d.begin(); i != d.end(); i++)
save(*i);
}
template <typename T>
void save(const std::list<T> &data)
{
std::list<T> &d = const_cast<std::list<T> &>(data);
auto & d = const_cast<std::list<T> &>(data);
ui32 length = (ui32)d.size();
*this & length;
for(typename std::list<T>::iterator i=d.begin();i!=d.end();i++)
for(auto i = d.begin(); i != d.end(); i++)
save(*i);
}
void save(const std::string &data)
@ -314,7 +314,7 @@ public:
void save(const std::map<T1,T2> &data)
{
*this & ui32(data.size());
for(typename std::map<T1,T2>::const_iterator i=data.begin();i!=data.end();i++)
for(auto i = data.begin(); i != data.end(); i++)
{
save(i->first);
save(i->second);
@ -324,7 +324,7 @@ public:
void save(const std::multimap<T1, T2> &data)
{
*this & ui32(data.size());
for(typename std::map<T1, T2>::const_iterator i = data.begin(); i != data.end(); i++)
for(auto i = data.begin(); i != data.end(); i++)
{
save(i->first);
save(i->second);

View File

@ -76,7 +76,7 @@ class DLL_LINKAGE CSerializer
vectors[&typeid(T)] = VectorizedObjectInfo<T, U>(Vector, idRetriever);
}
typedef std::map<const std::type_info *, std::any, TypeComparer> TTypeVecMap;
using TTypeVecMap = std::map<const std::type_info *, std::any, TypeComparer>;
TTypeVecMap vectors; //entry must be a pointer to vector containing pointers to the objects of key type
public:
@ -94,7 +94,7 @@ public:
myType = &typeid(T);
TTypeVecMap::iterator i = vectors.find(myType);
auto i = vectors.find(myType);
if(i == vectors.end())
return nullptr;
else
@ -134,8 +134,8 @@ public:
template<class S, class T>
struct is_serializeable
{
typedef char (&Yes)[1];
typedef char (&No)[2];
using Yes = char (&)[1];
using No = char (&)[2];
template<class U>
static Yes test(U * data, S* arg1 = 0,
@ -149,42 +149,42 @@ struct is_serializeable
template <typename T> //metafunction returning CGObjectInstance if T is its derivate or T elsewise
struct VectorizedTypeFor
{
typedef typename
using type = typename
//if
boost::mpl::eval_if<std::is_same<CGHeroInstance,T>,
boost::mpl::eval_if<std::is_same<CGHeroInstance, T>,
boost::mpl::identity<CGHeroInstance>,
//else if
boost::mpl::eval_if<std::is_base_of<CGObjectInstance,T>,
boost::mpl::eval_if<std::is_base_of<CGObjectInstance, T>,
boost::mpl::identity<CGObjectInstance>,
//else
boost::mpl::identity<T>
> >::type type;
>>::type;
};
template <typename U>
struct VectorizedIDType
{
typedef typename
using type = typename
//if
boost::mpl::eval_if<std::is_same<CArtifact,U>,
boost::mpl::eval_if<std::is_same<CArtifact, U>,
boost::mpl::identity<ArtifactID>,
//else if
boost::mpl::eval_if<std::is_same<CCreature,U>,
boost::mpl::eval_if<std::is_same<CCreature, U>,
boost::mpl::identity<CreatureID>,
//else if
boost::mpl::eval_if<std::is_same<CHero,U>,
boost::mpl::eval_if<std::is_same<CHero, U>,
boost::mpl::identity<HeroTypeID>,
//else if
boost::mpl::eval_if<std::is_same<CArtifactInstance,U>,
boost::mpl::eval_if<std::is_same<CArtifactInstance, U>,
boost::mpl::identity<ArtifactInstanceID>,
//else if
boost::mpl::eval_if<std::is_same<CGHeroInstance,U>,
boost::mpl::eval_if<std::is_same<CGHeroInstance, U>,
boost::mpl::identity<HeroTypeID>,
//else if
boost::mpl::eval_if<std::is_base_of<CGObjectInstance,U>,
boost::mpl::eval_if<std::is_base_of<CGObjectInstance, U>,
boost::mpl::identity<ObjectInstanceID>,
//else
boost::mpl::identity<si32>
> > > > > >::type type;
>>>>>>::type;
};
/// Base class for deserializers

View File

@ -66,17 +66,18 @@ class DLL_LINKAGE CTypeList: public boost::noncopyable
{
//public:
struct TypeDescriptor;
typedef std::shared_ptr<TypeDescriptor> TypeInfoPtr;
typedef std::weak_ptr<TypeDescriptor> WeakTypeInfoPtr;
using TypeInfoPtr = std::shared_ptr<TypeDescriptor>;
using WeakTypeInfoPtr = std::weak_ptr<TypeDescriptor>;
struct TypeDescriptor
{
ui16 typeID;
const char *name;
std::vector<WeakTypeInfoPtr> children, parents;
};
typedef boost::shared_mutex TMutex;
typedef boost::unique_lock<TMutex> TUniqueLock;
typedef boost::shared_lock<TMutex> TSharedLock;
using TMutex = boost::shared_mutex;
using TUniqueLock = boost::unique_lock<TMutex>;
using TSharedLock = boost::shared_lock<TMutex>;
private:
mutable TMutex mx;
@ -103,7 +104,7 @@ private:
if(!casters.count(castingPair))
THROW_FORMAT("Cannot find caster for conversion %s -> %s which is needed to cast %s -> %s", from->name % to->name % fromArg->name() % toArg->name());
auto &caster = casters.at(castingPair);
const auto & caster = casters.at(castingPair);
ptr = (*caster.*CastingFunction)(ptr); //Why does unique_ptr not have operator->* ..?
}
@ -150,7 +151,7 @@ public:
template<typename TInput>
void * castToMostDerived(const TInput * inputPtr) const
{
auto &baseType = typeid(typename std::remove_cv<TInput>::type);
const auto & baseType = typeid(typename std::remove_cv<TInput>::type);
auto derivedType = getTypeInfo(inputPtr);
if (strcmp(baseType.name(), derivedType->name()) == 0)
@ -166,7 +167,7 @@ public:
template<typename TInput>
std::any castSharedToMostDerived(const std::shared_ptr<TInput> inputPtr) const
{
auto &baseType = typeid(typename std::remove_cv<TInput>::type);
const auto & baseType = typeid(typename std::remove_cv<TInput>::type);
auto derivedType = getTypeInfo(inputPtr.get());
if (!strcmp(baseType.name(), derivedType->name()))

View File

@ -14,8 +14,8 @@
#if BOOST_VERSION >= 107000 // Boost version >= 1.70
#include <boost/asio.hpp>
typedef boost::asio::basic_stream_socket < boost::asio::ip::tcp > TSocket;
typedef boost::asio::basic_socket_acceptor < boost::asio::ip::tcp > TAcceptor;
using TSocket = boost::asio::basic_stream_socket<boost::asio::ip::tcp>;
using TAcceptor = boost::asio::basic_socket_acceptor<boost::asio::ip::tcp>;
#else
namespace boost
{

View File

@ -461,7 +461,7 @@ private:
void doSerializeInternal(const std::string & fieldName, VType & value, const std::optional<DVType> & defaultValue, Args... args)
{
const std::optional<IType> tempDefault = defaultValue ? std::optional<IType>(static_cast<IType>(defaultValue.value())) : std::nullopt;
IType temp = static_cast<IType>(value);
auto temp = static_cast<IType>(value);
serializeInternal(fieldName, temp, tempDefault, args...);
@ -476,7 +476,7 @@ private:
{
if(value)
{
IType temp = static_cast<IType>(value.value());
auto temp = static_cast<IType>(value.value());
pushField(fieldName);
serializeInternal(temp, args...);
pop();
@ -518,7 +518,7 @@ void JsonArraySerializer::syncSize(Container & c, JsonNode::JsonType type)
template <typename T>
void JsonArraySerializer::serializeInt(const size_t index, T & value)
{
int64_t temp = static_cast<int64_t>(value);
auto temp = static_cast<int64_t>(value);
serializeInt64(index, temp);

View File

@ -92,8 +92,8 @@ public:
}
};
typedef AnimationItem TAnimation;
typedef std::vector<TAnimation> TAnimationQueue;
using TAnimation = AnimationItem;
using TAnimationQueue = std::vector<TAnimation>;
struct DLL_LINKAGE AnimationInfo
{

View File

@ -34,13 +34,13 @@ PACKED_STRUCT_BEGIN struct unaligned_Uint32 { ui32 val; } PACKED_STRUCT_END;
static inline ui16 read_unaligned_u16(const void *p)
{
const struct unaligned_Uint16 *v = reinterpret_cast<const struct unaligned_Uint16 *>(p);
const auto * v = reinterpret_cast<const struct unaligned_Uint16 *>(p);
return v->val;
}
static inline ui32 read_unaligned_u32(const void *p)
{
const struct unaligned_Uint32 *v = reinterpret_cast<const struct unaligned_Uint32 *>(p);
const auto * v = reinterpret_cast<const struct unaligned_Uint32 *>(p);
return v->val;
}

View File

@ -31,7 +31,7 @@ struct Gens : Gens<N-1, N-1, S...> {};
template<int ...S>
struct Gens<0, S...>
{
typedef Seq<S...> type;
using type = Seq<S...>;
};
template <typename R, typename ... Args>

View File

@ -100,7 +100,7 @@ public:
return;
}
UData * ptr = static_cast<UData *>(raw);
auto * ptr = static_cast<UData *>(raw);
*ptr = value;
luaL_getmetatable(L, KEY);

View File

@ -79,8 +79,8 @@ public:
struct CasualtiesAfterBattle
{
typedef std::pair<StackLocation, int> TStackAndItsNewCount;
typedef std::map<CreatureID, TQuantity> TSummoned;
using TStackAndItsNewCount = std::pair<StackLocation, int>;
using TSummoned = std::map<CreatureID, TQuantity>;
enum {ERASE = -1};
const CArmedInstance * army;
std::vector<TStackAndItsNewCount> newStackCounts;

View File

@ -26,7 +26,7 @@ class CObjectVisitQuery;
class CQuery;
class Queries;
typedef std::shared_ptr<CQuery> QueryPtr;
using QueryPtr = std::shared_ptr<CQuery>;
// This class represents any kind of prolonged interaction that may need to do something special after it is over.
// It does not necessarily has to be "query" requiring player action, it can be also used internally within server.