Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify version support #2191

Merged
merged 6 commits into from
Feb 4, 2024
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
25 changes: 10 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,23 @@ include(AutoRevision)
# Set some variables from AutoRevision for use here and later
list(LENGTH FC21_REV_TAG_LIST FC21_REV_TAG_LIST_LENGTH)

# When we tag a stable release we only get 2 of the 4 components populated
# So we manually set some of the variables we need for the full version.
if(${FC21_REV_TAG_LIST_LENGTH} EQUAL 2)
# When we tag a stable release we only get 3 of the 4 components populated,
# so we manually set some of the variables we need for the full version.
if (${FC21_REV_TAG_LIST_LENGTH} EQUAL 3)
list(GET FC21_REV_TAG_LIST 0 FC21_MAJOR_VERSION)
list(GET FC21_REV_TAG_LIST 1 FC21_MINOR_VERSION)
set(FC21_LABEL_VERSION "Stable")
set(FC21_EMER_VERSION "0")
set(FC21_PATCH_VERSION "0")
list(GET FC21_REV_TAG_LIST 2 FC21_PATCH_VERSION)
set(FC21_VERSION_LABEL "stable")
set(IS_STABLE_VERSION true)
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}")
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}.${FC21_PATCH_VERSION}")
else()
message(STATUS "${FC21_REV_TAG_LIST}")
list(GET FC21_REV_TAG_LIST 0 FC21_MAJOR_VERSION)
list(GET FC21_REV_TAG_LIST 1 FC21_MINOR_VERSION)
list(GET FC21_REV_TAG_LIST 2 FC21_LABEL_VERSION)
if (${FC21_REV_TAG_LIST_LENGTH} GREATER 3)
list(GET FC21_REV_TAG_LIST 3 FC21_EMER_VERSION)
else()
set(FC21_EMER_VERSION 0)
endif()
set(FC21_PATCH_VERSION ${FC21_REV_HEAD_HASH_D})
list(GET FC21_REV_TAG_LIST 2 FC21_VERSION_LABEL)
list(GET FC21_REV_TAG_LIST 3 FC21_PATCH_VERSION)
set(IS_STABLE_VERSION false)
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}.${FC21_PATCH_VERSION}")
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}")
endif()

# Set project
Expand Down
2 changes: 1 addition & 1 deletion client/packhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void handle_server_join_reply(bool you_can_join, const char *message,
}

client_info._obsolete = 5; // Old value for gui_type(GUI_QT)
client_info.emerg_version = EMERGENCY_VERSION;
client_info._obsolete2 = 0;
qstrncpy(client_info.distribution, FREECIV_DISTRIBUTOR,
sizeof(client_info.distribution));
send_packet_client_info(&client.conn, &client_info);
Expand Down
7 changes: 2 additions & 5 deletions client/page_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

page_main::page_main(QWidget *parent, fc_client *gui) : QWidget(parent)
{
QString msgbuf;
QString beta;
ui.setupUi(this);
ui.btut->setText(_("Tutorial"));
ui.bstart->setText(_("Start new game"));
Expand All @@ -46,9 +44,8 @@ page_main::page_main(QWidget *parent, fc_client *gui) : QWidget(parent)
connect(ui.bload, &QPushButton::clicked,
[gui]() { gui->switch_page(PAGE_LOAD); });

// TRANS: "version 2.6.0"
msgbuf = QString(_("%1%2")).arg(word_version()).arg(freeciv21_version());
ui.lversion->setText(QString(msgbuf) + beta);
// TRANS: "Version 2.6.0"
ui.lversion->setText(QString(_("Version %1")).arg(freeciv21_version()));
setLayout(ui.gridLayout);
}

Expand Down
2 changes: 1 addition & 1 deletion client/servers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static struct server_list *parse_metaserver_data(QIODevice *f)
"version_comments." FOLLOWTAG);

