Skip to content

Commit

Permalink
Replace typedef by using.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Aug 7, 2023
1 parent c7c66df commit 77e3f63
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/game/trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down
2 changes: 1 addition & 1 deletion src/include/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class COrder
bool Instant; /// true to ignore TimeCost
};

typedef COrder *COrderPtr;
using COrderPtr = COrder *;


/*----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/include/animation/animation_ifvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CAnimation_IfVar : public CAnimation
virtual void Init(const char *s, lua_State *l);

private:
typedef bool BinOpFunc(int lhs, int rhs);
using BinOpFunc = bool (int lhs, int rhs);

private:
std::string leftVar;
Expand Down
2 changes: 1 addition & 1 deletion src/include/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <stdint.h>

typedef uint32_t IntColor; // Uint32 in SDL
using IntColor = uint32_t; // Uint32 in SDL

struct SDL_Color;
struct lua_State;
Expand Down
2 changes: 1 addition & 1 deletion src/include/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ extern void CommandSharedVision(int player, bool state, int opponent);
/**
** Unit references over network, or for memory saving.
*/
typedef unsigned short UnitRef;
using UnitRef = unsigned short;

/// Send stop command
extern void SendCommandStopUnit(CUnit &unit);
Expand Down
2 changes: 1 addition & 1 deletion src/include/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ enum ButtonCmd {
};

class ButtonAction;
typedef bool (*ButtonCheckFunc)(const CUnit &, const ButtonAction &);
using ButtonCheckFunc = bool (*)(const CUnit &, const ButtonAction &);

/// Action of button
class ButtonAction
Expand Down
2 changes: 1 addition & 1 deletion src/include/luacallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <utility>
#include <variant>

typedef int lua_Object; // from tolua++.h
using lua_Object = int; // from tolua++.h
struct lua_State;

class LuaCallback
Expand Down
4 changes: 2 additions & 2 deletions src/include/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ extern int ReplayRevealMap;
// in map_fog.c
//
/// 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
extern int MapFogFilterFlags(CPlayer &player, const Vec2i &pos, int mask);
Expand Down Expand Up @@ -383,7 +383,7 @@ extern bool UnitCanBeAt(const CUnit &unit, const Vec2i &pos);
extern void PreprocessMap();

// in unit.c
//typedef void MapClearField(const Vec2i &tilePos);
//using MapClearField = void(const Vec2i &tilePos);

/// Mark on vision table the Sight of the unit.
void MapMarkUnitSight(CUnit &unit);
Expand Down
4 changes: 2 additions & 2 deletions src/include/net_lowlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
(int)(((ad) >> 8) & 0xff), (int)((ad) & 0xff)

#ifdef USE_WINSOCK
typedef SOCKET Socket;
using Socket = SOCKET;
#else
typedef int Socket;
using Socket = int;
#endif

