From 8c4df5d42a8ae9c32a3a48ab36b5082138d8c6cb Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:43:59 +0200 Subject: [PATCH 01/18] Fix server-side debugscript behavior Additionally refactor loop. --- .../deathmatch/logic/CScriptDebugging.cpp | 32 ++++++++++++++++--- .../mods/deathmatch/logic/CScriptDebugging.h | 1 + 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index b00f9617430..e389b555f3a 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -143,16 +143,38 @@ void CScriptDebugging::PrintLog(const char* szText) } } +bool CScriptDebugging::CheckForSufficientDebugLevel(unsigned int uiPlayerDebugLevel, unsigned int uiMessageDebugLevel) +{ + bool uiSufficientDebugLevel = false; + + switch (uiMessageDebugLevel) + { + case 1: // error message + uiSufficientDebugLevel = (uiPlayerDebugLevel >= 1); // errors + break; + case 2: // warning message + uiSufficientDebugLevel = (uiPlayerDebugLevel >= 2); // errors, warnings + break; + case 3: // information message + case 4: // custom message + case 0: // debug message + uiSufficientDebugLevel = (uiPlayerDebugLevel == 3); // all + break; + } + + return uiSufficientDebugLevel; +} + void CScriptDebugging::Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel) { // Tell everyone we log to about it - list::const_iterator iter = m_Players.begin(); - auto uiRequiredDebugLevel = std::min(uiMinimumDebugLevel, 3u); // Make sure it doesn't skip outputDebugString with level 4 - for (; iter != m_Players.end(); iter++) + for (const auto& pPlayer : m_Players) { - if ((*iter)->m_uiScriptDebugLevel >= uiRequiredDebugLevel) + bool uiSufficientDebugLevel = CheckForSufficientDebugLevel(pPlayer->m_uiScriptDebugLevel, uiMinimumDebugLevel); + + if (uiSufficientDebugLevel) { - (*iter)->Send(Packet); + pPlayer->Send(Packet); } } } diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 116b4825b2c..ecf484d3d39 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -73,6 +73,7 @@ class CScriptDebugging unsigned char ucGreen = 255, unsigned char ucBlue = 255); void PrintLog(const char* szText); + bool CheckForSufficientDebugLevel(unsigned int uiPlayerDebugLevel, unsigned int uiMessageDebugLevel); void Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel); unsigned int m_uiLogFileLevel; From 9a325fbe4541945eee6c05b9042e9eb59f32c0cb Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:39:45 +0200 Subject: [PATCH 02/18] Fix magic numbers. --- .../mods/deathmatch/logic/CScriptDebugging.cpp | 16 ++++++++-------- Server/mods/deathmatch/logic/CScriptDebugging.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index e389b555f3a..12e3c1f5c07 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -149,16 +149,16 @@ bool CScriptDebugging::CheckForSufficientDebugLevel(unsigned int uiPlayerDebugLe switch (uiMessageDebugLevel) { - case 1: // error message - uiSufficientDebugLevel = (uiPlayerDebugLevel >= 1); // errors + case eDebugMessageLevels::MESSAGE_TYPE_ERROR: + uiSufficientDebugLevel = (uiPlayerDebugLevel >= eDebugScriptLevels::ERRORS_ONLY); break; - case 2: // warning message - uiSufficientDebugLevel = (uiPlayerDebugLevel >= 2); // errors, warnings + case eDebugMessageLevels::MESSAGE_TYPE_WARNING: + uiSufficientDebugLevel = (uiPlayerDebugLevel >= eDebugScriptLevels::ERRORS_AND_WARNINGS); break; - case 3: // information message - case 4: // custom message - case 0: // debug message - uiSufficientDebugLevel = (uiPlayerDebugLevel == 3); // all + case eDebugMessageLevels::MESSAGE_TYPE_INFO: + case eDebugMessageLevels::MESSAGE_TYPE_CUSTOM: + case eDebugMessageLevels::MESSAGE_TYPE_DEBUG: + uiSufficientDebugLevel = (uiPlayerDebugLevel == eDebugScriptLevels::ALL); break; } diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index ecf484d3d39..9a97c5fa126 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -16,6 +16,22 @@ #include #include +enum eDebugMessageLevels +{ + MESSAGE_TYPE_DEBUG = 0, + MESSAGE_TYPE_ERROR = 1, + MESSAGE_TYPE_WARNING = 2, + MESSAGE_TYPE_INFO = 3, + MESSAGE_TYPE_CUSTOM = 4, +}; + +enum eDebugScriptLevels +{ + ERRORS_ONLY = 1, + ERRORS_AND_WARNINGS = 2, + ALL = 3, +}; + struct SLogLine { SString strText; From f18eca66e475da9e4d1d4ff150575f18735ff508 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:40:39 +0200 Subject: [PATCH 03/18] Remove notation --- .../deathmatch/logic/CScriptDebugging.cpp | 28 +++++++++---------- .../mods/deathmatch/logic/CScriptDebugging.h | 6 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index 12e3c1f5c07..a9b797c5ade 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -143,26 +143,26 @@ void CScriptDebugging::PrintLog(const char* szText) } } -bool CScriptDebugging::CheckForSufficientDebugLevel(unsigned int uiPlayerDebugLevel, unsigned int uiMessageDebugLevel) +bool CScriptDebugging::CheckForSufficientDebugLevel(unsigned int playerDebugLevel, unsigned int messageDebugLevel) { - bool uiSufficientDebugLevel = false; + bool sufficientDebugLevel = false; - switch (uiMessageDebugLevel) + switch (messageDebugLevel) { - case eDebugMessageLevels::MESSAGE_TYPE_ERROR: - uiSufficientDebugLevel = (uiPlayerDebugLevel >= eDebugScriptLevels::ERRORS_ONLY); + case DebugMessageLevels::MESSAGE_TYPE_ERROR: + sufficientDebugLevel = (playerDebugLevel >= DebugScriptLevels::ERRORS_ONLY); break; - case eDebugMessageLevels::MESSAGE_TYPE_WARNING: - uiSufficientDebugLevel = (uiPlayerDebugLevel >= eDebugScriptLevels::ERRORS_AND_WARNINGS); + case DebugMessageLevels::MESSAGE_TYPE_WARNING: + sufficientDebugLevel = (playerDebugLevel >= DebugScriptLevels::ERRORS_AND_WARNINGS); break; - case eDebugMessageLevels::MESSAGE_TYPE_INFO: - case eDebugMessageLevels::MESSAGE_TYPE_CUSTOM: - case eDebugMessageLevels::MESSAGE_TYPE_DEBUG: - uiSufficientDebugLevel = (uiPlayerDebugLevel == eDebugScriptLevels::ALL); + case DebugMessageLevels::MESSAGE_TYPE_INFO: + case DebugMessageLevels::MESSAGE_TYPE_CUSTOM: + case DebugMessageLevels::MESSAGE_TYPE_DEBUG: + sufficientDebugLevel = (playerDebugLevel == DebugScriptLevels::ALL); break; } - return uiSufficientDebugLevel; + return sufficientDebugLevel; } void CScriptDebugging::Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel) @@ -170,9 +170,9 @@ void CScriptDebugging::Broadcast(const CPacket& Packet, unsigned int uiMinimumDe // Tell everyone we log to about it for (const auto& pPlayer : m_Players) { - bool uiSufficientDebugLevel = CheckForSufficientDebugLevel(pPlayer->m_uiScriptDebugLevel, uiMinimumDebugLevel); + bool sufficientDebugLevel = CheckForSufficientDebugLevel(pPlayer->m_uiScriptDebugLevel, uiMinimumDebugLevel); - if (uiSufficientDebugLevel) + if (sufficientDebugLevel) { pPlayer->Send(Packet); } diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 9a97c5fa126..529c8beca43 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -16,7 +16,7 @@ #include #include -enum eDebugMessageLevels +enum DebugMessageLevels { MESSAGE_TYPE_DEBUG = 0, MESSAGE_TYPE_ERROR = 1, @@ -25,7 +25,7 @@ enum eDebugMessageLevels MESSAGE_TYPE_CUSTOM = 4, }; -enum eDebugScriptLevels +enum DebugScriptLevels { ERRORS_ONLY = 1, ERRORS_AND_WARNINGS = 2, @@ -89,7 +89,7 @@ class CScriptDebugging unsigned char ucGreen = 255, unsigned char ucBlue = 255); void PrintLog(const char* szText); - bool CheckForSufficientDebugLevel(unsigned int uiPlayerDebugLevel, unsigned int uiMessageDebugLevel); + bool CheckForSufficientDebugLevel(unsigned int playerDebugLevel, unsigned int messageDebugLevel); void Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel); unsigned int m_uiLogFileLevel; From af20b46d946538e6436391b6bc7b040c5b0f817a Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:52:05 +0200 Subject: [PATCH 04/18] Replace with std::uint32_t and add const noexcept (per suggestion) --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 2 +- Server/mods/deathmatch/logic/CScriptDebugging.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index a9b797c5ade..3cf8b522693 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -143,7 +143,7 @@ void CScriptDebugging::PrintLog(const char* szText) } } -bool CScriptDebugging::CheckForSufficientDebugLevel(unsigned int playerDebugLevel, unsigned int messageDebugLevel) +bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint32_t playerDebugLevel, std::uint32_t messageDebugLevel) const noexcept { bool sufficientDebugLevel = false; diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 529c8beca43..be8c27d777c 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -89,7 +89,7 @@ class CScriptDebugging unsigned char ucGreen = 255, unsigned char ucBlue = 255); void PrintLog(const char* szText); - bool CheckForSufficientDebugLevel(unsigned int playerDebugLevel, unsigned int messageDebugLevel); + bool CheckForSufficientDebugLevel(std::uint32_t playerDebugLevel, std::uint32_t messageDebugLevel) const noexcept; void Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel); unsigned int m_uiLogFileLevel; From a413e9d5f90f3f4ac0cff4bd1c2eb28419c1d1f4 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Fri, 21 Jun 2024 23:47:19 +0200 Subject: [PATCH 05/18] Move enums. --- .../mods/deathmatch/logic/CScriptDebugging.h | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index be8c27d777c..358fad34915 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -16,22 +16,6 @@ #include #include -enum DebugMessageLevels -{ - MESSAGE_TYPE_DEBUG = 0, - MESSAGE_TYPE_ERROR = 1, - MESSAGE_TYPE_WARNING = 2, - MESSAGE_TYPE_INFO = 3, - MESSAGE_TYPE_CUSTOM = 4, -}; - -enum DebugScriptLevels -{ - ERRORS_ONLY = 1, - ERRORS_AND_WARNINGS = 2, - ALL = 3, -}; - struct SLogLine { SString strText; @@ -100,4 +84,20 @@ class CScriptDebugging SLuaDebugInfo m_SavedLuaDebugInfo; std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; + + enum DebugMessageLevels + { + MESSAGE_TYPE_DEBUG = 0, + MESSAGE_TYPE_ERROR = 1, + MESSAGE_TYPE_WARNING = 2, + MESSAGE_TYPE_INFO = 3, + MESSAGE_TYPE_CUSTOM = 4, + }; + + enum DebugScriptLevels + { + ERRORS_ONLY = 1, + ERRORS_AND_WARNINGS = 2, + ALL = 3, + }; }; From f95dff21e12eaaf143e399cc9b3a4567bd4777d5 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:08:17 +0200 Subject: [PATCH 06/18] Remove prefixes --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index 3cf8b522693..49992ad2ffc 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -149,15 +149,15 @@ bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint32_t playerDebugLev switch (messageDebugLevel) { - case DebugMessageLevels::MESSAGE_TYPE_ERROR: + case MESSAGE_TYPE_ERROR: sufficientDebugLevel = (playerDebugLevel >= DebugScriptLevels::ERRORS_ONLY); break; - case DebugMessageLevels::MESSAGE_TYPE_WARNING: + case MESSAGE_TYPE_WARNING: sufficientDebugLevel = (playerDebugLevel >= DebugScriptLevels::ERRORS_AND_WARNINGS); break; - case DebugMessageLevels::MESSAGE_TYPE_INFO: - case DebugMessageLevels::MESSAGE_TYPE_CUSTOM: - case DebugMessageLevels::MESSAGE_TYPE_DEBUG: + case MESSAGE_TYPE_INFO: + case MESSAGE_TYPE_CUSTOM: + case MESSAGE_TYPE_DEBUG: sufficientDebugLevel = (playerDebugLevel == DebugScriptLevels::ALL); break; } From 2c23ba317a043808bec255adface01071fb14a53 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:14:10 +0200 Subject: [PATCH 07/18] Update CScriptDebugging.cpp --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index 49992ad2ffc..e5156347ef4 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -150,15 +150,15 @@ bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint32_t playerDebugLev switch (messageDebugLevel) { case MESSAGE_TYPE_ERROR: - sufficientDebugLevel = (playerDebugLevel >= DebugScriptLevels::ERRORS_ONLY); + sufficientDebugLevel = (playerDebugLevel >= ERRORS_ONLY); break; case MESSAGE_TYPE_WARNING: - sufficientDebugLevel = (playerDebugLevel >= DebugScriptLevels::ERRORS_AND_WARNINGS); + sufficientDebugLevel = (playerDebugLevel >= ERRORS_AND_WARNINGS); break; case MESSAGE_TYPE_INFO: case MESSAGE_TYPE_CUSTOM: case MESSAGE_TYPE_DEBUG: - sufficientDebugLevel = (playerDebugLevel == DebugScriptLevels::ALL); + sufficientDebugLevel = (playerDebugLevel == ALL); break; } From 4efa1490e8bce4eb2a53251c5c218a234073021c Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:28:00 +0200 Subject: [PATCH 08/18] Move enums to .cpp --- .../mods/deathmatch/logic/CScriptDebugging.cpp | 16 ++++++++++++++++ Server/mods/deathmatch/logic/CScriptDebugging.h | 17 ++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index e5156347ef4..91f2a9c4b73 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -15,6 +15,22 @@ extern CGame* g_pGame; +enum CScriptDebugging::DebugMessageLevels +{ + MESSAGE_TYPE_DEBUG = 0, + MESSAGE_TYPE_ERROR = 1, + MESSAGE_TYPE_WARNING = 2, + MESSAGE_TYPE_INFO = 3, + MESSAGE_TYPE_CUSTOM = 4, +}; + +enum CScriptDebugging::DebugScriptLevels +{ + ERRORS_ONLY = 1, + ERRORS_AND_WARNINGS = 2, + ALL = 3, +}; + CScriptDebugging::CScriptDebugging() { m_uiLogFileLevel = 0; diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 358fad34915..382928d0f17 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -85,19 +85,6 @@ class CScriptDebugging std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; - enum DebugMessageLevels - { - MESSAGE_TYPE_DEBUG = 0, - MESSAGE_TYPE_ERROR = 1, - MESSAGE_TYPE_WARNING = 2, - MESSAGE_TYPE_INFO = 3, - MESSAGE_TYPE_CUSTOM = 4, - }; - - enum DebugScriptLevels - { - ERRORS_ONLY = 1, - ERRORS_AND_WARNINGS = 2, - ALL = 3, - }; + enum DebugMessageLevels; + enum DebugScriptLevels; }; From b2a60758cb81a691ab8b0494992efeda78a7c2b2 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:44:47 +0200 Subject: [PATCH 09/18] Update CScriptDebugging.h --- Server/mods/deathmatch/logic/CScriptDebugging.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 382928d0f17..5a7f0b61368 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -85,6 +85,6 @@ class CScriptDebugging std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; - enum DebugMessageLevels; - enum DebugScriptLevels; + enum DebugMessageLevels : std::uint32_t; + enum DebugScriptLevels : std::uint32_t; }; From ba32b26c24cec431e131cd4e4b64d5e355930ad6 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 22 Jun 2024 01:35:07 +0200 Subject: [PATCH 10/18] Fix enum errors. --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index 91f2a9c4b73..84b3bf9b75a 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -15,8 +15,7 @@ extern CGame* g_pGame; -enum CScriptDebugging::DebugMessageLevels -{ +enum CScriptDebugging::DebugMessageLevels : std::uint32_t { MESSAGE_TYPE_DEBUG = 0, MESSAGE_TYPE_ERROR = 1, MESSAGE_TYPE_WARNING = 2, @@ -24,8 +23,7 @@ enum CScriptDebugging::DebugMessageLevels MESSAGE_TYPE_CUSTOM = 4, }; -enum CScriptDebugging::DebugScriptLevels -{ +enum CScriptDebugging::DebugScriptLevels : std::uint32_t { ERRORS_ONLY = 1, ERRORS_AND_WARNINGS = 2, ALL = 3, From 8231c25a3ef9b521c96ddb12f27c7a3065134917 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 22 Jun 2024 02:27:46 +0200 Subject: [PATCH 11/18] Fix brackets --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index 84b3bf9b75a..8cb0ad3898e 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -15,7 +15,8 @@ extern CGame* g_pGame; -enum CScriptDebugging::DebugMessageLevels : std::uint32_t { +enum CScriptDebugging::DebugMessageLevels : std::uint32_t +{ MESSAGE_TYPE_DEBUG = 0, MESSAGE_TYPE_ERROR = 1, MESSAGE_TYPE_WARNING = 2, @@ -23,7 +24,8 @@ enum CScriptDebugging::DebugMessageLevels : std::uint32_t { MESSAGE_TYPE_CUSTOM = 4, }; -enum CScriptDebugging::DebugScriptLevels : std::uint32_t { +enum CScriptDebugging::DebugScriptLevels : std::uint32_t +{ ERRORS_ONLY = 1, ERRORS_AND_WARNINGS = 2, ALL = 3, From 5cd034af5e78ea4ee18106f80283446b0e69485a Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sat, 22 Jun 2024 19:53:19 +0200 Subject: [PATCH 12/18] Replace to std::uint8_t --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 6 +++--- Server/mods/deathmatch/logic/CScriptDebugging.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index 8cb0ad3898e..29675c4bda0 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -15,7 +15,7 @@ extern CGame* g_pGame; -enum CScriptDebugging::DebugMessageLevels : std::uint32_t +enum CScriptDebugging::DebugMessageLevels : std::uint8_t { MESSAGE_TYPE_DEBUG = 0, MESSAGE_TYPE_ERROR = 1, @@ -24,7 +24,7 @@ enum CScriptDebugging::DebugMessageLevels : std::uint32_t MESSAGE_TYPE_CUSTOM = 4, }; -enum CScriptDebugging::DebugScriptLevels : std::uint32_t +enum CScriptDebugging::DebugScriptLevels : std::uint8_t { ERRORS_ONLY = 1, ERRORS_AND_WARNINGS = 2, @@ -159,7 +159,7 @@ void CScriptDebugging::PrintLog(const char* szText) } } -bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint32_t playerDebugLevel, std::uint32_t messageDebugLevel) const noexcept +bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept { bool sufficientDebugLevel = false; diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 5a7f0b61368..e28f1fd5153 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -73,7 +73,7 @@ class CScriptDebugging unsigned char ucGreen = 255, unsigned char ucBlue = 255); void PrintLog(const char* szText); - bool CheckForSufficientDebugLevel(std::uint32_t playerDebugLevel, std::uint32_t messageDebugLevel) const noexcept; + bool CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept; void Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel); unsigned int m_uiLogFileLevel; @@ -85,6 +85,6 @@ class CScriptDebugging std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; - enum DebugMessageLevels : std::uint32_t; - enum DebugScriptLevels : std::uint32_t; + enum DebugMessageLevels : std::uint8_t; + enum DebugScriptLevels : std::uint8_t; }; From 52298da89ea9e699e6b1e4b187d17308e8d6a908 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Sun, 23 Jun 2024 21:50:16 +0200 Subject: [PATCH 13/18] Remove unnecessary std::uint8_t --- Server/mods/deathmatch/logic/CScriptDebugging.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index e28f1fd5153..7cf2bc7107e 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -85,6 +85,6 @@ class CScriptDebugging std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; - enum DebugMessageLevels : std::uint8_t; - enum DebugScriptLevels : std::uint8_t; + enum DebugMessageLevels; + enum DebugScriptLevels; }; From 9ff940da9a577feafe00d986dd509317ef5e8ca8 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Mon, 24 Jun 2024 01:43:53 +0200 Subject: [PATCH 14/18] Move to enum class Thanks for help @FileEX Co-Authored-By: FileEX --- .../deathmatch/logic/CScriptDebugging.cpp | 30 +++++++++---------- .../mods/deathmatch/logic/CScriptDebugging.h | 3 -- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index 29675c4bda0..da1c40eea9c 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -15,16 +15,16 @@ extern CGame* g_pGame; -enum CScriptDebugging::DebugMessageLevels : std::uint8_t +enum class DebugMessageLevels : std::uint8_t { MESSAGE_TYPE_DEBUG = 0, - MESSAGE_TYPE_ERROR = 1, - MESSAGE_TYPE_WARNING = 2, - MESSAGE_TYPE_INFO = 3, - MESSAGE_TYPE_CUSTOM = 4, + MESSAGE_TYPE_ERROR, + MESSAGE_TYPE_WARNING, + MESSAGE_TYPE_INFO, + MESSAGE_TYPE_CUSTOM, }; -enum CScriptDebugging::DebugScriptLevels : std::uint8_t +enum class DebugScriptLevels : std::uint8_t { ERRORS_ONLY = 1, ERRORS_AND_WARNINGS = 2, @@ -163,18 +163,18 @@ bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint8_t playerDebugLeve { bool sufficientDebugLevel = false; - switch (messageDebugLevel) + switch (static_cast(messageDebugLevel)) { - case MESSAGE_TYPE_ERROR: - sufficientDebugLevel = (playerDebugLevel >= ERRORS_ONLY); + case DebugMessageLevels::MESSAGE_TYPE_ERROR: + sufficientDebugLevel = (playerDebugLevel >= static_cast(DebugScriptLevels::ERRORS_ONLY)); break; - case MESSAGE_TYPE_WARNING: - sufficientDebugLevel = (playerDebugLevel >= ERRORS_AND_WARNINGS); + case DebugMessageLevels::MESSAGE_TYPE_WARNING: + sufficientDebugLevel = (playerDebugLevel >= static_cast(DebugScriptLevels::ERRORS_AND_WARNINGS)); break; - case MESSAGE_TYPE_INFO: - case MESSAGE_TYPE_CUSTOM: - case MESSAGE_TYPE_DEBUG: - sufficientDebugLevel = (playerDebugLevel == ALL); + case DebugMessageLevels::MESSAGE_TYPE_INFO: + case DebugMessageLevels::MESSAGE_TYPE_CUSTOM: + case DebugMessageLevels::MESSAGE_TYPE_DEBUG: + sufficientDebugLevel = (playerDebugLevel == static_cast(DebugScriptLevels::ALL)); break; } diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 7cf2bc7107e..e6ef81a0e17 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -84,7 +84,4 @@ class CScriptDebugging SLuaDebugInfo m_SavedLuaDebugInfo; std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; - - enum DebugMessageLevels; - enum DebugScriptLevels; }; From 3fd1ba79266a7f57e7c5fd87db011d27826d54ce Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:06:00 +0200 Subject: [PATCH 15/18] Keep it consistent with other enum --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index da1c40eea9c..e12b85903bd 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -18,10 +18,10 @@ extern CGame* g_pGame; enum class DebugMessageLevels : std::uint8_t { MESSAGE_TYPE_DEBUG = 0, - MESSAGE_TYPE_ERROR, - MESSAGE_TYPE_WARNING, - MESSAGE_TYPE_INFO, - MESSAGE_TYPE_CUSTOM, + MESSAGE_TYPE_ERROR = 1, + MESSAGE_TYPE_WARNING = 2, + MESSAGE_TYPE_INFO = 3, + MESSAGE_TYPE_CUSTOM = 4, }; enum class DebugScriptLevels : std::uint8_t From 74291e26fa0fecb0209dffc8479c5e5bb92f065c Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:32:40 +0200 Subject: [PATCH 16/18] Back to enum --- .../deathmatch/logic/CScriptDebugging.cpp | 39 ++++++++++--------- .../mods/deathmatch/logic/CScriptDebugging.h | 3 ++ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index e12b85903bd..fe3e5ad1cd7 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -15,20 +15,21 @@ extern CGame* g_pGame; -enum class DebugMessageLevels : std::uint8_t +enum CScriptDebugging::DebugScriptLevels : std::uint8_t { - MESSAGE_TYPE_DEBUG = 0, - MESSAGE_TYPE_ERROR = 1, - MESSAGE_TYPE_WARNING = 2, - MESSAGE_TYPE_INFO = 3, - MESSAGE_TYPE_CUSTOM = 4, + NONE, + ERRORS_ONLY, + ERRORS_AND_WARNINGS, + ALL, }; -enum class DebugScriptLevels : std::uint8_t +enum CScriptDebugging::DebugMessageLevels : std::uint8_t { - ERRORS_ONLY = 1, - ERRORS_AND_WARNINGS = 2, - ALL = 3, + MESSAGE_TYPE_DEBUG, + MESSAGE_TYPE_ERROR, + MESSAGE_TYPE_WARNING, + MESSAGE_TYPE_INFO, + MESSAGE_TYPE_CUSTOM, }; CScriptDebugging::CScriptDebugging() @@ -163,18 +164,18 @@ bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint8_t playerDebugLeve { bool sufficientDebugLevel = false; - switch (static_cast(messageDebugLevel)) + switch (messageDebugLevel) { - case DebugMessageLevels::MESSAGE_TYPE_ERROR: - sufficientDebugLevel = (playerDebugLevel >= static_cast(DebugScriptLevels::ERRORS_ONLY)); + case MESSAGE_TYPE_ERROR: + sufficientDebugLevel = (playerDebugLevel >= ERRORS_ONLY); break; - case DebugMessageLevels::MESSAGE_TYPE_WARNING: - sufficientDebugLevel = (playerDebugLevel >= static_cast(DebugScriptLevels::ERRORS_AND_WARNINGS)); + case MESSAGE_TYPE_WARNING: + sufficientDebugLevel = (playerDebugLevel >= ERRORS_AND_WARNINGS); break; - case DebugMessageLevels::MESSAGE_TYPE_INFO: - case DebugMessageLevels::MESSAGE_TYPE_CUSTOM: - case DebugMessageLevels::MESSAGE_TYPE_DEBUG: - sufficientDebugLevel = (playerDebugLevel == static_cast(DebugScriptLevels::ALL)); + case MESSAGE_TYPE_INFO: + case MESSAGE_TYPE_CUSTOM: + case MESSAGE_TYPE_DEBUG: + sufficientDebugLevel = (playerDebugLevel == ALL); break; } diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index e6ef81a0e17..10a273eaccf 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -84,4 +84,7 @@ class CScriptDebugging SLuaDebugInfo m_SavedLuaDebugInfo; std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; + + enum DebugScriptLevels; + enum DebugMessageLevels; }; From c2f861c99ed008aa54f553e12f011fc22cbd877b Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:39:44 +0200 Subject: [PATCH 17/18] Update CScriptDebugging.h --- Server/mods/deathmatch/logic/CScriptDebugging.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 10a273eaccf..52c677056e6 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -85,6 +85,6 @@ class CScriptDebugging std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; - enum DebugScriptLevels; - enum DebugMessageLevels; + enum DebugScriptLevels : std::uint8_t; + enum DebugMessageLevels : std::uint8_t; }; From 9c548c79993af75a0b0dccf8e10ce0fe49a1b7e9 Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Wed, 26 Jun 2024 14:52:46 +0200 Subject: [PATCH 18/18] Apply suggestions from code review --- Server/mods/deathmatch/logic/CScriptDebugging.cpp | 4 ++-- Server/mods/deathmatch/logic/CScriptDebugging.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.cpp b/Server/mods/deathmatch/logic/CScriptDebugging.cpp index fe3e5ad1cd7..0f3a6c204ad 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.cpp +++ b/Server/mods/deathmatch/logic/CScriptDebugging.cpp @@ -15,7 +15,7 @@ extern CGame* g_pGame; -enum CScriptDebugging::DebugScriptLevels : std::uint8_t +enum DebugScriptLevels : std::uint8_t { NONE, ERRORS_ONLY, @@ -23,7 +23,7 @@ enum CScriptDebugging::DebugScriptLevels : std::uint8_t ALL, }; -enum CScriptDebugging::DebugMessageLevels : std::uint8_t +enum DebugMessageLevels : std::uint8_t { MESSAGE_TYPE_DEBUG, MESSAGE_TYPE_ERROR, diff --git a/Server/mods/deathmatch/logic/CScriptDebugging.h b/Server/mods/deathmatch/logic/CScriptDebugging.h index 52c677056e6..e6ef81a0e17 100644 --- a/Server/mods/deathmatch/logic/CScriptDebugging.h +++ b/Server/mods/deathmatch/logic/CScriptDebugging.h @@ -84,7 +84,4 @@ class CScriptDebugging SLuaDebugInfo m_SavedLuaDebugInfo; std::list m_LuaMainStack; CDuplicateLineFilter m_DuplicateLineFilter; - - enum DebugScriptLevels : std::uint8_t; - enum DebugMessageLevels : std::uint8_t; };