Skip to content

Commit

Permalink
Fix: Globally apply preprocessor directive coding style
Browse files Browse the repository at this point in the history
Global; except for the 32-bit SSE blitter, which has some #DEFINEs
in not-very-nice places.
  • Loading branch information
techgeeknz authored and nielsmh committed Jul 3, 2020
1 parent 97592c4 commit 716c883
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 197 deletions.
40 changes: 20 additions & 20 deletions src/core/endian_func.hpp
Expand Up @@ -15,27 +15,27 @@

/* Setup alignment and conversion macros */
#if TTD_ENDIAN == TTD_BIG_ENDIAN
#define FROM_BE16(x) (x)
#define FROM_BE32(x) (x)
#define TO_BE16(x) (x)
#define TO_BE32(x) (x)
#define TO_BE32X(x) (x)
#define FROM_LE16(x) BSWAP16(x)
#define FROM_LE32(x) BSWAP32(x)
#define TO_LE16(x) BSWAP16(x)
#define TO_LE32(x) BSWAP32(x)
#define TO_LE32X(x) BSWAP32(x)
# define FROM_BE16(x) (x)
# define FROM_BE32(x) (x)
# define TO_BE16(x) (x)
# define TO_BE32(x) (x)
# define TO_BE32X(x) (x)
# define FROM_LE16(x) BSWAP16(x)
# define FROM_LE32(x) BSWAP32(x)
# define TO_LE16(x) BSWAP16(x)
# define TO_LE32(x) BSWAP32(x)
# define TO_LE32X(x) BSWAP32(x)
#else
#define FROM_BE16(x) BSWAP16(x)
#define FROM_BE32(x) BSWAP32(x)
#define TO_BE16(x) BSWAP16(x)
#define TO_BE32(x) BSWAP32(x)
#define TO_BE32X(x) BSWAP32(x)
#define FROM_LE16(x) (x)
#define FROM_LE32(x) (x)
#define TO_LE16(x) (x)
#define TO_LE32(x) (x)
#define TO_LE32X(x) (x)
# define FROM_BE16(x) BSWAP16(x)
# define FROM_BE32(x) BSWAP32(x)
# define TO_BE16(x) BSWAP16(x)
# define TO_BE32(x) BSWAP32(x)
# define TO_BE32X(x) BSWAP32(x)
# define FROM_LE16(x) (x)
# define FROM_LE32(x) (x)
# define TO_LE16(x) (x)
# define TO_LE32(x) (x)
# define TO_LE32X(x) (x)
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */

static inline uint16 ReadLE16Aligned(const void *x)
Expand Down
4 changes: 2 additions & 2 deletions src/core/endian_type.hpp
Expand Up @@ -12,10 +12,10 @@

#if defined(ARM) || defined(__arm__) || defined(__alpha__)
/** The architecture requires aligned access. */
#define OTTD_ALIGNMENT 1
# define OTTD_ALIGNMENT 1
#else
/** The architecture does not require aligned access. */
#define OTTD_ALIGNMENT 0
# define OTTD_ALIGNMENT 0
#endif

/** Little endian builds use this for TTD_ENDIAN. */
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry_type.hpp
Expand Up @@ -12,8 +12,8 @@

#if defined(__APPLE__)
/* Mac OS X already has both Rect and Point declared */
#define Rect OTTD_Rect
#define Point OTTD_Point
# define Rect OTTD_Rect
# define Point OTTD_Point
#endif /* __APPLE__ */


Expand Down
18 changes: 9 additions & 9 deletions src/core/random_func.hpp
Expand Up @@ -12,7 +12,7 @@

#if defined(__APPLE__)
/* Apple already has Random declared */
#define Random OTTD_Random
# define Random OTTD_Random
#endif /* __APPLE__ */

