From 7fff22ccec9d894b46ff35766e107dfce7d99f1f Mon Sep 17 00:00:00 2001 From: Amos <48657826+Mauler125@users.noreply.github.com> Date: Sun, 6 Feb 2022 17:27:47 +0100 Subject: [PATCH] Slight cleanup --- r5dev/core/init.cpp | 4 ++-- r5dev/netconsole/netconsole.cpp | 16 +++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index 09f2d854..ba6419b4 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -73,7 +73,7 @@ void Systems_Init() int nError = ::WSAStartup(MAKEWORD(2, 2), &wsaData); if (nError != 0) { - assert(nError != 0 && "Failed to start Winsock via WSAStartup."); + std::cerr << "Failed to start Winsock via WSAStartup. Error: " << nError << std::endl; } // Begin the detour transaction to hook the the process @@ -149,7 +149,7 @@ void Systems_Shutdown() int nError = ::WSACleanup(); if (nError != 0) { - assert(nError != 0 && "Failed to stop winsock via WSACleanup.\n"); + std::cerr << "Failed to stop winsock via WSACleanup. Error: " << nError << std::endl; } // Begin the detour transaction to unhook the the process diff --git a/r5dev/netconsole/netconsole.cpp b/r5dev/netconsole/netconsole.cpp index 41c9f878..cb8c866f 100644 --- a/r5dev/netconsole/netconsole.cpp +++ b/r5dev/netconsole/netconsole.cpp @@ -14,8 +14,7 @@ //----------------------------------------------------------------------------- void CNetCon::Send(void) { - char buf[MAX_NETCONSOLE_INPUT_LEN]{}; - std::string svUserInput; + static std::string svUserInput; do { @@ -24,11 +23,6 @@ void CNetCon::Send(void) svUserInput.append("\n\r"); int nSendResult = ::send(pSocket->GetAcceptedSocketData(0)->m_hSocket, svUserInput.c_str(), svUserInput.size(), MSG_NOSIGNAL); - - if (nSendResult != SOCKET_ERROR) - { - memcpy(buf, "", MAX_NETCONSOLE_INPUT_LEN); - } } while (svUserInput.size() > 0); } @@ -37,17 +31,17 @@ void CNetCon::Send(void) //----------------------------------------------------------------------------- void CNetCon::Recv(void) { - static char buf[MAX_NETCONSOLE_INPUT_LEN]{}; + static char szRecvBuf[MAX_NETCONSOLE_INPUT_LEN]{}; for (;;) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); - int nRecvLen = ::recv(pSocket->GetAcceptedSocketData(0)->m_hSocket, buf, sizeof(buf), MSG_NOSIGNAL); + int nRecvLen = ::recv(pSocket->GetAcceptedSocketData(0)->m_hSocket, szRecvBuf, sizeof(szRecvBuf), MSG_NOSIGNAL); if (nRecvLen > 0 && nRecvLen < MAX_NETCONSOLE_INPUT_LEN - 1) { - buf[nRecvLen + 1] = '\0'; - printf("%s\n", buf); + szRecvBuf[nRecvLen + 1] = '\0'; + printf("%s\n", szRecvBuf); } } }