From fd33f0fc1a5aaacf5be26033996e3edfb5f34b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 19 Sep 2024 20:47:56 +0200 Subject: [PATCH] Remove most clang-tidy parameter name exceptions - `maxModes` --> `MaxModesAvailable` (`MaxModes` is already used differently) - `numModes` --> `NumModesInserted` (`NumModes` is already used differently) - `mode` --> `Mode` - `rgb` --> `Color` - `png_ptr` --> `pPngStruct` - `error_msg` --> `pErrorMessage` - `warning_msg` --> `pWarningMessage` - `sw` --> `SubWidth` - `sh` --> `SubHeight` - `lhs` --> `Lhs` - `rhs` --> `Rhs` - `object` --> `pObject` - `index` --> `pIndex`/`Index` - `array` --> `pArray` - `string` --> `pString` - `integer` --> `pInteger` - `boolean` --> `pBoolean` - `p` --> `pObj` - `id` --> `Id`/`Index` - `width` --> `Width` - `height` --> `Height` - `ownId` --> `OwnId` - `xoff` --> `OffsetX` - `yoff` --> `OffsetY` - `pos0` --> `Pos0` - `pos1` --> `Pos1` - `fnMatchCallback` --> `pfnMatchCallback` - `dx` --> `DeltaX` - `dy` --> `DeltaY` - `wx`, `wy` --> `WorldPos` (`vec2` instead of two `float`s) --- .clang-tidy | 4 +- src/engine/client/backend_sdl.cpp | 32 +++++++-------- src/engine/client/text.cpp | 12 +++--- src/engine/gfx/image_loader.cpp | 14 +++---- src/engine/gfx/image_manipulation.cpp | 24 +++++------ src/engine/gfx/image_manipulation.h | 2 +- src/engine/shared/filecollection.cpp | 2 +- src/engine/shared/json.cpp | 32 +++++++-------- src/engine/textrender.h | 6 +-- src/game/alloc.h | 48 +++++++++++----------- src/game/client/components/freezebars.cpp | 8 ++-- src/game/client/components/freezebars.h | 2 +- src/game/client/components/hud.cpp | 8 ++-- src/game/client/components/hud.h | 2 +- src/game/client/gameclient.cpp | 12 +++--- src/game/client/gameclient.h | 2 +- src/game/collision.cpp | 22 +++++----- src/game/collision.h | 6 +-- src/game/editor/editor.cpp | 14 +++---- src/game/editor/editor.h | 8 ++-- src/game/editor/editor_server_settings.cpp | 8 ++-- src/game/editor/mapitems/layer.h | 4 +- src/game/editor/mapitems/layer_quads.cpp | 6 +-- src/game/editor/mapitems/layer_quads.h | 2 +- src/game/editor/mapitems/layer_sounds.cpp | 6 +-- src/game/editor/mapitems/layer_sounds.h | 2 +- src/game/editor/mapitems/layer_speedup.cpp | 6 +-- src/game/editor/mapitems/layer_speedup.h | 2 +- src/game/editor/mapitems/layer_switch.cpp | 6 +-- src/game/editor/mapitems/layer_switch.h | 2 +- src/game/editor/mapitems/layer_tele.cpp | 6 +-- src/game/editor/mapitems/layer_tele.h | 2 +- src/game/editor/mapitems/layer_tiles.cpp | 6 +-- src/game/editor/mapitems/layer_tiles.h | 2 +- src/game/editor/mapitems/layer_tune.cpp | 6 +-- src/game/editor/mapitems/layer_tune.h | 2 +- 36 files changed, 164 insertions(+), 164 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3ecdb32d8..0c1e11afb 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -136,7 +136,7 @@ CheckOptions: - key: readability-identifier-naming.ParameterCase value: CamelCase - key: readability-identifier-naming.ParameterIgnoredRegexp - value: '^(p|a|v|[a-z]$|s[hw]$|warning_msg$|error_msg$|string$|integer$|boolean$|object$|index$|rhs$|lhs$|[xy]off$|id$|mode$|rgb$|[xy][0123]$|width$|height$|[sdw][xy]$|ownId$|fnMatchCallback$).*' + value: '^(p|a|v|[a-z]$|[xy][0123]$).*' - key: readability-identifier-naming.ClassMethodIgnoredRegexp value: '^(Con_).*' - key: readability-identifier-naming.ClassMemberIgnoredRegexp @@ -144,5 +144,5 @@ CheckOptions: - key: readability-identifier-naming.LocalConstantIgnoredRegexp value: '^(p|a|v|s_|MAX_ANIM_SPEED$|DATA_OFFSET$|HEADER_LEN$|MIN_ANIM_SPEED$|[hwdcbqstf]$|[xt][0123]$|result$|sub$|it$|len$|d[xy]$).*' - key: readability-identifier-naming.LocalVariableIgnoredRegexp - value: '^(p|a|s_|FT_|TB_|s_|ul_|v|[xy]i$|[zijklxyhmrgbacwestnduvqf]$|[dmpwsitcf][xy]$|(ch|skel)[0-2]?$|it$|tw$|dt$|th$|ls$|func$|res$|shader$|len$|maxLength$|length$|offset$|offpos$|result$|bg$|sp$|url$|index$|ctxt$|key$|null$|logger$|LAST_MODIFIED$|teleNr$|target$|id$|hit$|hsl[0-2]?$|rgb[0-2]?$|dir$|tmp$|sub$|ret$|rendered$|(lower|upper)(16|26|24|32)|size$|isWeaponCollide$|zerochar$|dist$|sound$|match$|best_matches$|matches$|nohook$|btn$|savedLayers$|l[hw]$|evilz$|sec$|min$|to2$|delay$|mode$|maxModes$|numModes$|[xy]Fract$|[xy]Int$|imgg[xy]$|skip$|localPlayer$|fdratio$|[rgbat][0-2]$|[xy][0-3]$|x[rl]$).*' + value: '^(p|a|s_|FT_|TB_|s_|ul_|v|[xy]i$|[zijklxyhmrgbacwestnduvqf]$|[dmpwsitcf][xy]$|(ch|skel)[0-2]?$|it$|tw$|dt$|th$|ls$|func$|res$|shader$|len$|maxLength$|length$|offset$|offpos$|result$|bg$|sp$|url$|index$|ctxt$|key$|null$|logger$|LAST_MODIFIED$|teleNr$|target$|id$|hit$|hsl[0-2]?$|rgb[0-2]?$|dir$|tmp$|sub$|ret$|rendered$|size$|isWeaponCollide$|zerochar$|dist$|sound$|match$|best_matches$|matches$|nohook$|btn$|savedLayers$|l[hw]$|evilz$|sec$|min$|to2$|delay$|[xy]Fract$|[xy]Int$|imgg[xy]$|skip$|localPlayer$|fdratio$|[rgbat][0-2]$|[xy][0-3]$|x[rl]$).*' diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 8dccd39cf..cb42a1cfc 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -905,8 +905,7 @@ static void DisplayToVideoMode(CVideoMode *pVMode, SDL_DisplayMode *pMode, int H void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId) { SDL_DisplayMode DesktopMode; - int maxModes = SDL_GetNumDisplayModes(ScreenId); - int numModes = 0; + int MaxModesAvailable = SDL_GetNumDisplayModes(ScreenId); // Only collect fullscreen modes when requested, that makes sure in windowed mode no refresh rates are shown that aren't supported without // fullscreen anyway(except fullscreen desktop) @@ -921,49 +920,50 @@ void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, in constexpr int ModeCount = 256; SDL_DisplayMode aModes[ModeCount]; int NumModes = 0; - for(int i = 0; i < maxModes && NumModes < ModeCount; i++) + for(int i = 0; i < MaxModesAvailable && NumModes < ModeCount; i++) { - SDL_DisplayMode mode; - if(SDL_GetDisplayMode(ScreenId, i, &mode) < 0) + SDL_DisplayMode Mode; + if(SDL_GetDisplayMode(ScreenId, i, &Mode) < 0) { dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError()); continue; } - aModes[NumModes] = mode; + aModes[NumModes] = Mode; ++NumModes; } - auto &&ModeInsert = [&](SDL_DisplayMode &mode) { - if(numModes < MaxModes) + int NumModesInserted = 0; + auto &&ModeInsert = [&](SDL_DisplayMode &Mode) { + if(NumModesInserted < MaxModes) { // if last mode was equal, ignore this one --- in fullscreen this can really only happen if the screen // supports different color modes // in non fullscren these are the modes that show different refresh rate, but are basically the same - if(numModes > 0 && pModes[numModes - 1].m_WindowWidth == mode.w && pModes[numModes - 1].m_WindowHeight == mode.h && (pModes[numModes - 1].m_RefreshRate == mode.refresh_rate || (mode.refresh_rate != DesktopMode.refresh_rate && !CollectFullscreenModes))) + if(NumModesInserted > 0 && pModes[NumModesInserted - 1].m_WindowWidth == Mode.w && pModes[NumModesInserted - 1].m_WindowHeight == Mode.h && (pModes[NumModesInserted - 1].m_RefreshRate == Mode.refresh_rate || (Mode.refresh_rate != DesktopMode.refresh_rate && !CollectFullscreenModes))) return; - DisplayToVideoMode(&pModes[numModes], &mode, HiDPIScale, !CollectFullscreenModes ? DesktopMode.refresh_rate : mode.refresh_rate); - numModes++; + DisplayToVideoMode(&pModes[NumModesInserted], &Mode, HiDPIScale, !CollectFullscreenModes ? DesktopMode.refresh_rate : Mode.refresh_rate); + NumModesInserted++; } }; for(int i = 0; i < NumModes; i++) { - SDL_DisplayMode &mode = aModes[i]; + SDL_DisplayMode &Mode = aModes[i]; - if(mode.w > MaxWindowWidth || mode.h > MaxWindowHeight) + if(Mode.w > MaxWindowWidth || Mode.h > MaxWindowHeight) continue; - ModeInsert(mode); + ModeInsert(Mode); if(IsFullscreenDestkop) break; - if(numModes >= MaxModes) + if(NumModesInserted >= MaxModes) break; } - *pNumModes = numModes; + *pNumModes = NumModesInserted; } void CGraphicsBackend_SDL_GL::GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index b7c228221..1337d3293 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -1353,9 +1353,9 @@ public: m_Color.a = a; } - void TextColor(ColorRGBA rgb) override + void TextColor(ColorRGBA Color) override { - m_Color = rgb; + m_Color = Color; } void TextOutlineColor(float r, float g, float b, float a) override @@ -1366,9 +1366,9 @@ public: m_OutlineColor.a = a; } - void TextOutlineColor(ColorRGBA rgb) override + void TextOutlineColor(ColorRGBA Color) override { - m_OutlineColor = rgb; + m_OutlineColor = Color; } void TextSelectionColor(float r, float g, float b, float a) override @@ -1379,9 +1379,9 @@ public: m_SelectionColor.a = a; } - void TextSelectionColor(ColorRGBA rgb) override + void TextSelectionColor(ColorRGBA Color) override { - m_SelectionColor = rgb; + m_SelectionColor = Color; } ColorRGBA GetTextColor() const override diff --git a/src/engine/gfx/image_loader.cpp b/src/engine/gfx/image_loader.cpp index be80f82df..79d95956d 100644 --- a/src/engine/gfx/image_loader.cpp +++ b/src/engine/gfx/image_loader.cpp @@ -44,17 +44,17 @@ public: std::jmp_buf m_JmpBuf; }; -[[noreturn]] static void PngErrorCallback(png_structp png_ptr, png_const_charp error_msg) +[[noreturn]] static void PngErrorCallback(png_structp pPngStruct, png_const_charp pErrorMessage) { - CUserErrorStruct *pUserStruct = static_cast(png_get_error_ptr(png_ptr)); - log_error("png", "error for file \"%s\": %s", pUserStruct->m_pContextName, error_msg); + CUserErrorStruct *pUserStruct = static_cast(png_get_error_ptr(pPngStruct)); + log_error("png", "error for file \"%s\": %s", pUserStruct->m_pContextName, pErrorMessage); std::longjmp(pUserStruct->m_JmpBuf, 1); } -static void PngWarningCallback(png_structp png_ptr, png_const_charp warning_msg) +static void PngWarningCallback(png_structp pPngStruct, png_const_charp pWarningMessage) { - CUserErrorStruct *pUserStruct = static_cast(png_get_error_ptr(png_ptr)); - log_warn("png", "warning for file \"%s\": %s", pUserStruct->m_pContextName, warning_msg); + CUserErrorStruct *pUserStruct = static_cast(png_get_error_ptr(pPngStruct)); + log_warn("png", "warning for file \"%s\": %s", pUserStruct->m_pContextName, pWarningMessage); } static void PngReadDataCallback(png_structp pPngStruct, png_bytep pOutBytes, png_size_t ByteCountToRead) @@ -307,7 +307,7 @@ static void PngWriteDataCallback(png_structp pPngStruct, png_bytep pOutBytes, pn pWriter->Write(pOutBytes, ByteCountToWrite); } -static void PngOutputFlushCallback(png_structp png_ptr) +static void PngOutputFlushCallback(png_structp pPngStruct) { // no need to flush memory buffer } diff --git a/src/engine/gfx/image_manipulation.cpp b/src/engine/gfx/image_manipulation.cpp index 115a319ad..3b7ab1aac 100644 --- a/src/engine/gfx/image_manipulation.cpp +++ b/src/engine/gfx/image_manipulation.cpp @@ -157,41 +157,41 @@ void DilateImage(const CImageInfo &Image) DilateImage(Image.m_pData, Image.m_Width, Image.m_Height); } -void DilateImageSub(uint8_t *pImageBuff, int w, int h, int x, int y, int sw, int sh) +void DilateImageSub(uint8_t *pImageBuff, int w, int h, int x, int y, int SubWidth, int SubHeight) { uint8_t *apBuffer[2] = {nullptr, nullptr}; - const size_t ImageSize = (size_t)sw * sh * sizeof(uint8_t) * DILATE_BPP; + const size_t ImageSize = (size_t)SubWidth * SubHeight * sizeof(uint8_t) * DILATE_BPP; apBuffer[0] = (uint8_t *)malloc(ImageSize); apBuffer[1] = (uint8_t *)malloc(ImageSize); uint8_t *pBufferOriginal = (uint8_t *)malloc(ImageSize); - for(int Y = 0; Y < sh; ++Y) + for(int Y = 0; Y < SubHeight; ++Y) { int SrcImgOffset = ((y + Y) * w * DILATE_BPP) + (x * DILATE_BPP); - int DstImgOffset = (Y * sw * DILATE_BPP); - int CopySize = sw * DILATE_BPP; + int DstImgOffset = (Y * SubWidth * DILATE_BPP); + int CopySize = SubWidth * DILATE_BPP; mem_copy(&pBufferOriginal[DstImgOffset], &pImageBuff[SrcImgOffset], CopySize); } - Dilate(sw, sh, pBufferOriginal, apBuffer[0]); + Dilate(SubWidth, SubHeight, pBufferOriginal, apBuffer[0]); for(int i = 0; i < 5; i++) { - Dilate(sw, sh, apBuffer[0], apBuffer[1]); - Dilate(sw, sh, apBuffer[1], apBuffer[0]); + Dilate(SubWidth, SubHeight, apBuffer[0], apBuffer[1]); + Dilate(SubWidth, SubHeight, apBuffer[1], apBuffer[0]); } - CopyColorValues(sw, sh, apBuffer[0], pBufferOriginal); + CopyColorValues(SubWidth, SubHeight, apBuffer[0], pBufferOriginal); free(apBuffer[0]); free(apBuffer[1]); - for(int Y = 0; Y < sh; ++Y) + for(int Y = 0; Y < SubHeight; ++Y) { int SrcImgOffset = ((y + Y) * w * DILATE_BPP) + (x * DILATE_BPP); - int DstImgOffset = (Y * sw * DILATE_BPP); - int CopySize = sw * DILATE_BPP; + int DstImgOffset = (Y * SubWidth * DILATE_BPP); + int CopySize = SubWidth * DILATE_BPP; mem_copy(&pImageBuff[SrcImgOffset], &pBufferOriginal[DstImgOffset], CopySize); } diff --git a/src/engine/gfx/image_manipulation.h b/src/engine/gfx/image_manipulation.h index c005af7c1..ae39144e2 100644 --- a/src/engine/gfx/image_manipulation.h +++ b/src/engine/gfx/image_manipulation.h @@ -18,7 +18,7 @@ void ConvertToGrayscale(const CImageInfo &Image); // These functions assume that the image data is 4 bytes per pixel RGBA void DilateImage(uint8_t *pImageBuff, int w, int h); void DilateImage(const CImageInfo &Image); -void DilateImageSub(uint8_t *pImageBuff, int w, int h, int x, int y, int sw, int sh); +void DilateImageSub(uint8_t *pImageBuff, int w, int h, int x, int y, int SubWidth, int SubHeight); // Returned buffer is allocated with malloc, must be freed by caller uint8_t *ResizeImage(const uint8_t *pImageData, int Width, int Height, int NewWidth, int NewHeight, int BPP); diff --git a/src/engine/shared/filecollection.cpp b/src/engine/shared/filecollection.cpp index 835d7bddc..252e6e1ef 100644 --- a/src/engine/shared/filecollection.cpp +++ b/src/engine/shared/filecollection.cpp @@ -19,7 +19,7 @@ void CFileCollection::Init(IStorage *pStorage, const char *pPath, const char *pF m_pStorage = pStorage; m_pStorage->ListDirectory(IStorage::TYPE_SAVE, m_aPath, FilelistCallback, this); - std::sort(m_vFileEntries.begin(), m_vFileEntries.end(), [](const CFileEntry &lhs, const CFileEntry &rhs) { return lhs.m_Timestamp < rhs.m_Timestamp; }); + std::sort(m_vFileEntries.begin(), m_vFileEntries.end(), [](const CFileEntry &Lhs, const CFileEntry &Rhs) { return Lhs.m_Timestamp < Rhs.m_Timestamp; }); int FilesDeleted = 0; for(auto FileEntry : m_vFileEntries) diff --git a/src/engine/shared/json.cpp b/src/engine/shared/json.cpp index 37338ff1b..93660edcc 100644 --- a/src/engine/shared/json.cpp +++ b/src/engine/shared/json.cpp @@ -1,46 +1,46 @@ #include #include -const struct _json_value *json_object_get(const json_value *object, const char *index) +const struct _json_value *json_object_get(const json_value *pObject, const char *pIndex) { unsigned int i; - if(object->type != json_object) + if(pObject->type != json_object) return &json_value_none; - for(i = 0; i < object->u.object.length; ++i) - if(!str_comp(object->u.object.values[i].name, index)) - return object->u.object.values[i].value; + for(i = 0; i < pObject->u.object.length; ++i) + if(!str_comp(pObject->u.object.values[i].name, pIndex)) + return pObject->u.object.values[i].value; return &json_value_none; } -const struct _json_value *json_array_get(const json_value *array, int index) +const struct _json_value *json_array_get(const json_value *pArray, int Index) { - if(array->type != json_array || index >= (int)array->u.array.length) + if(pArray->type != json_array || Index >= (int)pArray->u.array.length) return &json_value_none; - return array->u.array.values[index]; + return pArray->u.array.values[Index]; } -int json_array_length(const json_value *array) +int json_array_length(const json_value *pArray) { - return array->u.array.length; + return pArray->u.array.length; } -const char *json_string_get(const json_value *string) +const char *json_string_get(const json_value *pString) { - return string->u.string.ptr; + return pString->u.string.ptr; } -int json_int_get(const json_value *integer) +int json_int_get(const json_value *pInteger) { - return integer->u.integer; + return pInteger->u.integer; } -int json_boolean_get(const json_value *boolean) +int json_boolean_get(const json_value *pBoolean) { - return boolean->u.boolean != 0; + return pBoolean->u.boolean != 0; } static char EscapeJsonChar(char c) diff --git a/src/engine/textrender.h b/src/engine/textrender.h index 3b0ca218e..3b26e0aaa 100644 --- a/src/engine/textrender.h +++ b/src/engine/textrender.h @@ -352,11 +352,11 @@ public: // old foolish interface virtual void TextColor(float r, float g, float b, float a) = 0; - virtual void TextColor(ColorRGBA rgb) = 0; + virtual void TextColor(ColorRGBA Color) = 0; virtual void TextOutlineColor(float r, float g, float b, float a) = 0; - virtual void TextOutlineColor(ColorRGBA rgb) = 0; + virtual void TextOutlineColor(ColorRGBA Color) = 0; virtual void TextSelectionColor(float r, float g, float b, float a) = 0; - virtual void TextSelectionColor(ColorRGBA rgb) = 0; + virtual void TextSelectionColor(ColorRGBA Color) = 0; virtual void Text(float x, float y, float Size, const char *pText, float LineWidth = -1.0f) = 0; virtual float TextWidth(float Size, const char *pText, int StrLength = -1, float LineWidth = -1.0f, int Flags = 0, const STextSizeProperties &TextSizeProps = {}) = 0; virtual STextBoundingBox TextBoundingBox(float Size, const char *pText, int StrLength = -1, float LineWidth = -1.0f, float LineSpacing = 0.0f, int Flags = 0) = 0; diff --git a/src/game/alloc.h b/src/game/alloc.h index b4a76a9bd..4a829a118 100644 --- a/src/game/alloc.h +++ b/src/game/alloc.h @@ -22,9 +22,9 @@ public: \ void *operator new(size_t Size) \ { \ - void *p = malloc(Size); \ - mem_zero(p, Size); \ - return p; \ + void *pObj = malloc(Size); \ + mem_zero(pObj, Size); \ + return pObj; \ } \ void operator delete(void *pPtr) \ { \ @@ -35,9 +35,9 @@ private: #define MACRO_ALLOC_POOL_ID() \ public: \ - void *operator new(size_t Size, int id); \ - void operator delete(void *p, int id); \ - void operator delete(void *p); /* NOLINT(misc-new-delete-overloads) */ \ + void *operator new(size_t Size, int Id); \ + void operator delete(void *pObj, int Id); \ + void operator delete(void *pObj); /* NOLINT(misc-new-delete-overloads) */ \ \ private: @@ -51,30 +51,30 @@ private: static char gs_PoolData##POOLTYPE[PoolSize][MACRO_ALLOC_GET_SIZE(POOLTYPE)] = {{0}}; \ static int gs_PoolUsed##POOLTYPE[PoolSize] = {0}; \ MAYBE_UNUSED static int gs_PoolDummy##POOLTYPE = (ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE, sizeof(gs_PoolData##POOLTYPE)), 0); \ - void *POOLTYPE::operator new(size_t Size, int id) \ + void *POOLTYPE::operator new(size_t Size, int Id) \ { \ dbg_assert(sizeof(POOLTYPE) >= Size, "size error"); \ - dbg_assert(!gs_PoolUsed##POOLTYPE[id], "already used"); \ - ASAN_UNPOISON_MEMORY_REGION(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \ - gs_PoolUsed##POOLTYPE[id] = 1; \ - mem_zero(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \ - return gs_PoolData##POOLTYPE[id]; \ + dbg_assert(!gs_PoolUsed##POOLTYPE[Id], "already used"); \ + ASAN_UNPOISON_MEMORY_REGION(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \ + gs_PoolUsed##POOLTYPE[Id] = 1; \ + mem_zero(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \ + return gs_PoolData##POOLTYPE[Id]; \ } \ - void POOLTYPE::operator delete(void *p, int id) \ + void POOLTYPE::operator delete(void *pObj, int Id) \ { \ - dbg_assert(gs_PoolUsed##POOLTYPE[id], "not used"); \ - dbg_assert(id == (POOLTYPE *)p - (POOLTYPE *)gs_PoolData##POOLTYPE, "invalid id"); \ - gs_PoolUsed##POOLTYPE[id] = 0; \ - mem_zero(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \ - ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \ + dbg_assert(gs_PoolUsed##POOLTYPE[Id], "not used"); \ + dbg_assert(Id == (POOLTYPE *)pObj - (POOLTYPE *)gs_PoolData##POOLTYPE, "invalid id"); \ + gs_PoolUsed##POOLTYPE[Id] = 0; \ + mem_zero(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \ + ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \ } \ - void POOLTYPE::operator delete(void *p) /* NOLINT(misc-new-delete-overloads) */ \ + void POOLTYPE::operator delete(void *pObj) /* NOLINT(misc-new-delete-overloads) */ \ { \ - int id = (POOLTYPE *)p - (POOLTYPE *)gs_PoolData##POOLTYPE; \ - dbg_assert(gs_PoolUsed##POOLTYPE[id], "not used"); \ - gs_PoolUsed##POOLTYPE[id] = 0; \ - mem_zero(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \ - ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \ + int Id = (POOLTYPE *)pObj - (POOLTYPE *)gs_PoolData##POOLTYPE; \ + dbg_assert(gs_PoolUsed##POOLTYPE[Id], "not used"); \ + gs_PoolUsed##POOLTYPE[Id] = 0; \ + mem_zero(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \ + ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[Id], sizeof(gs_PoolData##POOLTYPE[Id])); \ } #endif diff --git a/src/game/client/components/freezebars.cpp b/src/game/client/components/freezebars.cpp index ff629090b..1f5f0204e 100644 --- a/src/game/client/components/freezebars.cpp +++ b/src/game/client/components/freezebars.cpp @@ -36,7 +36,7 @@ void CFreezeBars::RenderFreezeBar(const int ClientId) RenderFreezeBarPos(Position.x, Position.y, FreezeBarWidth, FreezeBarHight, FreezeProgress, Alpha); } -void CFreezeBars::RenderFreezeBarPos(float x, const float y, const float width, const float height, float Progress, const float Alpha) +void CFreezeBars::RenderFreezeBarPos(float x, const float y, const float Width, const float Height, float Progress, const float Alpha) { Progress = clamp(Progress, 0.0f, 1.0f); @@ -45,9 +45,9 @@ void CFreezeBars::RenderFreezeBarPos(float x, const float y, const float width, const float RestPct = 0.5f; const float ProgPct = 0.5f; - const float EndWidth = height; // to keep the correct scale - the height of the sprite is as long as the width - const float BarHeight = height; - const float WholeBarWidth = width; + const float EndWidth = Height; // to keep the correct scale - the height of the sprite is as long as the width + const float BarHeight = Height; + const float WholeBarWidth = Width; const float MiddleBarWidth = WholeBarWidth - (EndWidth * 2.0f); const float EndProgressWidth = EndWidth * ProgPct; const float EndRestWidth = EndWidth * RestPct; diff --git a/src/game/client/components/freezebars.h b/src/game/client/components/freezebars.h index 7a7e83e2e..1f8307453 100644 --- a/src/game/client/components/freezebars.h +++ b/src/game/client/components/freezebars.h @@ -5,7 +5,7 @@ class CFreezeBars : public CComponent { void RenderFreezeBar(const int ClientId); - void RenderFreezeBarPos(float x, const float y, const float width, const float height, float Progress, float Alpha = 1.0f); + void RenderFreezeBarPos(float x, const float y, const float Width, const float Height, float Progress, float Alpha = 1.0f); bool IsPlayerInfoAvailable(int ClientId) const; public: diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index d435c81da..91aa90842 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -1040,7 +1040,7 @@ void CHud::RenderPlayerState(const int ClientId) } } -void CHud::RenderNinjaBarPos(const float x, float y, const float width, const float height, float Progress, const float Alpha) +void CHud::RenderNinjaBarPos(const float x, float y, const float Width, const float Height, float Progress, const float Alpha) { Progress = clamp(Progress, 0.0f, 1.0f); @@ -1049,9 +1049,9 @@ void CHud::RenderNinjaBarPos(const float x, float y, const float width, const fl const float RestPct = 0.5f; const float ProgPct = 0.5f; - const float EndHeight = width; // to keep the correct scale - the width of the sprite is as long as the height - const float BarWidth = width; - const float WholeBarHeight = height; + const float EndHeight = Width; // to keep the correct scale - the width of the sprite is as long as the height + const float BarWidth = Width; + const float WholeBarHeight = Height; const float MiddleBarHeight = WholeBarHeight - (EndHeight * 2.0f); const float EndProgressHeight = EndHeight * ProgPct; const float EndRestHeight = EndHeight * RestPct; diff --git a/src/game/client/components/hud.h b/src/game/client/components/hud.h index 769bc8d00..23463bc72 100644 --- a/src/game/client/components/hud.h +++ b/src/game/client/components/hud.h @@ -109,7 +109,7 @@ public: // DDRace virtual void OnMessage(int MsgType, void *pRawMsg) override; - void RenderNinjaBarPos(float x, const float y, const float width, const float height, float Progress, float Alpha = 1.0f); + void RenderNinjaBarPos(float x, const float y, const float Width, const float Height, float Progress, float Alpha = 1.0f); private: void RenderRecord(); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 9aa732795..bbeddef45 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -2772,16 +2772,16 @@ IGameClient *CreateGameClient() return new CGameClient(); } -int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, int ownId) +int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, int OwnId) { float Distance = 0.0f; int ClosestId = -1; - const CClientData &OwnClientData = m_aClients[ownId]; + const CClientData &OwnClientData = m_aClients[OwnId]; for(int i = 0; i < MAX_CLIENTS; i++) { - if(i == ownId) + if(i == OwnId) continue; const CClientData &Data = m_aClients[i]; @@ -2797,7 +2797,7 @@ int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, in bool IsOneSuper = Data.m_Super || OwnClientData.m_Super; bool IsOneSolo = Data.m_Solo || OwnClientData.m_Solo; - if(!IsOneSuper && (!m_Teams.SameTeam(i, ownId) || IsOneSolo || OwnClientData.m_HookHitDisabled)) + if(!IsOneSuper && (!m_Teams.SameTeam(i, OwnId) || IsOneSolo || OwnClientData.m_HookHitDisabled)) continue; vec2 ClosestPoint; @@ -3904,9 +3904,9 @@ void CGameClient::SnapCollectEntities() class CEntComparer { public: - bool operator()(const CSnapEntities &lhs, const CSnapEntities &rhs) const + bool operator()(const CSnapEntities &Lhs, const CSnapEntities &Rhs) const { - return lhs.m_Item.m_Id < rhs.m_Item.m_Id; + return Lhs.m_Item.m_Id < Rhs.m_Item.m_Id; } }; diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index bf0f9071d..d385bfd79 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -576,7 +576,7 @@ public: class CTeamsCore m_Teams; - int IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, int ownId); + int IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, int OwnId); int GetLastRaceTick() const override; diff --git a/src/game/collision.cpp b/src/game/collision.cpp index b640e04c3..acdc51558 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -602,28 +602,28 @@ int CCollision::IsSolid(int x, int y) const return index == TILE_SOLID || index == TILE_NOHOOK; } -bool CCollision::IsThrough(int x, int y, int xoff, int yoff, vec2 pos0, vec2 pos1) const +bool CCollision::IsThrough(int x, int y, int OffsetX, int OffsetY, vec2 Pos0, vec2 Pos1) const { int pos = GetPureMapIndex(x, y); if(m_pFront && (m_pFront[pos].m_Index == TILE_THROUGH_ALL || m_pFront[pos].m_Index == TILE_THROUGH_CUT)) return true; - if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_DIR && ((m_pFront[pos].m_Flags == ROTATION_0 && pos0.y > pos1.y) || (m_pFront[pos].m_Flags == ROTATION_90 && pos0.x < pos1.x) || (m_pFront[pos].m_Flags == ROTATION_180 && pos0.y < pos1.y) || (m_pFront[pos].m_Flags == ROTATION_270 && pos0.x > pos1.x))) + if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_DIR && ((m_pFront[pos].m_Flags == ROTATION_0 && Pos0.y > Pos1.y) || (m_pFront[pos].m_Flags == ROTATION_90 && Pos0.x < Pos1.x) || (m_pFront[pos].m_Flags == ROTATION_180 && Pos0.y < Pos1.y) || (m_pFront[pos].m_Flags == ROTATION_270 && Pos0.x > Pos1.x))) return true; - int offpos = GetPureMapIndex(x + xoff, y + yoff); + int offpos = GetPureMapIndex(x + OffsetX, y + OffsetY); return m_pTiles[offpos].m_Index == TILE_THROUGH || (m_pFront && m_pFront[offpos].m_Index == TILE_THROUGH); } -bool CCollision::IsHookBlocker(int x, int y, vec2 pos0, vec2 pos1) const +bool CCollision::IsHookBlocker(int x, int y, vec2 Pos0, vec2 Pos1) const { int pos = GetPureMapIndex(x, y); if(m_pTiles[pos].m_Index == TILE_THROUGH_ALL || (m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_ALL)) return true; - if(m_pTiles[pos].m_Index == TILE_THROUGH_DIR && ((m_pTiles[pos].m_Flags == ROTATION_0 && pos0.y < pos1.y) || - (m_pTiles[pos].m_Flags == ROTATION_90 && pos0.x > pos1.x) || - (m_pTiles[pos].m_Flags == ROTATION_180 && pos0.y > pos1.y) || - (m_pTiles[pos].m_Flags == ROTATION_270 && pos0.x < pos1.x))) + if(m_pTiles[pos].m_Index == TILE_THROUGH_DIR && ((m_pTiles[pos].m_Flags == ROTATION_0 && Pos0.y < Pos1.y) || + (m_pTiles[pos].m_Flags == ROTATION_90 && Pos0.x > Pos1.x) || + (m_pTiles[pos].m_Flags == ROTATION_180 && Pos0.y > Pos1.y) || + (m_pTiles[pos].m_Flags == ROTATION_270 && Pos0.x < Pos1.x))) return true; - if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_DIR && ((m_pFront[pos].m_Flags == ROTATION_0 && pos0.y < pos1.y) || (m_pFront[pos].m_Flags == ROTATION_90 && pos0.x > pos1.x) || (m_pFront[pos].m_Flags == ROTATION_180 && pos0.y > pos1.y) || (m_pFront[pos].m_Flags == ROTATION_270 && pos0.x < pos1.x))) + if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_DIR && ((m_pFront[pos].m_Flags == ROTATION_0 && Pos0.y < Pos1.y) || (m_pFront[pos].m_Flags == ROTATION_90 && Pos0.x > Pos1.x) || (m_pFront[pos].m_Flags == ROTATION_180 && Pos0.y > Pos1.y) || (m_pFront[pos].m_Flags == ROTATION_270 && Pos0.x < Pos1.x))) return true; return false; } @@ -1078,12 +1078,12 @@ int CCollision::Entity(int x, int y, int Layer) const } } -void CCollision::SetCollisionAt(float x, float y, int id) +void CCollision::SetCollisionAt(float x, float y, int Index) { int Nx = clamp(round_to_int(x) / 32, 0, m_Width - 1); int Ny = clamp(round_to_int(y) / 32, 0, m_Height - 1); - m_pTiles[Ny * m_Width + Nx].m_Index = id; + m_pTiles[Ny * m_Width + Nx].m_Index = Index; } void CCollision::SetDCollisionAt(float x, float y, int Type, int Flags, int Number) diff --git a/src/game/collision.h b/src/game/collision.h index 8ca313421..a5f987488 100644 --- a/src/game/collision.h +++ b/src/game/collision.h @@ -53,7 +53,7 @@ public: bool TestBox(vec2 Pos, vec2 Size) const; // DDRace - void SetCollisionAt(float x, float y, int id); + void SetCollisionAt(float x, float y, int Index); void SetDCollisionAt(float x, float y, int Type, int Flags, int Number); int GetDTileIndex(int Index) const; int GetDTileFlags(int Index) const; @@ -101,8 +101,8 @@ public: int GetSwitchDelay(int Index) const; int IsSolid(int x, int y) const; - bool IsThrough(int x, int y, int xoff, int yoff, vec2 pos0, vec2 pos1) const; - bool IsHookBlocker(int x, int y, vec2 pos0, vec2 pos1) const; + bool IsThrough(int x, int y, int OffsetX, int OffsetY, vec2 Pos0, vec2 Pos1) const; + bool IsHookBlocker(int x, int y, vec2 Pos0, vec2 Pos1) const; int IsWallJump(int Index) const; int IsNoLaser(int x, int y) const; int IsFNoLaser(int x, int y) const; diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index c527a6af9..19f7981ef 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3207,11 +3207,11 @@ void CEditor::DoMapEditor(CUIRect View) std::shared_ptr pBrushLayer = std::static_pointer_cast(m_pBrush->m_vpLayers[BrushIndex]); if(pLayer->m_Tele <= pBrushLayer->m_Tele && pLayer->m_Speedup <= pBrushLayer->m_Speedup && pLayer->m_Front <= pBrushLayer->m_Front && pLayer->m_Game <= pBrushLayer->m_Game && pLayer->m_Switch <= pBrushLayer->m_Switch && pLayer->m_Tune <= pBrushLayer->m_Tune) - pLayer->BrushDraw(pBrushLayer, wx, wy); + pLayer->BrushDraw(pBrushLayer, vec2(wx, wy)); } else { - apEditLayers[k].second->BrushDraw(m_pBrush->m_vpLayers[BrushIndex], wx, wy); + apEditLayers[k].second->BrushDraw(m_pBrush->m_vpLayers[BrushIndex], vec2(wx, wy)); } } } @@ -3304,7 +3304,7 @@ void CEditor::DoMapEditor(CUIRect View) BrushIndex = 0; if(apEditLayers[k].second->m_Type == m_pBrush->m_vpLayers[BrushIndex]->m_Type) - apEditLayers[k].second->BrushPlace(m_pBrush->m_vpLayers[BrushIndex], wx, wy); + apEditLayers[k].second->BrushPlace(m_pBrush->m_vpLayers[BrushIndex], vec2(wx, wy)); } } @@ -5915,14 +5915,14 @@ float CEditor::EnvelopeToScreenY(const CUIRect &View, float y) const return View.y + View.h - y / m_ZoomEnvelopeY.GetValue() * View.h - m_OffsetEnvelopeY * View.h; } -float CEditor::ScreenToEnvelopeDX(const CUIRect &View, float dx) +float CEditor::ScreenToEnvelopeDX(const CUIRect &View, float DeltaX) { - return dx / Graphics()->ScreenWidth() * Ui()->Screen()->w / View.w * m_ZoomEnvelopeX.GetValue(); + return DeltaX / Graphics()->ScreenWidth() * Ui()->Screen()->w / View.w * m_ZoomEnvelopeX.GetValue(); } -float CEditor::ScreenToEnvelopeDY(const CUIRect &View, float dy) +float CEditor::ScreenToEnvelopeDY(const CUIRect &View, float DeltaY) { - return dy / Graphics()->ScreenHeight() * Ui()->Screen()->h / View.h * m_ZoomEnvelopeY.GetValue(); + return DeltaY / Graphics()->ScreenHeight() * Ui()->Screen()->h / View.h * m_ZoomEnvelopeY.GetValue(); } void CEditor::RemoveTimeOffsetEnvelope(const std::shared_ptr &pEnvelope) diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index 39cf313b7..c1f9d42d6 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -850,9 +850,9 @@ public: void DoMapSettingsEditBox(CMapSettingsBackend::CContext *pContext, const CUIRect *pRect, float FontSize, float DropdownMaxHeight, int Corners = IGraphics::CORNER_ALL, const char *pToolTip = nullptr); template - int DoEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CLineInput *pLineInput, const CUIRect *pEditBoxRect, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &fnMatchCallback); + int DoEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CLineInput *pLineInput, const CUIRect *pEditBoxRect, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &pfnMatchCallback); template - int RenderEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CUIRect View, CLineInput *pLineInput, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &fnMatchCallback); + int RenderEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CUIRect View, CLineInput *pLineInput, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &pfnMatchCallback); void RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness) const; @@ -1121,8 +1121,8 @@ public: float EnvelopeToScreenX(const CUIRect &View, float x) const; float ScreenToEnvelopeY(const CUIRect &View, float y) const; float EnvelopeToScreenY(const CUIRect &View, float y) const; - float ScreenToEnvelopeDX(const CUIRect &View, float dx); - float ScreenToEnvelopeDY(const CUIRect &View, float dy); + float ScreenToEnvelopeDX(const CUIRect &View, float DeltaX); + float ScreenToEnvelopeDY(const CUIRect &View, float DeltaY); // DDRace diff --git a/src/game/editor/editor_server_settings.cpp b/src/game/editor/editor_server_settings.cpp index d2bddc2b0..0df350680 100644 --- a/src/game/editor/editor_server_settings.cpp +++ b/src/game/editor/editor_server_settings.cpp @@ -399,7 +399,7 @@ void CEditor::DoMapSettingsEditBox(CMapSettingsBackend::CContext *pContext, cons } template -int CEditor::DoEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CLineInput *pLineInput, const CUIRect *pEditBoxRect, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &fnMatchCallback) +int CEditor::DoEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CLineInput *pLineInput, const CUIRect *pEditBoxRect, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &pfnMatchCallback) { // Do an edit box with a possible dropdown // This is a generic method which can display any data we want @@ -439,7 +439,7 @@ int CEditor::DoEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CLineInput *p pDropdown->m_Selected %= vData.size(); } - int Selected = RenderEditBoxDropdown(pDropdown, *pEditBoxRect, pLineInput, x, MaxHeight, AutoWidth, vData, fnMatchCallback); + int Selected = RenderEditBoxDropdown(pDropdown, *pEditBoxRect, pLineInput, x, MaxHeight, AutoWidth, vData, pfnMatchCallback); if(Selected != -1) pDropdown->m_Selected = Selected; @@ -460,7 +460,7 @@ int CEditor::DoEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CLineInput *p } template -int CEditor::RenderEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CUIRect View, CLineInput *pLineInput, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &fnMatchCallback) +int CEditor::RenderEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CUIRect View, CLineInput *pLineInput, int x, float MaxHeight, bool AutoWidth, const std::vector &vData, const FDropdownRenderCallback &pfnMatchCallback) { // Render a dropdown tied to an edit box/line input auto *pListBox = &pDropdown->m_ListBox; @@ -506,7 +506,7 @@ int CEditor::RenderEditBoxDropdown(SEditBoxDropdownContext *pDropdown, CUIRect V // Call the callback to fill the current line string char aBuf[128]; - fnMatchCallback(vData.at(i), aBuf, Props.m_vColorSplits); + pfnMatchCallback(vData.at(i), aBuf, Props.m_vColorSplits); LargestWidth = maximum(LargestWidth, TextRender()->TextWidth(12.0f, aBuf) + 10.0f); if(!Item.m_Visible) diff --git a/src/game/editor/mapitems/layer.h b/src/game/editor/mapitems/layer.h index efd7a4899..3f62e04f9 100644 --- a/src/game/editor/mapitems/layer.h +++ b/src/game/editor/mapitems/layer.h @@ -46,8 +46,8 @@ public: virtual void BrushSelecting(CUIRect Rect) {} virtual int BrushGrab(std::shared_ptr pBrush, CUIRect Rect) { return 0; } virtual void FillSelection(bool Empty, std::shared_ptr pBrush, CUIRect Rect) {} - virtual void BrushDraw(std::shared_ptr pBrush, float x, float y) {} - virtual void BrushPlace(std::shared_ptr pBrush, float x, float y) {} + virtual void BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) {} + virtual void BrushPlace(std::shared_ptr pBrush, vec2 WorldPos) {} virtual void BrushFlipX() {} virtual void BrushFlipY() {} virtual void BrushRotate(float Amount) {} diff --git a/src/game/editor/mapitems/layer_quads.cpp b/src/game/editor/mapitems/layer_quads.cpp index 2afeec567..b523f815d 100644 --- a/src/game/editor/mapitems/layer_quads.cpp +++ b/src/game/editor/mapitems/layer_quads.cpp @@ -138,7 +138,7 @@ int CLayerQuads::BrushGrab(std::shared_ptr pBrush, CUIRect Rect) return pGrabbed->m_vQuads.empty() ? 0 : 1; } -void CLayerQuads::BrushPlace(std::shared_ptr pBrush, float wx, float wy) +void CLayerQuads::BrushPlace(std::shared_ptr pBrush, vec2 WorldPos) { std::shared_ptr pQuadLayer = std::static_pointer_cast(pBrush); std::vector vAddedQuads; @@ -148,8 +148,8 @@ void CLayerQuads::BrushPlace(std::shared_ptr pBrush, float wx, float wy) for(auto &Point : n.m_aPoints) { - Point.x += f2fx(wx); - Point.y += f2fx(wy); + Point.x += f2fx(WorldPos.x); + Point.y += f2fx(WorldPos.y); } m_vQuads.push_back(n); diff --git a/src/game/editor/mapitems/layer_quads.h b/src/game/editor/mapitems/layer_quads.h index c0087696b..e0026aaff 100644 --- a/src/game/editor/mapitems/layer_quads.h +++ b/src/game/editor/mapitems/layer_quads.h @@ -16,7 +16,7 @@ public: void BrushSelecting(CUIRect Rect) override; int BrushGrab(std::shared_ptr pBrush, CUIRect Rect) override; - void BrushPlace(std::shared_ptr pBrush, float wx, float wy) override; + void BrushPlace(std::shared_ptr pBrush, vec2 WorldPos) override; void BrushFlipX() override; void BrushFlipY() override; void BrushRotate(float Amount) override; diff --git a/src/game/editor/mapitems/layer_sounds.cpp b/src/game/editor/mapitems/layer_sounds.cpp index 039d02595..d25de9a2c 100644 --- a/src/game/editor/mapitems/layer_sounds.cpp +++ b/src/game/editor/mapitems/layer_sounds.cpp @@ -150,7 +150,7 @@ int CLayerSounds::BrushGrab(std::shared_ptr pBrush, CUIRect Rect) return pGrabbed->m_vSources.empty() ? 0 : 1; } -void CLayerSounds::BrushPlace(std::shared_ptr pBrush, float wx, float wy) +void CLayerSounds::BrushPlace(std::shared_ptr pBrush, vec2 WorldPos) { std::shared_ptr pSoundLayer = std::static_pointer_cast(pBrush); std::vector vAddedSources; @@ -158,8 +158,8 @@ void CLayerSounds::BrushPlace(std::shared_ptr pBrush, float wx, float wy { CSoundSource n = Source; - n.m_Position.x += f2fx(wx); - n.m_Position.y += f2fx(wy); + n.m_Position.x += f2fx(WorldPos.x); + n.m_Position.y += f2fx(WorldPos.y); m_vSources.push_back(n); vAddedSources.push_back(n); diff --git a/src/game/editor/mapitems/layer_sounds.h b/src/game/editor/mapitems/layer_sounds.h index bd9e09465..5efe11d51 100644 --- a/src/game/editor/mapitems/layer_sounds.h +++ b/src/game/editor/mapitems/layer_sounds.h @@ -15,7 +15,7 @@ public: void BrushSelecting(CUIRect Rect) override; int BrushGrab(std::shared_ptr pBrush, CUIRect Rect) override; - void BrushPlace(std::shared_ptr pBrush, float wx, float wy) override; + void BrushPlace(std::shared_ptr pBrush, vec2 WorldPos) override; CUi::EPopupMenuFunctionResult RenderProperties(CUIRect *pToolbox) override; diff --git a/src/game/editor/mapitems/layer_speedup.cpp b/src/game/editor/mapitems/layer_speedup.cpp index 9222bf551..e963da8e8 100644 --- a/src/game/editor/mapitems/layer_speedup.cpp +++ b/src/game/editor/mapitems/layer_speedup.cpp @@ -65,14 +65,14 @@ bool CLayerSpeedup::IsEmpty(const std::shared_ptr &pLayer) return true; } -void CLayerSpeedup::BrushDraw(std::shared_ptr pBrush, float wx, float wy) +void CLayerSpeedup::BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) { if(m_Readonly) return; std::shared_ptr pSpeedupLayer = std::static_pointer_cast(pBrush); - int sx = ConvertX(wx); - int sy = ConvertY(wy); + int sx = ConvertX(WorldPos.x); + int sy = ConvertY(WorldPos.y); if(str_comp(pSpeedupLayer->m_aFileName, m_pEditor->m_aFileName)) { m_pEditor->m_SpeedupAngle = pSpeedupLayer->m_SpeedupAngle; diff --git a/src/game/editor/mapitems/layer_speedup.h b/src/game/editor/mapitems/layer_speedup.h index 990f488e7..5b298d528 100644 --- a/src/game/editor/mapitems/layer_speedup.h +++ b/src/game/editor/mapitems/layer_speedup.h @@ -31,7 +31,7 @@ public: void Resize(int NewW, int NewH) override; void Shift(int Direction) override; bool IsEmpty(const std::shared_ptr &pLayer) override; - void BrushDraw(std::shared_ptr pBrush, float wx, float wy) override; + void BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) override; void BrushFlipX() override; void BrushFlipY() override; void BrushRotate(float Amount) override; diff --git a/src/game/editor/mapitems/layer_switch.cpp b/src/game/editor/mapitems/layer_switch.cpp index a66e02624..25e1bc35e 100644 --- a/src/game/editor/mapitems/layer_switch.cpp +++ b/src/game/editor/mapitems/layer_switch.cpp @@ -67,14 +67,14 @@ bool CLayerSwitch::IsEmpty(const std::shared_ptr &pLayer) return true; } -void CLayerSwitch::BrushDraw(std::shared_ptr pBrush, float wx, float wy) +void CLayerSwitch::BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) { if(m_Readonly) return; std::shared_ptr pSwitchLayer = std::static_pointer_cast(pBrush); - int sx = ConvertX(wx); - int sy = ConvertY(wy); + int sx = ConvertX(WorldPos.x); + int sy = ConvertY(WorldPos.y); if(str_comp(pSwitchLayer->m_aFileName, m_pEditor->m_aFileName)) { m_pEditor->m_SwitchNum = pSwitchLayer->m_SwitchNumber; diff --git a/src/game/editor/mapitems/layer_switch.h b/src/game/editor/mapitems/layer_switch.h index 9e21954ba..810cbf9ef 100644 --- a/src/game/editor/mapitems/layer_switch.h +++ b/src/game/editor/mapitems/layer_switch.h @@ -30,7 +30,7 @@ public: void Resize(int NewW, int NewH) override; void Shift(int Direction) override; bool IsEmpty(const std::shared_ptr &pLayer) override; - void BrushDraw(std::shared_ptr pBrush, float wx, float wy) override; + void BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) override; void BrushFlipX() override; void BrushFlipY() override; void BrushRotate(float Amount) override; diff --git a/src/game/editor/mapitems/layer_tele.cpp b/src/game/editor/mapitems/layer_tele.cpp index 977344a58..3e57388f7 100644 --- a/src/game/editor/mapitems/layer_tele.cpp +++ b/src/game/editor/mapitems/layer_tele.cpp @@ -68,14 +68,14 @@ bool CLayerTele::IsEmpty(const std::shared_ptr &pLayer) return true; } -void CLayerTele::BrushDraw(std::shared_ptr pBrush, float wx, float wy) +void CLayerTele::BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) { if(m_Readonly) return; std::shared_ptr pTeleLayer = std::static_pointer_cast(pBrush); - int sx = ConvertX(wx); - int sy = ConvertY(wy); + int sx = ConvertX(WorldPos.x); + int sy = ConvertY(WorldPos.y); if(str_comp(pTeleLayer->m_aFileName, m_pEditor->m_aFileName)) m_pEditor->m_TeleNumber = pTeleLayer->m_TeleNum; diff --git a/src/game/editor/mapitems/layer_tele.h b/src/game/editor/mapitems/layer_tele.h index 8d1c5570e..1a373e79a 100644 --- a/src/game/editor/mapitems/layer_tele.h +++ b/src/game/editor/mapitems/layer_tele.h @@ -28,7 +28,7 @@ public: void Resize(int NewW, int NewH) override; void Shift(int Direction) override; bool IsEmpty(const std::shared_ptr &pLayer) override; - void BrushDraw(std::shared_ptr pBrush, float wx, float wy) override; + void BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) override; void BrushFlipX() override; void BrushFlipY() override; void BrushRotate(float Amount) override; diff --git a/src/game/editor/mapitems/layer_tiles.cpp b/src/game/editor/mapitems/layer_tiles.cpp index 665a0fec9..a6a040a6d 100644 --- a/src/game/editor/mapitems/layer_tiles.cpp +++ b/src/game/editor/mapitems/layer_tiles.cpp @@ -487,15 +487,15 @@ void CLayerTiles::FillSelection(bool Empty, std::shared_ptr pBrush, CUIR FlagModified(sx, sy, w, h); } -void CLayerTiles::BrushDraw(std::shared_ptr pBrush, float wx, float wy) +void CLayerTiles::BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) { if(m_Readonly) return; // std::shared_ptr pTileLayer = std::static_pointer_cast(pBrush); - int sx = ConvertX(wx); - int sy = ConvertY(wy); + int sx = ConvertX(WorldPos.x); + int sy = ConvertY(WorldPos.y); bool Destructive = m_pEditor->m_BrushDrawDestructive || IsEmpty(pTileLayer); diff --git a/src/game/editor/mapitems/layer_tiles.h b/src/game/editor/mapitems/layer_tiles.h index 9af936281..b6ca148d7 100644 --- a/src/game/editor/mapitems/layer_tiles.h +++ b/src/game/editor/mapitems/layer_tiles.h @@ -125,7 +125,7 @@ public: void FillSelection(bool Empty, std::shared_ptr pBrush, CUIRect Rect) override; void FillGameTiles(EGameTileOp Fill); bool CanFillGameTiles() const; - void BrushDraw(std::shared_ptr pBrush, float wx, float wy) override; + void BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) override; void BrushFlipX() override; void BrushFlipY() override; void BrushRotate(float Amount) override; diff --git a/src/game/editor/mapitems/layer_tune.cpp b/src/game/editor/mapitems/layer_tune.cpp index c14a67767..a41759922 100644 --- a/src/game/editor/mapitems/layer_tune.cpp +++ b/src/game/editor/mapitems/layer_tune.cpp @@ -65,14 +65,14 @@ bool CLayerTune::IsEmpty(const std::shared_ptr &pLayer) return true; } -void CLayerTune::BrushDraw(std::shared_ptr pBrush, float wx, float wy) +void CLayerTune::BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) { if(m_Readonly) return; std::shared_ptr pTuneLayer = std::static_pointer_cast(pBrush); - int sx = ConvertX(wx); - int sy = ConvertY(wy); + int sx = ConvertX(WorldPos.x); + int sy = ConvertY(WorldPos.y); if(str_comp(pTuneLayer->m_aFileName, m_pEditor->m_aFileName)) { m_pEditor->m_TuningNum = pTuneLayer->m_TuningNumber; diff --git a/src/game/editor/mapitems/layer_tune.h b/src/game/editor/mapitems/layer_tune.h index cf35b9569..6ea607d8d 100644 --- a/src/game/editor/mapitems/layer_tune.h +++ b/src/game/editor/mapitems/layer_tune.h @@ -27,7 +27,7 @@ public: void Resize(int NewW, int NewH) override; void Shift(int Direction) override; bool IsEmpty(const std::shared_ptr &pLayer) override; - void BrushDraw(std::shared_ptr pBrush, float wx, float wy) override; + void BrushDraw(std::shared_ptr pBrush, vec2 WorldPos) override; void BrushFlipX() override; void BrushFlipY() override; void BrushRotate(float Amount) override;