Skip to content

Commit

Permalink
Optimize sqvm and net logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauler125 committed Aug 6, 2021
1 parent 7b39eb1 commit 92673ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 5 additions & 2 deletions r5dev/src/hooks/net.cpp
Expand Up @@ -8,6 +8,9 @@ namespace Hooks
NET_SendDatagramFn originalNET_SendDatagram = nullptr;
}

static std::ostringstream oss;
static auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);

//-----------------------------------------------------------------------------
// Purpose: log the clients signonstate to the console
//-----------------------------------------------------------------------------
Expand All @@ -18,8 +21,8 @@ void Hooks::NET_PrintFunc(const char* fmt, ...)
static auto iconsole = spdlog::stdout_logger_mt("net_iconsole"); // in-game console
static auto wconsole = spdlog::stdout_logger_mt("net_wconsole"); // windows console

std::ostringstream oss;
auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
oss.str("");
oss.clear();

iconsole = std::make_shared<spdlog::logger>("ostream", ostream_sink);
iconsole->set_pattern("[%S.%e] %v");
Expand Down
8 changes: 6 additions & 2 deletions r5dev/src/hooks/sqvm.cpp
Expand Up @@ -7,6 +7,9 @@ namespace Hooks
SQVM_LoadScriptFn originalSQVM_LoadScript = nullptr;
}

static std::ostringstream oss;
static auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);

//---------------------------------------------------------------------------------
// Purpose: prints the output of each VM to the console
//---------------------------------------------------------------------------------
Expand All @@ -21,8 +24,9 @@ void* Hooks::SQVM_Print(void* sqvm, char* fmt, ...)
static auto wconsole = spdlog::stdout_logger_mt("sqvm_wconsole"); // windows console

std::string vmStr = vmType[vmIdx].c_str();
std::ostringstream oss;
auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);

oss.str("");
oss.clear();

iconsole = std::make_shared<spdlog::logger>("ostream", ostream_sink);
iconsole->set_pattern("[%S.%e] %v");
Expand Down
8 changes: 1 addition & 7 deletions r5dev/src/id3dx.cpp
Expand Up @@ -550,10 +550,4 @@ void SetupDXSwapChain()
{
CloseHandle(hThread);
}
}



//#################################################################################
// UTILS
//#################################################################################
}

0 comments on commit 92673ca

Please sign in to comment.