Replace typedef by using.

This commit is contained in:
Jarod42 2023-08-07 01:18:19 +02:00 committed by Joris Dauphin
parent c7c66dfcfd
commit 77e3f63bb8
23 changed files with 50 additions and 52 deletions

View file

@ -120,7 +120,7 @@ static int CompareGr(int a, int b) { return a > b; }
static int CompareLeEq(int a, int b) { return a <= b; } static int CompareLeEq(int a, int b) { return a <= b; }
static int CompareLe(int a, int b) { return a < b; } static int CompareLe(int a, int b) { return a < b; }
typedef int (*CompareFunction)(int, int); using CompareFunction = int (*)(int, int);
/** /**
** Returns a function pointer to the comparison function ** Returns a function pointer to the comparison function

View file

@ -166,7 +166,7 @@ public:
bool Instant; /// true to ignore TimeCost bool Instant; /// true to ignore TimeCost
}; };
typedef COrder *COrderPtr; using COrderPtr = COrder *;
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------

View file

@ -44,7 +44,7 @@ public:
virtual void Init(const char *s, lua_State *l); virtual void Init(const char *s, lua_State *l);
private: private:
typedef bool BinOpFunc(int lhs, int rhs); using BinOpFunc = bool (int lhs, int rhs);
private: private:
std::string leftVar; std::string leftVar;

View file

@ -34,7 +34,7 @@
#include <stdint.h> #include <stdint.h>
typedef uint32_t IntColor; // Uint32 in SDL using IntColor = uint32_t; // Uint32 in SDL
struct SDL_Color; struct SDL_Color;
struct lua_State; struct lua_State;

View file

@ -126,7 +126,7 @@ extern void CommandSharedVision(int player, bool state, int opponent);
/** /**
** Unit references over network, or for memory saving. ** Unit references over network, or for memory saving.
*/ */
typedef unsigned short UnitRef; using UnitRef = unsigned short;
/// Send stop command /// Send stop command
extern void SendCommandStopUnit(CUnit &unit); extern void SendCommandStopUnit(CUnit &unit);

View file

@ -82,7 +82,7 @@ enum ButtonCmd {
}; };
class ButtonAction; class ButtonAction;
typedef bool (*ButtonCheckFunc)(const CUnit &, const ButtonAction &); using ButtonCheckFunc = bool (*)(const CUnit &, const ButtonAction &);
/// Action of button /// Action of button
class ButtonAction class ButtonAction

View file

@ -35,7 +35,7 @@
#include <utility> #include <utility>
#include <variant> #include <variant>
typedef int lua_Object; // from tolua++.h using lua_Object = int; // from tolua++.h
struct lua_State; struct lua_State;
class LuaCallback class LuaCallback

View file

@ -300,7 +300,7 @@ extern int ReplayRevealMap;
// in map_fog.c // in map_fog.c
// //
/// Function to (un)mark the vision table. /// Function to (un)mark the vision table.
typedef void MapMarkerFunc(const CPlayer &player, const unsigned int index); using MapMarkerFunc = void(const CPlayer &player, const unsigned int index);
/// Filter map flags through fog /// Filter map flags through fog
extern int MapFogFilterFlags(CPlayer &player, const Vec2i &pos, int mask); extern int MapFogFilterFlags(CPlayer &player, const Vec2i &pos, int mask);
@ -383,7 +383,7 @@ extern bool UnitCanBeAt(const CUnit &unit, const Vec2i &pos);
extern void PreprocessMap(); extern void PreprocessMap();
// in unit.c // in unit.c
//typedef void MapClearField(const Vec2i &tilePos); //using MapClearField = void(const Vec2i &tilePos);
/// Mark on vision table the Sight of the unit. /// Mark on vision table the Sight of the unit.
void MapMarkUnitSight(CUnit &unit); void MapMarkUnitSight(CUnit &unit);

View file

@ -73,9 +73,9 @@
(int)(((ad) >> 8) & 0xff), (int)((ad) & 0xff) (int)(((ad) >> 8) & 0xff), (int)((ad) & 0xff)
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
typedef SOCKET Socket; using Socket = SOCKET;
#else #else
typedef int Socket; using Socket = int;
#endif #endif
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------

View file

