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

Demo Qt 6 build #2222

Draft
wants to merge 89 commits into
base: master
Choose a base branch
from
Draft

Demo Qt 6 build #2222

wants to merge 89 commits into from

Conversation

lmoureaux
Copy link
Contributor

@lmoureaux lmoureaux commented Mar 17, 2024

Opening this commit mostly to see how easy it is to get going with the port (quite easy).

Known bugs:

  • Closing the client is impossible (getting the confirmation dialog in a loop)
  • It seems the font height metric changed, affecting city names
  • Cannot connect to a server started separately (the built-in one works)
  • Empty unit names are shown as garbage
  • Encodings are most likely broken on bad platforms ( 🪟 )
  • Distribution and CI issues are still not tackled at all

If you have Qt6 and Kf6 on your platform, give this branch a try! I'm sure there are many more bugs.

lmoureaux and others added 30 commits January 8, 2024 03:05
There was an encoding issue in fileinfoname() that prevented finding files with
special characters in the path (fc_stat would fail). Rewrite it using Qt APIs
only.

Closes longturn#565.
This prevents encoding issues.

See longturn#565.
Use QFileInfo. This removes the need to encode the file name in the system
locale by hand.

See longturn#565.
QFile() provides an API that doesn't require dangerous explicit encoding
conversions.

See longturn#565.
We need only two character encodings: whatever the local 8-bits encoding is and
UTF-8. QString provides native conversion between those so we don't need
anything of our own.

This also fully removes traces of past support for custom internal and data
encodings -- why would anyone want this now that UTF-8 has finally taken over
the world?

See longturn#565.
If a city is too large, the current logic will cause citizen sprites to overlap, which isn't very ergonomic. Instead, draw citizens in rows of a max size so players can see all of them.

Also fix specialist rotating logic which was broken when citizen sprites were overlapping.
Commit d1f50af broke the listener<> template
in a subtle way: the destructor wouldn't remove listeners from the set because
dynamic_cast to a derived type returns nullptr in a destructor. This caused a
segfault upon saving map images.

In order to solve both the warning that lead to the commit and the new bug,
change the set of instances to hold listener<A>* instead of A*, and use
dynamic_cast in invoke since the A objects are still valid there.

While I was there, I changed invoke() to be a variadic template. It wasn't one
because the code originally had to support C++03.
This simplifies the user interface and removes a clang warning about it being
potentially uninitialized.

See longturn#2139.
The checks whether the find, disband and upgrade buttons should be
enabled reference the wrong columns in the table.

This commit fixes the column references.
Freeciv21 has been added to the FreeBSD ports tree as `games/freeciv21`.
Add installation instructions.
Rendering of the Libertinus fonts was terrible with the (default) DirectWrite
backend on Windows. Install a `qt.conf` file forcing Qt to use FreeType.

While reviewing Qt options I also found a way to make the window title bars
dark if the user chose a dark theme. I enabled this as well.

Finally I moved files used for the Windows installer to dist/windows in an
effort to organize that folder.
It was noted in longturn#2155 that when packaging Freeciv21, sphinx_rtd_theme and
sphinx_last_updated_by_git were needed at build time to create the man pages.
The rtd theme is obviously only needed for HTML output and last_updated_by_git
doesn't seem to be used with the man pages. Make them both optional by checking
if they can be imported when evaluating the config.

This will allow package maintainers to ship man pages even when one of the two
packages are missing from their distribution.
This commit fixes the handling of the `FREECIV_ENABLE_MANPAGES` option,
leveraging the fact, that an `option` call is a no-op if the value is
already set.

While here, allow users on non-Unix systems to build manpages.

Closes longturn#2155
jwrober and others added 29 commits March 17, 2024 05:48
As the name suggests, this function can be used to change the size of
cities. This allows for some interesting scripted bonuses and penalties.
This allows enabling partisans earlier in the game with less powerful
units, and making partisans increasingly harder to kill as the attacked
player has more techs -- after all, partisans get their weapons by
plundering the city's stocks, so their equipment should be similar to
the units the player can build.
In rulesets where partisans cost population, we reduce the city size
accordingly by default (this be overriden by rulesets). This avoids an
exploit where two players would keep conquering a city back and forth to
generate an unbounded number of partisans: with this change, the city
would (very) quickly reach size 1 and become useless.
Develop your civilization from humble roots to a global empire.
Closes longturn#2182
If `FREECIV_ENABLE_MANPAGES` was set to `OFF` and Sphinx was available,
this setting was ignored during the build on Unix-like systems.

This commit fixes this issue.
When the modpack installer updates an already installed modpack, it
emits a bogus critical message that a query failed with error code 100.

Error code 100 is `SQLITE_ROW` and is not really an error, but signals
that a data row has been successfully read. `SQLITE_ROW` is also an
expected return value in `mpdb_update_modpack`.

Change the check for failed to queries to ignore `SQLITE_ROW`.
Make sure that every prepared statement in `mpdb_query` is finalized.
This changes the return value as an side effect (see below), change
return value checks accordingly.

This commit changes the return value of `mpdb_query`, as the old code
contained this special handling for `ret == SQLITE_DONE`:

```
if (ret == SQLITE_DONE) {
  ret = sqlite3_finalize(stmt);
}
```

This not only finalized the prepared statement, but also changed `ret`
to `SQLITE_OK`. After this commit `mpdb_query` returns either
`SQLITE_DONE` or `SQLITE_ROW`, instead of `SQLITE_OK` or `SQLITE_ROW`.
Make sure that every prepared statement in `mpdb_installed_version` is
finalized. After finalizing the pointer returned by
`sqlite3_column_text` becomes invalid and we must duplicate the string.
No functional changes.
Delete the strings returned by `mpdb_installed_version`.
This changes the CMake code to build Freeciv21 against Qt 6 and Kde
Frameworks 6.

See longturn#1198.
Still need to sort out encoding issues.
Known bug: cannot quit the client.
Qt's UI compiler uses connect() with the pointer-to-member-function
("pmf") syntax by default, but doesn't add a qOverride when needed.
Switch it back to string-based connections, as it was in Qt 5, for the
only UI file where this breaks in our code base.
@psampathkumar psampathkumar self-requested a review March 23, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants