Skip to content

Commit

Permalink
fix: update Linux offsets in renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
NeKzor committed Oct 25, 2023
1 parent 1adadeb commit cbdc056
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
26 changes: 5 additions & 21 deletions src/Features/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,39 +1142,23 @@ void Renderer::Init(void **videomode) {
#else
if (sar.game->Is(SourceGame_Portal2)) {
SND_RecordBuffer = (void (*)())Memory::Scan(engine->Name(), "80 3D ? ? ? ? 00 75 07 C3 ? ? ? ? ? ? 55 89 E5 57 56 53 83 EC 1C E8 ? ? ? ? 84 C0 0F 85 ? ? ? ?");
} else if (sar.game->Is(SourceGame_PortalReloaded) || sar.game->Is(SourceGame_PortalStoriesMel)) {
SND_RecordBuffer = (void (*)())Memory::Scan(engine->Name(), "55 89 E5 57 56 53 83 EC 3C 65 A1 ? ? ? ? 89 45 E4 31 C0 E8 ? ? ? ? 84 C0 75 1B");
} else { // Pre-update engine
SND_RecordBuffer = (void (*)())Memory::Scan(engine->Name(), "55 89 E5 57 56 53 83 EC 2C E8 ? ? ? ? 84 C0 75 0E 8D 65 F4 5B 5E 5F 5D C3");
}

if (sar.game->Is(SourceGame_Portal2)) {
g_movieInfo = *(MovieInfo_t **)((uintptr_t)SND_RecordBuffer + 2);
} else if (sar.game->Is(SourceGame_PortalReloaded) || sar.game->Is(SourceGame_PortalStoriesMel)) {
SND_RecordBuffer = (void (*)())Memory::Scan(engine->Name(), "55 89 E5 57 56 53 83 EC 3C 65 A1 ? ? ? ? 89 45 E4 31 C0 E8 ? ? ? ? 84 C0 75 1B");
uintptr_t SND_IsRecording = Memory::Read((uintptr_t)SND_RecordBuffer + 21);
g_movieInfo = *(MovieInfo_t **)(SND_IsRecording + 2);
} else { // Pre-update engine
SND_RecordBuffer = (void (*)())Memory::Scan(engine->Name(), "55 89 E5 57 56 53 83 EC 2C E8 ? ? ? ? 84 C0 75 0E 8D 65 F4 5B 5E 5F 5D C3");
uintptr_t SND_IsRecording = Memory::Read((uintptr_t)SND_RecordBuffer + 10);
g_movieInfo = *(MovieInfo_t **)(SND_IsRecording + 11);
}
#endif

g_RecordBufferHook.SetFunc(SND_RecordBuffer);

#ifndef _WIN32
if (sar.game->Is(SourceGame_Portal2)) {
uint32_t fn = (uint32_t)SND_RecordBuffer;
uint32_t base = fn + 11 + *(uint32_t *)(fn + 13);
g_snd_linear_count = (int *)(base + *(uint32_t *)(fn + 49));
g_snd_p = (int **)(base + *(uint32_t *)(fn + 96));
g_snd_vol = (int *)(base + *(uint32_t *)(fn + 102));
} else
#endif
{
g_snd_linear_count = *(int **)((uintptr_t)SND_RecordBuffer + Offsets::snd_linear_count);
g_snd_p = *(int ***)((uintptr_t)SND_RecordBuffer + Offsets::snd_p);
g_snd_vol = *(int **)((uintptr_t)SND_RecordBuffer + Offsets::snd_vol);
}
g_snd_linear_count = *(int **)((uintptr_t)SND_RecordBuffer + Offsets::snd_linear_count);
g_snd_p = *(int ***)((uintptr_t)SND_RecordBuffer + Offsets::snd_p);
g_snd_vol = *(int **)((uintptr_t)SND_RecordBuffer + Offsets::snd_vol);

Command::Hook("startmovie", &startmovie_cbk, startmovie_origCbk);
Command::Hook("endmovie", &endmovie_cbk, endmovie_origCbk);
Expand Down
9 changes: 6 additions & 3 deletions src/OffsetsData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ OFFSET_DEFAULT(VideoMode_Create, 88, 103)
OFFSET_DEFAULT(videomode, 35, 178)
OFFSET_EMPTY(VID_ProcessMovieFrame_1)
OFFSET_EMPTY(VID_ProcessMovieFrame_2)
OFFSET_DEFAULT(snd_linear_count, 63, 57)
OFFSET_DEFAULT(snd_p, 98, 65)
OFFSET_DEFAULT(snd_vol, 108, 71)
OFFSET_DEFAULT(snd_linear_count, 63, 69)
OFFSET_DEFAULT(snd_p, 98, 116)
OFFSET_DEFAULT(snd_vol, 108, 122)
OFFSET_DEFAULT(StartTouch, 102, 103)
OFFSET_DEFAULT(FindMaterial, 82, 82)
OFFSET_DEFAULT(CreateProceduralTexture, 91, 91)
Expand Down Expand Up @@ -348,3 +348,6 @@ OFFSET_LINMOD(StartDrawing, 692)
OFFSET_LINMOD(FinishDrawing, 627)
OFFSET_LINMOD(OnGameOverlayActivated, 152)
OFFSET_LINMOD(FontManager, 11)
OFFSET_LINMOD(snd_linear_count, 57)
OFFSET_LINMOD(snd_p, 65)
OFFSET_LINMOD(snd_vol, 71)

0 comments on commit cbdc056

Please sign in to comment.