@ -140,7 +140,7 @@ enum VisitResult {
class TerrainTraversal class TerrainTraversal
{ {
public: public:
typedef short int dataType; using dataType = short int;
public: public:
void SetSize(unsigned int width, unsigned int height); void SetSize(unsigned int width, unsigned int height);
void Init(); void Init();

View file

@ -73,7 +73,7 @@ class PathFinderData;
class SpellType; class SpellType;
struct lua_State; struct lua_State;
typedef COrder *COrderPtr; using COrderPtr = COrder *;
/* /*
** Configuration of the small (unit) AI. ** Configuration of the small (unit) AI.

View file

@ -50,8 +50,8 @@ class CMap;
class CUnitCache class CUnitCache
{ {
public: public:
typedef std::vector<CUnit *>::iterator iterator; using iterator = std::vector<CUnit *>::iterator;
typedef std::vector<CUnit *>::const_iterator const_iterator; using const_iterator = std::vector<CUnit *>::const_iterator;
public: public:
CUnitCache() : Units() {} CUnitCache() : Units() {}

View file

@ -50,7 +50,7 @@ struct lua_State;
class CUnitManager class CUnitManager
{ {
public: public:
typedef std::vector<CUnit *>::iterator Iterator; using Iterator = std::vector<CUnit *>::iterator;
public: public:
CUnitManager(); CUnitManager();
void Init(); void Init();

View file

@ -93,7 +93,7 @@ extern uint32_t fletcher32(const std::string &content);
#endif #endif
#ifndef HAVE_ERRNOT #ifndef HAVE_ERRNOT
typedef int errno_t; using errno_t = int;
#endif #endif
#ifndef HAVE_STRCPYS #ifndef HAVE_STRCPYS

View file

@ -159,11 +159,11 @@ inline int Distance(const Vec2T<T> &pos1, const Vec2T<T> &pos2)
return isqrt(SquareDistance(pos1, pos2)); return isqrt(SquareDistance(pos1, pos2));
} }
typedef Vec2T<short int> Vec2i; using Vec2i = Vec2T<short int>;
typedef Vec2T<int> PixelPos; using PixelPos = Vec2T<int>;
typedef Vec2T<int> PixelDiff; using PixelDiff = Vec2T<int>;
typedef Vec2T<int> PixelSize; using PixelSize = Vec2T<int>;
typedef Vec2T<double> PixelPrecise; using PixelPrecise = Vec2T<double>;
//@} //@}

View file

@ -67,7 +67,7 @@ static std::vector<Missile *> GlobalMissiles; /// all global missiles on map
static std::vector<Missile *> LocalMissiles; /// all local missiles on map static std::vector<Missile *> LocalMissiles; /// all local missiles on map
/// lookup table for missile names /// lookup table for missile names
typedef std::map<std::string, MissileType *> MissileTypeMap; using MissileTypeMap = std::map<std::string, MissileType *>;
static MissileTypeMap MissileTypes; static MissileTypeMap MissileTypes;
std::vector<BurningBuildingFrame *> BurningBuildingFrames; /// Burning building frames std::vector<BurningBuildingFrame *> BurningBuildingFrames; /// Burning building frames
@ -576,11 +576,9 @@ static bool MissileDrawLevelCompare(const Missile *const l, const Missile *const
*/ */
void FindAndSortMissiles(const CViewport &vp, std::vector<Missile *> &table) void FindAndSortMissiles(const CViewport &vp, std::vector<Missile *> &table)
{ {
typedef std::vector<Missile *>::const_iterator MissilePtrConstiterator;
// Loop through global missiles, then through locals. // Loop through global missiles, then through locals.
for (MissilePtrConstiterator i = GlobalMissiles.begin(); i != GlobalMissiles.end(); ++i) { for (auto* missilePtr : GlobalMissiles) {
Missile &missile = *(*i); Missile &missile = *missilePtr;
if (missile.Delay || missile.Hidden) { if (missile.Delay || missile.Hidden) {
continue; // delayed or hidden -> aren't shown continue; // delayed or hidden -> aren't shown
} }
@ -590,8 +588,8 @@ void FindAndSortMissiles(const CViewport &vp, std::vector<Missile *> &table)
} }
} }
for (MissilePtrConstiterator i = LocalMissiles.begin(); i != LocalMissiles.end(); ++i) { for (auto* missilePtr : LocalMissiles) {
Missile &missile = *(*i); Missile &missile = *missilePtr;
if (missile.Delay || missile.Hidden) { if (missile.Delay || missile.Hidden) {
continue; // delayed or hidden -> aren't shown continue; // delayed or hidden -> aren't shown
} }

View file

@ -53,18 +53,18 @@
#include <Iphlpapi.h> #include <Iphlpapi.h>
#pragma comment(lib, "Iphlpapi.lib") #pragma comment(lib, "Iphlpapi.lib")
typedef const char *setsockopttype; using setsockopttype = const char *;
typedef char *recvfrombuftype; using recvfrombuftype = char *;
typedef char *recvbuftype; using recvbuftype = char *;
typedef const char *sendtobuftype; using sendtobuftype = const char *;
typedef const char *sendbuftype; using sendbuftype = const char *;
typedef int socklen_t; using socklen_t = int;
#else #else
typedef const void *setsockopttype; using setsockopttype = const void *;
typedef void *recvfrombuftype; using recvfrombuftype = void *;
typedef void *recvbuftype; using recvbuftype = void *;
typedef const void *sendtobuftype; using sendtobuftype = const void *;
typedef const void *sendbuftype; using sendbuftype = const void *;
#endif #endif
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View file

@ -85,10 +85,10 @@ namespace pvpgn
return temp; return temp;
} }
typedef enum { enum t_hash_variant{
do_blizzard_hash, do_blizzard_hash,
do_sha1_hash do_sha1_hash
} t_hash_variant; };
static void hash_init(t_hash * hash); static void hash_init(t_hash * hash);
static void do_hash(t_hash * hash, std::uint32_t * tmp); static void do_hash(t_hash * hash, std::uint32_t * tmp);

View file

@ -46,7 +46,7 @@
-- Variables -- Variables
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
typedef std::map<std::string, std::string> EntriesType; using EntriesType = std::map<std::string, std::string>;
static EntriesType Entries; static EntriesType Entries;
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------

View file

@ -50,7 +50,7 @@
-- Variables -- Variables
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
typedef std::map<std::string, CIcon *> IconMap; using IconMap = std::map<std::string, CIcon *>;
static IconMap Icons; /// Map of ident to icon. static IconMap Icons; /// Map of ident to icon.

View file

@ -47,10 +47,10 @@
-- Variables -- Variables
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
typedef std::map<std::string, CFont *> FontMap; using FontMap = std::map<std::string, CFont *>;
static FontMap Fonts; /// Font mappings static FontMap Fonts; /// Font mappings
typedef std::map<std::string, CFontColor *> FontColorMap; using FontColorMap = std::map<std::string, CFontColor *>;
static FontColorMap FontColors; /// Map of ident to font color. static FontColorMap FontColors; /// Map of ident to font color.
static CFontColor *FontColor; /// Current font color static CFontColor *FontColor; /// Current font color
@ -65,7 +65,7 @@ static std::string DefaultReverseColorIndex; /// Default reverse color index
** Font color graphics ** Font color graphics
** Usage: FontColorGraphics[CFont *font][CFontColor *color] ** Usage: FontColorGraphics[CFont *font][CFontColor *color]
*/ */
typedef std::map<const CFontColor *, CGraphic *> FontColorGraphicMap; using FontColorGraphicMap = std::map<const CFontColor *, CGraphic *>;
static std::map<const CFont *, FontColorGraphicMap> FontColorGraphics; static std::map<const CFont *, FontColorGraphicMap> FontColorGraphics;
// FIXME: remove these // FIXME: remove these

View file

@ -874,9 +874,9 @@ class CRenderer : public CPrimitives
}; };
typedef CRenderer<2, 0xfbde> Primitive16_555_t; using Primitive16_555_t = CRenderer<2, 0xfbde>;
typedef CRenderer<2, 0xf7de> Primitive16_565_t; using Primitive16_565_t = CRenderer<2, 0xf7de>;
typedef CRenderer<4, 0> Primitive32_t; using Primitive32_t = CRenderer<4, 0>;
#endif #endif

View file

@ -281,11 +281,11 @@ static void InitKey2Str()
} }
#ifdef USE_WIN32 #ifdef USE_WIN32
typedef enum PROCESS_DPI_AWARENESS { enum PROCESS_DPI_AWARENESS {
PROCESS_DPI_UNAWARE = 0, PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2 PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS; };
static void setDpiAware() { static void setDpiAware() {
void* userDLL; void* userDLL;