Skip to content

Commit

Permalink
Support legacy engine (#63)
Browse files Browse the repository at this point in the history
* Add support to the pre-HL25 engine

* Try to improve actions

* Use GITHUB_REF_NAME

* Update metahook submodule

* Try to fix action

* Try again

* Try again

* Add branch name
  • Loading branch information
LAGonauta authored Dec 12, 2023
1 parent bc2f854 commit 0295b98
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: Get branch name
run: echo "BranchName=$env:GITHUB_REF_NAME" >> $env:GITHUB_ENV

- name: Get commit hash
run: echo "CommitHash=$(git rev-parse --short=7 HEAD)" >> $env:GITHUB_ENV

- name: Get commit count
run: echo "CommitCount=$(git rev-list --count master)" >> $env:GITHUB_ENV
run: echo "CommitCount=$(git rev-list --count ${{env.BranchName}})" >> $env:GITHUB_ENV

- name: Get current date
run: echo "CurrentDate=$(date +'%Y-%m-%d')" >> $env:GITHUB_ENV
Expand Down Expand Up @@ -82,8 +85,8 @@ jobs:

- name: Download MetaHook
run: |
Invoke-WebRequest -Uri https://github.com/hzqst/MetaHookSv/releases/download/v20231124b/MetaHookSv-windows-x86.zip -OutFile MetaHook.zip
if (!(Get-FileHash ./MetaHook.zip).Hash.Equals("4B22EA01E0B025CAEABD7301FEF52FA05A807263B8B761760FA3AAD7E1D2EA23")) {
Invoke-WebRequest -Uri https://github.com/hzqst/MetaHookSv/releases/download/v20231210a/MetaHookSv-windows-x86.zip -OutFile MetaHook.zip
if (!(Get-FileHash ./MetaHook.zip).Hash.Equals("E5F3DB974C0D00241125757A6CE83E1BCF114D156E8E3E27C7622CAE7DDE36A1")) {
Exit -1
}
Expand-Archive ./MetaHook.zip -DestinationPath MetaHook/
Expand All @@ -93,7 +96,7 @@ jobs:

- uses: actions/upload-artifact@v3
with:
name: '${{env.CurrentDate}}_MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}'
name: '${{env.CurrentDate}}_MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}-${{env.BranchName}}'
path: Output/

- name: Make Release folder
Expand All @@ -103,16 +106,16 @@ jobs:
uses: papeloto/action-zip@v1
with:
files: 'Output/'
dest: 'Release/${{env.CurrentDate}}_MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}.zip'
dest: 'Release/${{env.CurrentDate}}_MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}-${{env.BranchName}}.zip'

- name: Make copy for static download URL
run: copy 'Release/${{env.CurrentDate}}_MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}.zip' 'Release/MetaAudio.zip'
run: copy 'Release/${{env.CurrentDate}}_MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}-${{env.BranchName}}.zip' 'Release/MetaAudio.zip'

- name: GitHub pre-release
uses: 'marvinpinto/action-automatic-releases@latest'
with:
repo_token: '${{secrets.GITHUB_TOKEN}}'
automatic_release_tag: 'latest'
prerelease: true
title: '[${{env.CurrentDate}}] MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}'
title: '[${{env.CurrentDate}}] MetaAudio-${{env.CommitCount}}@${{env.CommitHash}}-${{env.BranchName}}'
files: "Release/*"
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ jobs:

- name: Download MetaHook
run: |
Invoke-WebRequest -Uri https://github.com/hzqst/MetaHookSv/releases/download/v20231124b/MetaHookSv-windows-x86.zip -OutFile MetaHook.zip
if (!(Get-FileHash ./MetaHook.zip).Hash.Equals("4B22EA01E0B025CAEABD7301FEF52FA05A807263B8B761760FA3AAD7E1D2EA23")) {
Invoke-WebRequest -Uri https://github.com/hzqst/MetaHookSv/releases/download/v20231210a/MetaHookSv-windows-x86.zip -OutFile MetaHook.zip
if (!(Get-FileHash ./MetaHook.zip).Hash.Equals("E5F3DB974C0D00241125757A6CE83E1BCF114D156E8E3E27C7622CAE7DDE36A1")) {
Exit -1
}
Expand-Archive ./MetaHook.zip -DestinationPath MetaHook/
Expand Down
2 changes: 1 addition & 1 deletion externals/MetaHookSv
28 changes: 17 additions & 11 deletions src/snd_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void S_FillAddress()

if (!ctx.branch_succ)
{
Sig_NotFound("SND_Spatialize_branch_succ");
// if not found, we will fallback to the old method at the end
}

g_pMetaHookAPI->DisasmRanges(ctx.branch_succ, 0x100, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context)
Expand Down Expand Up @@ -617,7 +617,7 @@ void S_FillAddress()
}, 0, &ctx);

Sig_FuncNotFound(cszrawsentences);
Sig_FuncNotFound(rgpszrawsentence);
// if rgpszrawsentence is not found we will fallback to the old way
}

