[Refactor]: Use enum instead of int to catch mistakes (#646)

This commit is contained in:
Edo 2022-12-15 16:38:50 +01:00 committed by GitHub
parent ab0da964ee
commit 3622946a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 14 deletions

View File

@ -304,7 +304,7 @@ namespace Components
if (!result) if (!result)
{ {
Logger::PrintError(1, "CopyFile failed({}) {} {}\n", GetLastError(), "console_mp.log", newFileName); Logger::PrintError(Game::CON_CHANNEL_ERROR, "CopyFile failed({}) {} {}\n", GetLastError(), "console_mp.log", newFileName);
} }
} }

View File

@ -70,7 +70,7 @@ namespace Components
MessagePrint(Game::CON_CHANNEL_DONT_FILTER, out); MessagePrint(Game::CON_CHANNEL_DONT_FILTER, out);
} }
void Logger::PrintInternal(int channel, std::string_view fmt, std::format_args&& args) void Logger::PrintInternal(Game::conChannel_t channel, std::string_view fmt, std::format_args&& args)
{ {
const auto msg = std::vformat(fmt, args); const auto msg = std::vformat(fmt, args);
@ -87,7 +87,7 @@ namespace Components
Game::Com_Error(error, "%s", msg.data()); Game::Com_Error(error, "%s", msg.data());
} }
void Logger::PrintErrorInternal(int channel, std::string_view fmt, std::format_args&& args) void Logger::PrintErrorInternal(Game::conChannel_t channel, std::string_view fmt, std::format_args&& args)
{ {
const auto msg = "^1Error: " + std::vformat(fmt, args); const auto msg = "^1Error: " + std::vformat(fmt, args);
@ -100,7 +100,7 @@ namespace Components
} }
} }
void Logger::WarningInternal(int channel, std::string_view fmt, std::format_args&& args) void Logger::WarningInternal(Game::conChannel_t channel, std::string_view fmt, std::format_args&& args)
{ {
const auto msg = "^3" + std::vformat(fmt, args); const auto msg = "^3" + std::vformat(fmt, args);

View File

@ -14,10 +14,10 @@ namespace Components
static void PipeOutput(const std::function<void(const std::string&)>& callback); static void PipeOutput(const std::function<void(const std::string&)>& callback);
static void PrintInternal(int channel, std::string_view fmt, std::format_args&& args); static void PrintInternal(Game::conChannel_t channel, std::string_view fmt, std::format_args&& args);
static void ErrorInternal(Game::errorParm_t error, std::string_view fmt, std::format_args&& args); static void ErrorInternal(Game::errorParm_t error, std::string_view fmt, std::format_args&& args);
static void PrintErrorInternal(int channel, std::string_view fmt, std::format_args&& args); static void PrintErrorInternal(Game::conChannel_t channel, std::string_view fmt, std::format_args&& args);
static void WarningInternal(int channel, std::string_view fmt, std::format_args&& args); static void WarningInternal(Game::conChannel_t channel, std::string_view fmt, std::format_args&& args);
static void DebugInternal(std::string_view fmt, std::format_args&& args, const std::source_location& loc); static void DebugInternal(std::string_view fmt, std::format_args&& args, const std::source_location& loc);
static void Print(std::string_view fmt) static void Print(std::string_view fmt)
@ -25,7 +25,7 @@ namespace Components
PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args(0)); PrintInternal(Game::CON_CHANNEL_DONT_FILTER, fmt, std::make_format_args(0));
} }
static void Print(int channel, std::string_view fmt) static void Print(Game::conChannel_t channel, std::string_view fmt)
{ {
PrintInternal(channel, fmt, std::make_format_args(0)); PrintInternal(channel, fmt, std::make_format_args(0));
} }
@ -38,7 +38,7 @@ namespace Components
} }
template <typename... Args> template <typename... Args>
static void Print(int channel, std::string_view fmt, Args&&... args) static void Print(Game::conChannel_t channel, std::string_view fmt, Args&&... args)
{ {
(Utils::String::SanitizeFormatArgs(args), ...); (Utils::String::SanitizeFormatArgs(args), ...);
PrintInternal(channel, fmt, std::make_format_args(args...)); PrintInternal(channel, fmt, std::make_format_args(args...));
@ -56,25 +56,25 @@ namespace Components
ErrorInternal(error, fmt, std::make_format_args(args...)); ErrorInternal(error, fmt, std::make_format_args(args...));
} }
static void Warning(int channel, std::string_view fmt) static void Warning(Game::conChannel_t channel, std::string_view fmt)
{ {
WarningInternal(channel, fmt, std::make_format_args(0)); WarningInternal(channel, fmt, std::make_format_args(0));
} }
template <typename... Args> template <typename... Args>
static void Warning(int channel, std::string_view fmt, Args&&... args) static void Warning(Game::conChannel_t channel, std::string_view fmt, Args&&... args)
{ {
(Utils::String::SanitizeFormatArgs(args), ...); (Utils::String::SanitizeFormatArgs(args), ...);
WarningInternal(channel, fmt, std::make_format_args(args...)); WarningInternal(channel, fmt, std::make_format_args(args...));
} }
static void PrintError(int channel, std::string_view fmt) static void PrintError(Game::conChannel_t channel, std::string_view fmt)
{ {
PrintErrorInternal(channel, fmt, std::make_format_args(0)); PrintErrorInternal(channel, fmt, std::make_format_args(0));
} }
template <typename... Args> template <typename... Args>
static void PrintError(int channel, std::string_view fmt, Args&&... args) static void PrintError(Game::conChannel_t channel, std::string_view fmt, Args&&... args)
{ {
(Utils::String::SanitizeFormatArgs(args), ...); (Utils::String::SanitizeFormatArgs(args), ...);
PrintErrorInternal(channel, fmt, std::make_format_args(args...)); PrintErrorInternal(channel, fmt, std::make_format_args(args...));

View File

@ -9239,7 +9239,7 @@ namespace Game
char* openScriptIOFileBuffers[1]; char* openScriptIOFileBuffers[1];
com_parse_mark_t currentScriptIOLineMark[1]; com_parse_mark_t currentScriptIOLineMark[1];
cached_tag_mat_t cachedTagMat; cached_tag_mat_t cachedTagMat;
int scriptPrintChannel; conChannel_t scriptPrintChannel;
float compassMapUpperLeft[2]; float compassMapUpperLeft[2];
float compassMapWorldSize[2]; float compassMapWorldSize[2];
float compassNorth[2]; float compassNorth[2];