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_mapFlags {};
|
||||
|
||||
float m_slowFrame; // per second updated frame
|
||||
float m_oneSecondFrame; // per second updated
|
||||
float m_halfSecondFrame; // per half second update
|
||||
|
||||
public:
|
||||
Game ();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ Game::Game () {
|
|||
|
||||
m_gameFlags = 0;
|
||||
m_mapFlags = 0;
|
||||
m_slowFrame = 0.0f;
|
||||
m_oneSecondFrame = 0.0f;
|
||||
m_halfSecondFrame = 0.0f;
|
||||
|
||||
m_cvars.clear ();
|
||||
}
|
||||
|
|
@ -156,7 +157,8 @@ void Game::levelInitialize (edict_t *entities, int max) {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
|
|
@ -928,7 +930,19 @@ void Game::applyGameModes () {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
ctrl.maintainAdminRights ();
|
||||
|
|
@ -939,12 +953,12 @@ void Game::slowFrame () {
|
|||
// check if we're need to autokill bots
|
||||
bots.maintainAutoKill ();
|
||||
|
||||
// maintain leaders selection upon round start
|
||||
bots.maintainLeaders ();
|
||||
|
||||
// update client pings
|
||||
util.calculatePings ();
|
||||
|
||||
// maintain leaders selection upon round start
|
||||
bots.maintainLeaders ();
|
||||
|
||||
// initialize light levels
|
||||
graph.initLightLevels ();
|
||||
|
||||
|
|
@ -957,12 +971,11 @@ void Game::slowFrame () {
|
|||
// check the cvar bounds
|
||||
checkCvarsBounds ();
|
||||
|
||||
// refresh bomb origin in case some plugin moved it out
|
||||
graph.setBombOrigin ();
|
||||
|
||||
// display welcome message
|
||||
util.checkWelcome ();
|
||||
m_slowFrame = time () + 1.0f;
|
||||
|
||||
// update next update time
|
||||
m_oneSecondFrame = nextUpdate + time ();
|
||||
}
|
||||
|
||||
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 (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;
|
||||
|
||||
// send our version of pings
|
||||
util.sendPings (ent);
|
||||
}
|
||||
}
|
||||
|
||||
if (game.is (GameFlags::Metamod)) {
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue