Skip to content

Commit

Permalink
Sven Co-op 5.26-rc1 support (closes #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Sep 4, 2024
1 parent 80fd672 commit 7de9533
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 74 deletions.
47 changes: 16 additions & 31 deletions src/SvenBXT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void SvenBXT_FindEngineStuff()

if (!g_engfuncs)
{
Sys_Printf("[hw so] Failed to get \"g_engfuncsExportedToDlls\".\n[hw dll] Sharing time to clients is not available.\n");
Sys_Printf("[hw so] Failed to get \"g_engfuncsExportedToDlls\".\n[Engine] Sharing time to clients is not available.\n");
}

if (!sv)
Expand Down Expand Up @@ -103,7 +103,17 @@ void SvenBXT_FindEngineStuff()

if (g_lpEngfuncs)
{
Sys_Printf("[hw dll] Found cl_enginefuncs at 0x%p.\n", g_lpEngfuncs);
Sys_Printf("[Engine] Found cl_enginefuncs at 0x%p.\n", g_lpEngfuncs);
SvenBXT_HookClient();
}
break;
case 1: // Sven-5.26-rc1
Sys_Printf("Searching cl_enginefuncs in Sven-5.26-rc1 pattern...\n");
g_lpEngfuncs = *reinterpret_cast<cl_enginefunc_t**>(reinterpret_cast<uintptr_t>(ClientDLL_Init) + 354);

if (g_lpEngfuncs)
{
Sys_Printf("[Engine] Found cl_enginefuncs at 0x%p.\n", g_lpEngfuncs);
SvenBXT_HookClient();
}
break;
Expand All @@ -126,10 +136,10 @@ void SvenBXT_FindEngineStuff()
gpGlobals = *reinterpret_cast<globalvars_t**>(reinterpret_cast<uintptr_t>(LoadThisDll) + 67);

if (g_engfuncs)
Sys_Printf("[hw dll] Found g_engfuncs at 0x%p.\n", g_engfuncs);
Sys_Printf("[Engine] Found g_engfuncs at 0x%p.\n", g_engfuncs);

if (gpGlobals)
Sys_Printf("[hw dll] Found gpGlobals at 0x%p.\n", gpGlobals);
Sys_Printf("[Engine] Found gpGlobals at 0x%p.\n", gpGlobals);
break;
}
});
Expand All @@ -143,37 +153,12 @@ void SvenBXT_FindEngineStuff()
switch (pattern - patterns::engine::Host_ClearMemory.cbegin())
{
default:
case 0: // HL-9920
Sys_Printf("Searching sv in HL-9920 pattern...\n");
sv = *reinterpret_cast<server_t**>(reinterpret_cast<uintptr_t>(Host_ClearMemory) + 0xA4);

if (sv)
{
Sys_Printf("[hw dll] Found sv at 0x%p.\n", sv);
}
break;
case 1: // HL-8684
Sys_Printf("Searching sv in HL-8684 pattern...\n");
sv = *reinterpret_cast<server_t**>(reinterpret_cast<uintptr_t>(Host_ClearMemory) + 0x5E);
if (sv)
{
Sys_Printf("[hw dll] Found sv at 0x%p.\n", sv);
}
break;
case 2: // HL-4554
Sys_Printf("Searching sv in HL-4554 pattern...\n");
sv = *reinterpret_cast<server_t**>(reinterpret_cast<uintptr_t>(Host_ClearMemory) + 0x5C);
if (sv)
{
Sys_Printf("[hw dll] Found sv at 0x%p.\n", sv);
}
break;
case 3: // Sven-5.25
case 0: // Sven-5.25
Sys_Printf("Searching sv in Sven-5.25 pattern...\n");
sv = *reinterpret_cast<server_t**>(reinterpret_cast<uintptr_t>(Host_ClearMemory) + 0x98);
if (sv)
{
Sys_Printf("[hw dll] Found sv at 0x%p.\n", sv);
Sys_Printf("[Engine] Found sv at 0x%p.\n", sv);
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SvenBXT.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ extern server_t* sv;
auto pattern = f##future_name.get(); \
if (ORIG_##future_name) \
{ \
Sys_Printf("[hw dll] Found " #future_name " at %p (using the %s pattern).\n", ORIG_##future_name, pattern->name()); \
Sys_Printf("[Engine] Found " #future_name " at %p (using the %s pattern).\n", ORIG_##future_name, pattern->name()); \
} \
else \
Sys_Printf("[hw dll] Could not find " #future_name ".\n"); \
Sys_Printf("[Engine] Could not find " #future_name ".\n"); \
}

#define SPTServerFind(future_name) \
Expand Down
60 changes: 19 additions & 41 deletions src/engine_patterns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,31 @@ namespace patterns
{
PATTERNS(CNihilanth_DyingThink,
"Sven-5.25",
"A1 ?? ?? ?? ?? 83 EC 74 F3 0F 10 00");


"A1 ?? ?? ?? ?? 83 EC 74 F3 0F 10 00",
"Sven-5.26",
"83 EC 6C A1 ?? ?? ?? ?? 53 56 8B F1 F3 0F 10 00 0F 5A C0 57 8B 46 ?? 51 C7 04 24 CD CC CC 3D F2 0F 58 05 ?? ?? ?? ??");
}

namespace engine
{
// STRINGS
// ../engine/cdll_int.c, line %d: could not link client DLL for HUD initialization
// joysupported
// HUD_GetStudioModelInterface
PATTERNS(ClientDLL_HudInit,
"HL-9920",
"A1 ?? ?? ?? ?? 85 C0 75 ?? 68 47 04 00 00", // + 0x4D
"HL-8684",
"55 8B EC E8 ?? ?? ?? ?? A1 ?? ?? ?? ?? 85 C0", // ClientDLL_CheckStudioInterface (+ 0x2A)
"HL-4554",
"E8 ?? ?? ?? ?? A1 ?? ?? ?? ?? 85 C0 74 ?? 8B 44 24 ??", // ClientDLL_CheckStudioInterface (+ 0x28)
"Sven-5.25",
"A1 ?? ?? ?? ?? 85 C0 75 ?? 68 ?? ?? ?? ?? E8 ?? ?? ?? ?? A1 ?? ?? ?? ??"
);

// STRINGS
// cl_dlls/client
// ScreenShake
// ScreenFade
PATTERNS(ClientDLL_Init,
"HL-9920",
"55 8B EC 81 EC 04 02 00 00 A1 ?? ?? ?? ?? 33 C5 89 45 ?? 68 ?? ?? ?? ?? 8D 85 ?? ?? ?? ??",
"HL-8684",
"55 8B EC 81 EC 00 02 00 00 68 ?? ?? ?? ?? 8D 85 ?? ?? ?? ?? 68",
"HL-4554",
"81 EC 00 04 00 00 8D 44 24 00 68 ?? 6D ?? ??",
"HL-3248",
"81 EC 00 04 00 00 8D 44 24 00 68 94 75 EB 01",
"Sven-5.25",
"81 EC 04 02 00 00 A1 ?? ?? ?? ?? 33 C4 89 84 24 ?? ?? ?? ?? 68 ?? ?? ?? ?? 8D 44 24 ?? 68 00 02 00 00"
"81 EC 04 02 00 00 A1 ?? ?? ?? ?? 33 C4 89 84 24 ?? ?? ?? ?? 68 ?? ?? ?? ?? 8D 44 24 ?? 68 00 02 00 00",
"Sven-5.26-rc1",
"81 EC 04 02 00 00 A1 ?? ?? ?? ?? 33 C4 89 84 24 ?? ?? ?? ?? 68 00 02 00 00 8D 44 24 ?? 6A 00 50 E8 ?? ?? ?? ?? 68 ?? ?? ?? ?? 8D 44 24 ?? 68 FF 01 00 00"
);

PATTERNS(GL_Begin2D, // a.k.a GLBeginHud
Expand All @@ -56,13 +52,9 @@ namespace patterns
"Sven-5.25",
"56 68 01 17 00 00 FF 15 ?? ?? ?? ?? 8B 35 ?? ?? ?? ?? FF D6 68 00 17 00 00");

// STRINGS
// Clearing memory
PATTERNS(Host_ClearMemory,
"HL-9920",
"55 8B EC E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 7D ?? 00 75 ?? 68 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 C4 04 E8 ?? ?? ?? ??",
"HL-8684",
"55 8B EC E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 8B 45 ?? 85 C0 75 ?? 68 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 C4 04 E8 ?? ?? ?? ?? E8 ?? ?? ?? ??",
"HL-4554",
"E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 8B 44 24 ?? 85 C0",
"Sven-5.25",
"E8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 7C 24 ?? 00 75 ??");

Expand All @@ -71,19 +63,15 @@ namespace patterns
"53 57 8B 7C 24 ?? 57 E8 ?? ?? ?? ?? 8B D8 83 C4 04 85 DB 75 ?? E8 ?? ?? ?? ??");

PATTERNS(Netchan_CreateFragments,
"HL-8684", "55 8B EC B8 14 00 01 00 E8 ?? ?? ?? ?? 53",
"Sven-5.25", "B8 1C 00 04 00");
"Sven-5.25", "B8 1C 00 04 00 E8 ?? ?? ?? ?? A1 ?? ?? ?? ?? 33 C4 89 84 24 ?? ?? ?? ?? 55 8B AC 24 ?? ?? ?? ??");

PATTERNS(SZ_Write,
"HL-8684", "55 8B EC 56 8B 75 ?? 85 F6 75 ?? 8B 45 ??",
"Sven-5.25", "8B 4C 24 ?? 85 C9 75 ?? 56");

PATTERNS(SZ_GetSpace,
"HL-8684", "55 8B EC 56 8B 75 ?? 57 8B 7D ?? 8B 4E ??",
"Sven-5.25", "56 8B 74 24 08 57 8B 7C 24 10 8B 4E 10 8B 56 0C 8D 04 39 3B C2 0F 8E ?? ?? ?? ?? F6 46 04 01 75 2E 8B 06 85 D2 75 11 85 C0 75 05 B8 ?? ?? ?? ?? 50 68 ?? ?? ?? ?? EB 0F 85 C0 75 05 B8");

PATTERNS(Mod_LoadTextures,
"HL-8684", "55 8B EC B8 C0 53 05 00",
"Sven-5.25", "83 EC 74 A1 ?? ?? ?? ?? 33 C4 89 44 24 ?? 53 8B 5C 24 ??");

PATTERNS(SCR_BeginLoadingPlaque,
Expand All @@ -99,22 +87,12 @@ namespace patterns
"?? ?? ?? ?? ?? ?? ?? ?? 30 83 3D ?? ?? ?? ?? 00 53 55 56 57 0F 84 ?? ?? ?? ??");

PATTERNS(S_StartDynamicSound,
"HL-9920",
"55 8B EC 83 EC 5C A1 ?? ?? ?? ?? 33 C5 89 45 ?? 83 3D ?? ?? ?? ?? 00 8B 45 ?? 8B 4D ??",
"HL-8684",
"55 8B EC 83 EC 48 A1 ?? ?? ?? ?? 53",
"HL-4554",
"?? ?? ?? ?? ?? ?? ?? ?? 53 55 56 85 C0 57 C7 44 24 ?? 00 00 00 00 0F 84 ?? ?? ?? ??", // BXT steals my S_StartDynamicSound :o
"Sven-5.25",
"83 EC 58 A1 ?? ?? ?? ?? 33 C4 89 44 24 ?? 8B 44 24 ??");

PATTERNS(S_StartStaticSound,
"HL-9920",
"55 8B EC 83 EC 50 A1 ?? ?? ?? ?? 33 C5 89 45 ?? 57",
"HL-8684",
"55 8B EC 83 EC 44 53 56 57 8B 7D ?? 85 FF",
"HL-4554",
"83 EC 44 53 55 8B 6C 24 ?? 56 85 ED");
"Sven-5.25",
"83 EC 4C A1 ?? ?? ?? ?? 33 C4 89 44 24 ?? 57 8B 7C 24 ?? 85 FF 0F 84 ?? ?? ?? ?? 80 3F 2A 55 56");
}
}

Expand Down

0 comments on commit 7de9533

Please sign in to comment.