From 0e677e8f3644cd03dcb0c65cc222343d2d3852d5 Mon Sep 17 00:00:00 2001 From: AC-Gazda <83228456+AC-Gazda@users.noreply.github.com> Date: Wed, 12 May 2021 17:55:25 +0200 Subject: [PATCH] Macros converted to function --- source/src/clientgame.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 6de7a513..5559e04c 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1734,17 +1734,19 @@ void setfollowplayer(int cn) } COMMANDF(setfollowplayer, "i", (int *cn) { setfollowplayer(*cn); }); -// macros to determine when SM_OVERVIEW and SM_FLY are permitted // the spectate mode SM_OVERVIEW is like a radar hack and therefore is only allowed under certain conditions -#define NOT_MATCH_NOT_PRIVATE (servstate.mastermode != MM_MATCH && servstate.mastermode != MM_PRIVATE) -#define SM_56_FOBRIDDEN (player1->state == CS_DEAD || player1->team == TEAM_CLA_SPECT || player1->team == TEAM_RVSF_SPECT || NOT_MATCH_NOT_PRIVATE) +bool smoverviewflyforbidden() +{ + bool notmatchnotprivate = servstate.mastermode != MM_MATCH && servstate.mastermode != MM_PRIVATE; + return (player1->state == CS_DEAD || player1->team == TEAM_CLA_SPECT || player1->team == TEAM_RVSF_SPECT || notmatchnotprivate); +} // set new spect mode void spectatemode(int mode) { if((player1->state != CS_DEAD && player1->state != CS_SPECTATE && !team_isspect(player1->team)) || (!m_teammode && !team_isspect(player1->team) && servstate.mastermode == MM_MATCH)) return; // during ffa matches only SPECTATORS can spectate if(mode == player1->spectatemode || (m_botmode && mode != SM_FLY)) return; - if((mode == SM_OVERVIEW || mode == SM_FLY) && SM_56_FOBRIDDEN) return; + if((mode == SM_OVERVIEW || mode == SM_FLY) && smoverviewflyforbidden()) return; showscores(false); switch(mode) { @@ -1790,7 +1792,7 @@ void togglespect() // cycle through all spectating modes { int mode; if(player1->spectatemode==SM_NONE) mode = SM_FOLLOW1ST; // start with 1st person spect - else mode = SM_FOLLOW1ST + ((player1->spectatemode - SM_FOLLOW1ST + 1) % ((SM_56_FOBRIDDEN ? SM_FLY : SM_OVERVIEW)-SM_FOLLOW1ST)); // replace SM_OVERVIEW by SM_NUM to enable overview mode + else mode = SM_FOLLOW1ST + ((player1->spectatemode - SM_FOLLOW1ST + 1) % ((smoverviewflyforbidden() ? SM_FLY : SM_OVERVIEW)-SM_FOLLOW1ST)); // replace SM_OVERVIEW by SM_NUM to enable overview mode spectatemode(mode); } }