@@ -30,7 +30,38 @@ void __fastcall CPortal_Player__PlayerDeathThink_hook(CPortal_Player* thisPtr)
3030 CPortal_Player__PlayerDeathThink_orig (thisPtr);
3131}
3232
33+ // ---------------------------------------------------------------------------------
34+ // Purpose: Change out the original Flashlight turn and off with our versions.
35+ // TODO: Have flashlight on and off sound work again.
36+ // ---------------------------------------------------------------------------------
37+ bool (__fastcall* CPortal_Player__FlashlightTurnOn_orig)(CPortal_Player* thisPtr, void * edx, bool playSound);
38+ bool __fastcall CPortal_Player__FlashlightTurnOn_hook (CPortal_Player* thisPtr, void * edx, bool playSound)
39+ {
40+ const int playerIndex = ENTINDEX (reinterpret_cast <CBaseEntity*>(thisPtr));
41+ if (playerIndex <= 0 || playerIndex > MAX_PLAYERS)
42+ {
43+ Log (WARNING, false , " CPortal_Player::FlashlightTurnOn was called with a invalid player!" );
44+ return false ;
45+ }
46+
47+ CPortal_Player__SetFlashlightState (playerIndex, true );
48+ // engineServer->EmitAmbientSound(playerIndex)
49+ return true ;
50+ }
51+
52+ void (__fastcall* CPortal_Player__FlashlightTurnOff_orig)(CPortal_Player* thisPtr, void * edx, bool playSound);
53+ void __fastcall CPortal_Player__FlashlightTurnOff_hook (CPortal_Player* thisPtr, void * edx, bool playSound)
3354{
55+ const int playerIndex = ENTINDEX (reinterpret_cast <CBaseEntity*>(thisPtr));
56+ if (playerIndex <= 0 || playerIndex > MAX_PLAYERS)
57+ {
58+ Log (WARNING, false , " CPortal_Player::FlashlightTurnOff was called with a invalid player!" );
59+ return ;
60+ }
61+
62+ CPortal_Player__SetFlashlightState (playerIndex, false );
63+ // engineServer->EmitAmbientSound(playerIndex)
64+ return ;
3465}
3566
3667// / Interfaced UTIL Functions \\\
0 commit comments