@@ -1216,6 +1216,7 @@ namespace Mod::Perf::SendProp_Optimize
1216
1216
1217
1217
DETOUR_DECL_STATIC (void , SV_ComputeClientPacks, int clientCount, CGameClient **clients, CFrameSnapshot *snapshot)
1218
1218
{
1219
+ // Do not network dead bots and reduce update rate for their weapons
1219
1220
for (int i = 1 ; i <= gpGlobals->maxClients ; i++) {
1220
1221
edict_t *edict = world_edict + i;
1221
1222
if (!edict->IsFree () /* && edict->m_fStateFlags & (FL_EDICT_CHANGED | FL_FULL_EDICT_CHANGED)*/ && !(edict->m_fStateFlags & FL_EDICT_DONTSEND)) {
@@ -1244,6 +1245,7 @@ namespace Mod::Perf::SendProp_Optimize
1244
1245
return ;
1245
1246
}
1246
1247
1248
+ // Synchronous compute first
1247
1249
for (int clientIndex = 0 ; clientIndex < clientCount; clientIndex ++) {
1248
1250
computedPackInfos[clientIndex] = false ;
1249
1251
checkTransmitComplete[clientIndex] = false ;
@@ -1264,6 +1266,10 @@ namespace Mod::Perf::SendProp_Optimize
1264
1266
int packWorkTaskCount = (int ) threadPoolPackWork.get_thread_count ();
1265
1267
CFrameSnapshotManager &snapmgr = g_FrameSnapshotManager;
1266
1268
1269
+ std::vector<edict_t *> *entitiesWithNotUpdatedChangedProps = new std::vector<edict_t *>[packWorkTaskCount];
1270
+ std::vector<edict_t *> *entitiesWithNotUpdatedFullyChangedProps = new std::vector<edict_t *>[packWorkTaskCount];
1271
+
1272
+ // Threaded networking starts here
1267
1273
threadPool.push_task ([&](){
1268
1274
for (int clientIndex = 0 ; clientIndex < clientCount; clientIndex ++) {
1269
1275
auto client = clients[clientIndex];
@@ -1278,14 +1284,22 @@ namespace Mod::Perf::SendProp_Optimize
1278
1284
1279
1285
for (int i = 0 ; i < packWorkTaskCount; i++) {
1280
1286
threadPoolPackWork.push_task ([&](int num){
1287
+ entitiesWithNotUpdatedChangedProps[num].reserve (8 );
1288
+ entitiesWithNotUpdatedFullyChangedProps[num].reserve (2 );
1281
1289
size_t workEntryCount = snapshot->m_nValidEntities /packWorkTaskCount+1 ;
1282
1290
PackWork_t *workEntities = (PackWork_t *) operator new [](workEntryCount * sizeof (PackWork_t));
1283
1291
size_t workEntitiesCount = 0 ;
1284
1292
for (int i = num; i < snapshot->m_nValidEntities ; i += packWorkTaskCount) {
1285
1293
int idx = snapshot->m_pValidEntities [i];
1286
1294
auto edict = world_edict + idx;
1295
+ // Don't update props for non networked entities
1287
1296
if ((edict->m_fStateFlags & FL_EDICT_DONTSEND) && ((CBaseEntity *)edict->GetUnknown ())->FirstMoveChild () == nullptr
1288
1297
&& snapmgr.UsePreviouslySentPacket (snapshot, idx, edict->m_NetworkSerialNumber )) {
1298
+
1299
+ if (edict->m_fStateFlags & FL_FULL_EDICT_CHANGED)
1300
+ entitiesWithNotUpdatedFullyChangedProps->push_back (edict);
1301
+ else if (edict->m_fStateFlags & FL_EDICT_CHANGED)
1302
+ entitiesWithNotUpdatedChangedProps->push_back (edict);
1289
1303
continue ;
1290
1304
}
1291
1305
PackWork_t &work = workEntities[workEntitiesCount++];
@@ -1350,6 +1364,16 @@ namespace Mod::Perf::SendProp_Optimize
1350
1364
edict->m_fStateFlags &= ~(FL_FULL_EDICT_CHANGED|FL_EDICT_CHANGED);
1351
1365
}
1352
1366
1367
+ for (int i = 0 ; i < packWorkTaskCount; i++) {
1368
+ for (auto edict : entitiesWithNotUpdatedChangedProps[i]) {
1369
+ edict->m_fStateFlags |= FL_EDICT_CHANGED;
1370
+ }
1371
+
1372
+ for (auto edict : entitiesWithNotUpdatedFullyChangedProps[i]) {
1373
+ edict->m_fStateFlags |= (FL_EDICT_CHANGED | FL_FULL_EDICT_CHANGED);
1374
+ }
1375
+ }
1376
+
1353
1377
threadPool.wait_for_tasks ();
1354
1378
threadPoolPackWork.wait_for_tasks ();
1355
1379
0 commit comments