/*----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/include/pathfinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ enum VisitResult {
class TerrainTraversal
{
public:
typedef short int dataType;
using dataType = short int;
public:
void SetSize(unsigned int width, unsigned int height);
void Init();
Expand Down
2 changes: 1 addition & 1 deletion src/include/unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PathFinderData;
class SpellType;
struct lua_State;

typedef COrder *COrderPtr;
using COrderPtr = COrder *;

/*
** Configuration of the small (unit) AI.
Expand Down
4 changes: 2 additions & 2 deletions src/include/unit_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class CMap;
class CUnitCache
{
public:
typedef std::vector<CUnit *>::iterator iterator;
typedef std::vector<CUnit *>::const_iterator const_iterator;
using iterator = std::vector<CUnit *>::iterator;
using const_iterator = std::vector<CUnit *>::const_iterator;

public:
CUnitCache() : Units() {}
Expand Down
2 changes: 1 addition & 1 deletion src/include/unit_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct lua_State;
class CUnitManager
{
public:
typedef std::vector<CUnit *>::iterator Iterator;
using Iterator = std::vector<CUnit *>::iterator;
public:
CUnitManager();
void Init();
Expand Down
2 changes: 1 addition & 1 deletion src/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ extern uint32_t fletcher32(const std::string &content);
#endif

#ifndef HAVE_ERRNOT
typedef int errno_t;
using errno_t = int;
#endif

#ifndef HAVE_STRCPYS
Expand Down
10 changes: 5 additions & 5 deletions src/include/vec2i.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ inline int Distance(const Vec2T<T> &pos1, const Vec2T<T> &pos2)
return isqrt(SquareDistance(pos1, pos2));
}

typedef Vec2T<short int> Vec2i;
typedef Vec2T<int> PixelPos;
typedef Vec2T<int> PixelDiff;
typedef Vec2T<int> PixelSize;
typedef Vec2T<double> PixelPrecise;
using Vec2i = Vec2T<short int>;
using PixelPos = Vec2T<int>;
using PixelDiff = Vec2T<int>;
using PixelSize = Vec2T<int>;
using PixelPrecise = Vec2T<double>;

//@}

Expand Down
12 changes: 5 additions & 7 deletions src/missile/missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static std::vector<Missile *> GlobalMissiles; /// all global missiles on map
static std::vector<Missile *> LocalMissiles; /// all local missiles on map

/// lookup table for missile names
typedef std::map<std::string, MissileType *> MissileTypeMap;
using MissileTypeMap = std::map<std::string, MissileType *>;
static MissileTypeMap MissileTypes;

std::vector<BurningBuildingFrame *> BurningBuildingFrames; /// Burning building frames
Expand Down Expand Up @@ -576,11 +576,9 @@ static bool MissileDrawLevelCompare(const Missile *const l, const Missile *const
*/
void FindAndSortMissiles(const CViewport &vp, std::vector<Missile *> &table)
{
typedef std::vector<Missile *>::const_iterator MissilePtrConstiterator;

// Loop through global missiles, then through locals.
for (MissilePtrConstiterator i = GlobalMissiles.begin(); i != GlobalMissiles.end(); ++i) {
Missile &missile = *(*i);
for (auto* missilePtr : GlobalMissiles) {
Missile &missile = *missilePtr;
if (missile.Delay || missile.Hidden) {
continue; // delayed or hidden -> aren't shown
}
Expand All @@ -590,8 +588,8 @@ void FindAndSortMissiles(const CViewport &vp, std::vector<Missile *> &table)
}
}

for (MissilePtrConstiterator i = LocalMissiles.begin(); i != LocalMissiles.end(); ++i) {
Missile &missile = *(*i);
for (auto* missilePtr : LocalMissiles) {
Missile &missile = *missilePtr;
if (missile.Delay || missile.Hidden) {
continue; // delayed or hidden -> aren't shown
}
Expand Down
22 changes: 11 additions & 11 deletions src/network/net_lowlevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@
#include <Iphlpapi.h>
#pragma comment(lib, "Iphlpapi.lib")

typedef const char *setsockopttype;
typedef char *recvfrombuftype;
typedef char *recvbuftype;
typedef const char *sendtobuftype;
typedef const char *sendbuftype;
typedef int socklen_t;
using setsockopttype = const char *;
using recvfrombuftype = char *;
using recvbuftype = char *;
using sendtobuftype = const char *;
using sendbuftype = const char *;
using socklen_t = int;
#else
typedef const void *setsockopttype;
typedef void *recvfrombuftype;
typedef void *recvbuftype;
typedef const void *sendtobuftype;
typedef const void *sendbuftype;
using setsockopttype = const void *;
using recvfrombuftype = void *;
using recvbuftype = void *;
using sendtobuftype = const void *;
using sendbuftype = const void *;
#endif

//----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/network/xsha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ namespace pvpgn
return temp;
}

typedef enum {
enum t_hash_variant{
do_blizzard_hash,
do_sha1_hash
} t_hash_variant;
};

static void hash_init(t_hash * hash);
static void do_hash(t_hash * hash, std::uint32_t * tmp);
Expand Down
2 changes: 1 addition & 1 deletion src/stratagus/translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
-- Variables
----------------------------------------------------------------------------*/

typedef std::map<std::string, std::string> EntriesType;
using EntriesType = std::map<std::string, std::string>;
static EntriesType Entries;

/*----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/ui/icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
-- Variables
----------------------------------------------------------------------------*/

typedef std::map<std::string, CIcon *> IconMap;
using IconMap = std::map<std::string, CIcon *>;
static IconMap Icons; /// Map of ident to icon.


Expand Down
6 changes: 3 additions & 3 deletions src/video/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
-- Variables
----------------------------------------------------------------------------*/

typedef std::map<std::string, CFont *> FontMap;
using FontMap = std::map<std::string, CFont *>;
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 CFontColor *FontColor; /// Current font color
Expand All @@ -65,7 +65,7 @@ static std::string DefaultReverseColorIndex; /// Default reverse color index
** Font color graphics
** 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;

// FIXME: remove these
Expand Down
6 changes: 3 additions & 3 deletions src/video/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,9 +874,9 @@ class CRenderer : public CPrimitives

};

typedef CRenderer<2, 0xfbde> Primitive16_555_t;
typedef CRenderer<2, 0xf7de> Primitive16_565_t;
typedef CRenderer<4, 0> Primitive32_t;
using Primitive16_555_t = CRenderer<2, 0xfbde>;
using Primitive16_565_t = CRenderer<2, 0xf7de>;
using Primitive32_t = CRenderer<4, 0>;

#endif

4 changes: 2 additions & 2 deletions src/video/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ static void InitKey2Str()
}

#ifdef USE_WIN32
typedef enum PROCESS_DPI_AWARENESS {
enum PROCESS_DPI_AWARENESS {
PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS;
};

static void setDpiAware() {
void* userDLL;
Expand Down

0 comments on commit 77e3f63

Please sign in to comment.