if (1)
Expand Down Expand Up @@ -842,27 +842,33 @@ void S_FillAddress()
Sig_AddrNotFound(cl_viewentity);

gAudEngine.cl_viewentity = *(int**)((ULONG_PTR)addr + 2);
}

if (!gAudEngine.cl_num_entities)
{
//idk why but cl_num_entities always be at &cl_viewentity + sizeof(uintptr_t) * 3 no matter in Sven or in HL
gAudEngine.cl_num_entities = gAudEngine.cl_viewentity + 3;
}

//gAudEngine.cl_parsecount = gAudEngine.cl_viewentity - (0x1789C8 / 4);
//gAudEngine.cl_servercount = gAudEngine.cl_parsecount - 2;
//gAudEngine.cl_waterlevel = gAudEngine.cl_servercount + 0x450 / 4;
if (!gAudEngine.cl_parsecount)
{
gAudEngine.cl_parsecount = gAudEngine.cl_viewentity - (0x1789C8 / 4);
gAudEngine.cl_servercount = gAudEngine.cl_parsecount - 2;
gAudEngine.cl_waterlevel = gAudEngine.cl_servercount + 0x450 / 4;
}

addr = (ULONG_PTR)Search_Pattern_From_Size((void*)gEngfuncs.GetClientTime, 0x20, "\xDD\x05");
Sig_AddrNotFound("cl_time");
gAudEngine.cl_time = (decltype(gAudEngine.cl_time))*(ULONG_PTR*)(addr + 2);
gAudEngine.cl_oldtime = (decltype(gAudEngine.cl_oldtime))(gAudEngine.cl_time + 1);

#define CL_WATERLEVEL_SIG "\x83\x3D\x2A\x2A\x2A\x2A\x02\xA1\x2A\x2A\x2A\x2A\x2A\x2A\x85\xC0"
addr = (ULONG_PTR)Search_Pattern(CL_WATERLEVEL_SIG);
Sig_AddrNotFound("cl_waterlevel");
gAudEngine.cl_waterlevel = (decltype(gAudEngine.cl_waterlevel))*(ULONG_PTR*)(addr + 2);

// gAudEngine.cl_time = (double *)(gAudEngine.cl_waterlevel + 11);
// gAudEngine.cl_oldtime = gAudEngine.cl_time + 1;
if (!gAudEngine.cl_waterlevel)
{
addr = (ULONG_PTR)Search_Pattern(CL_WATERLEVEL_SIG);
Sig_AddrNotFound("cl_waterlevel");
gAudEngine.cl_waterlevel = (decltype(gAudEngine.cl_waterlevel)) * (ULONG_PTR*)(addr + 2);
}

if (!gAudEngine.cszrawsentences)
{
Expand Down

0 comments on commit 0295b98

Please sign in to comment.