diff --git a/desktop_version/src/ReleaseVersion.h b/desktop_version/src/ReleaseVersion.h index 288946dd..a6163bf8 100644 --- a/desktop_version/src/ReleaseVersion.h +++ b/desktop_version/src/ReleaseVersion.h @@ -1,6 +1,17 @@ #ifndef RELEASEVERSION_H #define RELEASEVERSION_H -#define RELEASE_VERSION "v2.5" +#define MAJOR_VERSION 2 +#define MINOR_VERSION 5 +#define PATCH_VERSION 0 + +#define VVV_STRINGIFY(x) #x +#define VVV_TOSTRING(x) VVV_STRINGIFY(x) + +#if PATCH_VERSION == 0 +#define RELEASE_VERSION "v" VVV_TOSTRING(MAJOR_VERSION) "." VVV_TOSTRING(MINOR_VERSION) +#else +#define RELEASE_VERSION "v" VVV_TOSTRING(MAJOR_VERSION) "." VVV_TOSTRING(MINOR_VERSION) "." VVV_TOSTRING(PATCH_VERSION) +#endif #endif /* RELEASEVERSION_H */ diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index e14066aa..6bcf193f 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -20,6 +20,7 @@ #include "LocalizationStorage.h" #include "Map.h" #include "Music.h" +#include "ReleaseVersion.h" #include "Unreachable.h" #include "UtilityClass.h" #include "VFormat.h" @@ -338,6 +339,67 @@ void scriptclass::run(void) } } } + if (words[0] == "ifversion") + { + // A short for each is SURELY enough + unsigned short version[3] = { 0, 0, 0 }; + bool valid_version = true; + int current = 0; + + // Crawl through the string + for (int i = 0; i < words[1].size(); i++) + { + // If the current character is a number, add it to the current version part + if (words[1][i] >= '0' && words[1][i] <= '9') + { + version[current] = version[current] * 10 + (words[1][i] - '0'); + } + else if (words[1][i] == '.') + { + current++; + if (current >= 3) + { + break; + } + } + else + { + // Unexpected character + valid_version = false; + break; + } + } + + if (valid_version) + { + bool version_is_met = false; + + if (MAJOR_VERSION > version[0]) + { + version_is_met = true; + } + else if (MAJOR_VERSION == version[0]) + { + if (MINOR_VERSION > version[1]) + { + version_is_met = true; + } + else if (MINOR_VERSION == version[1]) + { + if (PATCH_VERSION >= version[2]) + { + version_is_met = true; + } + } + } + + if (version_is_met) + { + loadalts("custom_" + words[2], "custom_" + raw_words[2]); + position--; + } + } + } if (words[0] == "customiftrinkets") { if (game.trinkets() >= ss_toi(words[1])) @@ -3574,6 +3636,9 @@ bool scriptclass::loadcustom(const std::string& t) }else if(words[0] == "iftrinketsless"){ if(customtextmode==1){ add("endtext"); customtextmode=0;} add("custom"+lines[i]); + }else if(words[0] == "ifversion"){ + if(customtextmode==1){ add("endtext"); customtextmode=0;} + add(lines[i]); }else if(words[0] == "textcase"){ if(customtextmode==1){ add("endtext"); customtextmode=0;} add(lines[i]);