bot: switch look/body angles updates to thread worker
build: msvc projects now again targets msvc by default
This commit is contained in:
parent
52bfac2b09
commit
5ce2032acd
8 changed files with 59 additions and 35 deletions
|
|
@ -412,7 +412,9 @@ void BotSupport::updateClients () {
|
|||
}
|
||||
|
||||
int BotSupport::getPingBitmask (edict_t *ent, int loss, int ping) {
|
||||
// this function generats bitmask for SVC_PINGS engine message. See SV_EmitPings from engine for details
|
||||
// this function generates bitmask for SVC_PINGS engine message
|
||||
// see:
|
||||
// https://github.com/dreamstalker/rehlds/blob/a680f18ee1e7eb8c39fbdc45682163ca9477d783/rehlds/engine/sv_main.cpp#L4590
|
||||
|
||||
const auto emit = [] (int s0, int s1, int s2) {
|
||||
return (s0 & (cr::bit (s1) - 1)) << s2;
|
||||
|
|
@ -443,6 +445,16 @@ void BotSupport::syncCalculatePings () {
|
|||
int ping, loss;
|
||||
engfuncs.pfnGetPlayerStats (client.ent, &ping, &loss);
|
||||
|
||||
// @note: for those who asking on a email, we CAN call pfnGetPlayerStats hl-engine function in a separate thread
|
||||
// since the function doesn't modify anything inside engine, so race-condition and crash isn't viable situation
|
||||
// it's just fills ping and loss from engine structures, the only way to cause crash in separate thread
|
||||
// is to call it with a invalid ``client`` pointer (on goldsrc), thus causing Con_Printf which is not compatible with
|
||||
// multi-threaded environment
|
||||
//
|
||||
// see:
|
||||
// https://github.com/dreamstalker/rehlds/blob/a680f18ee1e7eb8c39fbdc45682163ca9477d783/rehlds/engine/pr_cmds.cpp#L2735C15-L2735C32
|
||||
// https://github.com/fwgs/xash3d-fwgs/blob/f5b9826fd9bbbdc5293c1ff522de11ce28d3c9f2/engine/server/sv_game.c#L4443
|
||||
|
||||
// store normal client ping
|
||||
client.ping = getPingBitmask (client.ent, loss, ping > 0 ? ping : rg.get (8, 16)); // getting player ping sometimes fails
|
||||
++numHumans;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue