Merge pull request #92 from Rackover/skip_specops_entities

Skip specops entities
This commit is contained in:
Dss0 2021-07-28 23:18:12 +02:00 committed by GitHub
commit f7ab9896f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 1 deletions

View File

@ -380,6 +380,34 @@ namespace Components
} }
} }
bool QuickPatch::IsDynClassnameStub(char* a1)
{
auto version = Zones::GetEntitiesZoneVersion();
if (version >= VERSION_LATEST_CODO)
{
for (auto i = 0; i < Game::spawnVars->numSpawnVars; i++)
{
char** kvPair = Game::spawnVars->spawnVars[i];
auto key = kvPair[0];
auto val = kvPair[1];
bool isSpecOps = strncmp(key, "script_specialops", 17) == 0;
bool isSpecOpsOnly = val[0] == '1' && val[1] == '\0';
if (isSpecOps && isSpecOpsOnly)
{
// This will prevent spawning of any entity that contains "script_specialops: '1'"
// It removes extra hitboxes / meshes on 461+ CODO multiplayer maps
return true;
}
}
}
// Passthrough to the game's own IsDynClassname
return Utils::Hook::Call<bool(char*)>(0x444810)(a1);
}
QuickPatch::QuickPatch() QuickPatch::QuickPatch()
{ {
QuickPatch::FrameTime = 0; QuickPatch::FrameTime = 0;
@ -397,6 +425,9 @@ namespace Components
ntdll.InvokePascal<void>("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data); ntdll.InvokePascal<void>("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data);
}); });
// Filtering any mapents that is intended for Spec:Ops gamemode (CODO) and prevent them from spawning
Utils::Hook(0x5FBD6E, QuickPatch::IsDynClassnameStub, HOOK_CALL).install()->quick();
// bounce dvar // bounce dvar
sv_enableBounces = Game::Dvar_RegisterBool("sv_enableBounces", false, Game::DVAR_FLAG_REPLICATED, "Enables bouncing on the server"); sv_enableBounces = Game::Dvar_RegisterBool("sv_enableBounces", false, Game::DVAR_FLAG_REPLICATED, "Enables bouncing on the server");
Utils::Hook(0x4B1B2D, QuickPatch::BounceStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x4B1B2D, QuickPatch::BounceStub, HOOK_JUMP).install()->quick();

View File

@ -47,5 +47,6 @@ namespace Components
static void PlayerCollisionStub(); static void PlayerCollisionStub();
static Game::dvar_t* g_playerEjection; static Game::dvar_t* g_playerEjection;
static void PlayerEjectionStub(); static void PlayerEjectionStub();
static bool IsDynClassnameStub(char* a1);
}; };
} }

View File

@ -4,6 +4,7 @@
namespace Components namespace Components
{ {
int Zones::ZoneVersion; int Zones::ZoneVersion;
int Zones::EntitiesVersion;
int Zones::FxEffectIndex; int Zones::FxEffectIndex;
char* Zones::FxEffectStrings[64]; char* Zones::FxEffectStrings[64];
@ -2561,6 +2562,8 @@ namespace Components
int Zones::LoadMapEnts(bool atStreamStart, Game::MapEnts* buffer, int size) int Zones::LoadMapEnts(bool atStreamStart, Game::MapEnts* buffer, int size)
{ {
EntitiesVersion = Zones::Version();
if (Zones::Version() >= 446) if (Zones::Version() >= 446)
{ {
size /= 44; size /= 44;

View File

@ -24,9 +24,12 @@ namespace Components
static int Version() { return Zones::ZoneVersion; }; static int Version() { return Zones::ZoneVersion; };
static int GetEntitiesZoneVersion() { return Zones::EntitiesVersion; };
private: private:
static int ZoneVersion; static int ZoneVersion;
static int EntitiesVersion;
static int FxEffectIndex; static int FxEffectIndex;
static char* FxEffectStrings[64]; static char* FxEffectStrings[64];