From 9720a634010b67ef051744ffa0e5e26cc5589355 Mon Sep 17 00:00:00 2001 From: jeefo Date: Thu, 5 Sep 2019 10:44:08 +0300 Subject: [PATCH] Do not buy secondary without enough money on not first round. --- include/crlib/cr-files.h | 8 +++++--- include/crlib/cr-http.h | 6 ++++-- source/basecode.cpp | 2 +- source/navigate.cpp | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/crlib/cr-files.h b/include/crlib/cr-files.h index c373821..26c4040 100644 --- a/include/crlib/cr-files.h +++ b/include/crlib/cr-files.h @@ -192,7 +192,9 @@ public: class MemFile final : public DenyCopying { private: - static constexpr char kEOF = static_cast (-1); + enum : char { + Eof = static_cast (-1) + }; private: uint8 *m_data = nullptr; @@ -231,7 +233,7 @@ public: char getChar () { if (!m_data || m_pos >= m_length) { - return kEOF; + return Eof; } auto ch = m_data[m_pos]; ++m_pos; @@ -266,7 +268,7 @@ public: line.clear (); char ch; - while ((ch = getChar ()) != kEOF) { + while ((ch = getChar ()) != Eof) { line += ch; if (ch == '\n') { diff --git a/include/crlib/cr-http.h b/include/crlib/cr-http.h index bc3ea3c..3d7a006 100644 --- a/include/crlib/cr-http.h +++ b/include/crlib/cr-http.h @@ -198,7 +198,9 @@ namespace detail { // simple http client for downloading/uploading files only class HttpClient final : public Singleton { private: - static constexpr int32 kMaxRecvErrors = 12; + enum : int32 { + MaxReceiveErrors = 12 + }; private: Socket m_socket; @@ -218,7 +220,7 @@ private: // prase response header while (!isFinished && pos < m_chunkSize) { if (m_socket.recv (&buffer[pos], 1) < 1) { - if (++errors > kMaxRecvErrors) { + if (++errors > MaxReceiveErrors) { isFinished = true; } else { diff --git a/source/basecode.cpp b/source/basecode.cpp index 623a694..2b60da7 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -1496,7 +1496,7 @@ void Bot::buyStuff () { break; case BuyState::SecondaryWeapon: // if bot has still some money, buy a better secondary weapon - if (isPistolMode || (isFirstRound && hasDefaultPistols) || (hasDefaultPistols && bots.getLastWinner () != m_team) || (hasPrimaryWeapon () && hasDefaultPistols && m_moneyAmount > rg.int_ (7500, 9000))) { + if (isPistolMode || (isFirstRound && hasDefaultPistols) || (hasDefaultPistols && bots.getLastWinner () == m_team && m_moneyAmount > rg.int_ (3500, 4500)) || (hasPrimaryWeapon () && hasDefaultPistols && m_moneyAmount > rg.int_ (7500, 9000))) { do { pref--; diff --git a/source/navigate.cpp b/source/navigate.cpp index f063ef4..b8a44a5 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -10,7 +10,7 @@ #include ConVar yb_whose_your_daddy ("yb_whose_your_daddy", "0", "Enables or disables extra hard difficulty for bots."); -ConVar yb_debug_heuristic_type ("yb_debug_heuristic_type", "4", "Selects the heuristic function mode. For debug purposes only.", true, 0.0f, 4.0f); +ConVar yb_debug_heuristic_type ("yb_debug_heuristic_type", "0", "Selects the heuristic function mode. For debug purposes only.", true, 0.0f, 4.0f); int Bot::findBestGoal () { @@ -745,7 +745,7 @@ bool Bot::updateNavigation () { edict_t *pent = nullptr; - if (m_tryOpenDoor++ > 2 && util.findNearestPlayer (reinterpret_cast (&pent), ent (), 256.0f, false, false, true, true, false)) { + if (++m_tryOpenDoor > 2 && util.findNearestPlayer (reinterpret_cast (&pent), ent (), 256.0f, false, false, true, true, false)) { m_seeEnemyTime = game.time () - 0.5f; m_states |= Sense::SeeingEnemy;