Minor refactoring.

This commit is contained in:
jeefo 2019-12-01 23:42:31 +03:00
commit d7ee3ae35a
2 changed files with 6 additions and 9 deletions

View file

@ -116,7 +116,6 @@ private:
int m_spawnCount[Team::Unassigned]; int m_spawnCount[Team::Unassigned];
// bot client command // bot client command
bool m_isBotCommand;
StringArray m_botArgs; StringArray m_botArgs;
edict_t *m_startEntity; edict_t *m_startEntity;
@ -224,7 +223,7 @@ public:
// get the fakeclient command interface // get the fakeclient command interface
bool isBotCmd () const { bool isBotCmd () const {
return m_isBotCommand; return !m_botArgs.empty ();
} }
// gets custom engine args for client command // gets custom engine args for client command

View file

@ -19,7 +19,6 @@ Game::Game () {
m_localEntity = nullptr; m_localEntity = nullptr;
m_precached = false; m_precached = false;
m_isBotCommand = false;
plat.bzero (m_drawModels, sizeof (m_drawModels)); plat.bzero (m_drawModels, sizeof (m_drawModels));
plat.bzero (m_spawnCount, sizeof (m_spawnCount)); plat.bzero (m_spawnCount, sizeof (m_spawnCount));
@ -405,8 +404,6 @@ void Game::prepareBotArgs (edict_t *ent, String str) {
if (str.empty ()) { if (str.empty ()) {
return; return;
} }
m_isBotCommand = true;
m_botArgs.clear ();
// helper to parse single (not multi) command // helper to parse single (not multi) command
auto parsePartArgs = [&] (String &args) { 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 m_botArgs.push (cr::move (args.substr (quote, args.length () - 1).trim ("\""))); // add string with trimmed quotes
} }
else { else {
for (auto &arg : args.split (" ")) { for (auto &&arg : args.split (" ")) {
m_botArgs.push (cr::move (arg)); 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 m_botArgs.push (cr::move (args)); // move all the part to args
} }
MDLL_ClientCommand (ent); 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) { if (str.find (';', 0) != String::InvalidIndex) {
for (auto &part : str.split (";")) { for (auto &&part : str.split (";")) {
parsePartArgs (part); parsePartArgs (part);
} }
} }
else { else {
parsePartArgs (str); parsePartArgs (str);
} }
m_isBotCommand = false;
} }
bool Game::isSoftwareRenderer () { bool Game::isSoftwareRenderer () {