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

Bugfix/clang tidy compilation database #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
48 changes: 8 additions & 40 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,17 @@ on: [pull_request]
jobs:
build:
name: clang-tidy
strategy:
matrix:
os: [ubuntu-latest]
compiler: [gcc]
build_type: [Debug]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- name: Set base_dir
run: echo "base_dir=$(pwd)" >> $GITHUB_ENV

- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install GCC
if: ${{ matrix.compiler == 'gcc' }}
run: |
sudo apt-get install g++
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install \
cmake \
ninja-build \
python3 \
gettext \
qtbase5-dev \
libqt5svg5-dev \
libkf5archive-dev \
liblua5.3-dev \
libsqlite3-dev \
libsdl2-mixer-dev
- name: Configure
run: |
cmake . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=on
- name: Build
run: |
cmake --build build
- uses: ZedThree/[email protected]

- uses: ZedThree/[email protected]
id: review
with:
# Tell clang-tidy-review the base directory.
# This will get replaced by the new working
# directory inside the action
base_dir: ${{ matrix.base_dir }}
apt_packages: 'cmake,ninja-build,python3,g++,gettext,qtbase5-dev,libqt5svg5-dev,libkf5archive-dev,liblua5.3-dev,libsqlite3-dev,libsdl2-mixer-dev'

# Tell clang-tidy-review the build directory, so it finds the
# compilation database.
build_dir: build
6 changes: 2 additions & 4 deletions client/client_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,17 +585,15 @@ int client_main(int argc, char *argv[])
boot_help_texts(client_current_nation_set(), tileset_help(tileset));

fill_topo_ts_default();

if (!forced_tileset_name.isEmpty()) {
if (!tilespec_try_read(qUtf8Printable(forced_tileset_name), true, -1,
true)) {
if (!tilespec_try_read(forced_tileset_name, true, -1)) {
qCritical(_("Can't load requested tileset %s!"),
qUtf8Printable(forced_tileset_name));
client_exit();
return EXIT_FAILURE;
}
} else {
tilespec_try_read(gui_options.default_tileset_name, false, -1, true);
tilespec_try_read(QString(), false, -1);
}

audio_real_init(sound_set_name, music_set_name, sound_plugin_name);
Expand Down
39 changes: 1 addition & 38 deletions client/connectdlg_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static int find_next_free_port(int starting_port, int highest_port)
bool client_start_server(const QString &user_name)
{
QStringList arguments;
QString trueFcser, ruleset, storage, port_buf, savesdir, scensdir;
QString trueFcser, storage, port_buf, savesdir, scensdir;
char buf[512];
int connect_tries = 0;

Expand Down Expand Up @@ -233,8 +233,6 @@ bool client_start_server(const QString &user_name)
return false;
}

ruleset = QString::fromUtf8(tileset_what_ruleset(tileset));

// Set up the command-line parameters.
port_buf = QString::number(internal_server_port);
savesdir = QStringLiteral("%1/saves").arg(storage);
Expand All @@ -256,9 +254,6 @@ bool client_start_server(const QString &user_name)
if (savefile.isEmpty()) {
arguments << QStringLiteral("--file") << savefile;
}
if (ruleset != nullptr) {
arguments << QStringLiteral("--ruleset") << ruleset;
}

// Look for a server binary
const QString server_name = QStringLiteral("freeciv21-server");
Expand Down Expand Up @@ -330,38 +325,6 @@ bool client_start_server(const QString &user_name)
return false;
}