/**
Expand Down Expand Up @@ -57,13 +57,13 @@ static inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)

void SetRandomSeed(uint32 seed);
#ifdef RANDOM_DEBUG
#ifdef __APPLE__
#define OTTD_Random() DoRandom(__LINE__, __FILE__)
#else
#define Random() DoRandom(__LINE__, __FILE__)
#endif
# ifdef __APPLE__
# define OTTD_Random() DoRandom(__LINE__, __FILE__)
# else
# define Random() DoRandom(__LINE__, __FILE__)
# endif
uint32 DoRandom(int line, const char *file);
#define RandomRange(limit) DoRandomRange(limit, __LINE__, __FILE__)
# define RandomRange(limit) DoRandomRange(limit, __LINE__, __FILE__)
uint32 DoRandomRange(uint32 limit, int line, const char *file);
#else
static inline uint32 Random()
Expand Down Expand Up @@ -126,7 +126,7 @@ static inline bool Chance16I(const uint a, const uint b, const uint32 r)
* @return True with (a/b) probability
*/
#ifdef RANDOM_DEBUG
#define Chance16(a, b) Chance16I(a, b, DoRandom(__LINE__, __FILE__))
# define Chance16(a, b) Chance16I(a, b, DoRandom(__LINE__, __FILE__))
#else
static inline bool Chance16(const uint a, const uint b)
{
Expand All @@ -150,7 +150,7 @@ static inline bool Chance16(const uint a, const uint b)
* @return True in (a/b) percent
*/
#ifdef RANDOM_DEBUG
#define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r))
# define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r))
#else
static inline bool Chance16R(const uint a, const uint b, uint32 &r)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ini.cpp
Expand Up @@ -90,7 +90,7 @@ bool IniFile::SaveToDisk(const char *filename)

#if defined(_WIN32)
/* _tcsncpy = strcpy is TCHAR is char, but isn't when TCHAR is wchar. */
#undef strncpy
# undef strncpy
/* Allocate space for one more \0 character. */
TCHAR tfilename[MAX_PATH + 1], tfile_new[MAX_PATH + 1];
_tcsncpy(tfilename, OTTD2FS(filename), MAX_PATH);
Expand Down
4 changes: 2 additions & 2 deletions src/landscape.cpp
Expand Up @@ -1186,8 +1186,8 @@ static void BuildRiver(TileIndex begin, TileIndex end)
*/
static bool FlowRiver(TileIndex spring, TileIndex begin)
{
#define SET_MARK(x) marks.insert(x)
#define IS_MARKED(x) (marks.find(x) != marks.end())
# define SET_MARK(x) marks.insert(x)
# define IS_MARKED(x) (marks.find(x) != marks.end())

uint height = TileHeight(begin);
if (IsWaterTile(begin)) return DistanceManhattan(spring, begin) > _settings_game.game_creation.min_river_length;
Expand Down
4 changes: 2 additions & 2 deletions src/map_func.h
Expand Up @@ -241,11 +241,11 @@ static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
* @param y Another tile to add
* @return The resulting tile(index)
*/
#define TILE_ADD(x, y) ((x) + (y))
# define TILE_ADD(x, y) ((x) + (y))
#else
extern TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
const char *exp, const char *file, int line);
#define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
# define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
#endif

/**
Expand Down
4 changes: 2 additions & 2 deletions src/misc/binaryheap.hpp
Expand Up @@ -17,10 +17,10 @@

#if BINARYHEAP_CHECK
/** Check for consistency. */
#define CHECK_CONSISTY() this->CheckConsistency()
# define CHECK_CONSISTY() this->CheckConsistency()
#else
/** Don't check for consistency. */
#define CHECK_CONSISTY() ;
# define CHECK_CONSISTY() ;
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion src/music/dmusic.cpp
Expand Up @@ -10,7 +10,7 @@
#define INITGUID
#include "../stdafx.h"
#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN // Don't exclude rarely-used stuff from Windows headers
# undef WIN32_LEAN_AND_MEAN // Don't exclude rarely-used stuff from Windows headers
#endif
#include "../debug.h"
#include "../os/windows/win32.h"
Expand Down
4 changes: 2 additions & 2 deletions src/os/os2/os2.cpp
Expand Up @@ -26,7 +26,7 @@
#include <stdlib.h>
#include <time.h>
#ifndef __INNOTEK_LIBC__
#include <dos.h>
# include <dos.h>
#endif

#include "../../safeguards.h"
Expand All @@ -36,7 +36,7 @@

#include <os2.h>
#ifndef __INNOTEK_LIBC__
#include <i86.h>
# include <i86.h>
#endif

bool FiosIsRoot(const char *file)
Expand Down
6 changes: 3 additions & 3 deletions src/os/unix/unix.cpp
Expand Up @@ -29,13 +29,13 @@
#endif

#ifdef __APPLE__
#include <sys/mount.h>
# include <sys/mount.h>
#elif (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__)
#define HAS_STATVFS
# define HAS_STATVFS
#endif

#if defined(OPENBSD) || defined(__NetBSD__) || defined(__FreeBSD__)
#define HAS_SYSCTL
# define HAS_SYSCTL
#endif

#ifdef HAS_STATVFS
Expand Down

0 comments on commit 716c883

Please sign in to comment.