fix: disabled frame skipping on xash3d still works partially (ref #593)

This commit is contained in:
jeefo 2024-07-14 15:01:36 +03:00
commit 18fe797c7b
No known key found for this signature in database
GPG key ID: D696786B81B667C8
2 changed files with 19 additions and 9 deletions

View file

@ -129,6 +129,7 @@ public:
bool balancedKickRandom (bool decQuota); bool balancedKickRandom (bool decQuota);
bool hasCustomCSDMSpawnEntities (); bool hasCustomCSDMSpawnEntities ();
bool isLineBlockedBySmoke (const Vector &from, const Vector &to, float grenadeBloat = 1.0f); bool isLineBlockedBySmoke (const Vector &from, const Vector &to, float grenadeBloat = 1.0f);
bool isFrameSkipDisabled ();
public: public:
const Array <edict_t *> &getActiveGrenades () { const Array <edict_t *> &getActiveGrenades () {

View file

@ -1664,21 +1664,23 @@ void Bot::newRound () {
pushChatterMessage (Chatter::NewRound); pushChatterMessage (Chatter::NewRound);
} }
auto thinkFps = cr::clamp (cv_think_fps.as <float> (), 30.0f, 90.0f); auto thinkFps = cr::clamp (cv_think_fps.as <float> (), 30.0f, 90.0f);
auto updateInterval = 1.0f / thinkFps;
if (game.is (GameFlags::Xash3D)) { auto updateInterval = 1.0f / thinkFps;
if (cv_think_fps_disable) { auto commandInterval = 1.0f / 60.0f;
updateInterval = 0.0f;
} if (game.is (GameFlags::Xash3D | GameFlags::Xash3DLegacy)) {
else if (thinkFps < 50) { if (thinkFps < 50) {
updateInterval = 1.0f / 50.0f; // xash3d works acceptable at 50fps updateInterval = 1.0f / 50.0f; // xash3d works acceptable at 50fps
} }
} }
else if (game.is (GameFlags::Legacy)) {
updateInterval = 0.0f; // legacy games behaves strange, when this enabled // legacy games behaves strange, when this enabled, disable for xash3d as well if requested
if (bots.isFrameSkipDisabled ()) {
updateInterval = 0.0f;
commandInterval = 0.0f;
} }
m_thinkDelay.interval = updateInterval; m_thinkDelay.interval = updateInterval;
m_commandDelay.interval = 1.0f / 60.0f; m_commandDelay.interval = commandInterval;
} }
void Bot::resetPathSearchType () { void Bot::resetPathSearchType () {
@ -2308,3 +2310,10 @@ bool BotManager::isLineBlockedBySmoke (const Vector &from, const Vector &to, flo
// return true if the total length of smoke-covered line-of-sight is too much // return true if the total length of smoke-covered line-of-sight is too much
return (totalSmokedLength > maxSmokedLength); return (totalSmokedLength > maxSmokedLength);
} }
bool BotManager::isFrameSkipDisabled () {
if (game.is (GameFlags::Legacy)) {
return true;
}
return game.is (GameFlags::Xash3D | GameFlags::Xash3DLegacy) && cv_think_fps_disable;
}