From d45e534f3c6a759db5b53e960181a517a07fb9f4 Mon Sep 17 00:00:00 2001 From: dmitry Date: Thu, 16 Sep 2021 20:11:57 +0300 Subject: [PATCH] fix: fakeping disappearance completely not sure when and why pingUpdate was appeared, but it was the cause --- inc/support.h | 2 +- inc/yapb.h | 1 - src/linkage.cpp | 21 ++++----------------- src/support.cpp | 10 +--------- 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/inc/support.h b/inc/support.h index b8f839a..d87bcbc 100644 --- a/inc/support.h +++ b/inc/support.h @@ -101,7 +101,7 @@ public: void calculatePings (); // send modified pings to all the clients - void sendPings (edict_t *to); + void emitPings (edict_t *to); // installs the sendto function intreception void installSendTo (); diff --git a/inc/yapb.h b/inc/yapb.h index 0ac4681..0491555 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -579,7 +579,6 @@ struct Client { int ping; // when bot latency is enabled, client ping stored here int iconFlags[kGameMaxPlayers]; // flag holding chatter icons float iconTimestamp[kGameMaxPlayers]; // timers for chatter icons - bool pingUpdate; // update ping ? ClientNoise noise; }; diff --git a/src/linkage.cpp b/src/linkage.cpp index 18ad439..4913838 100644 --- a/src/linkage.cpp +++ b/src/linkage.cpp @@ -409,6 +409,7 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { if (game.is (GameFlags::HasFakePings) && cv_show_latency.int_ () == 2) { if (!util.isFakeClient (ent) && (ent->v.oldbuttons | ent->v.button | cmd->buttons) & IN_SCORE) { cmd->buttons &= ~IN_SCORE; + util.emitPings (ent); } } @@ -418,32 +419,18 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { dllapi.pfnCmdStart (ent, cmd, random_seed); }; - table->pfnUpdateClientData = [] (const struct edict_s *player, int sendweapons, struct clientdata_s *cd) { - auto ent = const_cast (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 *pm, int server) { // this is the player movement code clients run to predict things when the server can't update // them often enough (or doesn't want to). The server runs exactly the same function for // moving players. There is normally no distinction between them, else client-side prediction // wouldn't work properly (and it doesn't work that well, already...) - illum.setWorldModel (playerMove->physents[0].model); + illum.setWorldModel (pm->physents[0].model); if (game.is (GameFlags::Metamod)) { RETURN_META (MRES_IGNORED); } - dllapi.pfnPM_Move (playerMove, server); + dllapi.pfnPM_Move (pm, server); }; return HLTrue; } diff --git a/src/support.cpp b/src/support.cpp index 0a7b64d..003be9b 100644 --- a/src/support.cpp +++ b/src/support.cpp @@ -581,8 +581,6 @@ void BotSupport::calculatePings () { // store normal client ping client.ping = getPingBitmask (client.ent, loss, ping > 0 ? ping : rg.get (8, 16)); // getting player ping sometimes fails - client.pingUpdate = true; // force resend ping - ++numHumans; average.first += ping; @@ -620,13 +618,11 @@ void BotSupport::calculatePings () { else if (botPing > 70) { botPing = rg.get (30, 40); } - client.ping = getPingBitmask (client.ent, botLoss, botPing); - client.pingUpdate = true; // force resend ping } } -void BotSupport::sendPings (edict_t *to) { +void BotSupport::emitPings (edict_t *to) { MessageWriter msg; // missing from sdk @@ -636,10 +632,6 @@ void BotSupport::sendPings (edict_t *to) { if (!(client.flags & ClientFlags::Used) || client.ent == game.getLocalEntity ()) { continue; } - if (!client.pingUpdate) { - continue; - } - client.pingUpdate = false; // no ping, no fun if (!client.ping) {