From af9952e3da1728e453161c8c72a49e49ff194d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Troch?= Date: Sat, 21 Sep 2024 21:15:55 +0200 Subject: [PATCH] Add missing func_vehicle sound client side event Fixes https://github.com/ValveSoftware/halflife/issues/3746 --- CHANGELOG.md | 1 + FULL_UPDATED_CHANGELOG.md | 1 + cl_dll/ev_hldm.cpp | 60 +++++++++++++++++++++++++++++++++++++++ cl_dll/ev_hldm.h | 1 + cl_dll/hl/hl_events.cpp | 1 + 5 files changed, 64 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe15c700..9f184cf5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Bug fixes +* Added missing client side event for `func_vehicle` sounds * Link Linux binaries with `-Wl` and `--no-undefined` flags to avoid situations where something was referenced but wasn't added in the build (Thanks a1batross) ## Changes in V1.1.0 diff --git a/FULL_UPDATED_CHANGELOG.md b/FULL_UPDATED_CHANGELOG.md index 2d6f8d475..19387a410 100644 --- a/FULL_UPDATED_CHANGELOG.md +++ b/FULL_UPDATED_CHANGELOG.md @@ -293,6 +293,7 @@ Fixes for bugs introduced in beta builds are not included in this list. * Prevent breakables from spawning multiple items when destroyed by gunfire and explosives at the same time (Thanks Oxofemple.) * Added cvar `sv_allowbunnyhopping` to control whether the bunny hopping limiter is enabled (halflife issue [#11](https://github.com/ValveSoftware/halflife/issues/11)) * Added `sv_load_all_maps` & `sv_stop_loading_all_maps` to help automate node graph generation +* Added missing client side event for `func_vehicle` sounds ## Code cleanup diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 76549efcb..b5f3b7eac 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1612,6 +1612,66 @@ void EV_TrainPitchAdjust(event_args_t* args) } } +void EV_VehiclePitchAdjust(event_args_t* args) +{ + int idx; + Vector origin; + + unsigned short us_params; + int noise; + float m_flVolume; + int pitch; + bool stop; + + char sz[256]; + + idx = args->entindex; + + VectorCopy(args->origin, origin); + + us_params = (unsigned short)args->iparam1; + stop = 0 != args->bparam1; + + m_flVolume = (float)(us_params & 0x003f) / 40.0; + noise = (int)(((us_params) >> 12) & 0x0007); + pitch = (int)(10.0 * (float)((us_params >> 6) & 0x003f)); + + switch (noise) + { + case 1: + strcpy(sz, "plats/vehicle1.wav"); + break; + case 2: + strcpy(sz, "plats/vehicle2.wav"); + break; + case 3: + strcpy(sz, "plats/vehicle3.wav"); + break; + case 4: + strcpy(sz, "plats/vehicle4.wav"); + break; + case 5: + strcpy(sz, "plats/vehicle6.wav"); + break; + case 6: + strcpy(sz, "plats/vehicle7.wav"); + break; + default: + // no sound + strcpy(sz, ""); + return; + } + + if (stop) + { + gEngfuncs.pEventAPI->EV_StopSound(idx, CHAN_STATIC, sz); + } + else + { + gEngfuncs.pEventAPI->EV_PlaySound(idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch); + } +} + bool EV_TFC_IsAllyTeam(int iTeam1, int iTeam2) { return false; diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index db841fd3b..ac0d31e83 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -35,3 +35,4 @@ void EV_SnarkFire(event_args_t* args); void EV_TrainPitchAdjust(event_args_t* args); +void EV_VehiclePitchAdjust(event_args_t* args); diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index f2bf12292..b609aa89d 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -42,6 +42,7 @@ void Game_HookEvents() gEngfuncs.pfnHookEvent("events/gauss.sc", EV_FireGauss); gEngfuncs.pfnHookEvent("events/gaussspin.sc", EV_SpinGauss); gEngfuncs.pfnHookEvent("events/train.sc", EV_TrainPitchAdjust); + gEngfuncs.pfnHookEvent("events/vehicle.sc", EV_VehiclePitchAdjust); gEngfuncs.pfnHookEvent("events/crowbar.sc", EV_Crowbar); gEngfuncs.pfnHookEvent("events/crossbow1.sc", EV_FireCrossbow); gEngfuncs.pfnHookEvent("events/crossbow2.sc", EV_FireCrossbow2);