From d7ee3ae35ac045f86bce7ef658bee3fb40eb3514 Mon Sep 17 00:00:00 2001 From: jeefo Date: Sun, 1 Dec 2019 23:42:31 +0300 Subject: [PATCH] Minor refactoring. --- include/engine.h | 3 +-- source/engine.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/engine.h b/include/engine.h index 45a6a4d..8349e5f 100644 --- a/include/engine.h +++ b/include/engine.h @@ -116,7 +116,6 @@ private: int m_spawnCount[Team::Unassigned]; // bot client command - bool m_isBotCommand; StringArray m_botArgs; edict_t *m_startEntity; @@ -224,7 +223,7 @@ public: // get the fakeclient command interface bool isBotCmd () const { - return m_isBotCommand; + return !m_botArgs.empty (); } // gets custom engine args for client command diff --git a/source/engine.cpp b/source/engine.cpp index cf2fcef..766b746 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -19,7 +19,6 @@ Game::Game () { m_localEntity = nullptr; m_precached = false; - m_isBotCommand = false; plat.bzero (m_drawModels, sizeof (m_drawModels)); plat.bzero (m_spawnCount, sizeof (m_spawnCount)); @@ -405,8 +404,6 @@ void Game::prepareBotArgs (edict_t *ent, String str) { if (str.empty ()) { return; } - m_isBotCommand = true; - m_botArgs.clear (); // helper to parse single (not multi) command auto parsePartArgs = [&] (String &args) { @@ -430,7 +427,7 @@ void Game::prepareBotArgs (edict_t *ent, String str) { m_botArgs.push (cr::move (args.substr (quote, args.length () - 1).trim ("\""))); // add string with trimmed quotes } else { - for (auto &arg : args.split (" ")) { + for (auto &&arg : args.split (" ")) { m_botArgs.push (cr::move (arg)); } } @@ -439,18 +436,19 @@ void Game::prepareBotArgs (edict_t *ent, String str) { m_botArgs.push (cr::move (args)); // move all the part to args } MDLL_ClientCommand (ent); - m_botArgs.clear (); // clear space for next cmd + + // clear space for next cmd + m_botArgs.clear (); }; if (str.find (';', 0) != String::InvalidIndex) { - for (auto &part : str.split (";")) { + for (auto &&part : str.split (";")) { parsePartArgs (part); } } else { parsePartArgs (str); } - m_isBotCommand = false; } bool Game::isSoftwareRenderer () {