/* We set the topology to match the view.
*
* When a typical player launches a game, he wants the map orientation to
* match the tileset orientation. So if you use an isometric tileset you
* get an iso-map and for a classic tileset you get a classic map. In
* both cases the map wraps in the X direction by default.
*
* This works with hex maps too now. A hex map always has
* tileset_is_isometric(tileset) return TRUE. An iso-hex map has
* tileset_hex_height(tileset) != 0, while a non-iso hex map
* has tileset_hex_width(tileset) != 0.
*
* Setting the option here is a bit of a hack, but so long as the client
* has sufficient permissions to do so (it doesn't have HACK access yet) it
* is safe enough. Note that if you load a savegame the topology will be
* set but then overwritten during the load.
*
* Don't send it now, it will be sent to the server when receiving the
* server setting infos. */
{
char topobuf[16];

fc_strlcpy(topobuf, "WRAPX", sizeof(topobuf));
if (tileset_is_isometric(tileset) && 0 == tileset_hex_height(tileset)) {
fc_strlcat(topobuf, "|ISO", sizeof(topobuf));
}
if (0 < tileset_hex_width(tileset) || 0 < tileset_hex_height(tileset)) {
fc_strlcat(topobuf, "|HEX", sizeof(topobuf));
}
desired_settable_option_update("topology", topobuf, false);
}

return true;
}

Expand Down
21 changes: 3 additions & 18 deletions client/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ struct client_options gui_options = {

/** Migrations **/
false, //.first_boot =
"\0", //.default_tileset_name =
"\0", //.default_tileset_overhead_name =
"\0", //.default_tileset_iso_name =
false, //.gui_qt_migrated_from_2_5 =
Expand Down Expand Up @@ -4418,11 +4417,6 @@ void options_load()
secfile_lookup_bool_default(sf, gui_options.gui_qt_migrated_from_2_5,
"%s.migration_qt_from_2_5", prefix);

str =
secfile_lookup_str_default(sf, nullptr, "client.default_tileset_name");
if (str != nullptr) {
sz_strlcpy(gui_options.default_tileset_name, str);
}
str = secfile_lookup_str_default(sf, nullptr,
"client.default_tileset_overhead_name");
if (str != nullptr) {
Expand Down Expand Up @@ -4531,11 +4525,6 @@ void options_save(option_save_log_callback log_cb)
client_options_iterate_all(poption) { client_option_save(poption, sf); }
client_options_iterate_all_end;

if (gui_options.default_tileset_name[0] != '\0') {
secfile_insert_str(sf, gui_options.default_tileset_name,
"client.default_tileset_name");
}

message_options_save(sf, "client");
options_dialogs_save(sf);

Expand Down Expand Up @@ -4878,10 +4867,6 @@ const char *tileset_name_for_topology(int topology_id)
break;
}

if (tsn == nullptr) {
tsn = gui_options.default_tileset_name;
}

return tsn;
}

Expand Down Expand Up @@ -4957,15 +4942,15 @@ void fill_topo_ts_default()
sizeof(gui_options.default_tileset_square_name));
} else {
log_debug("Setting tileset for square topologies.");
tilespec_try_read(nullptr, false, 0, false);
tilespec_try_read(QString(), false, 0);
}
}
if (is_ts_option_unset("default_tileset_hex_name")) {
log_debug("Setting tileset for hex topology.");
tilespec_try_read(nullptr, false, TF_HEX, false);
tilespec_try_read(QString(), false, TF_HEX);
}
if (is_ts_option_unset("default_tileset_isohex_name")) {
log_debug("Setting tileset for isohex topology.");
tilespec_try_read(nullptr, false, TF_ISO | TF_HEX, false);
tilespec_try_read(QString(), false, TF_ISO | TF_HEX);
}
}
5 changes: 2 additions & 3 deletions client/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ struct client_options {
bool save_options_on_exit;

/** Migrations **/
bool first_boot; /* There was no earlier options saved.
* This affects some migrations, but not all. */
char default_tileset_name[512]; // pre-2.6 had just this one tileset name
bool first_boot; /* There was no earlier options saved.
* This affects some migrations, but not all. */
char default_tileset_overhead_name[512]; /* 2.6 had separate tilesets for
... */
char default_tileset_iso_name[512]; // ...overhead and iso topologies.
Expand Down
Loading