Fixes and shit

This commit is contained in:
momo5502 2016-06-04 00:06:07 +02:00
parent e8c915374b
commit 74033ad557
5 changed files with 61 additions and 45 deletions

2
deps/protobuf vendored

@ -1 +1 @@
Subproject commit 18a9140f3308272313a9642af58ab0051ac09fd2
Subproject commit 20b532544fde1dff34429b52db95c3a96409b73c

View File

@ -80,13 +80,9 @@ namespace Components
Localization::Set("MPUI_SECURITY_INCREASE_MESSAGE", Utils::VA("Increasing security level from %d to %d (est. %s)", Auth::GetSecurityLevel(), Auth::TokenContainer.targetLevel, Utils::FormatTimeSpan(static_cast<int>(mseconds)).data()));
}
else
else if(Auth::TokenContainer.thread.joinable())
{
if (Auth::TokenContainer.thread.joinable())
{
Auth::TokenContainer.thread.join();
}
Auth::TokenContainer.thread.join();
Auth::TokenContainer.generating = false;
Auth::StoreKey();

View File

@ -13,27 +13,30 @@ namespace Components
void Logger::Print(const char* message, ...)
{
char buffer[0x1000] = { 0 };
return Logger::MessagePrint(0, Logger::Format(&message));
}
va_list ap;
va_start(ap, message);
vsprintf_s(buffer, message, ap);
va_end(ap);
void Logger::Print(int channel, const char* message, ...)
{
return Logger::MessagePrint(channel, Logger::Format(&message));
}
void Logger::MessagePrint(int channel, std::string message)
{
if (Flags::HasFlag("stdout"))
{
printf("%s", buffer);
printf("%s", message.data());
fflush(stdout);
}
else if (Logger::IsConsoleReady())
{
if (!Game::Sys_IsMainThread())
{
Logger::EnqueueMessage(buffer);
Logger::EnqueueMessage(message);
}
else
{
Game::Com_PrintMessage(0, buffer, 0);
Game::Com_PrintMessage(0, message.data(), 0);
}
}
else
@ -41,36 +44,44 @@ namespace Components
// Only print to stdout, when doing unit tests
if (Loader::PerformingUnitTests())
{
printf("%s", buffer);
printf("%s", message.data());
fflush(stdout);
}
OutputDebugStringA(buffer);
OutputDebugStringA(message.data());
}
}
void Logger::ErrorPrint(int error, std::string message)
{
return Game::Com_Error(error, "%s", message.data());
}
void Logger::Error(int error, const char* message, ...)
{
return Logger::ErrorPrint(error, Logger::Format(&message));
}
void Logger::Error(const char* message, ...)
{
char buffer[0x1000] = { 0 };
va_list ap;
va_start(ap, message);
vsprintf_s(buffer, message, ap);
va_end(ap);
Game::Com_Error(0, "%s", buffer);
return Logger::ErrorPrint(0, Logger::Format(&message));
}
void Logger::SoftError(const char* message, ...)
{
return Logger::ErrorPrint(2, Logger::Format(&message));
}
std::string Logger::Format(const char** message)
{
char buffer[0x1000] = { 0 };
va_list ap;
va_start(ap, message);
vsprintf_s(buffer, message, ap);
va_list ap = reinterpret_cast<char*>(const_cast<char**>(&message[1]));
//va_start(ap, *message);
vsprintf_s(buffer, *message, ap);
va_end(ap);
Game::Com_Error(2, "%s", buffer);
return buffer;
}
void Logger::Frame()

View File

@ -7,8 +7,13 @@ namespace Components
~Logger();
const char* GetName() { return "Logger"; };
static void MessagePrint(int channel, std::string message);
static void Print(int channel, const char* message, ...);
static void Print(const char* message, ...);
static void ErrorPrint(int error, std::string message);
static void Error(const char* message, ...);
static void Error(int error, const char* message, ...);
static void SoftError(const char* message, ...);
static bool IsConsoleReady();
@ -23,5 +28,7 @@ namespace Components
static void PrintMessageStub();
static void PrintMessagePipe(const char* data);
static void EnqueueMessage(std::string message);
static std::string Format(const char** message);
};
}

View File

@ -11,12 +11,14 @@ namespace Components
{
std::string funcName = Game::SL_ConvertToString(Script::FunctionName);
Game::Com_Printf(23, "\n");
Game::Com_Printf(23, "******* script compile error *******\n");
Game::Com_Printf(23, "Error: unknown function %s in %s\n", funcName.data(), Script::ScriptName.data());
Game::Com_Printf(23, "************************************\n");
Game::Scr_ShutdownAllocNode();
Game::Com_Error(5, "script compile error\nunknown function %s\n%s\n", funcName.data(), Script::ScriptName.data());
Logger::Print(23, "\n");
Logger::Print(23, "******* script compile error *******\n");
Logger::Print(23, "Error: unknown function %s in %s\n", funcName.data(), Script::ScriptName.data());
Logger::Print(23, "************************************\n");
Logger::Error(5, "script compile error\nunknown function %s\n%s\n", funcName.data(), Script::ScriptName.data());
}
void __declspec(naked) Script::StoreFunctionNameStub()
@ -127,22 +129,22 @@ namespace Components
}
}
Game::Com_Printf(23, "in file %s, line %d:", filename, line);
Logger::Print(23, "in file %s, line %d:", filename, line);
if (currentLine)
{
Game::Com_Printf(23, "%s\n", currentLine);
Logger::Print(23, "%s\n", currentLine);
for (int i = 0; i < (inLineOffset - 1); i++)
{
Game::Com_Printf(23, " ");
Logger::Print(23, " ");
}
Game::Com_Printf(23, "*\n");
Logger::Print(23, "*\n");
}
else
{
Game::Com_Printf(23, "\n");
Logger::Print(23, "\n");
}
if (freeScript)
@ -161,13 +163,13 @@ namespace Components
Game::Scr_ShutdownAllocNode();
Game::Com_Printf(23, "\n");
Game::Com_Printf(23, "******* script compile error *******\n");
Game::Com_Printf(23, "Error: %s ", msgbuf);
Logger::Print(23, "\n");
Logger::Print(23, "******* script compile error *******\n");
Logger::Print(23, "Error: %s ", msgbuf);
Script::PrintSourcePos(Script::ScriptName.data(), offset);
Game::Com_Printf(23, "************************************\n");
Logger::Print(23, "************************************\n");
Game::Com_Error(5, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, Script::ScriptName.data());
Logger::Error(5, "script compile error\n%s\n%s\n(see console for actual details)\n", msgbuf, Script::ScriptName.data());
}
int Script::LoadScriptAndLabel(std::string script, std::string label)
@ -177,7 +179,7 @@ namespace Components
if (!Game::Scr_LoadScript(script.data()))
{
Logger::Print("Script %s encountered an error while loading. (doesn't exist?)", script.data());
Game::Com_Error(1, (char*)0x70B810, script.data());
Logger::Error(1, (char*)0x70B810, script.data());
}
else
{