From 7a6e3febf2041fd243497b4414559685ca9998c6 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sun, 28 Jul 2019 21:30:33 +0300 Subject: [PATCH] Fixed displaying of flags of loaded game. Fixed incorrect usage of setsockopt (). Fixed chat preparation doesn't replace all placeholders. --- include/crlib/cr-http.h | 6 +++--- source/chatlib.cpp | 4 ++-- source/engine.cpp | 13 +++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/crlib/cr-http.h b/include/crlib/cr-http.h index e904e0f..1c20711 100644 --- a/include/crlib/cr-http.h +++ b/include/crlib/cr-http.h @@ -56,7 +56,7 @@ public: #if defined(CR_WINDOWS) WSADATA wsa; - if (WSAStartup (MAKEWORD (1, 1), &wsa) != 0) { + if (WSAStartup (MAKEWORD (2, 2), &wsa) != 0) { logger.error ("Unable to inialize sockets."); } #endif @@ -93,11 +93,11 @@ public: }; auto timeouts = getTimeouts (); - if (setsockopt (m_socket, SOL_SOCKET, SO_RCVTIMEO, timeouts.first, timeouts.second) < 1) { + if (setsockopt (m_socket, SOL_SOCKET, SO_RCVTIMEO, timeouts.first, timeouts.second) == -1) { logger.error ("Unable to set SO_RCVTIMEO."); } - if (setsockopt (m_socket, SOL_SOCKET, SO_SNDTIMEO, timeouts.first, timeouts.second) < 1) { + if (setsockopt (m_socket, SOL_SOCKET, SO_SNDTIMEO, timeouts.first, timeouts.second) == -1) { logger.error ("Unable to set SO_SNDTIMEO."); } diff --git a/source/chatlib.cpp b/source/chatlib.cpp index 2d6c0e6..e017552 100644 --- a/source/chatlib.cpp +++ b/source/chatlib.cpp @@ -231,13 +231,13 @@ void Bot::prepareChatMessage (const String &message) { return humanizedName (game.indexOfPlayer (client.ent)); } } - return "UnknowPA"; + return getHighfragPlayer (); }; size_t replaceCounter = 0; while (replaceCounter < 6 && (pos = m_chatBuffer.find ('%')) != String::kInvalidIndex) { // found one, let's do replace - switch (message[pos + 1]) { + switch (m_chatBuffer[pos + 1]) { // the highest frag player case 'f': diff --git a/source/engine.cpp b/source/engine.cpp index 95bd1a9..91add79 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -1105,6 +1105,7 @@ bool Game::postload () { // print game detection info auto printGame = [&] () { String gameVersionStr; + StringArray gameVersionFlags; if (is (GameFlags::Legacy)) { gameVersionStr.assign ("Legacy"); @@ -1126,17 +1127,21 @@ bool Game::postload () { } if (is (GameFlags::HasBotVoice)) { - gameVersionStr.append (" (BV)"); + gameVersionFlags.push ("BotVoice"); } if (is (GameFlags::ReGameDLL)) { - gameVersionStr.append (" (RE)"); + gameVersionFlags.push ("ReGameDLL"); } if (is (GameFlags::HasFakePings)) { - gameVersionStr.append (" (SVC)"); + gameVersionFlags.push ("FakePing"); } - print ("[YAPB] Bot v%s.0.%d Loaded. Game detected as Counter-Strike: %s", PRODUCT_VERSION, util.buildNumber (), gameVersionStr.chars ()); + + if (is (GameFlags::Metamod)) { + gameVersionFlags.push ("Metamod"); + } + print ("%s v%s.0.%d successfully loaded for game: Counter-Strike %s (%s).\n", PRODUCT_SHORT_NAME, PRODUCT_VERSION, util.buildNumber (), gameVersionStr.chars (), String::join (gameVersionFlags, ", ").chars ()); }; if (plat.isAndroid) {