From 47790b09a41429fd7673d152e0c64c33630505ee Mon Sep 17 00:00:00 2001 From: glx Date: Fri, 14 Feb 2020 17:53:24 +0100 Subject: Codechange: Simplify CheckAPIVersion() --- src/ai/ai_info.cpp | 8 +++----- src/game/game_info.cpp | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index 6e1ef6cec..c5280fe5d 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -15,6 +15,7 @@ #include "../debug.h" #include "../string_func.h" #include "../rev.h" +#include #include "../safeguards.h" @@ -24,11 +25,8 @@ */ static bool CheckAPIVersion(const char *api_version) { - return strcmp(api_version, "0.7") == 0 || strcmp(api_version, "1.0") == 0 || strcmp(api_version, "1.1") == 0 || - strcmp(api_version, "1.2") == 0 || strcmp(api_version, "1.3") == 0 || strcmp(api_version, "1.4") == 0 || - strcmp(api_version, "1.5") == 0 || strcmp(api_version, "1.6") == 0 || strcmp(api_version, "1.7") == 0 || - strcmp(api_version, "1.8") == 0 || strcmp(api_version, "1.9") == 0 || strcmp(api_version, "1.10") == 0 || - strcmp(api_version, "1.11") == 0; + static const std::set versions = { "0.7", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11" }; + return versions.find(api_version) != versions.end(); } #if defined(_WIN32) diff --git a/src/game/game_info.cpp b/src/game/game_info.cpp index a039401b3..77725c5e7 100644 --- a/src/game/game_info.cpp +++ b/src/game/game_info.cpp @@ -13,6 +13,7 @@ #include "game_info.hpp" #include "game_scanner.hpp" #include "../debug.h" +#include #include "../safeguards.h" @@ -22,10 +23,8 @@ */ static bool CheckAPIVersion(const char *api_version) { - return strcmp(api_version, "1.2") == 0 || strcmp(api_version, "1.3") == 0 || strcmp(api_version, "1.4") == 0 || - strcmp(api_version, "1.5") == 0 || strcmp(api_version, "1.6") == 0 || strcmp(api_version, "1.7") == 0 || - strcmp(api_version, "1.8") == 0 || strcmp(api_version, "1.9") == 0 || strcmp(api_version, "1.10") == 0 || - strcmp(api_version, "1.11") == 0; + static const std::set versions = {"1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11"}; + return versions.find(api_version) != versions.end(); } #if defined(_WIN32) -- cgit v1.2.3-70-g09d2