From 33046aa9938be8b9b8a451ddba3ad100fba0ece5 Mon Sep 17 00:00:00 2001 From: flowtron Date: Sat, 15 Jan 2022 11:57:55 +0100 Subject: [PATCH] fix flying failures --- source/src/clientgame.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 5a34e17c..2abd5dc3 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1748,7 +1748,7 @@ void setfollowplayer(int cn) } COMMANDF(setfollowplayer, "i", (int *cn) { setfollowplayer(*cn); }); -// SM_OVERVIEW shows all players and their activity - could be used unfairly, possible TODO: allow restricting access by server config and votes +// SM_OVERVIEW shows all players and their activity - could be used unfairly, possible TODO: allow restricting access by server config and votes bool smoverviewflyforbidden() { return (player1->team != TEAM_SPECT && !watchingdemo); @@ -1783,6 +1783,22 @@ void spectatemode(int mode) player1->yaw = f->yaw; player1->pitch = 0.0f; player1->resetinterp(); + physent d = *player1; + d.radius = d.eyeheight = d.maxeyeheight = d.aboveeye = 0.1; + if(collide(&d, false)) // need air around + { + int x = findentity(PLAYERSTART,rnd(ents.length())); + if(x>=0) + { + gotoplayerstart(player1, &ents[x]); + player1->o.z = S((int)player1->o.x, (int)player1->o.y)->floor + player1->maxeyeheight; + entinmap(player1); + } + else + { + spectatemode(SM_OVERVIEW); // fail-safe + } + } } else entinmap(player1); // or drop 'em at a random place addmsg(SV_SPECTCN, "ri", (player1->followplayercn = FPCN_FLY));