From 358800f2609ee2058face4ce336232f9691bf4e5 Mon Sep 17 00:00:00 2001 From: Davi Date: Sun, 15 Jul 2018 16:07:34 -0300 Subject: [PATCH] Flashlight fixes: dead players and spectators may no longer toggle the flashlight, spectating other players while dead will keep your flashlight off --- Sources/Client/ClientPlayer.cpp | 3 ++- Sources/Client/Client_Input.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/Client/ClientPlayer.cpp b/Sources/Client/ClientPlayer.cpp index 81e49f88..a644f942 100644 --- a/Sources/Client/ClientPlayer.cpp +++ b/Sources/Client/ClientPlayer.cpp @@ -617,7 +617,8 @@ namespace spades { eyeMatrix.GetOrigin() + Vector3(20.f, 20.f, 20.f))); sandboxedRenderer->SetAllowDepthHack(true); - if (client->flashlightOn) { + // no flashlight if spectating other players while dead + if (client->flashlightOn && world->GetLocalPlayer()->IsAlive()) { float brightness; brightness = client->time - client->flashlightOnTime; brightness = 1.f - expf(-brightness * 5.f); diff --git a/Sources/Client/Client_Input.cpp b/Sources/Client/Client_Input.cpp index 5bb72ec5..071ce3ae 100644 --- a/Sources/Client/Client_Input.cpp +++ b/Sources/Client/Client_Input.cpp @@ -558,6 +558,9 @@ namespace spades { } else if (CheckKey(cg_keySaveMap, name) && down) { TakeMapShot(); } else if (CheckKey(cg_keyFlashlight, name) && down) { + // spectators and dead players should not be able to toggle the flashlight + if (world->GetLocalPlayer()->IsSpectator() || !world->GetLocalPlayer()->IsAlive()) + return; flashlightOn = !flashlightOn; flashlightOnTime = time; Handle chunk =