Merge pull request #145 from diamante0018/refactor-logger-error
[Logger] Use correct enum over numbers for com_error
This commit is contained in:
commit
e68c402095
@ -97,7 +97,7 @@ namespace Components
|
|||||||
Game::SV_GameSendServerCommand(-1, 0, list.data());
|
Game::SV_GameSendServerCommand(-1, 0, list.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dedicated::TimeWrapStub(int code, const char* message)
|
void Dedicated::TimeWrapStub(Game::errorParm_t code, const char* message)
|
||||||
{
|
{
|
||||||
static bool partyEnable;
|
static bool partyEnable;
|
||||||
static std::string mapname;
|
static std::string mapname;
|
||||||
|
@ -28,6 +28,6 @@ namespace Components
|
|||||||
|
|
||||||
static void TransmitGuids();
|
static void TransmitGuids();
|
||||||
|
|
||||||
static void TimeWrapStub(int code, const char* message);
|
static void TimeWrapStub(Game::errorParm_t code, const char* message);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::ErrorPrint(int error, const std::string& message)
|
void Logger::ErrorPrint(Game::errorParm_t error, const std::string& message)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (IsDebuggerPresent()) __debugbreak();
|
if (IsDebuggerPresent()) __debugbreak();
|
||||||
@ -60,19 +60,19 @@ namespace Components
|
|||||||
return Game::Com_Error(error, "%s", message.data());
|
return Game::Com_Error(error, "%s", message.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Error(int error, const char* message, ...)
|
void Logger::Error(Game::errorParm_t error, const char* message, ...)
|
||||||
{
|
{
|
||||||
return Logger::ErrorPrint(error, Logger::Format(&message));
|
return Logger::ErrorPrint(error, Logger::Format(&message));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Error(const char* message, ...)
|
void Logger::Error(const char* message, ...)
|
||||||
{
|
{
|
||||||
return Logger::ErrorPrint(0, Logger::Format(&message));
|
return Logger::ErrorPrint(Game::ERR_FATAL, Logger::Format(&message));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::SoftError(const char* message, ...)
|
void Logger::SoftError(const char* message, ...)
|
||||||
{
|
{
|
||||||
return Logger::ErrorPrint(2, Logger::Format(&message));
|
return Logger::ErrorPrint(Game::ERR_SERVERDISCONNECT, Logger::Format(&message));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Logger::Format(const char** message)
|
std::string Logger::Format(const char** message)
|
||||||
|
@ -11,9 +11,9 @@ namespace Components
|
|||||||
static void MessagePrint(int channel, const std::string& message);
|
static void MessagePrint(int channel, const std::string& message);
|
||||||
static void Print(int channel, const char* message, ...);
|
static void Print(int channel, const char* message, ...);
|
||||||
static void Print(const char* message, ...);
|
static void Print(const char* message, ...);
|
||||||
static void ErrorPrint(int error, const std::string& message);
|
static void ErrorPrint(Game::errorParm_t error, const std::string& message);
|
||||||
static void Error(const char* message, ...);
|
static void Error(const char* message, ...);
|
||||||
static void Error(int error, const char* message, ...);
|
static void Error(Game::errorParm_t error, const char* message, ...);
|
||||||
static void SoftError(const char* message, ...);
|
static void SoftError(const char* message, ...);
|
||||||
static bool IsConsoleReady();
|
static bool IsConsoleReady();
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ namespace Components
|
|||||||
|
|
||||||
void Renderer::R_TextureFromCodeError(const char* sampler, Game::GfxCmdBufState* state)
|
void Renderer::R_TextureFromCodeError(const char* sampler, Game::GfxCmdBufState* state)
|
||||||
{
|
{
|
||||||
Game::Com_Error(0, "Tried to use sampler '%s' when it isn't valid for material '%s' and technique '%s'",
|
Game::Com_Error(Game::ERR_FATAL, "Tried to use sampler '%s' when it isn't valid for material '%s' and technique '%s'",
|
||||||
sampler, state->material->info.name, state->technique->name);
|
sampler, state->material->info.name, state->technique->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace Components
|
|||||||
Logger::Print(23, "Error: unknown function %s in %s\n", funcName.data(), Script::ScriptName.data());
|
Logger::Print(23, "Error: unknown function %s in %s\n", funcName.data(), Script::ScriptName.data());
|
||||||
Logger::Print(23, "************************************\n");
|
Logger::Print(23, "************************************\n");
|
||||||
|
|
||||||
Logger::Error(5, "script compile error\nunknown function %s\n%s\n\n", funcName.data(), Script::ScriptName.data());
|
Logger::Error(Game::ERR_SCRIPT_DROP, "script compile error\nunknown function %s\n%s\n\n", funcName.data(), Script::ScriptName.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(naked) void Script::StoreFunctionNameStub()
|
__declspec(naked) void Script::StoreFunctionNameStub()
|
||||||
@ -170,7 +170,7 @@ namespace Components
|
|||||||
Script::PrintSourcePos(Script::ScriptName.data(), offset);
|
Script::PrintSourcePos(Script::ScriptName.data(), offset);
|
||||||
Logger::Print(23, "************************************\n\n");
|
Logger::Print(23, "************************************\n\n");
|
||||||
|
|
||||||
Logger::Error(5, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, Script::ScriptName.data());
|
Logger::Error(Game::ERR_SCRIPT_DROP, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, Script::ScriptName.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Script::LoadScriptAndLabel(const std::string& script, const std::string& label)
|
int Script::LoadScriptAndLabel(const std::string& script, const std::string& label)
|
||||||
@ -180,7 +180,7 @@ namespace Components
|
|||||||
if (!Game::Scr_LoadScript(script.data()))
|
if (!Game::Scr_LoadScript(script.data()))
|
||||||
{
|
{
|
||||||
Logger::Print("Script %s encountered an error while loading. (doesn't exist?)", script.data());
|
Logger::Print("Script %s encountered an error while loading. (doesn't exist?)", script.data());
|
||||||
Logger::Error(1, reinterpret_cast<char*>(0x70B810), script.data());
|
Logger::Error(Game::ERR_DROP, reinterpret_cast<char*>(0x70B810), script.data());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -497,7 +497,7 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (!gentity->client)
|
if (!gentity->client)
|
||||||
{
|
{
|
||||||
Logger::Error(5, "Entity: %i is not a client", gentity);
|
Logger::Error(Game::ERR_SCRIPT_DROP, "Entity: %i is not a client", gentity);
|
||||||
}
|
}
|
||||||
return &Game::svs_clients[gentity->s.number];
|
return &Game::svs_clients[gentity->s.number];
|
||||||
}
|
}
|
||||||
|
@ -851,7 +851,7 @@ namespace Components
|
|||||||
|
|
||||||
Command::Add("error", [](Command::Params*)
|
Command::Add("error", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Game::Com_Error(0, "This is a test %s\n", "error");
|
Game::Com_Error(Game::ERR_FATAL, "This is a test %s\n", "error");
|
||||||
});
|
});
|
||||||
|
|
||||||
// now load default assets and shaders
|
// now load default assets and shaders
|
||||||
@ -1412,7 +1412,7 @@ namespace Components
|
|||||||
// build final techsets fastfile
|
// build final techsets fastfile
|
||||||
if (subCount > 24)
|
if (subCount > 24)
|
||||||
{
|
{
|
||||||
Logger::ErrorPrint(1, "How did you have 576 fastfiles?\n");
|
Logger::ErrorPrint(Game::ERR_DROP, "How did you have 576 fastfiles?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
curTechsets_list.clear();
|
curTechsets_list.clear();
|
||||||
|
@ -121,7 +121,7 @@ namespace Game
|
|||||||
typedef void(__cdecl * Com_ClientPacketEvent_t)();
|
typedef void(__cdecl * Com_ClientPacketEvent_t)();
|
||||||
extern Com_ClientPacketEvent_t Com_ClientPacketEvent;
|
extern Com_ClientPacketEvent_t Com_ClientPacketEvent;
|
||||||
|
|
||||||
typedef void(__cdecl * Com_Error_t)(int type, const char* message, ...);
|
typedef void(__cdecl * Com_Error_t)(errorParm_t type, const char* message, ...);
|
||||||
extern Com_Error_t Com_Error;
|
extern Com_Error_t Com_Error;
|
||||||
|
|
||||||
typedef void(__cdecl * Com_Printf_t)(int channel, const char *fmt, ...);
|
typedef void(__cdecl * Com_Printf_t)(int channel, const char *fmt, ...);
|
||||||
|
@ -177,6 +177,18 @@ namespace Game
|
|||||||
CS_ACTIVE = 0x5,
|
CS_ACTIVE = 0x5,
|
||||||
} clientstate_t;
|
} clientstate_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ERR_FATAL = 0x0,
|
||||||
|
ERR_DROP = 0x1,
|
||||||
|
ERR_SERVERDISCONNECT = 0x2,
|
||||||
|
ERR_DISCONNECT = 0x3,
|
||||||
|
ERR_SCRIPT = 0x4,
|
||||||
|
ERR_SCRIPT_DROP = 0x5,
|
||||||
|
ERR_LOCALIZATION = 0x6,
|
||||||
|
ERR_MAPLOADERRORSUMMARY = 0x7
|
||||||
|
} errorParm_t;
|
||||||
|
|
||||||
struct FxEffectDef;
|
struct FxEffectDef;
|
||||||
struct pathnode_t;
|
struct pathnode_t;
|
||||||
struct pathnode_tree_t;
|
struct pathnode_tree_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user