Flashlight fixes: dead players and spectators may no longer toggle the flashlight, spectating other players while dead will keep your flashlight off

This commit is contained in:
Davi 2018-07-15 16:07:34 -03:00
parent 3143e561c0
commit 358800f260
2 changed files with 5 additions and 1 deletions

View File

@ -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);

View File

@ -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<IAudioChunk> chunk =