diff --git a/.clang-format b/.clang-format index 3dedfeecf064..c29e19d6a350 100644 --- a/.clang-format +++ b/.clang-format @@ -62,6 +62,7 @@ IncludeCategories: - Regex: '^<' Priority: 2 IndentCaseLabels: true +IndentPPDirectives: AfterHash IndentWidth: 4 IndentWrappedFunctionNames: true KeepEmptyLinesAtTheStartOfBlocks: false diff --git a/src/openrct2-ui/TextComposition.cpp b/src/openrct2-ui/TextComposition.cpp index 4314edfbb44f..7ec180a5ce17 100644 --- a/src/openrct2-ui/TextComposition.cpp +++ b/src/openrct2-ui/TextComposition.cpp @@ -23,9 +23,9 @@ #ifdef __MACOSX__ // macOS uses COMMAND rather than CTRL for many keyboard shortcuts -#define KEYBOARD_PRIMARY_MODIFIER KMOD_GUI +# define KEYBOARD_PRIMARY_MODIFIER KMOD_GUI #else -#define KEYBOARD_PRIMARY_MODIFIER KMOD_CTRL +# define KEYBOARD_PRIMARY_MODIFIER KMOD_CTRL #endif using namespace OpenRCT2; diff --git a/src/openrct2-ui/UiContext.Android.cpp b/src/openrct2-ui/UiContext.Android.cpp index 76c96ff26b95..f6f3b2a15d20 100644 --- a/src/openrct2-ui/UiContext.Android.cpp +++ b/src/openrct2-ui/UiContext.Android.cpp @@ -9,15 +9,15 @@ #ifdef __ANDROID__ -#include "UiContext.h" +# include "UiContext.h" -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include namespace OpenRCT2::Ui { diff --git a/src/openrct2-ui/UiContext.Linux.cpp b/src/openrct2-ui/UiContext.Linux.cpp index ee2bda73f7d4..e3416573b0be 100644 --- a/src/openrct2-ui/UiContext.Linux.cpp +++ b/src/openrct2-ui/UiContext.Linux.cpp @@ -9,17 +9,17 @@ #if (defined(__linux__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__)) && !defined(__ANDROID__) -#include "UiContext.h" +# include "UiContext.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include +# include +# include namespace OpenRCT2::Ui { @@ -44,7 +44,7 @@ namespace OpenRCT2::Ui bool IsSteamOverlayAttached() override { -#ifdef __linux__ +# ifdef __linux__ // See http://syprog.blogspot.ru/2011/12/listing-loaded-shared-objects-in-linux.html struct lmap { @@ -79,9 +79,9 @@ namespace OpenRCT2::Ui dlclose(processHandle); } return result; -#else +# else return false; // Needed for OpenBSD, likely all other Unixes. -#endif +# endif } void ShowMessageBox(SDL_Window* window, const std::string& message) override @@ -258,7 +258,7 @@ namespace OpenRCT2::Ui static int32_t Execute(const std::string& command, std::string* output = nullptr) { -#ifndef __EMSCRIPTEN__ +# ifndef __EMSCRIPTEN__ log_verbose("executing \"%s\"...\n", command.c_str()); FILE* fpipe = popen(command.c_str(), "r"); if (fpipe == nullptr) @@ -301,10 +301,10 @@ namespace OpenRCT2::Ui // Return exit code return pclose(fpipe); -#else +# else log_warning("Emscripten cannot execute processes. The commandline was '%s'.", command.c_str()); return -1; -#endif // __EMSCRIPTEN__ +# endif // __EMSCRIPTEN__ } static std::string GetKDialogFilterString(const std::vector filters) diff --git a/src/openrct2-ui/UiContext.Win32.cpp b/src/openrct2-ui/UiContext.Win32.cpp index 3c66fed621ca..3478eca15cf2 100644 --- a/src/openrct2-ui/UiContext.Win32.cpp +++ b/src/openrct2-ui/UiContext.Win32.cpp @@ -9,31 +9,31 @@ #ifdef _WIN32 -#ifdef __MINGW32__ +# ifdef __MINGW32__ // 0x0600 == vista -#define WINVER 0x0600 -#define _WIN32_WINNT 0x0600 -#endif // __MINGW32__ +# define WINVER 0x0600 +# define _WIN32_WINNT 0x0600 +# endif // __MINGW32__ // Windows.h needs to be included first -#include -#undef CreateWindow +# include +# undef CreateWindow // Then the rest -#include "UiContext.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include "UiContext.h" + +# include +# include +# include +# include +# include +# include +# include +# include +# include // Native resource IDs -#include "../../resources/resource.h" +# include "../../resources/resource.h" static std::wstring SHGetPathFromIDListLongPath(LPCITEMIDLIST pidl) { diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index cc9fe87e2748..eb3a045f041e 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -51,9 +51,9 @@ using namespace OpenRCT2::Ui; #ifdef __MACOSX__ // macOS uses COMMAND rather than CTRL for many keyboard shortcuts -#define KEYBOARD_PRIMARY_MODIFIER KMOD_GUI +# define KEYBOARD_PRIMARY_MODIFIER KMOD_GUI #else -#define KEYBOARD_PRIMARY_MODIFIER KMOD_CTRL +# define KEYBOARD_PRIMARY_MODIFIER KMOD_CTRL #endif class UiContext final : public IUiContext diff --git a/src/openrct2-ui/UiContext.macOS.mm b/src/openrct2-ui/UiContext.macOS.mm index 8cccf6f9a1aa..8c060e07ea3b 100644 --- a/src/openrct2-ui/UiContext.macOS.mm +++ b/src/openrct2-ui/UiContext.macOS.mm @@ -9,19 +9,19 @@ #if defined(__APPLE__) && defined(__MACH__) -#include "UiContext.h" +# include "UiContext.h" -#include -#include -#include +# include +# include +# include // undefine `interface` and `abstract`, because it's causing conflicts with Objective-C's keywords -#undef interface -#undef abstract +# undef interface +# undef abstract -#import -#include -#include +# import +# include +# include namespace OpenRCT2::Ui { diff --git a/src/openrct2-ui/drawing/engines/opengl/ApplyPaletteShader.cpp b/src/openrct2-ui/drawing/engines/opengl/ApplyPaletteShader.cpp index 6b3365c5066c..fe7e15c3d18c 100644 --- a/src/openrct2-ui/drawing/engines/opengl/ApplyPaletteShader.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/ApplyPaletteShader.cpp @@ -9,7 +9,7 @@ #ifndef DISABLE_OPENGL -#include "ApplyPaletteShader.h" +# include "ApplyPaletteShader.h" namespace { diff --git a/src/openrct2-ui/drawing/engines/opengl/ApplyTransparencyShader.cpp b/src/openrct2-ui/drawing/engines/opengl/ApplyTransparencyShader.cpp index d87c1aeeb232..983b36e85625 100644 --- a/src/openrct2-ui/drawing/engines/opengl/ApplyTransparencyShader.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/ApplyTransparencyShader.cpp @@ -9,7 +9,7 @@ #ifndef DISABLE_OPENGL -#include "ApplyTransparencyShader.h" +# include "ApplyTransparencyShader.h" namespace { diff --git a/src/openrct2-ui/drawing/engines/opengl/DrawLineShader.cpp b/src/openrct2-ui/drawing/engines/opengl/DrawLineShader.cpp index adcabff95202..8a4104f97550 100644 --- a/src/openrct2-ui/drawing/engines/opengl/DrawLineShader.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/DrawLineShader.cpp @@ -9,9 +9,9 @@ #ifndef DISABLE_OPENGL -#include "DrawLineShader.h" +# include "DrawLineShader.h" -#include "OpenGLFramebuffer.h" +# include "OpenGLFramebuffer.h" namespace { diff --git a/src/openrct2-ui/drawing/engines/opengl/DrawRectShader.cpp b/src/openrct2-ui/drawing/engines/opengl/DrawRectShader.cpp index 80a12c36648c..44864711629a 100644 --- a/src/openrct2-ui/drawing/engines/opengl/DrawRectShader.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/DrawRectShader.cpp @@ -9,7 +9,7 @@ #ifndef DISABLE_OPENGL -#include "DrawRectShader.h" +# include "DrawRectShader.h" namespace { diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.cpp index afb46142bfa3..d821e53d73e0 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.cpp @@ -9,34 +9,34 @@ #ifndef DISABLE_OPENGL -#include "OpenGLAPI.h" +# include "OpenGLAPI.h" -#if OPENGL_NO_LINK +# if OPENGL_NO_LINK -#define OPENGL_PROC(TYPE, PROC) TYPE PROC = nullptr; -#include "OpenGLAPIProc.h" -#undef OPENGL_PROC +# define OPENGL_PROC(TYPE, PROC) TYPE PROC = nullptr; +# include "OpenGLAPIProc.h" +# undef OPENGL_PROC -#include -#include +# include +# include static const char* TryLoadAllProcAddresses() { -#define OPENGL_PROC(TYPE, PROC) \ - { \ - PROC = (TYPE)SDL_GL_GetProcAddress(#PROC); \ - if (PROC == nullptr) \ - { \ - return #PROC; \ - } \ - } -#include "OpenGLAPIProc.h" -#undef OPENGL_PROC +# define OPENGL_PROC(TYPE, PROC) \ + { \ + PROC = (TYPE)SDL_GL_GetProcAddress(#PROC); \ + if (PROC == nullptr) \ + { \ + return #PROC; \ + } \ + } +# include "OpenGLAPIProc.h" +# undef OPENGL_PROC return nullptr; } -#endif /* #if OPENGL_NO_LINK */ +# endif /* #if OPENGL_NO_LINK */ namespace OpenGLState { @@ -63,14 +63,14 @@ bool OpenGLAPI::Initialise() { OpenGLState::Reset(); -#ifdef OPENGL_NO_LINK +# ifdef OPENGL_NO_LINK const char* failedProcName = TryLoadAllProcAddresses(); if (failedProcName != nullptr) { Console::Error::WriteLine("Failed to load %s.", failedProcName); return false; } -#endif +# endif return true; } diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.h b/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.h index 94dc56bb54aa..e696e46809a9 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.h +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLAPI.h @@ -14,30 +14,30 @@ #ifdef OPENGL_NO_LINK // BEGIN [Do not define 1.1 function signatures] -#define glActiveTexture __static__glActiveTexture -#define glBegin __static__glBegin -#define glBindTexture __static__glBindTexture -#define glBlendFunc __static__glBlendFunc -#define glClear __static__glClear -#define glClearColor __static__glClearColor -#define glCullFace __static__glCullFace -#define glDeleteTextures __static__glDeleteTextures -#define glDepthFunc __static__glDepthFunc -#define glDisable __static__glDisable -#define glDrawArrays __static__glDrawArrays -#define glEnable __static__glEnable -#define glEnd __static__glEnd -#define glGenTextures __static__glGenTextures -#define glGetError __static__glGetError -#define glPixelStorei __static__glPixelStorei -#define glReadPixels __static__glReadPixels -#define glTexImage2D __static__glTexImage2D -#define glTexParameteri __static__glTexParameteri -#define glViewport __static__glViewport -#define glTexSubImage3D __static__glTexSubImage3D -#define glTexImage3D __static__glTexImage3D -#define glGetIntegerv __static__glGetIntegerv -#define glGetTexImage __static__glGetTexImage +# define glActiveTexture __static__glActiveTexture +# define glBegin __static__glBegin +# define glBindTexture __static__glBindTexture +# define glBlendFunc __static__glBlendFunc +# define glClear __static__glClear +# define glClearColor __static__glClearColor +# define glCullFace __static__glCullFace +# define glDeleteTextures __static__glDeleteTextures +# define glDepthFunc __static__glDepthFunc +# define glDisable __static__glDisable +# define glDrawArrays __static__glDrawArrays +# define glEnable __static__glEnable +# define glEnd __static__glEnd +# define glGenTextures __static__glGenTextures +# define glGetError __static__glGetError +# define glPixelStorei __static__glPixelStorei +# define glReadPixels __static__glReadPixels +# define glTexImage2D __static__glTexImage2D +# define glTexParameteri __static__glTexParameteri +# define glViewport __static__glViewport +# define glTexSubImage3D __static__glTexSubImage3D +# define glTexImage3D __static__glTexImage3D +# define glGetIntegerv __static__glGetIntegerv +# define glGetTexImage __static__glGetTexImage #endif @@ -48,30 +48,30 @@ #ifdef OPENGL_NO_LINK // END [Do not define 1.1 function signatures] -#undef glActiveTexture -#undef glBegin -#undef glBindTexture -#undef glBlendFunc -#undef glClear -#undef glClearColor -#undef glCullFace -#undef glDeleteTextures -#undef glDepthFunc -#undef glDisable -#undef glDrawArrays -#undef glEnable -#undef glEnd -#undef glGenTextures -#undef glGetError -#undef glPixelStorei -#undef glReadPixels -#undef glTexImage2D -#undef glTexParameteri -#undef glViewport -#undef glTexSubImage3D -#undef glTexImage3D -#undef glGetIntegerv -#undef glGetTexImage +# undef glActiveTexture +# undef glBegin +# undef glBindTexture +# undef glBlendFunc +# undef glClear +# undef glClearColor +# undef glCullFace +# undef glDeleteTextures +# undef glDepthFunc +# undef glDisable +# undef glDrawArrays +# undef glEnable +# undef glEnd +# undef glGenTextures +# undef glGetError +# undef glPixelStorei +# undef glReadPixels +# undef glTexImage2D +# undef glTexParameteri +# undef glViewport +# undef glTexSubImage3D +# undef glTexImage3D +# undef glGetIntegerv +# undef glGetTexImage // 1.1 function signatures typedef void(APIENTRYP PFNGLBEGINPROC)(GLenum mode); @@ -105,9 +105,9 @@ typedef void(APIENTRYP PFNGLTEXIMAGE3DPROC)( typedef void(APIENTRYP PFNGLGETINTERGERVPROC)(GLenum pname, GLint* data); typedef void(APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* img); -#define OPENGL_PROC(TYPE, PROC) extern TYPE PROC; -#include "OpenGLAPIProc.h" -#undef OPENGL_PROC +# define OPENGL_PROC(TYPE, PROC) extern TYPE PROC; +# include "OpenGLAPIProc.h" +# undef OPENGL_PROC #endif /* OPENGL_NO_LINK */ diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLAPIProc.h b/src/openrct2-ui/drawing/engines/opengl/OpenGLAPIProc.h index 71e846f55e2b..b5c894af35ae 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLAPIProc.h +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLAPIProc.h @@ -8,7 +8,7 @@ *****************************************************************************/ #ifndef OPENGL_PROC -#error "Do not include OpenGLAPIProc.h directly. Include OpenGLAPI.h instead." +# error "Do not include OpenGLAPIProc.h directly. Include OpenGLAPI.h instead." #endif // 1.1 function pointers diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 678f365f02ba..9a6da07598f2 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -9,33 +9,33 @@ #ifndef DISABLE_OPENGL -#include "../DrawingEngineFactory.hpp" -#include "ApplyPaletteShader.h" -#include "DrawCommands.h" -#include "DrawLineShader.h" -#include "DrawRectShader.h" -#include "GLSLTypes.h" -#include "OpenGLAPI.h" -#include "OpenGLFramebuffer.h" -#include "SwapFramebuffer.h" -#include "TextureCache.h" -#include "TransparencyDepth.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include "../DrawingEngineFactory.hpp" +# include "ApplyPaletteShader.h" +# include "DrawCommands.h" +# include "DrawLineShader.h" +# include "DrawRectShader.h" +# include "GLSLTypes.h" +# include "OpenGLAPI.h" +# include "OpenGLFramebuffer.h" +# include "SwapFramebuffer.h" +# include "TextureCache.h" +# include "TransparencyDepth.h" + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include using namespace OpenRCT2; using namespace OpenRCT2::Drawing; @@ -148,9 +148,9 @@ class OpenGLDrawingEngine : public IDrawingEngine { _window = (SDL_Window*)_uiContext->GetWindow(); _drawingContext = new OpenGLDrawingContext(this); -#ifdef __ENABLE_LIGHTFX__ +# ifdef __ENABLE_LIGHTFX__ lightfx_set_available(false); -#endif +# endif } ~OpenGLDrawingEngine() override @@ -941,9 +941,9 @@ void OpenGLDrawingContext::HandleTransparency() void OpenGLDrawingContext::SetDPI(rct_drawpixelinfo* dpi) { rct_drawpixelinfo* screenDPI = _engine->GetDPI(); -#ifndef NDEBUG +# ifndef NDEBUG size_t bitsSize = (size_t)screenDPI->height * (size_t)(screenDPI->width + screenDPI->pitch); -#endif +# endif size_t bitsOffset = (size_t)(dpi->bits - screenDPI->bits); assert(bitsOffset < bitsSize); diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp index cc05650451ca..2eb359059932 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp @@ -9,12 +9,12 @@ #ifndef DISABLE_OPENGL -#include "OpenGLFramebuffer.h" +# include "OpenGLFramebuffer.h" -#include -#include -#include -#include +# include +# include +# include +# include constexpr GLuint BACKBUFFER_ID = 0; diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp index 88e1f8abe073..0d2738ac55a9 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLShaderProgram.cpp @@ -9,14 +9,14 @@ #ifndef DISABLE_OPENGL -#include "OpenGLShaderProgram.h" - -#include -#include -#include -#include -#include -#include +# include "OpenGLShaderProgram.h" + +# include +# include +# include +# include +# include +# include using namespace OpenRCT2; diff --git a/src/openrct2-ui/drawing/engines/opengl/SwapFramebuffer.cpp b/src/openrct2-ui/drawing/engines/opengl/SwapFramebuffer.cpp index 52133d0222f0..dd902c6a21f6 100644 --- a/src/openrct2-ui/drawing/engines/opengl/SwapFramebuffer.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/SwapFramebuffer.cpp @@ -9,9 +9,9 @@ #ifndef DISABLE_OPENGL -#include "SwapFramebuffer.h" +# include "SwapFramebuffer.h" -#include "OpenGLFramebuffer.h" +# include "OpenGLFramebuffer.h" constexpr GLfloat depthValue[1] = { 1.0f }; constexpr GLfloat depthValueTransparent[1] = { 0.0f }; diff --git a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp index ecc4b6211ac3..d35faffcb04f 100644 --- a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp @@ -9,12 +9,12 @@ #ifndef DISABLE_OPENGL -#include "TextureCache.h" +# include "TextureCache.h" -#include -#include -#include -#include +# include +# include +# include +# include constexpr uint32_t UNUSED_INDEX = 0xFFFFFFFF; @@ -245,9 +245,9 @@ AtlasTextureInfo TextureCache::AllocateImage(int32_t imageWidth, int32_t imageHe int32_t atlasIndex = (int32_t)_atlases.size(); int32_t atlasSize = (int32_t)powf(2, (float)Atlas::CalculateImageSizeOrder(imageWidth, imageHeight)); -#ifdef DEBUG +# ifdef DEBUG log_verbose("new texture atlas #%d (size %d) allocated\n", atlasIndex, atlasSize); -#endif +# endif _atlases.emplace_back(atlasIndex, atlasSize); _atlases.back().Initialise(_atlasesTextureDimensions, _atlasesTextureDimensions); diff --git a/src/openrct2-ui/drawing/engines/opengl/TransparencyDepth.cpp b/src/openrct2-ui/drawing/engines/opengl/TransparencyDepth.cpp index c2c16e7bbd8f..542fc24ac375 100644 --- a/src/openrct2-ui/drawing/engines/opengl/TransparencyDepth.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/TransparencyDepth.cpp @@ -9,11 +9,11 @@ #ifndef DISABLE_OPENGL -#include "TransparencyDepth.h" +# include "TransparencyDepth.h" -#include -#include -#include +# include +# include +# include /* * Structure to store locations of vertical bounding box edge. diff --git a/src/openrct2-ui/input/KeyboardShortcuts.h b/src/openrct2-ui/input/KeyboardShortcuts.h index ef95930ccb8b..9812a4fee98b 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.h +++ b/src/openrct2-ui/input/KeyboardShortcuts.h @@ -17,9 +17,9 @@ #define ALT 0x400 #define CMD 0x800 #ifdef __MACOSX__ -#define PLATFORM_MODIFIER CMD +# define PLATFORM_MODIFIER CMD #else -#define PLATFORM_MODIFIER CTRL +# define PLATFORM_MODIFIER CTRL #endif enum diff --git a/src/openrct2/CmdlineSprite.cpp b/src/openrct2/CmdlineSprite.cpp index 1a1d89e72541..11abfb02f297 100644 --- a/src/openrct2/CmdlineSprite.cpp +++ b/src/openrct2/CmdlineSprite.cpp @@ -76,7 +76,7 @@ static FILE* fopen_utf8(const char* path, const char* mode) return file; } -#define fopen fopen_utf8 +# define fopen fopen_utf8 #endif diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index ae79b136e58f..76c5d75425a7 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -13,7 +13,7 @@ #include #include #ifdef __EMSCRIPTEN__ -#include +# include #endif // __EMSCRIPTEN__ #include "Context.h" #include "Editor.h" diff --git a/src/openrct2/Diagnostic.cpp b/src/openrct2/Diagnostic.cpp index 6962888cfef5..47744e517600 100644 --- a/src/openrct2/Diagnostic.cpp +++ b/src/openrct2/Diagnostic.cpp @@ -15,7 +15,7 @@ #include #ifdef __ANDROID__ -#include +# include #endif [[maybe_unused]] static bool _log_location_enabled = true; diff --git a/src/openrct2/Diagnostic.h b/src/openrct2/Diagnostic.h index 2bfb7d491c05..ef1bbc013e18 100644 --- a/src/openrct2/Diagnostic.h +++ b/src/openrct2/Diagnostic.h @@ -45,28 +45,28 @@ enum DIAGNOSTIC_LEVEL */ #if defined(DEBUG) -#if DEBUG > 0 -#define DEBUG_LEVEL_1 1 -#if DEBUG > 1 -#define DEBUG_LEVEL_2 1 -#if DEBUG > 2 -#define DEBUG_LEVEL_3 1 +# if DEBUG > 0 +# define DEBUG_LEVEL_1 1 +# if DEBUG > 1 +# define DEBUG_LEVEL_2 1 +# if DEBUG > 2 +# define DEBUG_LEVEL_3 1 +# else +# define DEBUG_LEVEL_3 0 +# endif // DEBUG > 2 +# else +# define DEBUG_LEVEL_3 0 +# define DEBUG_LEVEL_2 0 +# endif // DEBUG > 1 +# else +# define DEBUG_LEVEL_1 0 +# define DEBUG_LEVEL_2 0 +# define DEBUG_LEVEL_3 0 +# endif // DEBUG > 0 #else -#define DEBUG_LEVEL_3 0 -#endif // DEBUG > 2 -#else -#define DEBUG_LEVEL_3 0 -#define DEBUG_LEVEL_2 0 -#endif // DEBUG > 1 -#else -#define DEBUG_LEVEL_1 0 -#define DEBUG_LEVEL_2 0 -#define DEBUG_LEVEL_3 0 -#endif // DEBUG > 0 -#else -#define DEBUG_LEVEL_3 0 -#define DEBUG_LEVEL_2 0 -#define DEBUG_LEVEL_1 0 +# define DEBUG_LEVEL_3 0 +# define DEBUG_LEVEL_2 0 +# define DEBUG_LEVEL_1 0 #endif // defined(DEBUG) extern bool _log_levels[DIAGNOSTIC_LEVEL_COUNT]; @@ -76,11 +76,11 @@ void diagnostic_log_with_location( DIAGNOSTIC_LEVEL diagnosticLevel, const char* file, const char* function, int32_t line, const char* format, ...); #ifdef _MSC_VER -#define diagnostic_log_macro(level, format, ...) \ - diagnostic_log_with_location(level, __FILE__, __FUNCTION__, __LINE__, format, ##__VA_ARGS__) +# define diagnostic_log_macro(level, format, ...) \ + diagnostic_log_with_location(level, __FILE__, __FUNCTION__, __LINE__, format, ##__VA_ARGS__) #else -#define diagnostic_log_macro(level, format, ...) \ - diagnostic_log_with_location(level, __FILE__, __func__, __LINE__, format, ##__VA_ARGS__) +# define diagnostic_log_macro(level, format, ...) \ + diagnostic_log_with_location(level, __FILE__, __func__, __LINE__, format, ##__VA_ARGS__) #endif // _MSC_VER #define log_fatal(format, ...) diagnostic_log_macro(DIAGNOSTIC_LEVEL_FATAL, format, ##__VA_ARGS__) diff --git a/src/openrct2/Version.cpp b/src/openrct2/Version.cpp index fb53ccc81a90..1c2ccd9dedb3 100644 --- a/src/openrct2/Version.cpp +++ b/src/openrct2/Version.cpp @@ -12,7 +12,7 @@ #include #ifdef OPENRCT2_BUILD_INFO_HEADER -#include OPENRCT2_BUILD_INFO_HEADER +# include OPENRCT2_BUILD_INFO_HEADER #endif const char gVersionInfoFull[] = OPENRCT2_NAME ", " @@ -23,16 +23,16 @@ const char gVersionInfoFull[] = OPENRCT2_NAME ", " #endif #if defined(OPENRCT2_BRANCH) || defined(OPENRCT2_COMMIT_SHA1_SHORT) || !defined(NDEBUG) " (" -#if defined(OPENRCT2_BRANCH) && defined(OPENRCT2_COMMIT_SHA1_SHORT) +# if defined(OPENRCT2_BRANCH) && defined(OPENRCT2_COMMIT_SHA1_SHORT) OPENRCT2_COMMIT_SHA1_SHORT " on " OPENRCT2_BRANCH -#elif defined(OPENRCT2_COMMIT_SHA1_SHORT) +# elif defined(OPENRCT2_COMMIT_SHA1_SHORT) OPENRCT2_COMMIT_SHA1_SHORT -#elif defined(OPENRCT2_BRANCH) +# elif defined(OPENRCT2_BRANCH) OPENRCT2_BRANCH -#endif -#ifndef NDEBUG +# endif +# ifndef NDEBUG ", DEBUG" -#endif +# endif ")" #endif #ifdef OPENRCT2_BUILD_SERVER diff --git a/src/openrct2/Version.h b/src/openrct2/Version.h index 81de49ac138f..2fb0b2da7f8f 100644 --- a/src/openrct2/Version.h +++ b/src/openrct2/Version.h @@ -15,60 +15,60 @@ #define OPENRCT2_VERSION "0.2.0" #if defined(__amd64__) || defined(_M_AMD64) -#define OPENRCT2_ARCHITECTURE "x86-64" +# define OPENRCT2_ARCHITECTURE "x86-64" #elif defined(__i386__) || defined(_M_IX86) -#define OPENRCT2_ARCHITECTURE "x86" +# define OPENRCT2_ARCHITECTURE "x86" #elif defined(__aarch64__) -#define OPENRCT2_ARCHITECTURE "AArch64" +# define OPENRCT2_ARCHITECTURE "AArch64" #elif defined(__arm__) || defined(_M_ARM) -#if defined(__ARM_ARCH_7A__) -#define OPENRCT2_ARCHITECTURE "arm-v7a" -#else -#define OPENRCT2_ARCHITECTURE "arm" -#endif +# if defined(__ARM_ARCH_7A__) +# define OPENRCT2_ARCHITECTURE "arm-v7a" +# else +# define OPENRCT2_ARCHITECTURE "arm" +# endif #elif defined(__powerpc__) || defined(_M_PPC) -#define OPENRCT2_ARCHITECTURE "PowerPC" +# define OPENRCT2_ARCHITECTURE "PowerPC" #elif defined(__mips64) -#define OPENRCT2_ARCHITECTURE "mips64" +# define OPENRCT2_ARCHITECTURE "mips64" #elif defined(__mips__) -#define OPENRCT2_ARCHITECTURE "mips" +# define OPENRCT2_ARCHITECTURE "mips" #endif #ifdef __EMSCRIPTEN__ -#define OPENRCT2_ARCHITECTURE "Emscripten" +# define OPENRCT2_ARCHITECTURE "Emscripten" #endif #ifndef OPENRCT2_ARCHITECTURE -#error "OPENRCT2_ARCHITECTURE is undefined. Please add identification." +# error "OPENRCT2_ARCHITECTURE is undefined. Please add identification." #endif // Platform #ifdef _WIN32 -#define OPENRCT2_PLATFORM "Windows" +# define OPENRCT2_PLATFORM "Windows" #endif #if defined(__linux__) && !defined(__ANDROID__) -#define OPENRCT2_PLATFORM "Linux" +# define OPENRCT2_PLATFORM "Linux" #endif #if (defined(__APPLE__) && defined(__MACH__)) -#define OPENRCT2_PLATFORM "macOS" +# define OPENRCT2_PLATFORM "macOS" #endif #ifdef __FreeBSD__ -#define OPENRCT2_PLATFORM "FreeBSD" +# define OPENRCT2_PLATFORM "FreeBSD" #endif #ifdef __ANDROID__ -#define OPENRCT2_PLATFORM "Android" +# define OPENRCT2_PLATFORM "Android" #endif #ifdef __OpenBSD__ -#define OPENRCT2_PLATFORM "OpenBSD" +# define OPENRCT2_PLATFORM "OpenBSD" #endif #ifdef __EMSCRIPTEN__ -#define OPENRCT2_PLATFORM "Emscripten" +# define OPENRCT2_PLATFORM "Emscripten" #endif #ifndef OPENRCT2_PLATFORM -#error Unknown platform! +# error Unknown platform! #endif #ifndef OPENRCT2_CUSTOM_INFO -#define OPENRCT2_CUSTOM_INFO "" +# define OPENRCT2_CUSTOM_INFO "" #endif extern const char gVersionInfoFull[]; diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index a9c8e78eba5a..e0ab348bda6b 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -52,9 +52,9 @@ namespace GA_FLAGS } // namespace GA_FLAGS #ifdef __WARN_SUGGEST_FINAL_METHODS__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsuggest-final-methods" -#pragma GCC diagnostic ignored "-Wsuggest-final-types" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsuggest-final-methods" +# pragma GCC diagnostic ignored "-Wsuggest-final-types" #endif /** @@ -190,7 +190,7 @@ struct GameAction }; #ifdef __WARN_SUGGEST_FINAL_METHODS__ -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif template struct GameActionBase : GameAction diff --git a/src/openrct2/audio/AudioMixer.h b/src/openrct2/audio/AudioMixer.h index 7d36a6294fb9..e5b88bc51430 100644 --- a/src/openrct2/audio/AudioMixer.h +++ b/src/openrct2/audio/AudioMixer.h @@ -49,10 +49,10 @@ namespace OpenRCT2::Audio } // namespace OpenRCT2::Audio #ifndef DSBPAN_LEFT -#define DSBPAN_LEFT (-10000) +# define DSBPAN_LEFT (-10000) #endif #ifndef DSBPAN_RIGHT -#define DSBPAN_RIGHT 10000 +# define DSBPAN_RIGHT 10000 #endif void Mixer_Init(const char* device); diff --git a/src/openrct2/cmdline/RootCommands.cpp b/src/openrct2/cmdline/RootCommands.cpp index fda4d3472b71..ecc39e0682a9 100644 --- a/src/openrct2/cmdline/RootCommands.cpp +++ b/src/openrct2/cmdline/RootCommands.cpp @@ -29,9 +29,9 @@ #include #ifdef USE_BREAKPAD -#define IMPLIES_SILENT_BREAKPAD ", implies --silent-breakpad" +# define IMPLIES_SILENT_BREAKPAD ", implies --silent-breakpad" #else -#define IMPLIES_SILENT_BREAKPAD +# define IMPLIES_SILENT_BREAKPAD #endif // USE_BREAKPAD #ifndef DISABLE_NETWORK diff --git a/src/openrct2/common.h b/src/openrct2/common.h index 2f8d1437ad2f..4260e31497b7 100644 --- a/src/openrct2/common.h +++ b/src/openrct2/common.h @@ -11,12 +11,12 @@ #define _COMMON_H_ #ifndef _USE_MATH_DEFINES -#define _USE_MATH_DEFINES +# define _USE_MATH_DEFINES #endif #undef M_PI #ifdef _MSC_VER -#include +# include #endif #include "Diagnostic.h" @@ -35,7 +35,7 @@ using utf16string = utf16*; // Define MAX_PATH for various headers that don't want to include system headers // just for MAX_PATH #ifndef MAX_PATH -#define MAX_PATH 260 +# define MAX_PATH 260 #endif using codepoint_t = uint32_t; @@ -60,22 +60,22 @@ using colour_t = uint8_t; #define nameof(symbol) #symbol #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -#include -#define STUB() log_warning("Function %s at %s:%d is a stub.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__) -#define _strcmpi _stricmp -#define _stricmp(x, y) strcasecmp((x), (y)) -#define _strnicmp(x, y, n) strncasecmp((x), (y), (n)) -#define _strdup(x) strdup((x)) - -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -#define RCT2_ENDIANESS __ORDER_LITTLE_ENDIAN__ -#define LOBYTE(w) ((uint8_t)(w)) -#define HIBYTE(w) ((uint8_t)(((uint16_t)(w) >> 8) & 0xFF)) -#endif // __BYTE_ORDER__ - -#ifndef RCT2_ENDIANESS -#error Unknown endianess! -#endif // RCT2_ENDIANESS +# include +# define STUB() log_warning("Function %s at %s:%d is a stub.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__) +# define _strcmpi _stricmp +# define _stricmp(x, y) strcasecmp((x), (y)) +# define _strnicmp(x, y, n) strncasecmp((x), (y), (n)) +# define _strdup(x) strdup((x)) + +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define RCT2_ENDIANESS __ORDER_LITTLE_ENDIAN__ +# define LOBYTE(w) ((uint8_t)(w)) +# define HIBYTE(w) ((uint8_t)(((uint16_t)(w) >> 8) & 0xFF)) +# endif // __BYTE_ORDER__ + +# ifndef RCT2_ENDIANESS +# error Unknown endianess! +# endif // RCT2_ENDIANESS #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) @@ -87,7 +87,7 @@ char* strndup(const char* src, size_t size); // BSD and macOS have MAP_ANON instead of MAP_ANONYMOUS #ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON +# define MAP_ANONYMOUS MAP_ANON #endif #define OPENRCT2_MASTER_SERVER_URL "https://servers.openrct2.io" @@ -151,24 +151,24 @@ using rct_string_id = uint16_t; } while (false) #ifndef interface -#define interface struct +# define interface struct #endif #define abstract = 0 #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) -#define OPENRCT2_X86 +# define OPENRCT2_X86 #elif defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_X64) || defined(_M_IX86)) // VS2008 -#define OPENRCT2_X86 +# define OPENRCT2_X86 #endif #if defined(__i386__) || defined(_M_IX86) -#define PLATFORM_X86 +# define PLATFORM_X86 #endif #if defined(__LP64__) || defined(_WIN64) -#define PLATFORM_64BIT +# define PLATFORM_64BIT #else -#define PLATFORM_32BIT +# define PLATFORM_32BIT #endif // C99's restrict keywords guarantees the pointer in question, for the whole of its lifetime, @@ -176,26 +176,26 @@ using rct_string_id = uint16_t; // aliasing the same memory area. Using it lets compiler generate better code. If your compiler // does not support it, feel free to drop it, at some performance hit. #ifdef _MSC_VER -#define RESTRICT __restrict +# define RESTRICT __restrict #else -#define RESTRICT __restrict__ +# define RESTRICT __restrict__ #endif #define assert_struct_size(x, y) static_assert(sizeof(x) == (y), "Improper struct size") #ifdef PLATFORM_X86 -#ifndef FASTCALL -#ifdef __GNUC__ -#define FASTCALL __attribute__((fastcall)) -#elif defined(_MSC_VER) -#define FASTCALL __fastcall -#else -#pragma message "Not using fastcall calling convention, please check your compiler support" -#define FASTCALL -#endif -#endif // FASTCALL -#else // PLATFORM_X86 -#define FASTCALL +# ifndef FASTCALL +# ifdef __GNUC__ +# define FASTCALL __attribute__((fastcall)) +# elif defined(_MSC_VER) +# define FASTCALL __fastcall +# else +# pragma message "Not using fastcall calling convention, please check your compiler support" +# define FASTCALL +# endif +# endif // FASTCALL +#else // PLATFORM_X86 +# define FASTCALL #endif // PLATFORM_X86 /** diff --git a/src/openrct2/core/Crypt.OpenSSL.cpp b/src/openrct2/core/Crypt.OpenSSL.cpp index 8b421f765825..9046019cd760 100644 --- a/src/openrct2/core/Crypt.OpenSSL.cpp +++ b/src/openrct2/core/Crypt.OpenSSL.cpp @@ -9,13 +9,13 @@ #ifndef DISABLE_NETWORK -#include "Crypt.h" +# include "Crypt.h" -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include using namespace Crypt; diff --git a/src/openrct2/core/Diagnostics.cpp b/src/openrct2/core/Diagnostics.cpp index d50cfaa73eef..98e2f48f1e28 100644 --- a/src/openrct2/core/Diagnostics.cpp +++ b/src/openrct2/core/Diagnostics.cpp @@ -8,8 +8,8 @@ *****************************************************************************/ #if defined(DEBUG) && defined(_WIN32) -#define WIN32_LEAN_AND_MEAN -#include +# define WIN32_LEAN_AND_MEAN +# include #endif #include "Diagnostics.hpp" @@ -19,12 +19,12 @@ namespace Debug void Break() { #if defined(DEBUG) -#if defined(_WIN32) +# if defined(_WIN32) if (IsDebuggerPresent()) { DebugBreak(); } -#endif +# endif #endif } } // namespace Debug diff --git a/src/openrct2/core/File.cpp b/src/openrct2/core/File.cpp index 37b75c01bf93..98db53805e24 100644 --- a/src/openrct2/core/File.cpp +++ b/src/openrct2/core/File.cpp @@ -8,10 +8,10 @@ *****************************************************************************/ #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include +# define WIN32_LEAN_AND_MEAN +# include #else -#include +# include #endif #include "../platform/platform.h" diff --git a/src/openrct2/core/FileScanner.cpp b/src/openrct2/core/FileScanner.cpp index a7bbd64ebfe0..68b5abc23b61 100644 --- a/src/openrct2/core/FileScanner.cpp +++ b/src/openrct2/core/FileScanner.cpp @@ -10,18 +10,18 @@ #include "../common.h" #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include +# define WIN32_LEAN_AND_MEAN +# include #endif #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -#include -#include -#include -#include +# include +# include +# include +# include #elif defined(_WIN32) // Windows needs this for widechar <-> utf8 conversion utils -#include "../localisation/Language.h" +# include "../localisation/Language.h" #endif #include "FileScanner.h" diff --git a/src/openrct2/core/Guard.cpp b/src/openrct2/core/Guard.cpp index 65b10f25dc8f..b8950c50f167 100644 --- a/src/openrct2/core/Guard.cpp +++ b/src/openrct2/core/Guard.cpp @@ -8,8 +8,8 @@ *****************************************************************************/ #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include +# define WIN32_LEAN_AND_MEAN +# include #endif #include "../Version.h" @@ -142,12 +142,12 @@ namespace Guard static void ForceCrash() { -#ifdef USE_BREAKPAD +# ifdef USE_BREAKPAD // Force a crash that breakpad will handle allowing us to get a dump *((void**)0) = 0; -#else +# else assert(false); -#endif +# endif } #endif } // namespace Guard diff --git a/src/openrct2/core/Path.cpp b/src/openrct2/core/Path.cpp index 307bd4f5fad1..27d74604079c 100644 --- a/src/openrct2/core/Path.cpp +++ b/src/openrct2/core/Path.cpp @@ -9,7 +9,7 @@ #include #ifndef _WIN32 -#include +# include #endif #include "../localisation/Language.h" diff --git a/src/openrct2/core/String.cpp b/src/openrct2/core/String.cpp index 9f7d1c32abcf..292f341c211c 100644 --- a/src/openrct2/core/String.cpp +++ b/src/openrct2/core/String.cpp @@ -9,25 +9,25 @@ #ifdef __MINGW32__ // 0x0600 == vista -#define WINVER 0x0600 -#define _WIN32_WINNT 0x0600 +# define WINVER 0x0600 +# define _WIN32_WINNT 0x0600 #endif // __MINGW32__ #include #include #include #ifndef _WIN32 -#include -#include -#include +# include +# include +# include #endif #ifdef _WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif -#define WIN32_LEAN_AND_MEAN -#include +# ifndef NOMINMAX +# define NOMINMAX +# endif +# define WIN32_LEAN_AND_MEAN +# include #endif #include "../common.h" @@ -80,14 +80,14 @@ namespace String // Which constructor to use depends on the size of wchar_t... // UTF-32 is the default on most POSIX systems; Windows uses UTF-16. // Unfortunately, we'll have to help the compiler here. -#if U_SIZEOF_WCHAR_T == 4 +# if U_SIZEOF_WCHAR_T == 4 icu::UnicodeString str = icu::UnicodeString::fromUTF32((const UChar32*)src.data(), src.length()); -#elif U_SIZEOF_WCHAR_T == 2 +# elif U_SIZEOF_WCHAR_T == 2 std::wstring wstr = std::wstring(src); icu::UnicodeString str = icu::UnicodeString((const wchar_t*)wstr.c_str()); -#else -#error Unsupported U_SIZEOF_WCHAR_T size -#endif +# else +# error Unsupported U_SIZEOF_WCHAR_T size +# endif std::string result; str.toUTF8String(result); @@ -110,20 +110,20 @@ namespace String // Which constructor to use depends on the size of wchar_t... // UTF-32 is the default on most POSIX systems; Windows uses UTF-16. // Unfortunately, we'll have to help the compiler here. -#if U_SIZEOF_WCHAR_T == 4 +# if U_SIZEOF_WCHAR_T == 4 size_t length = (size_t)str.length(); std::wstring result(length, '\0'); UErrorCode status = U_ZERO_ERROR; str.toUTF32((UChar32*)&result[0], str.length(), status); -#elif U_SIZEOF_WCHAR_T == 2 +# elif U_SIZEOF_WCHAR_T == 2 const char16_t* buffer = str.getBuffer(); std::wstring result = (wchar_t*)buffer; -#else -#error Unsupported U_SIZEOF_WCHAR_T size -#endif +# else +# error Unsupported U_SIZEOF_WCHAR_T size +# endif return result; #endif diff --git a/src/openrct2/core/Zip.cpp b/src/openrct2/core/Zip.cpp index bb29f57bbb09..5cb0995d8dca 100644 --- a/src/openrct2/core/Zip.cpp +++ b/src/openrct2/core/Zip.cpp @@ -8,11 +8,11 @@ *****************************************************************************/ #ifndef __ANDROID__ -#include "Zip.h" +# include "Zip.h" -#include "IStream.hpp" +# include "IStream.hpp" -#include +# include class ZipArchive final : public IZipArchive { diff --git a/src/openrct2/core/ZipAndroid.cpp b/src/openrct2/core/ZipAndroid.cpp index 59826a03b6d0..0aba148469d3 100644 --- a/src/openrct2/core/ZipAndroid.cpp +++ b/src/openrct2/core/ZipAndroid.cpp @@ -9,11 +9,11 @@ #ifdef __ANDROID__ -#include "IStream.hpp" -#include "Zip.h" +# include "IStream.hpp" +# include "Zip.h" -#include -#include +# include +# include class ZipArchive final : public IZipArchive { diff --git a/src/openrct2/drawing/AVX2Drawing.cpp b/src/openrct2/drawing/AVX2Drawing.cpp index 8988e83c66f4..cbbae06b9d12 100644 --- a/src/openrct2/drawing/AVX2Drawing.cpp +++ b/src/openrct2/drawing/AVX2Drawing.cpp @@ -13,7 +13,7 @@ #ifdef __AVX2__ -#include +# include void mask_avx2( int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, @@ -44,9 +44,9 @@ void mask_avx2( #else -#ifdef OPENRCT2_X86 -#error You have to compile this file with AVX2 enabled, when targeting x86! -#endif +# ifdef OPENRCT2_X86 +# error You have to compile this file with AVX2 enabled, when targeting x86! +# endif void mask_avx2( int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, diff --git a/src/openrct2/drawing/Image.cpp b/src/openrct2/drawing/Image.cpp index d1fc1ce99793..44c0cdda093a 100644 --- a/src/openrct2/drawing/Image.cpp +++ b/src/openrct2/drawing/Image.cpp @@ -35,8 +35,8 @@ static std::list _allocatedLists; // MSVC's compiler doesn't support the [[maybe_unused]] attribute for unused static functions. Until this has been resolved, we // need to explicitly tell the compiler to temporarily disable the warning. // See discussion at https://github.com/OpenRCT2/OpenRCT2/pull/7617 -#pragma warning(push) -#pragma warning(disable : 4505) // unreferenced local function has been removed +# pragma warning(push) +# pragma warning(disable : 4505) // unreferenced local function has been removed [[maybe_unused]] static bool AllocatedListContains(uint32_t baseImageId, uint32_t count) { @@ -47,7 +47,7 @@ static std::list _allocatedLists; return contains; } -#pragma warning(pop) +# pragma warning(pop) static bool AllocatedListRemove(uint32_t baseImageId, uint32_t count) { diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index 0c72e757b88e..344d9c63f015 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -9,23 +9,23 @@ #ifdef __ENABLE_LIGHTFX__ -#include "LightFX.h" - -#include "../Game.h" -#include "../common.h" -#include "../config/Config.h" -#include "../interface/Viewport.h" -#include "../interface/Window.h" -#include "../ride/Ride.h" -#include "../util/Util.h" -#include "../world/Climate.h" -#include "../world/Map.h" -#include "../world/Sprite.h" -#include "Drawing.h" - -#include -#include -#include +# include "LightFX.h" + +# include "../Game.h" +# include "../common.h" +# include "../config/Config.h" +# include "../interface/Viewport.h" +# include "../interface/Window.h" +# include "../ride/Ride.h" +# include "../util/Util.h" +# include "../world/Climate.h" +# include "../world/Map.h" +# include "../world/Sprite.h" +# include "Drawing.h" + +# include +# include +# include static uint8_t _bakedLightTexture_lantern_0[32 * 32]; static uint8_t _bakedLightTexture_lantern_1[64 * 64]; @@ -242,7 +242,7 @@ void lightfx_prepare_light_list() break; } -#ifdef LIGHTFX_UNKNOWN_PART_1 +# ifdef LIGHTFX_UNKNOWN_PART_1 int32_t tileOffsetX = 0; int32_t tileOffsetY = 0; switch (_current_view_rotation_front) @@ -275,7 +275,7 @@ void lightfx_prepare_light_list() -3, -2, -3, 2, 3, -2, 3, 2, }; // clang-format on -#endif // LIGHTFX_UNKNOWN_PART_1 +# endif // LIGHTFX_UNKNOWN_PART_1 if (true) { @@ -304,7 +304,7 @@ void lightfx_prepare_light_list() // offsetPattern[pat*2+1] / mapFrontDiv, VIEWPORT_INTERACTION_MASK_NONE, &mapCoord.x, &mapCoord.y, // &interactionType, &tileElement, NULL); -#ifdef LIGHTFX_UNKNOWN_PART_1 +# ifdef LIGHTFX_UNKNOWN_PART_1 _unk9AC154 = ~VIEWPORT_INTERACTION_MASK_SPRITE & 0xFFFF; _viewportDpi1.zoom = _current_view_zoom_front; _viewportDpi1.x = entry->x + offsetPattern[0 + pat * 2] / mapFrontDiv; @@ -328,7 +328,7 @@ void lightfx_prepare_light_list() mapCoord.y = _interactionMapY + tileOffsetY; interactionType = _interactionSpriteType; tileElement = RCT2_GLOBAL(0x9AC150, rct_tile_element*); -#endif // LIGHTFX_UNKNOWN_PART_1 +# endif // LIGHTFX_UNKNOWN_PART_1 // RCT2_GLOBAL(0x9AC154, uint16_t) = VIEWPORT_INTERACTION_MASK_NONE; // RCT2_GLOBAL(0x9AC148, uint8_t) = 0; @@ -933,9 +933,9 @@ void lightfx_apply_palette_filter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b) float overExpose = 0.0f; float lightAvg = (natLightR + natLightG + natLightB) / 3.0f; -#ifdef LIGHTFX_UNKNOWN_PART_2 +# ifdef LIGHTFX_UNKNOWN_PART_2 float lightMax = (natLightR + natLightG + natLightB) / 3.0f; -#endif // LIGHTFX_UNKNOWN_PART_2 +# endif // LIGHTFX_UNKNOWN_PART_2 // overExpose += ((lightMax - lightAvg) / lightMax) * 0.01f; @@ -947,9 +947,9 @@ void lightfx_apply_palette_filter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b) // overExpose += offset * 0.1f; } -#ifdef LIGHTFX_UNKNOWN_PART_2 +# ifdef LIGHTFX_UNKNOWN_PART_2 lightAvg += (lightMax - lightAvg) * 0.6f; -#endif // LIGHTFX_UNKNOWN_PART_2 +# endif // LIGHTFX_UNKNOWN_PART_2 if (lightAvg > 1.0f) { diff --git a/src/openrct2/drawing/LightFX.h b/src/openrct2/drawing/LightFX.h index 5d0cc98aa22c..4e58e0b1f7b5 100644 --- a/src/openrct2/drawing/LightFX.h +++ b/src/openrct2/drawing/LightFX.h @@ -12,7 +12,7 @@ #ifdef __ENABLE_LIGHTFX__ -#include "../common.h" +# include "../common.h" struct LocationXY16; struct rct_drawpixelinfo; diff --git a/src/openrct2/drawing/SSE41Drawing.cpp b/src/openrct2/drawing/SSE41Drawing.cpp index 281a3a5e13fe..e781419b16fd 100644 --- a/src/openrct2/drawing/SSE41Drawing.cpp +++ b/src/openrct2/drawing/SSE41Drawing.cpp @@ -13,7 +13,7 @@ #ifdef __SSE4_1__ -#include +# include void mask_sse4_1( int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, @@ -58,9 +58,9 @@ void mask_sse4_1( #else -#ifdef OPENRCT2_X86 -#error You have to compile this file with SSE4.1 enabled, when targetting x86! -#endif +# ifdef OPENRCT2_X86 +# error You have to compile this file with SSE4.1 enabled, when targetting x86! +# endif void mask_sse4_1( int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, diff --git a/src/openrct2/drawing/TTF.cpp b/src/openrct2/drawing/TTF.cpp index 79ad45b50837..ac13be3c98ec 100644 --- a/src/openrct2/drawing/TTF.cpp +++ b/src/openrct2/drawing/TTF.cpp @@ -9,23 +9,23 @@ #ifndef NO_TTF -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdocumentation" -#include -#include FT_FREETYPE_H -#pragma clang diagnostic pop - -#include "../OpenRCT2.h" -#include "../config/Config.h" -#include "../localisation/Localisation.h" -#include "../localisation/LocalisationService.h" -#include "../platform/platform.h" -#include "TTF.h" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdocumentation" +# include +# include FT_FREETYPE_H +# pragma clang diagnostic pop + +# include "../OpenRCT2.h" +# include "../config/Config.h" +# include "../localisation/Localisation.h" +# include "../localisation/LocalisationService.h" +# include "../platform/platform.h" +# include "TTF.h" static bool _ttfInitialised = false; -#define TTF_SURFACE_CACHE_SIZE 256 -#define TTF_GETWIDTH_CACHE_SIZE 1024 +# define TTF_SURFACE_CACHE_SIZE 256 +# define TTF_GETWIDTH_CACHE_SIZE 1024 struct ttf_cache_entry { @@ -337,7 +337,7 @@ void ttf_free_surface(TTFSurface* surface) #else -#include "TTF.h" +# include "TTF.h" bool ttf_initialise() { diff --git a/src/openrct2/drawing/TTFSDLPort.cpp b/src/openrct2/drawing/TTFSDLPort.cpp index 77a19dc18ecc..7eca5a14c448 100644 --- a/src/openrct2/drawing/TTFSDLPort.cpp +++ b/src/openrct2/drawing/TTFSDLPort.cpp @@ -27,54 +27,54 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include -#include -#include -#include +# include +# include +# include +# include -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdocumentation" -#include -#include FT_FREETYPE_H -#include FT_OUTLINE_H -#include FT_STROKER_H -#include FT_GLYPH_H -#include FT_TRUETYPE_IDS_H -#pragma clang diagnostic pop +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdocumentation" +# include +# include FT_FREETYPE_H +# include FT_OUTLINE_H +# include FT_STROKER_H +# include FT_GLYPH_H +# include FT_TRUETYPE_IDS_H +# pragma clang diagnostic pop -#include "TTF.h" +# include "TTF.h" -#pragma warning(disable : 4018) // '<': signed / unsigned mismatch +# pragma warning(disable : 4018) // '<': signed / unsigned mismatch /* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */ -#define UNICODE_BOM_NATIVE 0xFEFF -#define UNICODE_BOM_SWAPPED 0xFFFE +# define UNICODE_BOM_NATIVE 0xFEFF +# define UNICODE_BOM_SWAPPED 0xFFFE /* Set and retrieve the font style */ -#define TTF_STYLE_NORMAL 0x00 -#define TTF_STYLE_BOLD 0x01 -#define TTF_STYLE_ITALIC 0x02 -#define TTF_STYLE_UNDERLINE 0x04 -#define TTF_STYLE_STRIKETHROUGH 0x08 +# define TTF_STYLE_NORMAL 0x00 +# define TTF_STYLE_BOLD 0x01 +# define TTF_STYLE_ITALIC 0x02 +# define TTF_STYLE_UNDERLINE 0x04 +# define TTF_STYLE_STRIKETHROUGH 0x08 /* Set and retrieve FreeType hinter settings */ -#define TTF_HINTING_NORMAL 0 -#define TTF_HINTING_LIGHT 1 -#define TTF_HINTING_MONO 2 -#define TTF_HINTING_NONE 3 +# define TTF_HINTING_NORMAL 0 +# define TTF_HINTING_LIGHT 1 +# define TTF_HINTING_MONO 2 +# define TTF_HINTING_NONE 3 /* FIXME: Right now we assume the gray-scale renderer Freetype is using supports 256 shades of gray, but we should instead key off of num_grays in the result FT_Bitmap after the FT_Render_Glyph() call. */ -#define NUM_GRAYS 256 +# define NUM_GRAYS 256 /* Handy routines for converting from fixed point */ -#define FT_FLOOR(X) (((X) & -64) / 64) -#define FT_CEIL(X) ((((X) + 63) & -64) / 64) +# define FT_FLOOR(X) (((X) & -64) / 64) +# define FT_CEIL(X) ((((X) + 63) & -64) / 64) -#define CACHED_METRICS 0x10 -#define CACHED_BITMAP 0x01 -#define CACHED_PIXMAP 0x02 +# define CACHED_METRICS 0x10 +# define CACHED_BITMAP 0x01 +# define CACHED_PIXMAP 0x02 /* Cached glyph information */ struct c_glyph @@ -137,31 +137,31 @@ struct _TTF_Font }; /* Handle a style only if the font does not already handle it */ -#define TTF_HANDLE_STYLE_BOLD(font) (((font)->style & TTF_STYLE_BOLD) && !((font)->face_style & TTF_STYLE_BOLD)) -#define TTF_HANDLE_STYLE_ITALIC(font) (((font)->style & TTF_STYLE_ITALIC) && !((font)->face_style & TTF_STYLE_ITALIC)) -#define TTF_HANDLE_STYLE_UNDERLINE(font) ((font)->style & TTF_STYLE_UNDERLINE) -#define TTF_HANDLE_STYLE_STRIKETHROUGH(font) ((font)->style & TTF_STYLE_STRIKETHROUGH) +# define TTF_HANDLE_STYLE_BOLD(font) (((font)->style & TTF_STYLE_BOLD) && !((font)->face_style & TTF_STYLE_BOLD)) +# define TTF_HANDLE_STYLE_ITALIC(font) (((font)->style & TTF_STYLE_ITALIC) && !((font)->face_style & TTF_STYLE_ITALIC)) +# define TTF_HANDLE_STYLE_UNDERLINE(font) ((font)->style & TTF_STYLE_UNDERLINE) +# define TTF_HANDLE_STYLE_STRIKETHROUGH(font) ((font)->style & TTF_STYLE_STRIKETHROUGH) /* Font styles that does not impact glyph drawing */ -#define TTF_STYLE_NO_GLYPH_CHANGE (TTF_STYLE_UNDERLINE | TTF_STYLE_STRIKETHROUGH) +# define TTF_STYLE_NO_GLYPH_CHANGE (TTF_STYLE_UNDERLINE | TTF_STYLE_STRIKETHROUGH) /* The FreeType font engine/library */ static FT_Library library; static int TTF_initialized = 0; -#define TTF_SetError log_error - -#define TTF_CHECKPOINTER(p, errval) \ - if (!TTF_initialized) \ - { \ - TTF_SetError("Library not initialized"); \ - return errval; \ - } \ - if (!(p)) \ - { \ - TTF_SetError("Passed a NULL pointer"); \ - return errval; \ - } +# define TTF_SetError log_error + +# define TTF_CHECKPOINTER(p, errval) \ + if (!TTF_initialized) \ + { \ + TTF_SetError("Library not initialized"); \ + return errval; \ + } \ + if (!(p)) \ + { \ + TTF_SetError("Passed a NULL pointer"); \ + return errval; \ + } /* Gets the top row of the underline. The outline is taken into account. @@ -264,15 +264,15 @@ static void TTF_drawLine_Shaded(const TTF_Font* font, const TTFSurface* textbuf, static void TTF_SetFTError(const char* msg, [[maybe_unused]] FT_Error error) { -#ifdef USE_FREETYPE_ERRORS -#undef FTERRORS_H -#define FT_ERRORDEF(e, v, s) { e, s }, +# ifdef USE_FREETYPE_ERRORS +# undef FTERRORS_H +# define FT_ERRORDEF(e, v, s) { e, s }, static const struct { int err_code; const char* err_msg; } ft_errors[] = { -#include +# include }; int i; const char* err_msg; @@ -292,9 +292,9 @@ static void TTF_SetFTError(const char* msg, [[maybe_unused]] FT_Error error) err_msg = "unknown FreeType error"; } TTF_SetError("%s: %s", msg, err_msg); -#else +# else TTF_SetError("%s", msg); -#endif /* USE_FREETYPE_ERRORS */ +# endif /* USE_FREETYPE_ERRORS */ } int TTF_Init(void) @@ -489,14 +489,14 @@ static TTF_Font* TTF_OpenFontIndexRW(FILE* src, int freesrc, int ptsize, long in font->underline_height = 1; } -#ifdef DEBUG_FONTS +# ifdef DEBUG_FONTS printf("Font metrics:\n"); printf("\tascent = %d, descent = %d\n", font->ascent, font->descent); printf("\theight = %d, lineskip = %d\n", font->height, font->lineskip); printf("\tunderline_offset = %d, underline_height = %d\n", font->underline_offset, font->underline_height); printf( "\tunderline_top_row = %d, strikethrough_top_row = %d\n", TTF_underline_top_row(font), TTF_strikethrough_top_row(font)); -#endif +# endif /* Initialize the font face style */ font->face_style = TTF_STYLE_NORMAL; @@ -997,7 +997,7 @@ void TTF_CloseFont(TTF_Font* font) } /* Gets a unicode value from a UTF-8 encoded string and advance the string */ -#define UNKNOWN_UNICODE 0xFFFD +# define UNKNOWN_UNICODE 0xFFFD static uint32_t UTF8_getch(const char** src, size_t* srclen) { const uint8_t* p = *(const uint8_t**)src; @@ -1172,7 +1172,7 @@ int TTF_SizeUTF8(TTF_Font* font, const char* text, int* w, int* h) x += delta.x >> 6; } -#if 0 +# if 0 if ((ch == text) && (glyph->minx < 0)) { /* Fixes the texture wrapping bug when the first letter * has a negative minx value or horibearing value. The entire @@ -1189,7 +1189,7 @@ int TTF_SizeUTF8(TTF_Font* font, const char* text, int* w, int* h) * */ z -= glyph->minx; } -#endif +# endif z = x + glyph->minx; if (minx > z) diff --git a/src/openrct2/drawing/X8DrawingEngine.cpp b/src/openrct2/drawing/X8DrawingEngine.cpp index af11e869fb08..6b0f328a8d8b 100644 --- a/src/openrct2/drawing/X8DrawingEngine.cpp +++ b/src/openrct2/drawing/X8DrawingEngine.cpp @@ -125,8 +125,8 @@ void X8RainDrawer::Restore() } #ifdef __WARN_SUGGEST_FINAL_METHODS__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsuggest-final-methods" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsuggest-final-methods" #endif X8DrawingEngine::X8DrawingEngine([[maybe_unused]] const std::shared_ptr& uiContext) @@ -462,7 +462,7 @@ void X8DrawingEngine::DrawDirtyBlocks(uint32_t x, uint32_t y, uint32_t columns, } #ifdef __WARN_SUGGEST_FINAL_METHODS__ -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif X8DrawingContext::X8DrawingContext(X8DrawingEngine* engine) diff --git a/src/openrct2/drawing/X8DrawingEngine.h b/src/openrct2/drawing/X8DrawingEngine.h index 3c962f68d650..7a5560f37105 100644 --- a/src/openrct2/drawing/X8DrawingEngine.h +++ b/src/openrct2/drawing/X8DrawingEngine.h @@ -60,8 +60,8 @@ namespace OpenRCT2 }; #ifdef __WARN_SUGGEST_FINAL_TYPES__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsuggest-final-types" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsuggest-final-types" #endif class X8DrawingEngine : public IDrawingEngine { @@ -116,7 +116,7 @@ namespace OpenRCT2 void DrawDirtyBlocks(uint32_t x, uint32_t y, uint32_t columns, uint32_t rows); }; #ifdef __WARN_SUGGEST_FINAL_TYPES__ -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif class X8DrawingContext final : public IDrawingContext diff --git a/src/openrct2/interface/FontFamilies.h b/src/openrct2/interface/FontFamilies.h index 2c6c5f358ca9..e7f45d6085c4 100644 --- a/src/openrct2/interface/FontFamilies.h +++ b/src/openrct2/interface/FontFamilies.h @@ -14,7 +14,7 @@ #ifndef NO_TTF -#include +# include struct TTFFontSetDescriptor; @@ -26,11 +26,11 @@ extern TTFontFamily const TTFFamilyJapanese; extern TTFontFamily const TTFFamilyKorean; extern TTFontFamily const TTFFamilySansSerif; -#define FAMILY(x) x +# define FAMILY(x) x #else // NO_TTF -#define FAMILY(x) FAMILY_OPENRCT2_SPRITE +# define FAMILY(x) FAMILY_OPENRCT2_SPRITE #endif // NO_TTF diff --git a/src/openrct2/interface/Fonts.h b/src/openrct2/interface/Fonts.h index a2df2fdf20f2..afe7aac0d207 100644 --- a/src/openrct2/interface/Fonts.h +++ b/src/openrct2/interface/Fonts.h @@ -28,9 +28,9 @@ extern TTFFontSetDescriptor TTFFontGulim; extern TTFFontSetDescriptor TTFFontNanum; extern TTFFontSetDescriptor TTFFontArial; extern TTFFontSetDescriptor TTFFontArialUnicode; -#define FONT(x) x +# define FONT(x) x #else -#define FONT(x) FONT_OPENRCT2_SPRITE +# define FONT(x) FONT_OPENRCT2_SPRITE #endif // NO_TTF void TryLoadFonts(OpenRCT2::Localisation::LocalisationService& localisationService); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 265d326e04b9..205192497c15 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -49,7 +49,7 @@ #include #ifndef NO_TTF -#include "../drawing/TTF.h" +# include "../drawing/TTF.h" #endif diff --git a/src/openrct2/localisation/Localisation.cpp b/src/openrct2/localisation/Localisation.cpp index 56f2660bdf48..5256f0bf766e 100644 --- a/src/openrct2/localisation/Localisation.cpp +++ b/src/openrct2/localisation/Localisation.cpp @@ -12,14 +12,14 @@ #include #ifdef _WIN32 -#include +# include #elif defined(__ANDROID__) -#include -#include +# include +# include #else -#include -#include +# include +# include #endif // _WIN32 #include "../Game.h" diff --git a/src/openrct2/network/DiscordService.cpp b/src/openrct2/network/DiscordService.cpp index 1585e3ec440f..1e4fa5b6150a 100644 --- a/src/openrct2/network/DiscordService.cpp +++ b/src/openrct2/network/DiscordService.cpp @@ -9,17 +9,17 @@ #ifdef __ENABLE_DISCORD__ -#include "DiscordService.h" +# include "DiscordService.h" -#include "../Context.h" -#include "../OpenRCT2.h" -#include "../core/Console.hpp" -#include "../core/String.hpp" -#include "../localisation/Localisation.h" -#include "../world/Park.h" -#include "network.h" +# include "../Context.h" +# include "../OpenRCT2.h" +# include "../core/Console.hpp" +# include "../core/String.hpp" +# include "../localisation/Localisation.h" +# include "../world/Park.h" +# include "network.h" -#include +# include constexpr const char* APPLICATION_ID = "378612438200877056"; constexpr const char* STEAM_APP_ID = nullptr; diff --git a/src/openrct2/network/DiscordService.h b/src/openrct2/network/DiscordService.h index 615c35627eb0..d98b3cace217 100644 --- a/src/openrct2/network/DiscordService.h +++ b/src/openrct2/network/DiscordService.h @@ -11,9 +11,9 @@ #ifdef __ENABLE_DISCORD__ -#include "../common.h" +# include "../common.h" -#include +# include class DiscordService final { diff --git a/src/openrct2/network/Http.cpp b/src/openrct2/network/Http.cpp index e2ce5c9d9ae4..ee4f30e4f121 100644 --- a/src/openrct2/network/Http.cpp +++ b/src/openrct2/network/Http.cpp @@ -16,16 +16,16 @@ #ifndef DISABLE_HTTP -#include "../Version.h" -#include "../core/Console.hpp" +# include "../Version.h" +# include "../core/Console.hpp" -#ifdef _WIN32 +# ifdef _WIN32 // cURL includes windows.h, but we don't need all of it. -#define WIN32_LEAN_AND_MEAN -#endif -#include +# define WIN32_LEAN_AND_MEAN +# endif +# include -#define OPENRCT2_USER_AGENT "OpenRCT2/" OPENRCT2_VERSION +# define OPENRCT2_USER_AGENT "OpenRCT2/" OPENRCT2_VERSION namespace OpenRCT2::Network::Http { diff --git a/src/openrct2/network/Http.h b/src/openrct2/network/Http.h index e1f17d436b22..fd972068fafb 100644 --- a/src/openrct2/network/Http.h +++ b/src/openrct2/network/Http.h @@ -11,11 +11,11 @@ #ifndef DISABLE_HTTP -#include "../common.h" +# include "../common.h" -#include -#include -#include +# include +# include +# include namespace OpenRCT2::Network::Http { diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 1dda32d93f73..568f43ed2edd 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -35,38 +35,38 @@ static int32_t _pickup_peep_old_x = LOCATION_NULL; #ifndef DISABLE_NETWORK -#include "../Cheats.h" -#include "../Game.h" -#include "../ParkImporter.h" -#include "../actions/GameAction.h" -#include "../config/Config.h" -#include "../core/Console.hpp" -#include "../core/FileStream.hpp" -#include "../core/Json.hpp" -#include "../core/Math.hpp" -#include "../core/MemoryStream.h" -#include "../core/Path.hpp" -#include "../core/String.hpp" -#include "../core/Util.hpp" -#include "../interface/Chat.h" -#include "../interface/Window.h" -#include "../localisation/Date.h" -#include "../localisation/Localisation.h" -#include "../object/ObjectManager.h" -#include "../object/ObjectRepository.h" -#include "../rct2/S6Exporter.h" -#include "../scenario/Scenario.h" -#include "../util/Util.h" -#include "../world/Park.h" -#include "NetworkAction.h" - -#include -#include -#include -#include -#include - -#pragma comment(lib, "Ws2_32.lib") +# include "../Cheats.h" +# include "../Game.h" +# include "../ParkImporter.h" +# include "../actions/GameAction.h" +# include "../config/Config.h" +# include "../core/Console.hpp" +# include "../core/FileStream.hpp" +# include "../core/Json.hpp" +# include "../core/Math.hpp" +# include "../core/MemoryStream.h" +# include "../core/Path.hpp" +# include "../core/String.hpp" +# include "../core/Util.hpp" +# include "../interface/Chat.h" +# include "../interface/Window.h" +# include "../localisation/Date.h" +# include "../localisation/Localisation.h" +# include "../object/ObjectManager.h" +# include "../object/ObjectRepository.h" +# include "../rct2/S6Exporter.h" +# include "../scenario/Scenario.h" +# include "../util/Util.h" +# include "../world/Park.h" +# include "NetworkAction.h" + +# include +# include +# include +# include +# include + +# pragma comment(lib, "Ws2_32.lib") using namespace OpenRCT2; @@ -699,9 +699,9 @@ bool Network::CheckSRAND(uint32_t tick, uint32_t srand0) // Check PRNG values and sprite hashes, if exist if ((srand0 != server_srand0) || sprites_mismatch) { -#ifdef DEBUG_DESYNC +# ifdef DEBUG_DESYNC dbg_report_desync(tick, srand0, server_srand0, client_sprite_hash, server_sprite_hash.c_str()); -#endif +# endif return false; } } @@ -1019,12 +1019,12 @@ void Network::BeginChatLog() auto directory = _env->GetDirectoryPath(DIRBASE::USER, DIRID::LOG_CHAT); _chatLogPath = BeginLog(directory, "", _chatLogFilenameFormat); -#if defined(_WIN32) && !defined(__MINGW32__) +# if defined(_WIN32) && !defined(__MINGW32__) auto pathW = std::unique_ptr(utf8_to_widechar(_chatLogPath.c_str())); _chat_log_fs.open(pathW.get(), std::ios::out | std::ios::app); -#else +# else _chat_log_fs.open(_chatLogPath, std::ios::out | std::ios::app); -#endif +# endif } void Network::AppendChatLog(const std::string& s) @@ -1045,12 +1045,12 @@ void Network::BeginServerLog() auto directory = _env->GetDirectoryPath(DIRBASE::USER, DIRID::LOG_SERVER); _serverLogPath = BeginLog(directory, ServerName, _serverLogFilenameFormat); -#if defined(_WIN32) && !defined(__MINGW32__) +# if defined(_WIN32) && !defined(__MINGW32__) auto pathW = std::unique_ptr(utf8_to_widechar(_serverLogPath.c_str())); _server_log_fs.open(pathW.get(), std::ios::out | std::ios::app); -#else +# else _server_log_fs.open(_serverLogPath, std::ios::out | std::ios::app); -#endif +# endif // Log server start event utf8 logMessage[256]; @@ -1424,7 +1424,7 @@ void Network::Server_Send_GAMEINFO(NetworkConnection& connection) { std::unique_ptr packet(NetworkPacket::Allocate()); *packet << (uint32_t)NETWORK_COMMAND_GAMEINFO; -#ifndef DISABLE_HTTP +# ifndef DISABLE_HTTP json_t* obj = json_object(); json_object_set_new(obj, "name", json_string(gConfigNetwork.server_name)); json_object_set_new(obj, "requiresPassword", json_boolean(_password.size() > 0)); @@ -1444,7 +1444,7 @@ void Network::Server_Send_GAMEINFO(NetworkConnection& connection) packet->WriteString(json_dumps(obj, 0)); json_decref(obj); -#endif +# endif connection.QueuePacket(std::move(packet)); } diff --git a/src/openrct2/network/NetworkAction.cpp b/src/openrct2/network/NetworkAction.cpp index c13a6e9333f5..e3d9d8a3e3be 100644 --- a/src/openrct2/network/NetworkAction.cpp +++ b/src/openrct2/network/NetworkAction.cpp @@ -9,12 +9,12 @@ #ifndef DISABLE_NETWORK -#include "NetworkAction.h" +# include "NetworkAction.h" -#include "../Game.h" -#include "../localisation/StringIds.h" +# include "../Game.h" +# include "../localisation/StringIds.h" -#include +# include int32_t NetworkActions::FindCommand(int32_t command) { diff --git a/src/openrct2/network/NetworkConnection.cpp b/src/openrct2/network/NetworkConnection.cpp index 37d25403a79d..d2f2d4519b82 100644 --- a/src/openrct2/network/NetworkConnection.cpp +++ b/src/openrct2/network/NetworkConnection.cpp @@ -9,12 +9,12 @@ #ifndef DISABLE_NETWORK -#include "NetworkConnection.h" +# include "NetworkConnection.h" -#include "../core/String.hpp" -#include "../localisation/Localisation.h" -#include "../platform/platform.h" -#include "network.h" +# include "../core/String.hpp" +# include "../localisation/Localisation.h" +# include "../platform/platform.h" +# include "network.h" constexpr size_t NETWORK_DISCONNECT_REASON_BUFFER_SIZE = 256; @@ -138,12 +138,12 @@ void NetworkConnection::ResetLastPacketTime() bool NetworkConnection::ReceivedPacketRecently() { -#ifndef DEBUG +# ifndef DEBUG if (platform_get_ticks() > _lastPacketTime + 7000) { return false; } -#endif +# endif return true; } diff --git a/src/openrct2/network/NetworkConnection.h b/src/openrct2/network/NetworkConnection.h index cf75a693f132..0b4dfd0c188f 100644 --- a/src/openrct2/network/NetworkConnection.h +++ b/src/openrct2/network/NetworkConnection.h @@ -10,14 +10,14 @@ #pragma once #ifndef DISABLE_NETWORK -#include "../common.h" -#include "NetworkKey.h" -#include "NetworkPacket.h" -#include "NetworkTypes.h" - -#include -#include -#include +# include "../common.h" +# include "NetworkKey.h" +# include "NetworkPacket.h" +# include "NetworkTypes.h" + +# include +# include +# include interface ITcpSocket; class NetworkPlayer; diff --git a/src/openrct2/network/NetworkGroup.cpp b/src/openrct2/network/NetworkGroup.cpp index 350f45174d13..c03bc4e20376 100644 --- a/src/openrct2/network/NetworkGroup.cpp +++ b/src/openrct2/network/NetworkGroup.cpp @@ -9,10 +9,10 @@ #ifndef DISABLE_NETWORK -#include "NetworkGroup.h" +# include "NetworkGroup.h" -#include "NetworkAction.h" -#include "NetworkTypes.h" +# include "NetworkAction.h" +# include "NetworkTypes.h" NetworkGroup NetworkGroup::FromJson(const json_t* json) { diff --git a/src/openrct2/network/NetworkKey.cpp b/src/openrct2/network/NetworkKey.cpp index cf9e9c6dcf61..1bb26c8f98d9 100644 --- a/src/openrct2/network/NetworkKey.cpp +++ b/src/openrct2/network/NetworkKey.cpp @@ -9,13 +9,13 @@ #ifndef DISABLE_NETWORK -#include "NetworkKey.h" +# include "NetworkKey.h" -#include "../Diagnostic.h" -#include "../core/Crypt.h" -#include "../core/IStream.hpp" +# include "../Diagnostic.h" +# include "../core/Crypt.h" +# include "../core/IStream.hpp" -#include +# include NetworkKey::NetworkKey() { diff --git a/src/openrct2/network/NetworkKey.h b/src/openrct2/network/NetworkKey.h index 41550e3a8611..c1480d3f125d 100644 --- a/src/openrct2/network/NetworkKey.h +++ b/src/openrct2/network/NetworkKey.h @@ -12,10 +12,10 @@ #ifndef DISABLE_NETWORK -#include "../common.h" +# include "../common.h" -#include -#include +# include +# include interface IStream; diff --git a/src/openrct2/network/NetworkPacket.cpp b/src/openrct2/network/NetworkPacket.cpp index 2f8c54d13efd..11a53d7ab3fa 100644 --- a/src/openrct2/network/NetworkPacket.cpp +++ b/src/openrct2/network/NetworkPacket.cpp @@ -9,11 +9,11 @@ #ifndef DISABLE_NETWORK -#include "NetworkPacket.h" +# include "NetworkPacket.h" -#include "NetworkTypes.h" +# include "NetworkTypes.h" -#include +# include std::unique_ptr NetworkPacket::Allocate() { diff --git a/src/openrct2/network/NetworkPlayer.cpp b/src/openrct2/network/NetworkPlayer.cpp index b896651c2aa7..8573e12ef407 100644 --- a/src/openrct2/network/NetworkPlayer.cpp +++ b/src/openrct2/network/NetworkPlayer.cpp @@ -9,11 +9,11 @@ #ifndef DISABLE_NETWORK -#include "NetworkPlayer.h" +# include "NetworkPlayer.h" -#include "../interface/Window.h" -#include "../localisation/Localisation.h" -#include "NetworkPacket.h" +# include "../interface/Window.h" +# include "../localisation/Localisation.h" +# include "NetworkPacket.h" void NetworkPlayer::SetName(const std::string& name) { diff --git a/src/openrct2/network/NetworkServerAdvertiser.cpp b/src/openrct2/network/NetworkServerAdvertiser.cpp index 4184b6202d5d..93e7eae7a3f1 100644 --- a/src/openrct2/network/NetworkServerAdvertiser.cpp +++ b/src/openrct2/network/NetworkServerAdvertiser.cpp @@ -9,25 +9,25 @@ #ifndef DISABLE_NETWORK -#include "NetworkServerAdvertiser.h" - -#include "../config/Config.h" -#include "../core/Console.hpp" -#include "../core/String.hpp" -#include "../core/Util.hpp" -#include "../localisation/Date.h" -#include "../management/Finance.h" -#include "../peep/Peep.h" -#include "../platform/platform.h" -#include "../util/Util.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "Http.h" -#include "network.h" - -#include - -#ifndef DISABLE_HTTP +# include "NetworkServerAdvertiser.h" + +# include "../config/Config.h" +# include "../core/Console.hpp" +# include "../core/String.hpp" +# include "../core/Util.hpp" +# include "../localisation/Date.h" +# include "../management/Finance.h" +# include "../peep/Peep.h" +# include "../platform/platform.h" +# include "../util/Util.h" +# include "../world/Map.h" +# include "../world/Park.h" +# include "Http.h" +# include "network.h" + +# include + +# ifndef DISABLE_HTTP using namespace OpenRCT2::Network; @@ -260,7 +260,7 @@ INetworkServerAdvertiser* CreateServerAdvertiser(uint16_t port) return new NetworkServerAdvertiser(port); } -#else // DISABLE_HTTP +# else // DISABLE_HTTP class DummyNetworkServerAdvertiser final : public INetworkServerAdvertiser { @@ -277,6 +277,6 @@ INetworkServerAdvertiser* CreateServerAdvertiser(uint16_t port) return new DummyNetworkServerAdvertiser(); } -#endif // DISABLE_HTTP +# endif // DISABLE_HTTP #endif // DISABLE_NETWORK diff --git a/src/openrct2/network/NetworkUser.cpp b/src/openrct2/network/NetworkUser.cpp index c448cd47c5b3..ffd21e5097d6 100644 --- a/src/openrct2/network/NetworkUser.cpp +++ b/src/openrct2/network/NetworkUser.cpp @@ -9,15 +9,15 @@ #ifndef DISABLE_NETWORK -#include "NetworkUser.h" +# include "NetworkUser.h" -#include "../core/Console.hpp" -#include "../core/Json.hpp" -#include "../core/Path.hpp" -#include "../core/String.hpp" -#include "../platform/platform.h" +# include "../core/Console.hpp" +# include "../core/Json.hpp" +# include "../core/Path.hpp" +# include "../core/String.hpp" +# include "../platform/platform.h" -#include +# include constexpr const utf8* USER_STORE_FILENAME = "users.json"; diff --git a/src/openrct2/network/TcpSocket.cpp b/src/openrct2/network/TcpSocket.cpp index 7bbc3c4f6322..ff8323413003 100644 --- a/src/openrct2/network/TcpSocket.cpp +++ b/src/openrct2/network/TcpSocket.cpp @@ -9,12 +9,12 @@ #ifndef DISABLE_NETWORK -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include // clang-format off // MSVC: include here otherwise PI gets defined twice @@ -58,13 +58,13 @@ #endif // _WIN32 // clang-format on -#include "TcpSocket.h" +# include "TcpSocket.h" constexpr auto CONNECT_TIMEOUT = std::chrono::milliseconds(3000); -#ifdef _WIN32 +# ifdef _WIN32 static bool _wsaInitialised = false; -#endif +# endif class TcpSocket; @@ -279,10 +279,10 @@ class TcpSocket final : public ITcpSocket fd_set writeFD; FD_ZERO(&writeFD); -#pragma warning(push) -#pragma warning(disable : 4548) // expression before comma has no effect; expected expression with side-effect +# pragma warning(push) +# pragma warning(disable : 4548) // expression before comma has no effect; expected expression with side-effect FD_SET(_socket, &writeFD); -#pragma warning(pop) +# pragma warning(pop) timeval timeout{}; timeout.tv_sec = 0; timeout.tv_usec = 0; @@ -384,7 +384,7 @@ class TcpSocket final : public ITcpSocket else if (readBytes == SOCKET_ERROR) { *sizeReceived = 0; -#ifndef _WIN32 +# ifndef _WIN32 // Removing the check for EAGAIN and instead relying on the values being the same allows turning on of // -Wlogical-op warning. // This is not true on Windows, see: @@ -395,7 +395,7 @@ class TcpSocket final : public ITcpSocket EWOULDBLOCK == EAGAIN, "Portability note: your system has different values for EWOULDBLOCK " "and EAGAIN, please extend the condition below"); -#endif // _WIN32 +# endif // _WIN32 if (LAST_SOCKET_ERROR() != EWOULDBLOCK) { return NETWORK_READPACKET_DISCONNECTED; @@ -477,13 +477,13 @@ class TcpSocket final : public ITcpSocket static bool SetNonBlocking(SOCKET socket, bool on) { -#ifdef _WIN32 +# ifdef _WIN32 u_long nonBlocking = on; return ioctlsocket(socket, FIONBIO, &nonBlocking) == 0; -#else +# else int32_t flags = fcntl(socket, F_GETFL, 0); return fcntl(socket, F_SETFL, on ? (flags | O_NONBLOCK) : (flags & ~O_NONBLOCK)) == 0; -#endif +# endif } static bool SetTCPNoDelay(SOCKET socket, bool enabled) @@ -499,7 +499,7 @@ ITcpSocket* CreateTcpSocket() bool InitialiseWSA() { -#ifdef _WIN32 +# ifdef _WIN32 if (!_wsaInitialised) { log_verbose("Initialising WSA"); @@ -512,20 +512,20 @@ bool InitialiseWSA() _wsaInitialised = true; } return _wsaInitialised; -#else +# else return true; -#endif +# endif } void DisposeWSA() { -#ifdef _WIN32 +# ifdef _WIN32 if (_wsaInitialised) { WSACleanup(); _wsaInitialised = false; } -#endif +# endif } namespace Convert diff --git a/src/openrct2/network/Twitch.cpp b/src/openrct2/network/Twitch.cpp index 8a7e81daac4d..12f481b41924 100644 --- a/src/openrct2/network/Twitch.cpp +++ b/src/openrct2/network/Twitch.cpp @@ -9,7 +9,7 @@ #ifdef DISABLE_TWITCH -#include "twitch.h" +# include "twitch.h" void twitch_update() { @@ -17,31 +17,31 @@ void twitch_update() #else -#ifdef DISABLE_HTTP -#error HTTP must be enabled to use the TWITCH functionality. -#endif - -#include "../Context.h" -#include "../Game.h" -#include "../OpenRCT2.h" -#include "../config/Config.h" -#include "../core/Json.hpp" -#include "../core/Math.hpp" -#include "../core/String.hpp" -#include "../drawing/Drawing.h" -#include "../interface/InteractiveConsole.h" -#include "../localisation/Localisation.h" -#include "../management/NewsItem.h" -#include "../peep/Peep.h" -#include "../platform/platform.h" -#include "../util/Util.h" -#include "../world/Sprite.h" -#include "Http.h" -#include "twitch.h" - -#include -#include -#include +# ifdef DISABLE_HTTP +# error HTTP must be enabled to use the TWITCH functionality. +# endif + +# include "../Context.h" +# include "../Game.h" +# include "../OpenRCT2.h" +# include "../config/Config.h" +# include "../core/Json.hpp" +# include "../core/Math.hpp" +# include "../core/String.hpp" +# include "../drawing/Drawing.h" +# include "../interface/InteractiveConsole.h" +# include "../localisation/Localisation.h" +# include "../management/NewsItem.h" +# include "../peep/Peep.h" +# include "../platform/platform.h" +# include "../util/Util.h" +# include "../world/Sprite.h" +# include "Http.h" +# include "twitch.h" + +# include +# include +# include using namespace OpenRCT2; using namespace OpenRCT2::Network; diff --git a/src/openrct2/network/network.h b/src/openrct2/network/network.h index 69fd22433492..b9649aa23866 100644 --- a/src/openrct2/network/network.h +++ b/src/openrct2/network/network.h @@ -52,26 +52,26 @@ namespace OpenRCT2 #ifndef DISABLE_NETWORK -#include "../actions/GameAction.h" -#include "../core/Json.hpp" -#include "../core/MemoryStream.h" -#include "../core/Nullable.hpp" -#include "NetworkConnection.h" -#include "NetworkGroup.h" -#include "NetworkKey.h" -#include "NetworkPacket.h" -#include "NetworkPlayer.h" -#include "NetworkServerAdvertiser.h" -#include "NetworkUser.h" -#include "TcpSocket.h" - -#include -#include -#include -#include -#include -#include -#include +# include "../actions/GameAction.h" +# include "../core/Json.hpp" +# include "../core/MemoryStream.h" +# include "../core/Nullable.hpp" +# include "NetworkConnection.h" +# include "NetworkGroup.h" +# include "NetworkKey.h" +# include "NetworkPacket.h" +# include "NetworkPlayer.h" +# include "NetworkServerAdvertiser.h" +# include "NetworkUser.h" +# include "TcpSocket.h" + +# include +# include +# include +# include +# include +# include +# include enum { diff --git a/src/openrct2/object/Object.cpp b/src/openrct2/object/Object.cpp index e73282734893..8dc642abf911 100644 --- a/src/openrct2/object/Object.cpp +++ b/src/openrct2/object/Object.cpp @@ -697,8 +697,8 @@ bool Object::IsOpenRCT2OfficialObject() } #ifdef __WARN_SUGGEST_FINAL_METHODS__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsuggest-final-methods" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsuggest-final-methods" #endif std::string Object::GetName() const @@ -712,5 +712,5 @@ std::string Object::GetName(int32_t language) const } #ifdef __WARN_SUGGEST_FINAL_METHODS__ -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif diff --git a/src/openrct2/object/Object.h b/src/openrct2/object/Object.h index 6164e14c1296..0cd8c8cea324 100644 --- a/src/openrct2/object/Object.h +++ b/src/openrct2/object/Object.h @@ -146,9 +146,9 @@ interface IReadObjectContext }; #ifdef __WARN_SUGGEST_FINAL_TYPES__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsuggest-final-types" -#pragma GCC diagnostic ignored "-Wsuggest-final-methods" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsuggest-final-types" +# pragma GCC diagnostic ignored "-Wsuggest-final-methods" #endif class Object { @@ -229,7 +229,7 @@ class Object rct_object_entry CreateHeader(const char name[9], uint32_t flags, uint32_t checksum); }; #ifdef __WARN_SUGGEST_FINAL_TYPES__ -#pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif enum OBJECT_ERROR : uint32_t diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 09799b75e2db..eff5a78ab37e 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -238,9 +238,9 @@ void testpaint_ignore(uint8_t direction, uint8_t trackSequence); void testpaint_ignore_all(); bool testpaint_is_ignored(uint8_t direction, uint8_t trackSequence); -#define TESTPAINT_IGNORE(direction, trackSequence) testpaint_ignore(direction, trackSequence) -#define TESTPAINT_IGNORE_ALL() testpaint_ignore_all() +# define TESTPAINT_IGNORE(direction, trackSequence) testpaint_ignore(direction, trackSequence) +# define TESTPAINT_IGNORE_ALL() testpaint_ignore_all() #else -#define TESTPAINT_IGNORE(direction, trackSequence) -#define TESTPAINT_IGNORE_ALL() +# define TESTPAINT_IGNORE(direction, trackSequence) +# define TESTPAINT_IGNORE_ALL() #endif diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 45b700d9282e..41e6d9318db5 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -3829,7 +3829,7 @@ void peep_handle_easteregg_name(rct_peep* peep) #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 void pathfind_logging_enable([[maybe_unused]] rct_peep* peep) { -#if defined(PATHFIND_DEBUG) && PATHFIND_DEBUG +# if defined(PATHFIND_DEBUG) && PATHFIND_DEBUG /* Determine if the pathfinding debugging is wanted for this peep. */ format_string(gPathFindDebugPeepName, sizeof(gPathFindDebugPeepName), peep->name_string_idx, &(peep->id)); @@ -3847,14 +3847,14 @@ void pathfind_logging_enable([[maybe_unused]] rct_peep* peep) { gPathFindDebug = strcmp(gPathFindDebugPeepName, "Mechanic Debug") == 0; } -#endif // defined(PATHFIND_DEBUG) && PATHFIND_DEBUG +# endif // defined(PATHFIND_DEBUG) && PATHFIND_DEBUG } void pathfind_logging_disable() { -#if defined(PATHFIND_DEBUG) && PATHFIND_DEBUG +# if defined(PATHFIND_DEBUG) && PATHFIND_DEBUG gPathFindDebug = false; -#endif // defined(PATHFIND_DEBUG) && PATHFIND_DEBUG +# endif // defined(PATHFIND_DEBUG) && PATHFIND_DEBUG } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index e5f2f94da60b..4d82eb8c11c5 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -986,9 +986,9 @@ bool is_valid_path_z_and_direction(rct_tile_element* tileElement, int32_t curren int32_t guest_path_finding(rct_peep* peep); #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 -#define PATHFIND_DEBUG \ - 0 // Set to 0 to disable pathfinding debugging; - // Set to 1 to enable pathfinding debugging. +# define PATHFIND_DEBUG \ + 0 // Set to 0 to disable pathfinding debugging; + // Set to 1 to enable pathfinding debugging. // Some variables used for the path finding debugging. extern bool gPathFindDebug; // Use to guard calls to log messages extern utf8 gPathFindDebugPeepName[256]; // Use to put the peep name in the log message diff --git a/src/openrct2/platform/Android.cpp b/src/openrct2/platform/Android.cpp index cb9ad35a16fe..c396fea99af9 100644 --- a/src/openrct2/platform/Android.cpp +++ b/src/openrct2/platform/Android.cpp @@ -9,22 +9,22 @@ #ifdef __ANDROID__ -#include "../config/Config.h" -#include "../localisation/Language.h" -#include "../util/Util.h" -#include "platform.h" +# include "../config/Config.h" +# include "../localisation/Language.h" +# include "../util/Util.h" +# include "platform.h" -#include -#include -#include +# include +# include +# include -#ifndef NO_TTF +# ifndef NO_TTF bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) { STUB(); return false; } -#endif +# endif uint16_t platform_get_locale_language() { diff --git a/src/openrct2/platform/Crash.cpp b/src/openrct2/platform/Crash.cpp index 624325e18a8f..d08ed00605cb 100644 --- a/src/openrct2/platform/Crash.cpp +++ b/src/openrct2/platform/Crash.cpp @@ -10,31 +10,31 @@ #include "Crash.h" #ifdef USE_BREAKPAD -#include -#include - -#if defined(_WIN32) -#include -#include -#include -#else -#error Breakpad support not implemented yet for this platform -#endif - -#include "../Version.h" -#include "../core/Console.hpp" -#include "../localisation/Language.h" -#include "../rct2/S6Exporter.h" -#include "../scenario/Scenario.h" -#include "platform.h" - -#define WSZ(x) L"" x - -#ifdef OPENRCT2_COMMIT_SHA1_SHORT +# include +# include + +# if defined(_WIN32) +# include +# include +# include +# else +# error Breakpad support not implemented yet for this platform +# endif + +# include "../Version.h" +# include "../core/Console.hpp" +# include "../localisation/Language.h" +# include "../rct2/S6Exporter.h" +# include "../scenario/Scenario.h" +# include "platform.h" + +# define WSZ(x) L"" x + +# ifdef OPENRCT2_COMMIT_SHA1_SHORT const wchar_t* _wszCommitSha1Short = WSZ(OPENRCT2_COMMIT_SHA1_SHORT); -#else +# else const wchar_t* _wszCommitSha1Short = WSZ(""); -#endif +# endif // OPENRCT2_ARCHITECTURE is required to be defined in version.h const wchar_t* _wszArchitecture = WSZ(OPENRCT2_ARCHITECTURE); diff --git a/src/openrct2/platform/Linux.cpp b/src/openrct2/platform/Linux.cpp index 169c0c6df293..f407d664407b 100644 --- a/src/openrct2/platform/Linux.cpp +++ b/src/openrct2/platform/Linux.cpp @@ -13,28 +13,28 @@ // Otherwise, they should be spun off into their own files. #if (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && !defined(__ANDROID__) -#ifdef __FreeBSD__ -#include -#endif - -#define OPENRCT2_MAX_COMMAND_LENGTH (2 * MAX_PATH) - -#include -#include -#include -#include -#ifndef NO_TTF -#include -#endif // NO_TTF -#include "../config/Config.h" -#include "../localisation/Language.h" -#include "../localisation/StringIds.h" -#include "../util/Util.h" -#include "platform.h" - -#include -#include -#include +# ifdef __FreeBSD__ +# include +# endif + +# define OPENRCT2_MAX_COMMAND_LENGTH (2 * MAX_PATH) + +# include +# include +# include +# include +# ifndef NO_TTF +# include +# endif // NO_TTF +# include "../config/Config.h" +# include "../localisation/Language.h" +# include "../localisation/StringIds.h" +# include "../util/Util.h" +# include "platform.h" + +# include +# include +# include uint16_t platform_get_locale_language() { @@ -126,11 +126,11 @@ uint8_t platform_get_locale_currency() uint8_t platform_get_locale_measurement_format() { // LC_MEASUREMENT is GNU specific. -#ifdef LC_MEASUREMENT +# ifdef LC_MEASUREMENT const char* langstring = setlocale(LC_MEASUREMENT, ""); -#else +# else const char* langstring = setlocale(LC_ALL, ""); -#endif +# endif if (langstring != nullptr) { @@ -189,7 +189,7 @@ bool platform_get_steam_path(utf8* outPath, size_t outSize) return false; } -#ifndef NO_TTF +# ifndef NO_TTF bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) { assert(buffer != nullptr); @@ -250,6 +250,6 @@ bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) FcFini(); return found; } -#endif // NO_TTF +# endif // NO_TTF #endif diff --git a/src/openrct2/platform/Platform.Android.cpp b/src/openrct2/platform/Platform.Android.cpp index 3253c1ea2957..797196131e35 100644 --- a/src/openrct2/platform/Platform.Android.cpp +++ b/src/openrct2/platform/Platform.Android.cpp @@ -9,8 +9,8 @@ #ifdef __ANDROID__ -#include "../core/Guard.hpp" -#include "Platform2.h" +# include "../core/Guard.hpp" +# include "Platform2.h" namespace Platform { diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp index d17f92cad9ae..624addb8b6b2 100644 --- a/src/openrct2/platform/Platform.Linux.cpp +++ b/src/openrct2/platform/Platform.Linux.cpp @@ -9,22 +9,22 @@ #if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__linux__) && !defined(__ANDROID__)) -#include -#include -#if defined(__FreeBSD__) -#include -#include -#include -#endif // __FreeBSD__ -#if defined(__linux__) +# include +# include +# if defined(__FreeBSD__) +# include +# include +# include +# endif // __FreeBSD__ +# if defined(__linux__) // for PATH_MAX -#include -#endif // __linux__ -#include "../OpenRCT2.h" -#include "../core/Path.hpp" -#include "../core/Util.hpp" -#include "Platform2.h" -#include "platform.h" +# include +# endif // __linux__ +# include "../OpenRCT2.h" +# include "../core/Path.hpp" +# include "../core/Util.hpp" +# include "Platform2.h" +# include "platform.h" namespace Platform { @@ -72,10 +72,10 @@ namespace Platform { static const char* SearchLocations[] = { "../share/openrct2", -#ifdef ORCT2_RESOURCE_DIR +# ifdef ORCT2_RESOURCE_DIR // defined in CMakeLists.txt ORCT2_RESOURCE_DIR, -#endif // ORCT2_RESOURCE_DIR +# endif // ORCT2_RESOURCE_DIR "/usr/local/share/openrct2", "/var/lib/openrct2", "/usr/share/openrct2", @@ -140,26 +140,26 @@ namespace Platform std::string GetCurrentExecutablePath() { char exePath[PATH_MAX] = { 0 }; -#ifdef __linux__ +# ifdef __linux__ auto bytesRead = readlink("/proc/self/exe", exePath, sizeof(exePath)); if (bytesRead == -1) { log_fatal("failed to read /proc/self/exe"); } -#elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) const int32_t mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; auto exeLen = sizeof(exePath); if (sysctl(mib, 4, exePath, &exeLen, nullptr, 0) == -1) { log_fatal("failed to get process path"); } -#elif defined(__OpenBSD__) +# elif defined(__OpenBSD__) // There is no way to get the path name of a running executable. // If you are not using the port or package, you may have to change this line! strlcpy(exePath, "/usr/local/bin/", sizeof(exePath)); -#else -#error "Platform does not support full path exe retrieval" -#endif +# else +# error "Platform does not support full path exe retrieval" +# endif return exePath; } } // namespace Platform diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 7f5f9a2f09f3..7260cb5109b8 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -9,14 +9,14 @@ #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) -#include "../core/String.hpp" -#include "Platform2.h" -#include "platform.h" +# include "../core/String.hpp" +# include "Platform2.h" +# include "platform.h" -#include -#include -#include -#include +# include +# include +# include +# include namespace Platform { diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 3d227fbb6d7c..36773254319e 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -10,35 +10,35 @@ #ifdef _WIN32 // Windows.h needs to be included first -#include +# include // Then the rest -#include -#include -#include -#undef GetEnvironmentVariable +# include +# include +# include +# undef GetEnvironmentVariable -#if !defined(__MINGW32__) && ((NTDDI_VERSION >= NTDDI_VISTA) && !defined(_USING_V110_SDK71_) && !defined(_ATL_XP_TARGETING)) -#define __USE_SHGETKNOWNFOLDERPATH__ -#define __USE_GETDATEFORMATEX__ -#else -#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 -#endif +# if !defined(__MINGW32__) && ((NTDDI_VERSION >= NTDDI_VISTA) && !defined(_USING_V110_SDK71_) && !defined(_ATL_XP_TARGETING)) +# define __USE_SHGETKNOWNFOLDERPATH__ +# define __USE_GETDATEFORMATEX__ +# else +# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +# endif -#include "../OpenRCT2.h" -#include "../core/Path.hpp" -#include "../core/String.hpp" -#include "../core/Util.hpp" -#include "Platform2.h" -#include "platform.h" +# include "../OpenRCT2.h" +# include "../core/Path.hpp" +# include "../core/String.hpp" +# include "../core/Util.hpp" +# include "Platform2.h" +# include "platform.h" namespace Platform { -#ifdef __USE_SHGETKNOWNFOLDERPATH__ +# ifdef __USE_SHGETKNOWNFOLDERPATH__ static std::string WIN32_GetKnownFolderPath(REFKNOWNFOLDERID rfid); -#else +# else static std::string WIN32_GetFolderPath(int nFolder); -#endif +# endif static std::string WIN32_GetModuleFileNameW(HMODULE hModule); uint32_t GetTicks() @@ -87,11 +87,11 @@ namespace Platform case SPECIAL_FOLDER::USER_CONFIG: case SPECIAL_FOLDER::USER_DATA: { -#ifdef __USE_SHGETKNOWNFOLDERPATH__ +# ifdef __USE_SHGETKNOWNFOLDERPATH__ auto path = WIN32_GetKnownFolderPath(FOLDERID_Documents); -#else +# else auto path = WIN32_GetFolderPath(CSIDL_PERSONAL); -#endif +# endif if (path.empty()) { path = GetFolderPath(SPECIAL_FOLDER::USER_HOME); @@ -100,11 +100,11 @@ namespace Platform } case SPECIAL_FOLDER::USER_HOME: { -#ifdef __USE_SHGETKNOWNFOLDERPATH__ +# ifdef __USE_SHGETKNOWNFOLDERPATH__ auto path = WIN32_GetKnownFolderPath(FOLDERID_Profile); -#else +# else auto path = WIN32_GetFolderPath(CSIDL_PROFILE); -#endif +# endif if (path.empty()) { path = GetHomePathViaEnvironment(); @@ -163,15 +163,15 @@ namespace Platform { SYSTEMTIME st = TimeToSystemTime(timestamp); -#ifdef __USE_GETDATEFORMATEX__ +# ifdef __USE_GETDATEFORMATEX__ wchar_t date[20]; GetDateFormatEx(LOCALE_NAME_USER_DEFAULT, DATE_SHORTDATE, &st, nullptr, date, sizeof(date), nullptr); std::string result = String::ToUtf8(std::wstring(date)); -#else +# else char date[20]; GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, nullptr, date, sizeof(date)); std::string result(date); -#endif +# endif return result; } @@ -180,15 +180,15 @@ namespace Platform { SYSTEMTIME st = TimeToSystemTime(timestamp); -#ifdef __USE_GETDATEFORMATEX__ +# ifdef __USE_GETDATEFORMATEX__ wchar_t time[20]; GetTimeFormatEx(LOCALE_NAME_USER_DEFAULT, 0, &st, nullptr, time, sizeof(time)); std::string result = String::ToUtf8(std::wstring(time)); -#else +# else char time[20]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, time, sizeof(time)); std::string result(time); -#endif +# endif return result; } @@ -263,7 +263,7 @@ namespace Platform return isSupported; } -#ifdef __USE_SHGETKNOWNFOLDERPATH__ +# ifdef __USE_SHGETKNOWNFOLDERPATH__ static std::string WIN32_GetKnownFolderPath(REFKNOWNFOLDERID rfid) { std::string path; @@ -275,7 +275,7 @@ namespace Platform CoTaskMemFree(wpath); return path; } -#else +# else static std::string WIN32_GetFolderPath(int nFolder) { std::string path; @@ -286,7 +286,7 @@ namespace Platform } return path; } -#endif +# endif static std::string WIN32_GetModuleFileNameW(HMODULE hModule) { diff --git a/src/openrct2/platform/Platform.macOS.mm b/src/openrct2/platform/Platform.macOS.mm index b466e04cbe2b..d2b9b3535be0 100644 --- a/src/openrct2/platform/Platform.macOS.mm +++ b/src/openrct2/platform/Platform.macOS.mm @@ -9,16 +9,16 @@ #if defined(__APPLE__) && defined(__MACH__) -#include "../OpenRCT2.h" -#include "../core/Path.hpp" -#include "Platform2.h" +# include "../OpenRCT2.h" +# include "../core/Path.hpp" +# include "Platform2.h" // undefine `interface` and `abstract`, because it's causing conflicts with Objective-C's keywords -#undef interface -#undef abstract +# undef interface +# undef abstract -#include -#include +# include +# include namespace Platform { diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index e98f1770aa54..489b7ece7fcc 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -9,35 +9,35 @@ #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) -#include -#include -#include -#include -#include -#include -#ifndef __EMSCRIPTEN__ -#include -#endif -#include "../OpenRCT2.h" -#include "../config/Config.h" -#include "../localisation/Date.h" -#include "../localisation/Language.h" -#include "../util/Util.h" -#include "platform.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# ifndef __EMSCRIPTEN__ +# include +# endif +# include "../OpenRCT2.h" +# include "../config/Config.h" +# include "../localisation/Date.h" +# include "../localisation/Language.h" +# include "../util/Util.h" +# include "platform.h" + +# include +# include +# include +# include +# include +# include +# include +# include +# include // The name of the mutex used to prevent multiple instances of the game from running -#define SINGLE_INSTANCE_MUTEX_NAME "openrct2.lock" +# define SINGLE_INSTANCE_MUTEX_NAME "openrct2.lock" -#define FILE_BUFFER_SIZE 4096 +# define FILE_BUFFER_SIZE 4096 static utf8 _userDataDirectoryPath[MAX_PATH] = { 0 }; @@ -195,7 +195,7 @@ bool platform_ensure_directory_exists(const utf8* path) bool platform_directory_delete(const utf8* path) { -#ifdef _FTS_H +# ifdef _FTS_H log_verbose("Recursively deleting directory %s", path); FTS* ftsp; @@ -251,9 +251,9 @@ bool platform_directory_delete(const utf8* path) free(ourPath); fts_close(ftsp); -#else +# else log_warning("OpenRCT2 was compiled without fts.h, deleting '%s' not done.", path); -#endif // _FTS_H +# endif // _FTS_H return true; } @@ -402,11 +402,11 @@ time_t platform_file_get_modified_time(const utf8* path) uint8_t platform_get_locale_temperature_format() { // LC_MEASUREMENT is GNU specific. -#ifdef LC_MEASUREMENT +# ifdef LC_MEASUREMENT const char* langstring = setlocale(LC_MEASUREMENT, ""); -#else +# else const char* langstring = setlocale(LC_ALL, ""); -#endif +# endif if (langstring != nullptr) { @@ -454,11 +454,11 @@ utf8* platform_get_username() bool platform_process_is_elevated() { -#ifndef __EMSCRIPTEN__ +# ifndef __EMSCRIPTEN__ return (geteuid() == 0); -#else +# else return false; -#endif // __EMSCRIPTEN__ +# endif // __EMSCRIPTEN__ } std::string platform_get_rct2_steam_dir() diff --git a/src/openrct2/platform/Shared.cpp b/src/openrct2/platform/Shared.cpp index 21f022985718..b5127a5a6a5d 100644 --- a/src/openrct2/platform/Shared.cpp +++ b/src/openrct2/platform/Shared.cpp @@ -10,10 +10,10 @@ #include "../common.h" #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include +# define WIN32_LEAN_AND_MEAN +# include #else -#include +# include #endif #include "../Context.h" @@ -32,11 +32,11 @@ #include #ifdef __APPLE__ -#include -#include -#ifndef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -#error Missing __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ define -#endif +# include +# include +# ifndef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# error Missing __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ define +# endif #endif #if defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 46c3527e35d5..04c8cffb3370 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -9,43 +9,43 @@ #ifdef __MINGW32__ // 0x0600 == vista -#define WINVER 0x0600 -#define _WIN32_WINNT 0x0600 +# define WINVER 0x0600 +# define _WIN32_WINNT 0x0600 #endif // __MINGW32__ #ifdef _WIN32 // Windows.h needs to be included first -#include +# include // Then the rest -#include "../OpenRCT2.h" -#include "../Version.h" -#include "../config/Config.h" -#include "../core/Util.hpp" -#include "../localisation/Date.h" -#include "../localisation/Language.h" -#include "../rct2/RCT2.h" -#include "../util/Util.h" -#include "platform.h" - -#include -#include -#include -#include +# include "../OpenRCT2.h" +# include "../Version.h" +# include "../config/Config.h" +# include "../core/Util.hpp" +# include "../localisation/Date.h" +# include "../localisation/Language.h" +# include "../rct2/RCT2.h" +# include "../util/Util.h" +# include "platform.h" + +# include +# include +# include +# include // Native resource IDs -#include "../../../resources/resource.h" +# include "../../../resources/resource.h" // Enable visual styles -#pragma comment( \ - linker, \ - "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +# pragma comment( \ + linker, \ + "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") // The name of the mutex used to prevent multiple instances of the game from running -#define SINGLE_INSTANCE_MUTEX_NAME "RollerCoaster Tycoon 2_GSKMUTEX" +# define SINGLE_INSTANCE_MUTEX_NAME "RollerCoaster Tycoon 2_GSKMUTEX" -#define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" +# define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" static HMODULE _dllModule = nullptr; @@ -423,10 +423,11 @@ uint8_t platform_get_locale_date_format() return DATE_FORMAT_DAY_MONTH_YEAR; } -#ifndef NO_TTF +# ifndef NO_TTF bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) { -#if !defined(__MINGW32__) && ((NTDDI_VERSION >= NTDDI_VISTA) && !defined(_USING_V110_SDK71_) && !defined(_ATL_XP_TARGETING)) +# if !defined(__MINGW32__) \ + && ((NTDDI_VERSION >= NTDDI_VISTA) && !defined(_USING_V110_SDK71_) && !defined(_ATL_XP_TARGETING)) wchar_t* fontFolder; if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Fonts, 0, NULL, &fontFolder))) { @@ -445,14 +446,14 @@ bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) { return false; } -#else +# else log_warning("Compatibility hack: falling back to C:\\Windows\\Fonts"); safe_strcpy(buffer, "C:\\Windows\\Fonts\\", size); safe_strcat_path(buffer, font->filename, size); return true; -#endif +# endif } -#endif // NO_TTF +# endif // NO_TTF utf8* platform_get_absolute_path(const utf8* relativePath, const utf8* basePath) { @@ -524,8 +525,8 @@ bool platform_process_is_elevated() // File association setup /////////////////////////////////////////////////////////////////////////////// -#define SOFTWARE_CLASSES L"Software\\Classes" -#define MUI_CACHE L"Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache" +# define SOFTWARE_CLASSES L"Software\\Classes" +# define MUI_CACHE L"Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache" static void get_progIdName(wchar_t* dst, const utf8* extension) { diff --git a/src/openrct2/platform/macos.mm b/src/openrct2/platform/macos.mm index b0b7276e17e0..45fa6087b493 100644 --- a/src/openrct2/platform/macos.mm +++ b/src/openrct2/platform/macos.mm @@ -9,19 +9,19 @@ #if defined(__APPLE__) && defined(__MACH__) -#include "../config/Config.h" -#include "../localisation/Language.h" -#include "../util/Util.h" -#include "platform.h" +# include "../config/Config.h" +# include "../localisation/Language.h" +# include "../util/Util.h" +# include "platform.h" // undefine `interface` and `abstract`, because it's causing conflicts with Objective-C's keywords -#undef interface -#undef abstract +# undef interface +# undef abstract -#import -#import -#include -#include +# import +# import +# include +# include void macos_disallow_automatic_window_tabbing() { @@ -46,7 +46,7 @@ void macos_disallow_automatic_window_tabbing() } } -#ifndef NO_TTF +# ifndef NO_TTF bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) { @autoreleasepool { @@ -65,7 +65,7 @@ bool platform_get_font_path(TTFFontDescriptor* font, utf8* buffer, size_t size) } } } -#endif // NO_TTF +# endif // NO_TTF bool platform_has_matching_language(NSString* preferredLocale, uint16_t* languageIdentifier) { diff --git a/src/openrct2/platform/platform.h b/src/openrct2/platform/platform.h index cdae69ccd32b..024e55e976f7 100644 --- a/src/openrct2/platform/platform.h +++ b/src/openrct2/platform/platform.h @@ -19,17 +19,17 @@ struct TTFFontDescriptor; struct rct2_install_info; #ifndef MAX_PATH -#define MAX_PATH 260 +# define MAX_PATH 260 #endif #define INVALID_HANDLE (-1) #ifdef _WIN32 -#define PATH_SEPARATOR "\\" -#define PLATFORM_NEWLINE "\r\n" +# define PATH_SEPARATOR "\\" +# define PLATFORM_NEWLINE "\r\n" #else -#define PATH_SEPARATOR "/" -#define PLATFORM_NEWLINE "\n" +# define PATH_SEPARATOR "/" +# define PLATFORM_NEWLINE "\n" #endif struct resolution_t @@ -134,16 +134,16 @@ void core_init(); // Windows specific definitions #ifdef _WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -#undef CreateDirectory -#undef CreateWindow -#undef GetMessage +# ifndef NOMINMAX +# define NOMINMAX +# endif +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include +# undef CreateDirectory +# undef CreateWindow +# undef GetMessage void platform_setup_file_associations(); void platform_remove_file_associations(); diff --git a/src/openrct2/rct12/SawyerChunkReader.cpp b/src/openrct2/rct12/SawyerChunkReader.cpp index d1ae613d1fb8..e7815de493a5 100644 --- a/src/openrct2/rct12/SawyerChunkReader.cpp +++ b/src/openrct2/rct12/SawyerChunkReader.cpp @@ -14,9 +14,9 @@ // malloc is very slow for large allocations in MSVC debug builds as it allocates // memory on a special debug heap and then initialises all the memory to 0xCC. #if defined(_WIN32) && defined(DEBUG) -#define __USE_HEAP_ALLOC__ -#define WIN32_LEAN_AND_MEAN -#include +# define __USE_HEAP_ALLOC__ +# define WIN32_LEAN_AND_MEAN +# include #endif // Allow chunks to be uncompressed to a maximum of 16 MiB diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 0374840a7349..66e0addedcd6 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -24,7 +24,7 @@ struct rct_vehicle_colour }; #ifdef __TESTPAINT__ -#pragma pack(push, 1) +# pragma pack(push, 1) #endif // __TESTPAINT__ /** * Ride type vehicle structure. @@ -88,7 +88,7 @@ struct rct_ride_entry_vehicle std::vector peep_loading_positions = {}; // previously 0x61 , 0x7B }; #ifdef __TESTPAINT__ -#pragma pack(pop) +# pragma pack(pop) #endif // __TESTPAINT__ #ifdef PLATFORM_32BIT static_assert(offsetof(rct_ride_entry_vehicle, peep_loading_positions) % 4 == 0, "Invalid struct layout"); diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index 9cdc2d9ca0c6..1f7d13b233bc 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -395,8 +395,8 @@ void scenario_update(); #ifdef DEBUG_DESYNC uint32_t dbg_scenario_rand(const char* file, const char* function, const uint32_t line, const void* data); -#define scenario_rand() dbg_scenario_rand(__FILE__, __FUNCTION__, __LINE__, NULL) -#define scenario_rand_data(data) dbg_scenario_rand(__FILE__, __FUNCTION__, __LINE__, data) +# define scenario_rand() dbg_scenario_rand(__FILE__, __FUNCTION__, __LINE__, NULL) +# define scenario_rand_data(data) dbg_scenario_rand(__FILE__, __FUNCTION__, __LINE__, data) void dbg_report_desync(uint32_t tick, uint32_t srand0, uint32_t server_srand0, const char* clientHash, const char* serverHash); #else uint32_t scenario_rand(); diff --git a/src/openrct2/util/Util.cpp b/src/openrct2/util/Util.cpp index 55bcfd215379..3921932151c9 100644 --- a/src/openrct2/util/Util.cpp +++ b/src/openrct2/util/Util.cpp @@ -167,7 +167,7 @@ int32_t bitscanforward(int32_t source) int32_t success = __builtin_ffs(source); return success - 1; #else -#pragma message "Falling back to iterative bitscan forward, consider using intrinsics" +# pragma message "Falling back to iterative bitscan forward, consider using intrinsics" // This is a low-hanging optimisation boost, check if your compiler offers // any intrinsic. // cf. https://github.com/OpenRCT2/OpenRCT2/pull/2093 @@ -180,26 +180,26 @@ int32_t bitscanforward(int32_t source) } #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) -#include -#define OpenRCT2_CPUID_GNUC_X86 +# include +# define OpenRCT2_CPUID_GNUC_X86 #elif defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_X64) || defined(_M_IX86)) // VS2008 -#include -#include -#define OpenRCT2_CPUID_MSVC_X86 +# include +# include +# define OpenRCT2_CPUID_MSVC_X86 #endif #ifdef OPENRCT2_X86 static bool cpuid_x86(uint32_t* cpuid_outdata, int32_t eax) { -#if defined(OpenRCT2_CPUID_GNUC_X86) +# if defined(OpenRCT2_CPUID_GNUC_X86) int ret = __get_cpuid(eax, &cpuid_outdata[0], &cpuid_outdata[1], &cpuid_outdata[2], &cpuid_outdata[3]); return ret == 1; -#elif defined(OpenRCT2_CPUID_MSVC_X86) +# elif defined(OpenRCT2_CPUID_MSVC_X86) __cpuid((int*)cpuid_outdata, (int)eax); return true; -#else +# else return false; -#endif +# endif } #endif // OPENRCT2_X86 @@ -223,16 +223,16 @@ bool avx2_available() // https://github.com/gcc-mirror/gcc/commit/132fa33ce998df69a9f793d63785785f4b93e6f1 // which causes it to ignore subleafs, but the new function is unavailable on Ubuntu's // prehistoric toolchains -#if defined(OpenRCT2_CPUID_GNUC_X86) && (!defined(__FreeBSD__) || (__FreeBSD__ > 10)) +# if defined(OpenRCT2_CPUID_GNUC_X86) && (!defined(__FreeBSD__) || (__FreeBSD__ > 10)) return __builtin_cpu_supports("avx2"); -#else +# else // AVX2 support is declared as the 5th bit of EBX with CPUID(EAX = 7, ECX = 0). uint32_t regs[4] = { 0 }; if (cpuid_x86(regs, 7)) { return (regs[1] & (1 << 5)); } -#endif +# endif #endif return false; }