From 5033c096a2d2cd7366cc6c75ac87d0a5f133cb1d Mon Sep 17 00:00:00 2001 From: Phnod Date: Fri, 1 Sep 2023 09:48:53 -0400 Subject: [PATCH] cleanup: move PLATFORM_N64 preprocessor checks for fov zoom into a separate macro to reduce clutter --- src/game/bondgunreset.c | 12 +++--------- src/game/bondmove.c | 10 ++-------- src/game/bondview.c | 6 +----- src/game/game_0b0fd0.c | 26 +++++--------------------- src/include/data.h | 6 ++++++ 5 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/game/bondgunreset.c b/src/game/bondgunreset.c index ed301b20f..182cefd75 100644 --- a/src/game/bondgunreset.c +++ b/src/game/bondgunreset.c @@ -239,15 +239,9 @@ void bgunReset(void) g_Vars.currentplayer->gunammooff = 0; g_Vars.currentplayer->gunsightoff = GUNSIGHTREASON_NOTAIMING; -#ifdef PLATFORM_N64 - g_Vars.currentplayer->gunzoomfovs[0] = 15; - g_Vars.currentplayer->gunzoomfovs[1] = 60; - g_Vars.currentplayer->gunzoomfovs[2] = 30; -#else - g_Vars.currentplayer->gunzoomfovs[0] = 15 * g_PlayerFovZoomMultiplier; - g_Vars.currentplayer->gunzoomfovs[1] = 60 * g_PlayerFovZoomMultiplier; - g_Vars.currentplayer->gunzoomfovs[2] = 30 * g_PlayerFovZoomMultiplier; -#endif + g_Vars.currentplayer->gunzoomfovs[0] = ADJUST_ZOOM_FOV(15); + g_Vars.currentplayer->gunzoomfovs[1] = ADJUST_ZOOM_FOV(60); + g_Vars.currentplayer->gunzoomfovs[2] = ADJUST_ZOOM_FOV(30); if (stageGetIndex(g_Vars.stagenum) == STAGEINDEX_AIRBASE) { g_Weapons[WEAPON_EYESPY]->name = L_GUN_061; // "DrugSpy" diff --git a/src/game/bondmove.c b/src/game/bondmove.c index d01809f90..1d2a33de1 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1705,15 +1705,9 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } #endif -#ifdef PLATFORM_N64 - if (eraserfov < 2) { - eraserfov = 2; + if (eraserfov < ADJUST_ZOOM_FOV(2)) { + eraserfov = ADJUST_ZOOM_FOV(2); } -#else - if (eraserfov < 2 * g_PlayerFovZoomMultiplier) { - eraserfov = 2 * g_PlayerFovZoomMultiplier; - } -#endif g_Vars.currentplayer->gunzoomfovs[1] = eraserfov; diff --git a/src/game/bondview.c b/src/game/bondview.c index 6e345ef96..bed52d33a 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -2377,11 +2377,7 @@ Gfx *bviewDrawHorizonScanner(Gfx *gdl) if (fovy == 0 || fovy == 60.0f) { fovy = 1; } else { -#ifdef PLATFORM_N64 - fovy = 60.0f / fovy + 1; -#else - fovy = 60.0f / fovy * g_PlayerFovZoomMultiplier; -#endif + fovy = 60.0f / ADJUST_ZOOM_FOV(fovy); } sprintf(zoomtext, "%s %s%s%4.2fX", arrows, "", "", fovy); diff --git a/src/game/game_0b0fd0.c b/src/game/game_0b0fd0.c index 0904f03b3..8e56c4aef 100644 --- a/src/game/game_0b0fd0.c +++ b/src/game/game_0b0fd0.c @@ -209,11 +209,7 @@ f32 currentPlayerGetGunZoomFov(void) if (weapon) { f32 fov = weapon->aimsettings->zoomfov; -#ifdef PLATFORM_N64 - return fov; -#else - return fov * g_PlayerFovZoomMultiplier; -#endif + return ADJUST_ZOOM_FOV(fov); } return 0; @@ -244,15 +240,9 @@ void currentPlayerZoomOut(f32 fovpersec) g_Vars.currentplayer->gunzoomfovs[index] *= 1.0f + amount * 0.1f; -#if PLATFORM_N64 - if (g_Vars.currentplayer->gunzoomfovs[index] > 60) { - g_Vars.currentplayer->gunzoomfovs[index] = 60; + if (g_Vars.currentplayer->gunzoomfovs[index] > ADJUST_ZOOM_FOV(60)) { + g_Vars.currentplayer->gunzoomfovs[index] = ADJUST_ZOOM_FOV(60); } -#else - if (g_Vars.currentplayer->gunzoomfovs[index] > 60 * g_PlayerFovZoomMultiplier) { - g_Vars.currentplayer->gunzoomfovs[index] = 60 * g_PlayerFovZoomMultiplier; - } -#endif } } @@ -281,15 +271,9 @@ void currentPlayerZoomIn(f32 fovpersec) g_Vars.currentplayer->gunzoomfovs[index] /= 1 + amount * 0.1f; -#ifdef PLATFORM_N64 - if (g_Vars.currentplayer->gunzoomfovs[index] < 2) { - g_Vars.currentplayer->gunzoomfovs[index] = 2; + if (g_Vars.currentplayer->gunzoomfovs[index] < ADJUST_ZOOM_FOV(2)) { + g_Vars.currentplayer->gunzoomfovs[index] = ADJUST_ZOOM_FOV(2); } -#else - if (g_Vars.currentplayer->gunzoomfovs[index] < 2 * g_PlayerFovZoomMultiplier) { - g_Vars.currentplayer->gunzoomfovs[index] = 2 * g_PlayerFovZoomMultiplier; - } -#endif } } diff --git a/src/include/data.h b/src/include/data.h index 2848e34cb..b0a0a3589 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -538,4 +538,10 @@ extern s32 g_PlayerFovAffectsZoom; extern f32 g_PlayerFovZoomMultiplier; #endif +#ifdef PLATFORM_N64 +#define ADJUST_ZOOM_FOV(x) (x) +#else +#define ADJUST_ZOOM_FOV(x) ((x) * g_PlayerFovZoomMultiplier) +#endif + #endif