Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion desktop_version/src/ReleaseVersion.h
Original file line number Diff line number Diff line change
@@ -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 */
65 changes: 65 additions & 0 deletions desktop_version/src/Script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]))
Expand Down Expand Up @@ -3560,6 +3622,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]);
Expand Down
Loading