@@ -235,6 +235,47 @@ static void __declspec(naked) HOOK_CVisibilityPlugins_RenderWeaponPedsForPC()
235235 }
236236}
237237
238+ // ////////////////////////////////////////////////////////////////////////////////////////
239+ //
240+ // CWaterLevel::TestLineAgainstWater
241+ //
242+ // Limit the values to world bounds, because the water level does not exceed it.
243+ //
244+ // ////////////////////////////////////////////////////////////////////////////////////////
245+ static void CLAMP_CWaterLevel_TestLineAgainstWater (float values[6 ])
246+ {
247+ for (int i = 0 ; i < 6 ; ++i)
248+ values[i] = Clamp (-3000 .0f , values[i], 3000 .0f );
249+ }
250+
251+ #define HOOKPOS_CWaterLevel_TestLineAgainstWater 0x6E61B0
252+ #define HOOKSIZE_CWaterLevel_TestLineAgainstWater 10
253+ static constexpr DWORD CONTINUE_CWaterLevel_TestLineAgainstWater = 0x6E61BA ;
254+ static void _declspec (naked) HOOK_CWaterLevel_TestLineAgainstWater()
255+ {
256+ MTA_VERIFY_HOOK_LOCAL_SIZE;
257+
258+ __asm
259+ {
260+ // [esp+4] from.x
261+ // [esp+8] from.y
262+ // [esp+12] from.z
263+ // [esp+16] to.x
264+ // [esp+20] to.y
265+ // [esp+24] to.z
266+ pushad
267+ lea eax, [esp+32 +4 ]
268+ push eax
269+ call CLAMP_CWaterLevel_TestLineAgainstWater
270+ add esp, 4
271+ popad
272+
273+ fld [esp+0Ch]
274+ sub esp, 88h
275+ jmp CONTINUE_CWaterLevel_TestLineAgainstWater
276+ }
277+ }
278+
238279// ////////////////////////////////////////////////////////////////////////////////////////
239280//
240281// CMultiplayerSA::InitHooks_Weapons
@@ -248,4 +289,5 @@ void CMultiplayerSA::InitHooks_Weapons()
248289 EZHookInstall (CShotInfo_Update);
249290 EZHookInstall (Fx_AddBulletImpact);
250291 EZHookInstall (CVisibilityPlugins_RenderWeaponPedsForPC);
292+ EZHookInstall (CWaterLevel_TestLineAgainstWater);
251293}
0 commit comments