Skip to content

Commit 91d1f1d

Browse files
committed
Fix for usehumananimations, sendprop optimize, anti stuck on players
1 parent 7ebdb2c commit 91d1f1d

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

src/mod/cond/reprogrammed.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace Mod::Cond::Reprogrammed
8282
// 0x50, // +0000 push eax
8383
// 0xff, 0x15, 0xff, 0xff, 0xff, 0xff, // +0001 call [<STUB> CBaseEntity::IsBot]
8484
// 0x83, 0xC4, 0x10, // +0007 add esp, 10h
85-
// 0x90, 0x90, // +000a nop nop
85+
// 0x84, 0xc0, // +000a test al, al
8686
// 0x0f, 0x85, 0xa5, 0x01, 0x00, 0x00, // +000c jnz +0x1a5
8787
// };
8888

@@ -118,9 +118,9 @@ namespace Mod::Cond::Reprogrammed
118118
buf[0x02] = 0x15;
119119
buf.SetDword(0x01 + 2, (uint32_t)&s_CBasePlayer_IsBot);
120120

121-
/* pad out extra space with NOPs */
122-
buf[0x0a] = 0x90;
123-
buf[0x0b] = 0x90;
121+
/* test result */
122+
buf[0x0a] = 0x84;
123+
buf[0x0b] = 0xc0;
124124

125125
/* invert the jump condition code */
126126
buf[0x0d] = 0x85;

src/mod/etc/unintended_class_weapon_improvements.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ namespace Mod::Etc::Unintended_Class_Weapon_Improvements
105105
}
106106

107107
owner->GetPlayerClass()->SetCustomModel(mod->properPlayerModel);
108+
owner->UpdateModel();
108109
mod->overridePlayerAnimClassApplied = true;
109110
owner->m_nRenderFX = 6;
110111
auto wearable_player = CreateCustomWeaponModelPlaceholder(owner, weapon, mod->oldPlayerModel);
@@ -177,6 +178,7 @@ namespace Mod::Etc::Unintended_Class_Weapon_Improvements
177178
if (mod->overridePlayerAnimClass != -1) {
178179
mod->overridePlayerAnimClassApplied = false;
179180
owner->GetPlayerClass()->SetCustomModel(mod->oldPlayerCustomModel.c_str());
181+
owner->UpdateModel();
180182
if (owner->IsAlive())
181183
owner->m_nRenderFX = 0;
182184
}

src/mod/perf/sendprop_optimize.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,7 @@ namespace Mod::Perf::SendProp_Optimize
12161216

12171217
DETOUR_DECL_STATIC(void, SV_ComputeClientPacks, int clientCount, CGameClient **clients, CFrameSnapshot *snapshot)
12181218
{
1219+
// Do not network dead bots and reduce update rate for their weapons
12191220
for (int i = 1; i <= gpGlobals->maxClients; i++) {
12201221
edict_t *edict = world_edict + i;
12211222
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
12441245
return;
12451246
}
12461247

1248+
// Synchronous compute first
12471249
for (int clientIndex = 0; clientIndex < clientCount; clientIndex ++) {
12481250
computedPackInfos[clientIndex] = false;
12491251
checkTransmitComplete[clientIndex] = false;
@@ -1264,6 +1266,10 @@ namespace Mod::Perf::SendProp_Optimize
12641266
int packWorkTaskCount = (int) threadPoolPackWork.get_thread_count();
12651267
CFrameSnapshotManager &snapmgr = g_FrameSnapshotManager;
12661268

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
12671273
threadPool.push_task([&](){
12681274
for (int clientIndex = 0; clientIndex < clientCount; clientIndex ++) {
12691275
auto client = clients[clientIndex];
@@ -1278,14 +1284,22 @@ namespace Mod::Perf::SendProp_Optimize
12781284

12791285
for (int i = 0; i < packWorkTaskCount; i++) {
12801286
threadPoolPackWork.push_task([&](int num){
1287+
entitiesWithNotUpdatedChangedProps[num].reserve(8);
1288+
entitiesWithNotUpdatedFullyChangedProps[num].reserve(2);
12811289
size_t workEntryCount = snapshot->m_nValidEntities/packWorkTaskCount+1;
12821290
PackWork_t *workEntities = (PackWork_t *) operator new[](workEntryCount * sizeof(PackWork_t));
12831291
size_t workEntitiesCount = 0;
12841292
for (int i = num; i < snapshot->m_nValidEntities; i += packWorkTaskCount) {
12851293
int idx = snapshot->m_pValidEntities[i];
12861294
auto edict = world_edict + idx;
1295+
// Don't update props for non networked entities
12871296
if ((edict->m_fStateFlags & FL_EDICT_DONTSEND) && ((CBaseEntity *)edict->GetUnknown())->FirstMoveChild() == nullptr
12881297
&& 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);
12891303
continue;
12901304
}
12911305
PackWork_t &work = workEntities[workEntitiesCount++];
@@ -1350,6 +1364,16 @@ namespace Mod::Perf::SendProp_Optimize
13501364
edict->m_fStateFlags &= ~(FL_FULL_EDICT_CHANGED|FL_EDICT_CHANGED);
13511365
}
13521366

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+
13531377
threadPool.wait_for_tasks();
13541378
threadPoolPackWork.wait_for_tasks();
13551379

src/mod/pop/ecattr_extensions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ namespace Mod::Pop::ECAttr_Extensions
267267
if (wearable != nullptr && wearable->GetCustomVariableBool<"humananimation">()) {
268268
int model_index = wearable->m_nModelIndexOverrides[0];
269269
bot->GetPlayerClass()->SetCustomModel(modelinfo->GetModelName(modelinfo->GetModel(model_index)), true);
270+
bot->UpdateModel();
270271
wearable->Remove();
271272
}
272273
}
@@ -1272,6 +1273,7 @@ namespace Mod::Pop::ECAttr_Extensions
12721273
wearable->SetModelIndexOverride(j, model_index);
12731274
}
12741275
bot->GetPlayerClass()->SetCustomModel(nullptr, true);
1276+
bot->UpdateModel();
12751277
wearable->SetCustomVariable("humananimation", Variant(true));
12761278
THINK_FUNC_SET(wearable, UpdateBodySkinPlayerWearable, gpGlobals->curtime);
12771279
}

src/mod/pop/popmgr_extensions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,7 @@ namespace Mod::Pop::PopMgr_Extensions
25112511
if (find->second != nullptr) {
25122512
int model_index = find->second->m_nModelIndexOverrides[0];
25132513
player->GetPlayerClass()->SetCustomModel(modelinfo->GetModelName(modelinfo->GetModel(model_index)), true);
2514+
player->UpdateModel();
25142515
find->second->Remove();
25152516
}
25162517
}

0 commit comments

Comments
 (0)