Skip to content

Commit 95e0752

Browse files
authored
Fix client-side createExplosion ignoring makeSound and camShake parameters (#4869)
#### Summary Make client-side `createExplosion` honour the `makeSound` and `camShake` arguments again. #### Motivation User report: since 1.7, client `createExplosion(..., makeSound, camShake, ...)` ignores those parameters; explosions always play sound and shake the camera with default strength. Caused by #4341, which routed script-driven explosions through a path that re-broadcasts them via the server and drops the script's arguments along the way. #### Test plan - `makeSound=false, camShake=0`: silent, no shake. - `makeSound=true, camShake=1.5`: sound + brief shake. - server API (no sound/shake params): unchanged -- still has sound + shake. Engine-side explosions (grenades, rockets, vehicle blow-ups) behave unchanged. #### Checklist * [x] Your code should follow the [coding guidelines](https://wiki.multitheftauto.com/index.php?title=Coding_guidelines). * [x] Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.
1 parent 9e1a38c commit 95e0752

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Client/mods/deathmatch/logic/CClientExplosionManager.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,20 @@ CExplosion* CClientExplosionManager::Create(eExplosionType explosionType, CVecto
211211
}
212212
else if (!pCreator)
213213
{
214+
// Fire onClientExplosion for script-driven createExplosion() calls without a
215+
// creator. We can't reuse Hook_ExplosionCreation here: when it sees the local
216+
// player as responsible it routes the explosion through SendExplosionSync and
217+
// the server-replayed copy uses default makeSound/camShake, ignoring the
218+
// script's arguments (regression from PR #4341).
214219
CClientPlayer* localPlayer = m_pManager->GetPlayerManager()->GetLocalPlayer();
215220
if (localPlayer)
216221
{
217-
bool allowExplosion = Hook_ExplosionCreation(nullptr, localPlayer->GetGameEntity(), vecPosition, explosionType);
218-
if (!allowExplosion)
222+
CLuaArguments arguments;
223+
arguments.PushNumber(vecPosition.fX);
224+
arguments.PushNumber(vecPosition.fY);
225+
arguments.PushNumber(vecPosition.fZ);
226+
arguments.PushNumber(m_LastWeaponType);
227+
if (!localPlayer->CallEvent("onClientExplosion", arguments, true))
219228
return nullptr;
220229
}
221230
}

0 commit comments

Comments
 (0)