From a9cbd784f756673c49a64ea916031f9352bd5a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Thu, 19 Oct 2023 11:36:19 +0200 Subject: [PATCH] Remove snapshot_id It is now consistently replaced by build_num. The next snapshot will be snapshot-353. --- .github/build.sh | 6 +----- meson_options.txt | 9 +-------- src/Config.template.h | 1 - src/client/GameSave.cpp | 1 - src/client/http/StartupRequest.cpp | 2 +- src/client/http/requestmanager/Common.cpp | 2 +- src/gui/game/GameController.cpp | 10 +++++----- src/gui/game/IntroText.h | 17 +++++++++++------ src/lua/LuaScriptInterface.cpp | 9 +-------- src/meson.build | 1 - 10 files changed, 21 insertions(+), 37 deletions(-) diff --git a/.github/build.sh b/.github/build.sh index 405e2577e..ff1384cbf 100755 --- a/.github/build.sh +++ b/.github/build.sh @@ -251,16 +251,12 @@ if [[ $stable_or_beta == yes ]]; then fi if [[ $RELEASE_TYPE == snapshot ]]; then meson_configure+=$'\t'-Dsnapshot=true - meson_configure+=$'\t'-Dsnapshot_id=$(echo $RELEASE_NAME | cut -d '-' -f 2) # $RELEASE_NAME is snapshot-X + meson_configure+=$'\t'-Dbuild_num=$(echo $RELEASE_NAME | cut -d '-' -f 2) # $RELEASE_NAME is snapshot-X fi if [[ $RELEASE_TYPE == snapshot ]] && [[ $MOD_ID != 0 ]]; then >&2 echo "mods and snapshots do not mix" exit 1 fi -if [[ $stable_or_beta == yes ]] && [[ $MOD_ID != 0 ]]; then - # mods and snapshots both check their snapshot_id against whatever version starcatcher.us/TPT has - meson_configure+=$'\t'-Dsnapshot_id=$(echo $RELEASE_NAME | cut -d '.' -f 3) # $RELEASE_NAME is vX.Y.Z -fi if [[ $RELEASE_TYPE == snapshot ]] || [[ $MOD_ID != 0 ]]; then meson_configure+=$'\t'-Dupdate_server=starcatcher.us/TPT fi diff --git a/meson_options.txt b/meson_options.txt index 2759c1316..016c61c9d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -36,13 +36,6 @@ option( value: false, description: 'Snapshot build' ) -option( - 'snapshot_id', - type: 'integer', - min: 0, - value: 0, - description: 'Snapshot ID, only relevant if \'snapshot\' is true' -) option( 'display_version_major', type: 'integer', @@ -140,7 +133,7 @@ option( 'update_server', type: 'string', value: '', - description: 'Update server, only used by snapshots and mods, see \'snapshot_id\' and \'mod_id\'' + description: 'Update server, only used by snapshots and mods, see \'snapshot\' and \'mod_id\'' ) option( 'workaround_noncpp_lua', diff --git a/src/Config.template.h b/src/Config.template.h index e9fce5618..8962bb543 100644 --- a/src/Config.template.h +++ b/src/Config.template.h @@ -45,7 +45,6 @@ constexpr char APPID[] = "@APPID@"; constexpr char APPDATA[] = "@APPDATA@"; constexpr char APPVENDOR[] = "@APPVENDOR@"; -constexpr int SNAPSHOT_ID = @SNAPSHOT_ID@; constexpr int MOD_ID = @MOD_ID@; struct DisplayVersionWithBuild diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index adbe30dd4..294aac63d 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -2317,7 +2317,6 @@ std::pair> GameSave::serialiseOPS() const bson_append_int(&b, "majorVersion", int(currentVersion[0])); bson_append_int(&b, "minorVersion", int(currentVersion[1])); bson_append_int(&b, "buildNum", APP_VERSION.build); - bson_append_int(&b, "snapshotId", SNAPSHOT_ID); bson_append_int(&b, "modId", MOD_ID); bson_append_string(&b, "releaseType", ByteString(1, IDENT_RELTYPE).c_str()); bson_append_string(&b, "platform", IDENT_PLATFORM); diff --git a/src/client/http/StartupRequest.cpp b/src/client/http/StartupRequest.cpp index 34fda09aa..d2a2ce95e 100644 --- a/src/client/http/StartupRequest.cpp +++ b/src/client/http/StartupRequest.cpp @@ -76,7 +76,7 @@ namespace http if constexpr (SNAPSHOT || MOD) { parseUpdate("Snapshot", UpdateInfo::channelSnapshot, [](int build) -> bool { - return build > SNAPSHOT_ID; + return size_t(build) > APP_VERSION.build; }); } else diff --git a/src/client/http/requestmanager/Common.cpp b/src/client/http/requestmanager/Common.cpp index e2cde7223..389861d9a 100644 --- a/src/client/http/requestmanager/Common.cpp +++ b/src/client/http/requestmanager/Common.cpp @@ -17,7 +17,7 @@ namespace http "; NO", // Unused, used to be SSE level. "; M", MOD_ID, "; ", IDENT, - ") TPTPP/", apiVersion[0], ".", apiVersion[1], ".", APP_VERSION.build, IDENT_RELTYPE, ".", SNAPSHOT_ID + ") TPTPP/", apiVersion[0], ".", apiVersion[1], ".", APP_VERSION.build, IDENT_RELTYPE, ".", 0 ); } diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 05e23a359..f8cf99e33 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1601,13 +1601,13 @@ void GameController::NotifyUpdateAvailable(Client * sender) updateMessage << "Click \"Continue\" to download the latest version from our website.\n\nCurrent version:\n "; } + if constexpr (MOD) + { + updateMessage << "Mod " << MOD_ID << " "; + } if constexpr (SNAPSHOT) { - updateMessage << "Snapshot " << SNAPSHOT_ID; - } - else if constexpr (MOD) - { - updateMessage << "Mod version " << SNAPSHOT_ID; + updateMessage << "Snapshot " << APP_VERSION.build; } else if constexpr (BETA) { diff --git a/src/gui/game/IntroText.h b/src/gui/game/IntroText.h index 741849ec7..ba094c0f0 100644 --- a/src/gui/game/IntroText.h +++ b/src/gui/game/IntroText.h @@ -5,14 +5,19 @@ inline ByteString VersionInfo() { ByteStringBuilder sb; - sb << DISPLAY_VERSION[0] << "." << DISPLAY_VERSION[1] << "." << APP_VERSION.build << " " << IDENT; + sb << DISPLAY_VERSION[0] << "." << DISPLAY_VERSION[1]; + if constexpr (!SNAPSHOT) + { + sb << "." << APP_VERSION.build; + } + sb << " " << IDENT; + if constexpr (MOD) + { + sb << " MOD " << MOD_ID << " UPSTREAM " << UPSTREAM_VERSION.build; + } if constexpr (SNAPSHOT) { - sb << " SNAPSHOT " << SNAPSHOT_ID; - } - else if constexpr (MOD) - { - sb << " MODVER " << SNAPSHOT_ID; + sb << " SNAPSHOT " << APP_VERSION.build; } if constexpr (LUACONSOLE) { diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index a40f74a13..597718fad 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -415,14 +415,7 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m): lua_setfield(l, tptPropertiesVersion, "upstream_minor"); lua_pushinteger(l, UPSTREAM_VERSION.build); lua_setfield(l, tptPropertiesVersion, "upstream_build"); - if constexpr (SNAPSHOT || MOD) - { - lua_pushinteger(l, SNAPSHOT_ID); - } - else - { - lua_pushinteger(l, 0); - } + lua_pushboolean(l, SNAPSHOT); lua_setfield(l, tptPropertiesVersion, "snapshot"); lua_pushinteger(l, MOD_ID); lua_setfield(l, tptPropertiesVersion, "modid"); diff --git a/src/meson.build b/src/meson.build index cb53f8a15..c97103939 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,7 +11,6 @@ conf_data.set('MOD_ID', mod_id) conf_data.set('DEBUG', is_debug.to_string()) conf_data.set('MOD', is_mod.to_string()) conf_data.set('SNAPSHOT', is_snapshot.to_string()) -conf_data.set('SNAPSHOT_ID', get_option('snapshot_id')) conf_data.set('DISPLAY_VERSION_MAJOR', get_option('display_version_major')) conf_data.set('DISPLAY_VERSION_MINOR', get_option('display_version_minor')) conf_data.set('BUILD_NUM', get_option('build_num'))