Fixed displaying of flags of loaded game.

Fixed incorrect usage  of setsockopt ().
Fixed chat preparation doesn't replace all placeholders.
This commit is contained in:
Dmitry 2019-07-28 21:30:33 +03:00 committed by jeefo
commit 7a6e3febf2
3 changed files with 14 additions and 9 deletions

View file

@ -56,7 +56,7 @@ public:
#if defined(CR_WINDOWS) #if defined(CR_WINDOWS)
WSADATA wsa; WSADATA wsa;
if (WSAStartup (MAKEWORD (1, 1), &wsa) != 0) { if (WSAStartup (MAKEWORD (2, 2), &wsa) != 0) {
logger.error ("Unable to inialize sockets."); logger.error ("Unable to inialize sockets.");
} }
#endif #endif
@ -93,11 +93,11 @@ public:
}; };
auto timeouts = getTimeouts (); 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."); 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."); logger.error ("Unable to set SO_SNDTIMEO.");
} }

View file

@ -231,13 +231,13 @@ void Bot::prepareChatMessage (const String &message) {
return humanizedName (game.indexOfPlayer (client.ent)); return humanizedName (game.indexOfPlayer (client.ent));
} }
} }
return "UnknowPA"; return getHighfragPlayer ();
}; };
size_t replaceCounter = 0; size_t replaceCounter = 0;
while (replaceCounter < 6 && (pos = m_chatBuffer.find ('%')) != String::kInvalidIndex) { while (replaceCounter < 6 && (pos = m_chatBuffer.find ('%')) != String::kInvalidIndex) {
// found one, let's do replace // found one, let's do replace
switch (message[pos + 1]) { switch (m_chatBuffer[pos + 1]) {
// the highest frag player // the highest frag player
case 'f': case 'f':

View file

@ -1105,6 +1105,7 @@ bool Game::postload () {
// print game detection info // print game detection info
auto printGame = [&] () { auto printGame = [&] () {
String gameVersionStr; String gameVersionStr;
StringArray gameVersionFlags;
if (is (GameFlags::Legacy)) { if (is (GameFlags::Legacy)) {
gameVersionStr.assign ("Legacy"); gameVersionStr.assign ("Legacy");
@ -1126,17 +1127,21 @@ bool Game::postload () {
} }
if (is (GameFlags::HasBotVoice)) { if (is (GameFlags::HasBotVoice)) {
gameVersionStr.append (" (BV)"); gameVersionFlags.push ("BotVoice");
} }
if (is (GameFlags::ReGameDLL)) { if (is (GameFlags::ReGameDLL)) {
gameVersionStr.append (" (RE)"); gameVersionFlags.push ("ReGameDLL");
} }
if (is (GameFlags::HasFakePings)) { 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) { if (plat.isAndroid) {