From 1311406544487faecafbaf8f7af5dd887b58618f Mon Sep 17 00:00:00 2001 From: jeefo Date: Tue, 13 May 2025 13:03:12 +0300 Subject: [PATCH] bot: allow to enable fake features with quoted value --- inc/engine.h | 14 +++++++------- src/chatlib.cpp | 2 -- src/engine.cpp | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/inc/engine.h b/inc/engine.h index 665aebe..6118649 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -316,27 +316,27 @@ public: } // gets edict pointer out of entity index - CR_FORCE_INLINE edict_t *entityOfIndex (const int index) { + CR_FORCE_INLINE edict_t *entityOfIndex (const int index) const { return static_cast (m_startEntity + index); }; // gets edict pointer out of entity index (player) - CR_FORCE_INLINE edict_t *playerOfIndex (const int index) { + CR_FORCE_INLINE edict_t *playerOfIndex (const int index) const { return entityOfIndex (index) + 1; }; // gets edict index out of it's pointer - CR_FORCE_INLINE int indexOfEntity (const edict_t *ent) { + CR_FORCE_INLINE int indexOfEntity (const edict_t *ent) const { return static_cast (ent - m_startEntity); }; // gets edict index of it's pointer (player) - CR_FORCE_INLINE int indexOfPlayer (const edict_t *ent) { + CR_FORCE_INLINE int indexOfPlayer (const edict_t *ent) const { return indexOfEntity (ent) - 1; } // verify entity isn't null - CR_FORCE_INLINE bool isNullEntity (const edict_t *ent) { + CR_FORCE_INLINE bool isNullEntity (const edict_t *ent) const { return !ent || !indexOfEntity (ent) || ent->free; } @@ -351,7 +351,7 @@ public: } // gets the player team - int getTeam (edict_t *ent) { + int getTeam (edict_t *ent) const { if (isNullEntity (ent)) { return Team::Unassigned; } @@ -359,7 +359,7 @@ public: } // gets the player team (real in ffa) - int getRealTeam (edict_t *ent) { + int getRealTeam (edict_t *ent) const { if (isNullEntity (ent)) { return Team::Unassigned; } diff --git a/src/chatlib.cpp b/src/chatlib.cpp index d6726c0..6fe3677 100644 --- a/src/chatlib.cpp +++ b/src/chatlib.cpp @@ -387,8 +387,6 @@ void Bot::checkForChat () { } } - - void Bot::sendToChat (StringRef message, bool teamOnly) { // this function prints saytext message to all players diff --git a/src/engine.cpp b/src/engine.cpp index 248f989..f3283e9 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -728,7 +728,7 @@ void Game::checkCvarsBounds () { static ConVarRef sv_forcesimulating ("sv_forcesimulating"); if (sv_forcesimulating.exists () && !cr::fequal (sv_forcesimulating.value (), 1.0f)) { - game.print ("Force-enable Xash3D sv_forcesimulating cvar."); + print ("Force-enable Xash3D sv_forcesimulating cvar."); sv_forcesimulating.set ("1.0"); } } @@ -935,14 +935,14 @@ bool Game::postload () { } // register fake metamod command handler if we not! under mm - if (!(game.is (GameFlags::Metamod))) { + if (!(is (GameFlags::Metamod))) { game.registerEngineCommand ("meta", [] () { game.print ("You're launched standalone version of %s. Metamod is not installed or not enabled!", product.name); }); } // is 25th anniversary - if (game.is25thAnniversaryUpdate ()) { + if (is25thAnniversaryUpdate ()) { m_gameFlags |= GameFlags::AnniversaryHL25; } @@ -1064,7 +1064,7 @@ void Game::slowFrame () { graph.setBombOrigin (); // ensure the server admin is confident about features he's using - game.ensureHealthyGameEnvironment (); + ensureHealthyGameEnvironment (); // update next update time m_halfSecondFrame = nextUpdate * 0.25f + time (); @@ -1115,7 +1115,7 @@ void Game::slowFrame () { void Game::searchEntities (StringRef field, StringRef value, EntitySearch functor) { edict_t *ent = nullptr; - while (!game.isNullEntity (ent = engfuncs.pfnFindEntityByString (ent, field.chars (), value.chars ()))) { + while (!isNullEntity (ent = engfuncs.pfnFindEntityByString (ent, field.chars (), value.chars ()))) { if ((ent->v.flags & EF_NODRAW) || (ent->v.flags & FL_CLIENT)) { continue; } @@ -1130,7 +1130,7 @@ void Game::searchEntities (const Vector &position, float radius, EntitySearch fu edict_t *ent = nullptr; const Vector &pos = position.empty () ? m_startEntity->v.origin : position; - while (!game.isNullEntity (ent = engfuncs.pfnFindEntityInSphere (ent, pos, radius))) { + while (!isNullEntity (ent = engfuncs.pfnFindEntityInSphere (ent, pos, radius))) { if ((ent->v.flags & EF_NODRAW) || (ent->v.flags & FL_CLIENT)) { continue; } @@ -1216,18 +1216,19 @@ void Game::printBotVersion () const { } void Game::ensureHealthyGameEnvironment () { - if (!isDedicated () || game.is (GameFlags::Legacy | GameFlags::Xash3D)) { + if (!isDedicated () || is (GameFlags::Legacy | GameFlags::Xash3D)) { return; // listen servers doesn't care about it at all } // magic string that's enables the features constexpr auto kAllowHash = StringRef::fnv1a32 ("i'm confident for what i'm doing"); + constexpr auto kAllowHash2 = StringRef::fnv1a32 ("\"i'm confident for what i'm doing\""); // fetch custom variable, so fake features are explicitly enabled static auto enableFakeFeatures = StringRef::fnv1a32 (conf.fetchCustom ("EnableFakeBotFeatures").chars ()); // if string matches, do not affect the cvars - if (enableFakeFeatures == kAllowHash) { + if (enableFakeFeatures == kAllowHash || enableFakeFeatures == kAllowHash2) { return; } @@ -1260,7 +1261,7 @@ void Game::ensureHealthyGameEnvironment () { edict_t *Game::createFakeClient (StringRef name) { auto ent = engfuncs.pfnCreateFakeClient (name.chars ()); - if (game.isNullEntity (ent)) { + if (isNullEntity (ent)) { return nullptr; } auto netname = ent->v.netname;