From b29f3e2fae63248f5d0f40af91cc0cb7594be8d7 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 4 Feb 2023 00:14:04 -0800 Subject: [PATCH] Silence various warnings in builds removing content The MAKEANDPLAY, NO_CUSTOM_LEVELS, and NO_EDITOR defines remove content or features. However, they then raise several warnings because of some cases, functions, or variables that end up not being used. This silences them by using the UNUSED macro, or by adding a default catch-all case if the define is defined (so unhandled cases will still raise warnings in a build that doesn't have these defines). --- desktop_version/src/Game.cpp | 14 ++++++++++++-- desktop_version/src/Map.cpp | 5 ++++- desktop_version/src/Script.cpp | 11 ++++++++++- desktop_version/src/main.cpp | 5 ++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 1a239c82..6e0ea7b6 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -25,6 +25,7 @@ #include "RoomnameTranslator.h" #include "Screen.h" #include "Script.h" +#include "Unused.h" #include "UtilityClass.h" #include "VFormat.h" #include "Vlogging.h" @@ -4207,7 +4208,9 @@ void Game::deletesettings(void) void Game::unlocknum( int t ) { -#if !defined(MAKEANDPLAY) +#ifdef MAKEANDPLAY + UNUSED(t); +#else if (map.custommode) { //Don't let custom levels unlock things! @@ -6821,6 +6824,11 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) option(loc::gettext("ok")); menuyoff = 50; break; +#ifdef NO_CUSTOM_LEVELS + /* Silence warnings about unhandled cases. */ + default: + break; +#endif } // Automatically center the menu. We must check the width of the menu with the initial horizontal spacing. @@ -7198,7 +7206,9 @@ void Game::returntoingame(void) void Game::unlockAchievement(const char* name) { -#ifndef MAKEANDPLAY +#ifdef MAKEANDPLAY + UNUSED(name); +#else if (map.custommode) { return; diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 3889de39..46cde1c8 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -13,6 +13,7 @@ #include "Maths.h" #include "Music.h" #include "Script.h" +#include "Unused.h" #include "UtilityClass.h" mapclass::mapclass(void) @@ -1544,7 +1545,9 @@ void mapclass::loadlevel(int rx, int ry) switch(t) { -#if !defined(MAKEANDPLAY) +#ifdef MAKEANDPLAY + UNUSED(copy_short_to_int); +#else case 0: case 1: //World Map { diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index cc9a4b7e..279edeb4 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -19,6 +19,7 @@ #include "Map.h" #include "Music.h" #include "Unreachable.h" +#include "Unused.h" #include "UtilityClass.h" #include "VFormat.h" #include "Vlogging.h" @@ -2741,7 +2742,9 @@ void scriptclass::startgamemode(const enum StartMode mode) } break; -#ifndef NO_CUSTOM_LEVELS +#ifdef NO_CUSTOM_LEVELS + UNUSED(gotoerrorloadinglevel); +#else # ifndef NO_EDITOR case Start_EDITOR: cl.reset(); @@ -2836,6 +2839,12 @@ void scriptclass::startgamemode(const enum StartMode mode) case Start_QUIT: VVV_unreachable(); + +#if defined(NO_CUSTOM_LEVELS) || defined(NO_EDITOR) + /* Silence warnings about unhandled cases. */ + default: + break; +#endif } game.gravitycontrol = game.savegc; diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 5739bb23..5fe7905a 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -29,6 +29,7 @@ #include "RenderFixed.h" #include "Screen.h" #include "Script.h" +#include "Unused.h" #include "UtilityClass.h" #include "Vlogging.h" @@ -177,7 +178,9 @@ static const inline struct ImplFunc* get_gamestate_funcs( {Func_fixed, gamecompletelogic2}, FUNC_LIST_END -#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) +#if defined(NO_CUSTOM_LEVELS) || defined(NO_EDITOR) + UNUSED(flipmodeoff); +#else FUNC_LIST_BEGIN(EDITORMODE) {Func_fixed, flipmodeoff}, {Func_input, editorinput},