Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8c4df5d
Fix server-side debugscript behavior
sacr1ficez Jun 20, 2024
9a325fb
Fix magic numbers.
sacr1ficez Jun 20, 2024
f18eca6
Remove notation
sacr1ficez Jun 21, 2024
af20b46
Replace with std::uint32_t and add const noexcept (per suggestion)
sacr1ficez Jun 21, 2024
13caba4
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 21, 2024
a413e9d
Move enums.
sacr1ficez Jun 21, 2024
b986f80
Merge branch 'fix-sside-debugscript-behavior' of https://github.com/s…
sacr1ficez Jun 21, 2024
4fa7436
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 21, 2024
f95dff2
Remove prefixes
sacr1ficez Jun 21, 2024
2c23ba3
Update CScriptDebugging.cpp
sacr1ficez Jun 21, 2024
4efa149
Move enums to .cpp
sacr1ficez Jun 21, 2024
b2a6075
Update CScriptDebugging.h
sacr1ficez Jun 21, 2024
ba32b26
Fix enum errors.
sacr1ficez Jun 21, 2024
8231c25
Fix brackets
sacr1ficez Jun 22, 2024
bae9d66
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 22, 2024
ee075c0
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 22, 2024
5cd034a
Replace to std::uint8_t
sacr1ficez Jun 22, 2024
d5d1b74
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 22, 2024
4702c27
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 22, 2024
9139808
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 23, 2024
52298da
Remove unnecessary std::uint8_t
sacr1ficez Jun 23, 2024
9ff940d
Move to enum class
sacr1ficez Jun 23, 2024
3fd1ba7
Keep it consistent with other enum
sacr1ficez Jun 24, 2024
d9de39e
Merge branch 'master' into fix-sside-debugscript-behavior
sacr1ficez Jun 24, 2024
74291e2
Back to enum
sacr1ficez Jun 24, 2024
c2f861c
Update CScriptDebugging.h
sacr1ficez Jun 24, 2024
9c548c7
Apply suggestions from code review
botder Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions Server/mods/deathmatch/logic/CScriptDebugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@

extern CGame* g_pGame;

enum DebugScriptLevels : std::uint8_t
{
NONE,
ERRORS_ONLY,
ERRORS_AND_WARNINGS,
ALL,
};

enum DebugMessageLevels : std::uint8_t
{
MESSAGE_TYPE_DEBUG,
MESSAGE_TYPE_ERROR,
MESSAGE_TYPE_WARNING,
MESSAGE_TYPE_INFO,
MESSAGE_TYPE_CUSTOM,
};

CScriptDebugging::CScriptDebugging()
{
m_uiLogFileLevel = 0;
Expand Down Expand Up @@ -143,16 +160,38 @@ void CScriptDebugging::PrintLog(const char* szText)
}
}

bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept
{
bool sufficientDebugLevel = false;

switch (messageDebugLevel)
{
case MESSAGE_TYPE_ERROR:
sufficientDebugLevel = (playerDebugLevel >= ERRORS_ONLY);
break;
case MESSAGE_TYPE_WARNING:
sufficientDebugLevel = (playerDebugLevel >= ERRORS_AND_WARNINGS);
break;
case MESSAGE_TYPE_INFO:
case MESSAGE_TYPE_CUSTOM:
case MESSAGE_TYPE_DEBUG:
sufficientDebugLevel = (playerDebugLevel == ALL);
break;
}

return sufficientDebugLevel;
}

void CScriptDebugging::Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel)
{
// Tell everyone we log to about it
list<CPlayer*>::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 sufficientDebugLevel = CheckForSufficientDebugLevel(pPlayer->m_uiScriptDebugLevel, uiMinimumDebugLevel);

if (sufficientDebugLevel)
{
(*iter)->Send(Packet);
pPlayer->Send(Packet);
}
}
}
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CScriptDebugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class CScriptDebugging
unsigned char ucGreen = 255, unsigned char ucBlue = 255);

void PrintLog(const char* szText);
bool CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept;
void Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel);

unsigned int m_uiLogFileLevel;
Expand Down