if (latest_ver != nullptr) {
const char *my_comparable = fc_comparable_version();
const char *my_comparable = freeciv21_version();
char vertext[2048];

qDebug("Metaserver says latest '" FOLLOWTAG
Expand Down
5 changes: 3 additions & 2 deletions common/networking/packets.def
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ end

PACKET_SERVER_INFO = 29; sc, dsend
STRING version_label[48];
UINT32 major_version, minor_version, patch_version, emerg_version;
UINT32 major_version, minor_version, patch_version;
UINT32 _obsolete; # Since 3.1
end

/************** City packets **********************/
Expand Down Expand Up @@ -1291,7 +1292,7 @@ end

PACKET_CLIENT_INFO = 119; cs, handle-per-conn
UINT8 _obsolete;
UINT32 emerg_version;
UINT32 _obsolete2; # Since 3.1
STRING distribution[MAX_LEN_NAME];
end

Expand Down
7 changes: 4 additions & 3 deletions docs/Contributing/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ These are the general steps to prepare and finalize a release:
`branches page <https://github.com/longturn/freeciv21/branches>`_.
#. From the same page, create a new ``stable`` branch from ``master``.
#. Update ``cmake/AutoRevision.txt`` with the hash of the last commit in ``master`` and
``v[major version].[minor version]-dev`` with the version of the :strong:`next stable release`, then
``v[major version].[minor version]-dev.0`` with the version of the :strong:`next stable release`, then
open a PR for this change to ``master``. This way, development builds from ``master`` will immediately
use the version number of the next stable.

#. If the release is a :strong:`release candidate` for a :strong:`stable release`, the release manager will
make sure that the :guilabel:`Target` branch in the release draft is set to ``stable``.
#. The release manager will add a tag to the release notes page and then click :guilabel:`Publish Release`.
The format of the tag is ``v[major version].[minor version]-[pre-release name].[number]``. For example:
``v3.0-beta.6``. :strong:`The format is very important` to the build configuration process.
The format of the tag is ``v[major version].[minor version]-[pre-release name].[number]`` for pre-releases
and ``v[major version].[minor version].[patch version]`` for stable versions. For example:
``v3.0-beta.6`` or ``v3.1.0``. :strong:`The format is very important` to the build configuration process.
#. After a few minutes the continuous integration (CI) will open a PR titled
``Release Update of AutoRevision.txt``. The release manager will open the PR, click on the
:guilabel:`Close pull request` button, and then click :guilabel:`Open pull request` button. This is a
Expand Down
2 changes: 1 addition & 1 deletion server/connecthand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ bool handle_login_request(struct connection *pconn,
info.major_version = MAJOR_VERSION;
info.minor_version = MINOR_VERSION;
info.patch_version = PATCH_VERSION;
info.emerg_version = EMERGENCY_VERSION;
info._obsolete = 0;
sz_strlcpy(info.version_label, VERSION_LABEL);
send_packet_server_info(pconn, &info);
}
Expand Down
4 changes: 1 addition & 3 deletions server/savegame/savegame3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,8 +1574,7 @@ static void sg_save_savefile(struct savedata *saving)
secfile_insert_str(saving->file, saving->save_reason, "savefile.reason");

// Save as accurate freeciv revision information as possible
secfile_insert_str(saving->file, freeciv_datafile_version(),
"savefile.revision");
secfile_insert_str(saving->file, freeciv21_version(), "savefile.revision");

/* Save rulesetdir at this point as this ruleset is required by this
* savefile. */
Expand Down Expand Up @@ -2376,7 +2375,6 @@ static void sg_save_scenario(struct savedata *saving)

game_version =
MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000 + PATCH_VERSION * 100;
game_version += EMERGENCY_VERSION;
secfile_insert_int(saving->file, game_version, "scenario.game_version");

if (!saving->scenario || !game.scenario.is_scenario) {
Expand Down
2 changes: 1 addition & 1 deletion tools/civmanual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static bool manual_command(struct tag_types *tag_info)

fprintf(doc, "%s", tag_info->header);
fprintf(doc, "<!-- Generated by freeciv21-manual version %s -->\n\n",
freeciv_datafile_version());
freeciv21_version());

switch (manuals) {
case MANUAL_SETTINGS:
Expand Down
5 changes: 1 addition & 4 deletions tools/fcmp/mpcli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ int main(int argc, char *argv[])
load_install_info_lists(&fcmp);

qInfo(_("Freeciv21 modpack installer (command line version)"));

qInfo("%s%s", word_version(), freeciv21_version());

qInfo("%s", "");
qInfo(_("Version %s"), freeciv21_version());

if (fcmp.autoinstall.isEmpty()) {
if (auto msg =
Expand Down
8 changes: 2 additions & 6 deletions tools/fcmp/mpgui_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,9 @@ void mpgui::setup(QWidget *central, struct fcmp_params *params)
new QPushButton(QString::fromUtf8(_("Install modpack")));
QStringList headers;
QLabel *URL_label;
QLabel *version_label;
char verbuf[2048];

fc_snprintf(verbuf, sizeof(verbuf), "%s%s", word_version(),
freeciv21_version());

version_label = new QLabel(QString::fromUtf8(verbuf));
auto version_label =
new QLabel(QString(_("Version %1")).arg(freeciv21_version()));
version_label->setAlignment(Qt::AlignHCenter);
version_label->setParent(central);
version_label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
Expand Down
9 changes: 3 additions & 6 deletions tools/ruledit/ruledit_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,19 @@ ruledit_gui::ruledit_gui(ruledit_main *main) : QObject(main)
QWidget *edit_widget = new QWidget();
QPushButton *ruleset_accept;
QLabel *rs_label;
QLabel *version_label;
char verbuf[2048];

data.nationlist = nullptr;
data.nationlist_saved = nullptr;

auto *central = new QWidget;
main->setCentralWidget(central);

fc_snprintf(verbuf, sizeof(verbuf), "%s%s", word_version(),
freeciv21_version());

main_layout = new QStackedLayout();

preload_layout->setSizeConstraint(QLayout::SetMaximumSize);
version_label = new QLabel(verbuf);

auto version_label =
new QLabel(QString(_("Version %1")).arg(freeciv21_version()));
version_label->setAlignment(Qt::AlignHCenter);
version_label->setParent(central);
preload_layout->addWidget(version_label);
Expand Down
2 changes: 1 addition & 1 deletion tools/ruleutil/rulesave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static struct section_file *create_ruleset_file(const char *rsname,
}

secfile_insert_str(sfile, buf, "datafile.description");
secfile_insert_str(sfile, freeciv_datafile_version(), "datafile.ruledit");
secfile_insert_str(sfile, freeciv21_version(), "datafile.ruledit");
secfile_insert_str(sfile, RULESET_CAPABILITIES, "datafile.options");
secfile_insert_int(sfile, FORMAT_VERSION, "datafile.format_version");

Expand Down
16 changes: 6 additions & 10 deletions utility/fc_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
#define MAJOR_VERSION @FC21_MAJOR_VERSION@
#define MINOR_VERSION @FC21_MINOR_VERSION@
#define PATCH_VERSION @FC21_PATCH_VERSION@
#define EMERGENCY_VERSION @FC21_EMER_VERSION@
#ifndef VERSION_LABEL
#define VERSION_LABEL "-@FC21_LABEL_VERSION@"
#endif
#define VERSION_LABEL "-@FC21_VERSION_LABEL@"

#cmakedefine01 IS_STABLE_VERSION
#ifndef VERSION_STRING
# if IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@"
# else // IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@.@FC21_PATCH_VERSION@.@FC21_EMER_VERSION@-@FC21_LABEL_VERSION@"
# endif
#if IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@.@FC21_PATCH_VERSION@"
#else // IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@-@FC21_VERSION_LABEL@.@FC21_PATCH_VERSION@"
#endif

#define NETWORK_CAPSTRING \
Expand Down
27 changes: 0 additions & 27 deletions utility/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,3 @@ const char *freeciv_name_version()

return msgbuf;
}

/**
Return string describing version type.
*/
const char *word_version() { return _("version "); }

/**
Returns version string that can be used to compare two freeciv builds.
This does not handle git revisions, as there's no way to compare
which of the two commits is "higher".
*/
const char *fc_comparable_version() { return freeciv21_version(); }

/**
Return version string in a format suitable to be written to created
datafiles as human readable information.
*/
const char *freeciv_datafile_version()
{
static char buf[500] = {'\0'};

if (buf[0] == '\0') {
fc_snprintf(buf, sizeof(buf), "%s", freeciv21_version());
}

return buf;
}
3 changes: 0 additions & 3 deletions utility/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@
// version informational strings
const char *freeciv21_version();
const char *freeciv_name_version();
const char *word_version();
const char *fc_comparable_version();
const char *freeciv_datafile_version();
Loading