fix: reduce chances fake ping disappears from scoreboard
This commit is contained in:
parent
e213e39d17
commit
570cfe0538
3 changed files with 41 additions and 16 deletions
|
|
@ -131,7 +131,8 @@ private:
|
||||||
int m_gameFlags {};
|
int m_gameFlags {};
|
||||||
int m_mapFlags {};
|
int m_mapFlags {};
|
||||||
|
|
||||||
float m_slowFrame; // per second updated frame
|
float m_oneSecondFrame; // per second updated
|
||||||
|
float m_halfSecondFrame; // per half second update
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game ();
|
Game ();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ Game::Game () {
|
||||||
|
|
||||||
m_gameFlags = 0;
|
m_gameFlags = 0;
|
||||||
m_mapFlags = 0;
|
m_mapFlags = 0;
|
||||||
m_slowFrame = 0.0f;
|
m_oneSecondFrame = 0.0f;
|
||||||
|
m_halfSecondFrame = 0.0f;
|
||||||
|
|
||||||
m_cvars.clear ();
|
m_cvars.clear ();
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +157,8 @@ void Game::levelInitialize (edict_t *entities, int max) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset some timers
|
// reset some timers
|
||||||
m_slowFrame = 0.0f;
|
m_oneSecondFrame = 0.0f;
|
||||||
|
m_halfSecondFrame = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::drawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, const Color &color, int brightness, int speed, int life, DrawLine type) {
|
void Game::drawLine (edict_t *ent, const Vector &start, const Vector &end, int width, int noise, const Color &color, int brightness, int speed, int life, DrawLine type) {
|
||||||
|
|
@ -928,7 +930,19 @@ void Game::applyGameModes () {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::slowFrame () {
|
void Game::slowFrame () {
|
||||||
if (m_slowFrame > time ()) {
|
const auto nextUpdate = cr::clamp (75.0f * globals->frametime, 0.5f, 1.0f);
|
||||||
|
|
||||||
|
// run something that is should run more
|
||||||
|
if (m_halfSecondFrame < time ()) {
|
||||||
|
|
||||||
|
// refresh bomb origin in case some plugin moved it out
|
||||||
|
graph.setBombOrigin ();
|
||||||
|
|
||||||
|
// update next update time
|
||||||
|
m_halfSecondFrame = nextUpdate * 0.25f + time ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_oneSecondFrame > time ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctrl.maintainAdminRights ();
|
ctrl.maintainAdminRights ();
|
||||||
|
|
@ -939,12 +953,12 @@ void Game::slowFrame () {
|
||||||
// check if we're need to autokill bots
|
// check if we're need to autokill bots
|
||||||
bots.maintainAutoKill ();
|
bots.maintainAutoKill ();
|
||||||
|
|
||||||
|
// update client pings
|
||||||
|
util.calculatePings ();
|
||||||
|
|
||||||
// maintain leaders selection upon round start
|
// maintain leaders selection upon round start
|
||||||
bots.maintainLeaders ();
|
bots.maintainLeaders ();
|
||||||
|
|
||||||
// update client pings
|
|
||||||
util.calculatePings ();
|
|
||||||
|
|
||||||
// initialize light levels
|
// initialize light levels
|
||||||
graph.initLightLevels ();
|
graph.initLightLevels ();
|
||||||
|
|
||||||
|
|
@ -957,12 +971,11 @@ void Game::slowFrame () {
|
||||||
// check the cvar bounds
|
// check the cvar bounds
|
||||||
checkCvarsBounds ();
|
checkCvarsBounds ();
|
||||||
|
|
||||||
// refresh bomb origin in case some plugin moved it out
|
|
||||||
graph.setBombOrigin ();
|
|
||||||
|
|
||||||
// display welcome message
|
// display welcome message
|
||||||
util.checkWelcome ();
|
util.checkWelcome ();
|
||||||
m_slowFrame = time () + 1.0f;
|
|
||||||
|
// update next update time
|
||||||
|
m_oneSecondFrame = nextUpdate + time ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::searchEntities (StringRef field, StringRef value, EntitySearch functor) {
|
void Game::searchEntities (StringRef field, StringRef value, EntitySearch functor) {
|
||||||
|
|
|
||||||
|
|
@ -407,18 +407,29 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
|
||||||
|
|
||||||
// if we're handle pings for bots and clients, clear IN_SCORE button so SV_ShouldUpdatePing engine function return false, and SV_EmitPings will not overwrite our results
|
// if we're handle pings for bots and clients, clear IN_SCORE button so SV_ShouldUpdatePing engine function return false, and SV_EmitPings will not overwrite our results
|
||||||
if (game.is (GameFlags::HasFakePings) && cv_show_latency.int_ () == 2) {
|
if (game.is (GameFlags::HasFakePings) && cv_show_latency.int_ () == 2) {
|
||||||
if (cmd->buttons & IN_SCORE) {
|
if (!util.isFakeClient (ent) && (ent->v.oldbuttons | ent->v.button | cmd->buttons) & IN_SCORE) {
|
||||||
cmd->buttons &= ~IN_SCORE;
|
cmd->buttons &= ~IN_SCORE;
|
||||||
|
|
||||||
// send our version of pings
|
|
||||||
util.sendPings (ent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.is (GameFlags::Metamod)) {
|
if (game.is (GameFlags::Metamod)) {
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
}
|
}
|
||||||
dllapi.pfnCmdStart (player, cmd, random_seed);
|
dllapi.pfnCmdStart (ent, cmd, random_seed);
|
||||||
|
};
|
||||||
|
|
||||||
|
table->pfnUpdateClientData = [] (const struct edict_s *player, int sendweapons, struct clientdata_s *cd) {
|
||||||
|
auto ent = const_cast <edict_t *> (player);
|
||||||
|
|
||||||
|
if (game.is (GameFlags::HasFakePings) && cv_show_latency.int_ () == 2) {
|
||||||
|
if (!util.isFakeClient (ent) && (ent->v.oldbuttons | ent->v.button) & IN_SCORE) {
|
||||||
|
util.sendPings (ent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (game.is (GameFlags::Metamod)) {
|
||||||
|
RETURN_META (MRES_IGNORED);
|
||||||
|
}
|
||||||
|
dllapi.pfnUpdateClientData (ent, sendweapons, cd);
|
||||||
};
|
};
|
||||||
|
|
||||||
table->pfnPM_Move = [] (playermove_t *playerMove, int server) {
|
table->pfnPM_Move = [] (playermove_t *playerMove, int server) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue