From f3a4fb5a8bdf24f0a29335d94eaebd06f1c6802e Mon Sep 17 00:00:00 2001 From: jeefo Date: Wed, 29 Nov 2023 22:34:45 +0300 Subject: [PATCH] combat: use scale for selecting new enemy linkage: display hw renderer as game flags linkage: display running engine (hl25) as game flags --- ext/crlib | 2 +- inc/engine.h | 5 ++++- src/combat.cpp | 8 ++++---- src/engine.cpp | 31 ++++++++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/ext/crlib b/ext/crlib index 7179ca3..5767ac6 160000 --- a/ext/crlib +++ b/ext/crlib @@ -1 +1 @@ -Subproject commit 7179ca3e4f1bc72620d9ef76a9cf67e59ce76120 +Subproject commit 5767ac6bd530cebd257747835361456f4a40d567 diff --git a/inc/engine.h b/inc/engine.h index 497ea2f..0550b59 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -45,7 +45,10 @@ CR_DECLARE_SCOPED_ENUM (GameFlags, FreeForAll = cr::bit (8), // csdm mod with ffa mode ReGameDLL = cr::bit (9), // server dll is a regamedll HasFakePings = cr::bit (10), // on that game version we can fake bots pings - HasBotVoice = cr::bit (11) // on that game version we can use chatter + HasBotVoice = cr::bit (11), // on that game version we can use chatter + SwRenderer = cr::bit (12), // game runs with software renderer + HwRenderer = cr::bit (13), // games runs with hardware renderer + AnniversaryHL25 = cr::bit (14) // half-life 25th anniversary engine ) // defines map type diff --git a/src/combat.cpp b/src/combat.cpp index e81c21a..6f8c2ba 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -284,7 +284,7 @@ bool Bot::lookupEnemies () { } // check the engine PVS - if (!frustum.check (m_viewFrustum, interesting) || !game.checkVisibility (interesting, set)) { + if (!game.checkVisibility (interesting, set)) { continue; } @@ -310,7 +310,7 @@ bool Bot::lookupEnemies () { player = client.ent; // check the engine PVS - if (!frustum.check (m_viewFrustum, player) || !game.checkVisibility (player, set)) { + if (!game.checkVisibility (player, set)) { continue; } @@ -322,7 +322,7 @@ bool Bot::lookupEnemies () { } const float distanceSq = player->v.origin.distanceSq (pev->origin); - if (distanceSq < nearestDistanceSq) { + if (distanceSq * 0.7f < nearestDistanceSq) { nearestDistanceSq = distanceSq; newEnemy = player; @@ -333,7 +333,7 @@ bool Bot::lookupEnemies () { } } } - m_enemyUpdateTime = game.time () + (usesKnife () ? 1.0f : 0.75f); + m_enemyUpdateTime = game.time () + (usesKnife () ? 1.0f : 0.5f); if (game.isNullEntity (newEnemy) && !game.isNullEntity (shieldEnemy)) { newEnemy = shieldEnemy; diff --git a/src/engine.cpp b/src/engine.cpp index 0d3fadb..09050c4 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -333,7 +333,7 @@ void Game::registerEngineCommand (const char *command, void func ()) { // pointed to by "function" in order to handle it. // check for hl pre 1.1.0.4, as it's doesn't have pfnAddServerCommand - if (!plat.checkPointer (engfuncs.pfnAddServerCommand)) { + if (!plat.isValidPtr (engfuncs.pfnAddServerCommand)) { logger.fatal ("%s's minimum HL engine version is 1.1.0.4 and minimum Counter-Strike is Beta 6.5. Please update your engine / game version.", product.name); } engfuncs.pfnAddServerCommand (const_cast (command), func); @@ -848,6 +848,19 @@ bool Game::postload () { }); } + // setup flags + if (game.isSoftwareRenderer ()) { + m_gameFlags |= GameFlags::SwRenderer; + } + else { + m_gameFlags |= GameFlags::SwRenderer; + } + + // is 25th anniversary + if (game.is25thAnniversaryUpdate ()) { + m_gameFlags |= GameFlags::AnniversaryHL25; + } + // initialize weapons conf.initWeapons (); @@ -1048,6 +1061,18 @@ void Game::printBotVersion () { botRuntimeFlags.push ("Metamod"); } + if (is (GameFlags::AnniversaryHL25)) { + botRuntimeFlags.push ("HL25"); + } + + if (is (GameFlags::SwRenderer)) { + botRuntimeFlags.push ("SWR"); + } + + if (is (GameFlags::HwRenderer)) { + botRuntimeFlags.push ("HWR"); + } + // print if we're using sse 4.x instructions if (cpuflags.sse41 || cpuflags.sse42 || cpuflags.neon) { Array simdLevels {}; @@ -1232,8 +1257,8 @@ float LightMeasure::getLightLevel (const Vector &point) { // it's depends if we're are on dedicated or on listenserver auto recursiveCheck = [&] () -> bool { - if (!game.isSoftwareRenderer ()) { - if (game.is25thAnniversaryUpdate ()) { + if (!game.is (GameFlags::SwRenderer)) { + if (game.is (GameFlags::AnniversaryHL25)) { return recursiveLightPoint (reinterpret_cast (m_worldModel->nodes), point, endPoint); } return recursiveLightPoint (reinterpret_cast (m_worldModel->nodes), point, endPoint);