%s | ", terrain_name_translation(pterrain));
fprintf(doc, "%d/%d/%d | \n", pterrain->output[O_FOOD],
pterrain->output[O_SHIELD], pterrain->output[O_TRADE]);
fprintf(doc, "\n");
for (r = pterrain->resources; *r; r++) {
fprintf(doc,
- "%s%s%s | %s | "
- "%d/%d/%d | \n",
- tag_info->image_begin, (*r)->graphic_str,
- tag_info->image_end, extra_name_translation(*r),
+ "%s | %d/%d/%d | \n",
+ extra_name_translation(*r),
(*r)->data.resource->output[O_FOOD],
(*r)->data.resource->output[O_SHIELD],
(*r)->data.resource->output[O_TRADE]);
@@ -477,7 +458,7 @@ static bool manual_command(struct tag_types *tag_info)
}
fprintf(doc,
- "\n%s | "
+ "\n%s | "
"%s %s | %s %s | %s | \n\n",
_("Name"), _("Cost"), _("Upkeep"), _("Requirement"),
_("Obsolete by"), _("More info"));
@@ -496,11 +477,10 @@ static bool manual_command(struct tag_types *tag_info)
nullptr);
fprintf(doc,
- "%s%s%s | %s | \n"
+ " %s | \n"
"%d %d | \n",
- tag_info->image_begin, pimprove->graphic_str,
- tag_info->image_end, improvement_name_translation(pimprove),
- pimprove->build_cost, pimprove->upkeep);
+ improvement_name_translation(pimprove), pimprove->build_cost,
+ pimprove->upkeep);
requirement_vector_iterate(&pimprove->reqs, req)
{
@@ -667,7 +647,7 @@ int main(int argc, char **argv)
QCoreApplication::setApplicationVersion(freeciv21_version());
init_nls();
- init_character_encodings(FC_DEFAULT_DATA_ENCODING, false);
+ init_character_encodings();
QCommandLineParser parser;
parser.addHelpOption();
diff --git a/tools/fcmp/CMakeLists.txt b/tools/fcmp/CMakeLists.txt
index 6b4ce120af..0cb659f2c8 100644
--- a/tools/fcmp/CMakeLists.txt
+++ b/tools/fcmp/CMakeLists.txt
@@ -28,7 +28,7 @@ if (FREECIV_ENABLE_FCMP_QT)
mpgui_qt.cpp
)
target_link_libraries(freeciv21-modpack-qt PRIVATE freeciv_modpack)
- target_link_libraries(freeciv21-modpack-qt PRIVATE Qt5::Widgets)
+ target_link_libraries(freeciv21-modpack-qt PRIVATE Qt6::Widgets)
install(TARGETS freeciv21-modpack-qt
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT freeciv21)
diff --git a/tools/fcmp/download.cpp b/tools/fcmp/download.cpp
index a577773dc7..f259b25939 100644
--- a/tools/fcmp/download.cpp
+++ b/tools/fcmp/download.cpp
@@ -318,6 +318,7 @@ const char *download_modpack(const QUrl &url, const struct fcmp_params *fcmp,
return msg;
}
}
+ delete[] inst_ver;
}
}
diff --git a/tools/fcmp/modinst.cpp b/tools/fcmp/modinst.cpp
index 80525a1029..ddfb84a07c 100644
--- a/tools/fcmp/modinst.cpp
+++ b/tools/fcmp/modinst.cpp
@@ -40,7 +40,6 @@ void load_install_info_lists(struct fcmp_params *fcmp)
{
char main_db_filename[500];
char scenario_db_filename[500];
- struct stat buf;
fc_snprintf(main_db_filename, sizeof(main_db_filename),
"%s/" DATASUBDIR "/" FCMP_CONTROLD "/mp.db",
@@ -56,14 +55,14 @@ void load_install_info_lists(struct fcmp_params *fcmp)
"%s/scenarios/" FCMP_CONTROLD "/modpacks.db",
qUtf8Printable(fcmp->inst_prefix));
- if (fc_stat(main_db_filename, &buf)) {
+ if (QFileInfo::exists(main_db_filename)) {
create_mpdb(main_db_filename, false);
load_install_info_list(main_ii_filename);
} else {
open_mpdb(main_db_filename, false);
}
- if (fc_stat(scenario_db_filename, &buf)) {
+ if (QFileInfo::exists(scenario_db_filename)) {
create_mpdb(scenario_db_filename, true);
load_install_info_list(scenario_ii_filename);
} else {
@@ -77,10 +76,9 @@ void load_install_info_lists(struct fcmp_params *fcmp)
void fcmp_init()
{
init_nls();
- init_character_encodings(FC_DEFAULT_DATA_ENCODING, false);
-
+ init_character_encodings();
fc_srand(time(nullptr)); /* Needed at least for Windows version of
- netfile_get_section_file() */
+ netfile_get_section_file() */
}
/**
diff --git a/tools/fcmp/mpcli.cpp b/tools/fcmp/mpcli.cpp
index 66aa2ae017..7d1576ff25 100644
--- a/tools/fcmp/mpcli.cpp
+++ b/tools/fcmp/mpcli.cpp
@@ -73,6 +73,8 @@ static void setup_modpack_list(const QString &name, const QUrl &url,
if (!notes.isEmpty()) {
qInfo() << _("Comment=") << notes;
}
+
+ delete[] tmp;
}
/**
@@ -91,10 +93,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 =
diff --git a/tools/fcmp/mpdb.cpp b/tools/fcmp/mpdb.cpp
index ac9496bb6e..da5e746062 100644
--- a/tools/fcmp/mpdb.cpp
+++ b/tools/fcmp/mpdb.cpp
@@ -111,12 +111,13 @@ static int mpdb_query(sqlite3 *handle, const char *query)
ret = sqlite3_step(stmt);
}
- if (ret == SQLITE_DONE) {
- ret = sqlite3_finalize(stmt);
+ if (ret != SQLITE_DONE && ret != SQLITE_ROW) {
+ qCritical("Query \"%s\" failed. (%d)", query, ret);
}
- if (ret != SQLITE_OK) {
- qCritical("Query \"%s\" failed. (%d)", query, ret);
+ if (int errcode = sqlite3_finalize(stmt); errcode != SQLITE_OK) {
+ qCritical("Finalizing query \"%s\" returned error. (%d)", query,
+ errcode);
}
return ret;
@@ -160,13 +161,13 @@ void create_mpdb(const char *filename, bool scenario_db)
");");
}
- if (ret == SQLITE_OK) {
+ if (ret == SQLITE_DONE) {
ret = mpdb_query(*handle,
"create table modpacks (name VARCHAR(60) NOT null, "
"type VARCHAR(32), version VARCHAR(32) NOT null);");
}
- if (ret == SQLITE_OK) {
+ if (ret == SQLITE_DONE) {
log_debug("Created %s", filename);
} else {
qCritical(_("Creating \"%s\" failed: %s"), filename,
@@ -240,21 +241,23 @@ bool mpdb_update_modpack(const char *name, enum modpack_type type,
ret = mpdb_query(*handle, qbuf);
}
- if (ret != SQLITE_OK) {
+ if (ret != SQLITE_DONE) {
qCritical(_("Failed to insert modpack '%s' information"), name);
}
- return ret != SQLITE_OK;
+ return ret != SQLITE_DONE;
}
/**
- Return version of modpack.
+ Return version of modpack. The caller is responsible to free the returned
+ string.
*/
const char *mpdb_installed_version(const char *name, enum modpack_type type)
{
sqlite3 **handle;
int ret;
char qbuf[2048];
+ const char *version = nullptr;
sqlite3_stmt *stmt;
if (type == MPT_SCENARIO) {
@@ -271,13 +274,20 @@ const char *mpdb_installed_version(const char *name, enum modpack_type type)
ret = sqlite3_step(stmt);
}
- if (ret == SQLITE_DONE) {
- ret = sqlite3_finalize(stmt);
+ if (ret == SQLITE_ROW) {
+ version = qstrdup((const char *) sqlite3_column_text(stmt, 2));
}
- if (ret == SQLITE_ROW) {
- return (const char *) sqlite3_column_text(stmt, 2);
+ if (ret != SQLITE_DONE && ret != SQLITE_ROW) {
+ qCritical("Query to get installed version for \"%s\" failed. (%d)", name,
+ ret);
+ }
+
+ if (int errcode = sqlite3_finalize(stmt); errcode != SQLITE_OK) {
+ qCritical(
+ "Finalizing query to get installed version for \"%s\" failed. (%d)",
+ name, errcode);
}
- return nullptr;
+ return version;
}
diff --git a/tools/fcmp/mpgui_qt.cpp b/tools/fcmp/mpgui_qt.cpp
index 28f0d6f180..197056308a 100644
--- a/tools/fcmp/mpgui_qt.cpp
+++ b/tools/fcmp/mpgui_qt.cpp
@@ -104,7 +104,7 @@ int main(int argc, char **argv)
central = new QWidget;
main_window = new mpgui_main(&app, central);
- main_window->setGeometry(0, 30, 640, 60);
+ main_window->resize(820, 140);
main_window->setWindowTitle(
QString::fromUtf8(_("Freeciv21 modpack installer (Qt)")));
@@ -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);
@@ -311,7 +307,6 @@ void mpgui::refresh_list_versions()
for (int i = 0; i < mpcount; i++) {
QString name_str;
int type_int;
- const char *new_inst;
enum modpack_type type;
QByteArray name_bytes;
@@ -319,13 +314,12 @@ void mpgui::refresh_list_versions()
type_int = mplist_table->item(i, ML_TYPE)->text().toInt();
type = (enum modpack_type) type_int;
name_bytes = name_str.toUtf8();
- new_inst = mpdb_installed_version(name_bytes.data(), type);
- if (new_inst == nullptr) {
- new_inst = _("Not installed");
- }
+ auto tmp = mpdb_installed_version(qUtf8Printable(name_bytes), type);
+ QString new_inst = tmp ? tmp : _("Not installed");
+ delete[] tmp;
- mplist_table->item(i, ML_COL_INST)->setText(QString::fromUtf8(new_inst));
+ mplist_table->item(i, ML_COL_INST)->setText(new_inst);
}
mplist_table->resizeColumnsToContents();
@@ -356,6 +350,7 @@ void mpgui::setup_list(const QString &name, const QUrl &url,
const char *tmp = mpdb_installed_version(qUtf8Printable(name), type);
QString inst_str = tmp ? tmp : _("Not installed");
+ delete[] tmp;
QString type_nbr;
QTableWidgetItem *item;
diff --git a/tools/ruledit/CMakeLists.txt b/tools/ruledit/CMakeLists.txt
index 8ff8267097..068bf3b065 100644
--- a/tools/ruledit/CMakeLists.txt
+++ b/tools/ruledit/CMakeLists.txt
@@ -28,7 +28,7 @@ add_executable(
target_link_libraries(freeciv21-ruledit server)
target_link_libraries(freeciv21-ruledit tools_ruleutil)
target_link_libraries(freeciv21-ruledit tools_shared)
-target_link_libraries(freeciv21-ruledit Qt5::Widgets)
+target_link_libraries(freeciv21-ruledit Qt6::Widgets)
add_dependencies(freeciv21-ruledit freeciv_translations)
install(TARGETS freeciv21-ruledit
diff --git a/tools/ruledit/ruledit.cpp b/tools/ruledit/ruledit.cpp
index 6d7c01cad8..e77f26feaa 100644
--- a/tools/ruledit/ruledit.cpp
+++ b/tools/ruledit/ruledit.cpp
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
QIcon::setFallbackThemeName(QIcon::themeName());
QIcon::setThemeName(QStringLiteral("icons"));
- qApp->setWindowIcon(QIcon::fromTheme(QStringLiteral("freeciv21-client")));
+ qApp->setWindowIcon(QIcon::fromTheme(QStringLiteral("freeciv21-ruledit")));
log_init();
@@ -75,9 +75,9 @@ int main(int argc, char **argv)
(void) bindtextdomain("freeciv21-ruledit", get_locale_dir());
#endif
- init_character_encodings(FC_DEFAULT_DATA_ENCODING, false);
+ init_character_encodings();
#ifdef ENABLE_NLS
- bind_textdomain_codeset("freeciv21-ruledit", get_internal_encoding());
+ bind_textdomain_codeset("freeciv21-ruledit", "UTF-8");
#endif
// Initialize command line arguments.
diff --git a/tools/ruledit/ruledit_qt.cpp b/tools/ruledit/ruledit_qt.cpp
index 5eed6e98b2..86b23b0dec 100644
--- a/tools/ruledit/ruledit_qt.cpp
+++ b/tools/ruledit/ruledit_qt.cpp
@@ -83,8 +83,6 @@ 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;
@@ -92,13 +90,12 @@ ruledit_gui::ruledit_gui(ruledit_main *main) : QObject(main)
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);
diff --git a/tools/ruleup.cpp b/tools/ruleup.cpp
index 15fab41290..e3b2b37b03 100644
--- a/tools/ruleup.cpp
+++ b/tools/ruleup.cpp
@@ -109,8 +109,7 @@ int main(int argc, char **argv)
log_init();
init_nls();
-
- init_character_encodings(FC_DEFAULT_DATA_ENCODING, false);
+ init_character_encodings();
rup_parse_cmdline(app);
diff --git a/tools/ruleutil/rulesave.cpp b/tools/ruleutil/rulesave.cpp
index 52fdfaaa07..5d8b53b329 100644
--- a/tools/ruleutil/rulesave.cpp
+++ b/tools/ruleutil/rulesave.cpp
@@ -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");
diff --git a/utility/CMakeLists.txt b/utility/CMakeLists.txt
index 8c4b29e57a..80b9fe5afe 100644
--- a/utility/CMakeLists.txt
+++ b/utility/CMakeLists.txt
@@ -65,8 +65,8 @@ target_include_directories(utility PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(utility PRIVATE ${STACK_UNWINDING_LIBRARY})
target_link_libraries(utility PRIVATE ${STACK_SYMBOLS_LIBRARY})
-target_link_libraries(utility PUBLIC Qt5::Core Qt5::Network)
-target_link_libraries(utility PRIVATE KF5::Archive)
+target_link_libraries(utility PUBLIC Qt6::Core Qt6::Network)
+target_link_libraries(utility PRIVATE KF6::Archive)
if (WIN32 OR MSYS OR MINGW)
target_link_libraries(utility PRIVATE ws2_32 wsock32)
endif()
diff --git a/utility/fc_version.h.in b/utility/fc_version.h.in
index 04673e0ce7..734bad4149 100644
--- a/utility/fc_version.h.in
+++ b/utility/fc_version.h.in
@@ -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 \
diff --git a/utility/fciconv.cpp b/utility/fciconv.cpp
index e940733d4f..61b576e52b 100644
--- a/utility/fciconv.cpp
+++ b/utility/fciconv.cpp
@@ -20,110 +20,45 @@
#include
#include
-#include
#include
-static QTextCodec *localCodec;
-static QTextCodec *dataCodec;
-static QTextCodec *internalCodec;
-
-static const char *transliteration_string;
-static const char *local_encoding, *data_encoding, *internal_encoding;
-
/**
Must be called during the initialization phase of server and client to
initialize the character encodings to be used.
Pass an internal encoding of nullptr to use the local encoding internally.
*/
-void init_character_encodings(const char *my_internal_encoding,
- bool my_use_transliteration)
+void init_character_encodings()
{
- transliteration_string = "";
- if (my_use_transliteration) {
- transliteration_string = "//TRANSLIT";
- }
-
- /* Set the data encoding - first check $FREECIV_DATA_ENCODING,
- * then fall back to the default. */
- data_encoding = getenv("FREECIV_DATA_ENCODING");
- if (!data_encoding) {
- data_encoding = FC_DEFAULT_DATA_ENCODING;
- }
-
- /* Set the local encoding - first check $FREECIV_LOCAL_ENCODING,
- * then ask the system. */
- local_encoding = getenv("FREECIV_LOCAL_ENCODING");
- if (!local_encoding) {
- local_encoding =
- qstrdup(QLocale::system().name().toLocal8Bit().constData());
- }
-
- /* Set the internal encoding - first check $FREECIV_INTERNAL_ENCODING,
- * then check the passed-in default value, then fall back to the local
- * encoding. */
- internal_encoding = getenv("FREECIV_INTERNAL_ENCODING");
- if (!internal_encoding) {
- internal_encoding = my_internal_encoding;
-
- if (!internal_encoding) {
- internal_encoding = local_encoding;
- }
- }
- localCodec = QTextCodec::codecForLocale();
- dataCodec = QTextCodec::codecForName(data_encoding);
- internalCodec = QTextCodec::codecForName(internal_encoding);
#ifdef FREECIV_ENABLE_NLS
- bind_textdomain_codeset("freeciv21-core", internal_encoding);
+ bind_textdomain_codeset("freeciv21-core", "UTF-8");
#endif
-
-#ifdef FREECIV_DEBUG
- fprintf(stderr, "Encodings: Data=%s, Local=%s, Internal=%s\n",
- data_encoding, local_encoding, internal_encoding);
-#endif // FREECIV_DEBUG
}
-/**
- Return the internal encoding. This depends on the server or GUI being
- used.
- */
-const char *get_internal_encoding() { return internal_encoding; }
-
char *data_to_internal_string_malloc(const char *text)
{
- QString s;
- s = dataCodec->toUnicode(text);
- s = internalCodec->fromUnicode(s);
- return qstrdup(s.toLocal8Bit().data());
+ return qstrdup(text);
}
+
char *internal_to_data_string_malloc(const char *text)
{
- QString s;
- s = internalCodec->toUnicode(text);
- s = dataCodec->fromUnicode(s);
- return qstrdup(s.toLocal8Bit().data());
+ return qstrdup(text);
}
+
char *internal_to_local_string_malloc(const char *text)
{
- QString s;
- s = internalCodec->toUnicode(text);
- s = localCodec->fromUnicode(s);
- return qstrdup(s.toLocal8Bit().data());
+ return qstrdup(QString(text).toLocal8Bit());
}
+
char *local_to_internal_string_malloc(const char *text)
{
- QString s;
- s = localCodec->toUnicode(text);
- s = internalCodec->fromUnicode(s);
- return qstrdup(s.toLocal8Bit().data());
+ return qstrdup(QString::fromLocal8Bit(text).toUtf8());
}
+
char *local_to_internal_string_buffer(const char *text, char *buf,
size_t bufsz)
{
- QString s;
- s = localCodec->toUnicode(text);
- s = internalCodec->fromUnicode(s);
- return qstrncpy(buf, s.toLocal8Bit().data(), bufsz);
+ return qstrncpy(buf, QString::fromLocal8Bit(text).toUtf8(), bufsz);
}
/**
diff --git a/utility/fciconv.h b/utility/fciconv.h
index 2de9b8d701..f96b46d41b 100644
--- a/utility/fciconv.h
+++ b/utility/fciconv.h
@@ -66,20 +66,15 @@
encoding.
*/
-#define FC_DEFAULT_DATA_ENCODING "UTF-8"
+void init_character_encodings();
-void init_character_encodings(const char *internal_encoding,
- bool use_transliteration);
+[[deprecated]] char *data_to_internal_string_malloc(const char *text);
+[[deprecated]] char *internal_to_data_string_malloc(const char *text);
+[[deprecated]] char *internal_to_local_string_malloc(const char *text);
+[[deprecated]] char *local_to_internal_string_malloc(const char *text);
-const char *get_internal_encoding();
-
-char *data_to_internal_string_malloc(const char *text);
-char *internal_to_data_string_malloc(const char *text);
-char *internal_to_local_string_malloc(const char *text);
-char *local_to_internal_string_malloc(const char *text);
-
-char *local_to_internal_string_buffer(const char *text, char *buf,
- size_t bufsz);
+[[deprecated]] char *
+local_to_internal_string_buffer(const char *text, char *buf, size_t bufsz);
#define fc_printf(...) fc_fprintf(stdout, __VA_ARGS__)
void fc_fprintf(FILE *stream, const char *format, ...)
diff --git a/utility/inputfile.cpp b/utility/inputfile.cpp
index 3508be98f2..f4b5e3eae6 100644
--- a/utility/inputfile.cpp
+++ b/utility/inputfile.cpp
@@ -68,7 +68,7 @@
#include
// KArchive
-#include
+#include
// utility
#include "fcintl.h"
@@ -206,7 +206,7 @@ struct inputfile *inf_from_file(const QString &filename,
fc_assert_ret_val(!filename.isEmpty(), nullptr);
fc_assert_ret_val(0 < filename.length(), nullptr);
- auto *fp = new KFilterDev(filename);
+ auto *fp = new KCompressionDevice(filename);
fp->open(QIODevice::ReadOnly);
if (!fp->isOpen()) {
delete fp;
@@ -234,7 +234,7 @@ struct inputfile *inf_from_stream(QIODevice *stream,
inf->filename.clear();
inf->fp = stream;
inf->stream = new QTextStream(stream);
- inf->stream->setCodec("UTF-8");
+ inf->stream->setEncoding(QStringConverter::Utf8);
inf->stream->setAutoDetectUnicode(true); // Allow UTF-16 and UTF-32
inf->datafn = datafn;
@@ -256,8 +256,8 @@ static void inf_close_partial(struct inputfile *inf)
// No way to determine whether a generic QIODevice has error'ed :(
bool error = false;
- if (dynamic_cast(inf->fp)) {
- error = dynamic_cast(inf->fp)->error() != 0;
+ if (dynamic_cast(inf->fp)) {
+ error = dynamic_cast(inf->fp)->error() != 0;
}
if (error) {
qCCritical(inf_category) << "Error before closing" << inf_filename(inf)
@@ -635,7 +635,7 @@ static QString get_token_entry_name(struct inputfile *inf)
}
// Check that we didn't eat a comment in the middle
- auto ref = inf->cur_line.midRef(inf->cur_line_pos, eq - inf->cur_line_pos);
+ auto ref = inf->cur_line.mid(inf->cur_line_pos, eq - inf->cur_line_pos);
if (ref.contains(';') || ref.contains('#')) {
return "";
}
@@ -802,7 +802,7 @@ static QString get_token_value(struct inputfile *inf)
qUtf8Printable(name));
return "";
}
- auto fp = new KFilterDev(rfname);
+ auto fp = new KCompressionDevice(rfname);
fp->open(QIODevice::ReadOnly);
if (!fp->isOpen()) {
qCCritical(inf_category, _("Cannot open stringfile \"%s\"."),
diff --git a/utility/registry_ini.cpp b/utility/registry_ini.cpp
index b55cd9914e..d660adb446 100644
--- a/utility/registry_ini.cpp
+++ b/utility/registry_ini.cpp
@@ -149,7 +149,8 @@
- Now uses hash.c
*/
// KArchive
-#include
+#include
+#include
// utility
#include "bugs.h"
@@ -620,7 +621,7 @@ bool secfile_save(const struct section_file *secfile, QString filename)
}
auto real_filename = interpret_tilde(filename);
- auto fs = std::make_unique(real_filename);
+ auto fs = std::make_unique(real_filename);
fs->open(QIODevice::WriteOnly);
if (!fs->isOpen()) {
diff --git a/utility/shared.cpp b/utility/shared.cpp
index d7debef602..ede808f030 100644
--- a/utility/shared.cpp
+++ b/utility/shared.cpp
@@ -56,7 +56,7 @@ static QStringList default_data_path()
QStringList{QStringLiteral("."), QStringLiteral("data"),
freeciv_storage_dir() + QStringLiteral("/" DATASUBDIR),
QStringLiteral(FREECIV_INSTALL_DATADIR)}
- + QStandardPaths::standardLocations(QStandardPaths::DataLocation);
+ + QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
QCoreApplication::setApplicationName(app_name);
return paths;
}
@@ -92,8 +92,6 @@ static QStringList scenario_dir_names = {};
static char *mc_group = nullptr;
-Q_GLOBAL_STATIC(QString, realfile);
-
/**
An AND function for fc_tristate.
*/
@@ -645,7 +643,7 @@ QVector *fileinfolist(const QStringList &dirs, const char *suffix)
dir.setNameFilters({QStringLiteral("*") + QString::fromUtf8(suffix)});
for (auto name : dir.entryList()) {
name.truncate(name.length() - qstrlen(suffix));
- files->append(name.toUtf8().data());
+ files->append(name);
}
}
std::sort(files->begin(), files->end());
@@ -657,48 +655,22 @@ QVector *fileinfolist(const QStringList &dirs, const char *suffix)
Returns a filename to access the specified file from a
directory by searching all specified directories for the file.
- If the specified 'filename' is empty, the returned string contains
- the effective path. (But this should probably only be used for
- debug output.)
-
Returns an empty string if the specified filename cannot be found
in any of the data directories.
*/
QString fileinfoname(const QStringList &dirs, const QString &filename)
{
- if (dirs.isEmpty()) {
- return QString();
- }
-
- if (filename.isEmpty()) {
- bool first = true;
-
- realfile->clear();
- for (const auto &dirname : dirs) {
- if (first) {
- *realfile += QStringLiteral("/%1").arg(dirname);
- first = false;
- } else {
- *realfile += QStringLiteral("%1").arg(dirname);
- }
- }
-
- return *realfile;
- }
-
for (const auto &dirname : dirs) {
- struct stat buf; // see if we can open the file or directory
-
- *realfile = QStringLiteral("%1/%2").arg(dirname, filename);
- if (fc_stat(qUtf8Printable(*realfile), &buf) == 0) {
- return *realfile;
+ QString path = dirname + QLatin1String("/") + filename;
+ if (QFileInfo::exists(path)) {
+ return path;
}
}
qDebug("Could not find readable file \"%s\" in data path.",
qUtf8Printable(filename));
- return nullptr;
+ return QString();
}
/**
@@ -1130,7 +1102,7 @@ QString interpret_tilde(const QString &filename)
if (filename == QLatin1String("~")) {
return QDir::homePath();
} else if (filename.startsWith(QLatin1String("~/"))) {
- return QDir::homePath() + filename.midRef(1);
+ return QDir::homePath() + filename.mid(1);
} else {
return filename;
}
diff --git a/utility/shared.h b/utility/shared.h
index 63c35cd13c..63e37066a5 100644
--- a/utility/shared.h
+++ b/utility/shared.h
@@ -21,8 +21,6 @@
#include
-template class QVector;
-
// Changing these will break network compatability!
#define MAX_LEN_ADDR 256 // see also MAXHOSTNAMELEN and RFC 1123 2.1
#define MAX_LEN_PATH 4095
diff --git a/utility/support.cpp b/utility/support.cpp
index 736d4c7825..e12aabf70b 100644
--- a/utility/support.cpp
+++ b/utility/support.cpp
@@ -101,7 +101,7 @@ int fc_strncasecmp(const char *str0, const char *str1, size_t n)
{
auto left = QString::fromUtf8(str0);
auto right = QString::fromUtf8(str1);
- return left.leftRef(n).compare(right.leftRef(n), Qt::CaseInsensitive);
+ return left.left(n).compare(right.left(n), Qt::CaseInsensitive);
}
/**
@@ -218,7 +218,7 @@ int fc_strncasequotecmp(const char *str0, const char *str1, size_t n)
&& right.endsWith(QLatin1String("\""))) {
right = right.mid(1, right.length() - 2);
}
- return left.leftRef(n).compare(right.leftRef(n), Qt::CaseInsensitive);
+ return left.left(n).compare(right.left(n), Qt::CaseInsensitive);
}
/**
@@ -267,44 +267,6 @@ FILE *fc_fopen(const char *filename, const char *opentype)
#endif // FREECIV_MSWINDOWS
}
-/**
- Wrapper function for remove() with filename conversion to local
- encoding on Windows.
- */
-int fc_remove(const char *filename)
-{
-#ifdef FREECIV_MSWINDOWS
- int result;
- char *filename_in_local_encoding =
- internal_to_local_string_malloc(filename);
-
- result = remove(filename_in_local_encoding);
- free(filename_in_local_encoding);
- return result;
-#else // FREECIV_MSWINDOWS
- return remove(filename);
-#endif // FREECIV_MSWINDOWS
-}
-
-/**
- Wrapper function for stat() with filename conversion to local
- encoding on Windows.
- */
-int fc_stat(const char *filename, struct stat *buf)
-{
-#ifdef FREECIV_MSWINDOWS
- int result;
- char *filename_in_local_encoding =
- internal_to_local_string_malloc(filename);
-
- result = stat(filename_in_local_encoding, buf);
- free(filename_in_local_encoding);
- return result;
-#else // FREECIV_MSWINDOWS
- return stat(filename, buf);
-#endif // FREECIV_MSWINDOWS
-}
-
/**
Returns last error code.
*/
@@ -423,7 +385,7 @@ size_t fc_strlcpy(char *dest, const char *src, size_t n)
size_t cut_at = n - 1;
QByteArray encoded;
do {
- encoded = source.leftRef(cut_at--).toUtf8();
+ encoded = source.left(cut_at--).toUtf8();
} while (cut_at > 0 && encoded.size() + 1 > n);
if (cut_at == 0) {
diff --git a/utility/support.h b/utility/support.h
index 445b428544..4b222ef541 100644
--- a/utility/support.h
+++ b/utility/support.h
@@ -123,8 +123,6 @@ int fc_strcoll(const char *str0, const char *str1);
int fc_stricoll(const char *str0, const char *str1);
FILE *fc_fopen(const char *filename, const char *opentype);
-int fc_remove(const char *filename);
-int fc_stat(const char *filename, struct stat *buf);
fc_errno fc_get_errno();
const char *fc_strerror(fc_errno err);
diff --git a/utility/tests/CMakeLists.txt b/utility/tests/CMakeLists.txt
index 2a25ad5537..1ef52e7e9e 100644
--- a/utility/tests/CMakeLists.txt
+++ b/utility/tests/CMakeLists.txt
@@ -1,5 +1,5 @@
set(CMAKE_AUTOMOC ON)
add_executable(test_utility_paths test_paths.cpp)
-target_link_libraries(test_utility_paths PRIVATE Qt5::Test utility)
+target_link_libraries(test_utility_paths PRIVATE Qt6::Test utility)
add_test(NAME test_utility_paths COMMAND test_utility_paths)
diff --git a/utility/version.cpp b/utility/version.cpp
index e815e6414d..f72c3d3c9c 100644
--- a/utility/version.cpp
+++ b/utility/version.cpp
@@ -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;
-}
diff --git a/utility/version.h b/utility/version.h
index b34df2157e..17db52af7e 100644
--- a/utility/version.h
+++ b/utility/version.h
@@ -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();
|
---|
|