No description
Find a file
Basile Clement c14936c63c
PictureLoader: Replace downloadedPics cache with QNetworkCache (#4756)
* PictureLoader: Replace downloadedPics cache with QNetworkCache

Currently when the "Download card pictures on the fly" option is
enabled, Cockatrice stores downloaded pictures into a downloadedPics
sub-folder, keyed on set and card name. If a picture is found in that
folder, we never try to download a picture for that card ever again
(until it is reprinted in a more recent set, I guess).

This has the unfortunate consequence that if you change the URLs for
downloading card images, the changes are not applied to cards that
already have their picture downloaded. In particular, if you use
localized card pictures (through !sflang!), you get a mix of cards in
different languages depending on the currently configured language at
the time each card was downloaded.

This patch removes that mechanism in favor of setting a
QNetworkDiskCache on the QNetworkAccessManager used by the PictureLoader
to download pictures. The QNetworkDiskCache caches the picture keyed on
their URL: if the URL changes, a new request will be made. In
particular, if you use picture URLs with !sflang! and change the
language, pictures for the current language will be downloaded even for
cards that already have a picture. The QNetworkDiskCache is configured
with a maximum size of 4GB, which should be enough to hold one
high-quality JPEG for each M:TG card in existence.

Note that this does not affect the existing mechanism for defining
custom card art, either through the CUSTOM directory or the set-based
one.  Cockatrice will still read existing cards in the downloadedPics
directory as before, it will just no longer write into that directory
(since pictures are cached by the QNetworkDiskCache instead). To fully
switch to the new cache, users should use the "Delete Downloaded Images"
button in the settings: it will clear the QNetworkDiskCache but also
remove the downloadedPics directory.

* Do not use system cache dir for portable installs

* Add settings for network cache size

* Delete corrupted cache entries

* Use old-style connect() syntax (Qt5 build failure)

* Add setNetworkCacheSizeInMB to test mocks

* setTransferTimeout was added in Qt 5.15

* Improve logging messages

We now have the following messages

 - "Trying to download picture from url: URL" before loading a picture
   when picture download is enabled
 - "Trying to load picture from cache: URL" before loading a picture
   when picture download is disabled (i.e. cache-only offline mode)
 - "Removing corrupted cache file for url URL and retrying (ERR)" when
   when we fail to load a picture from the cache. Usually, this should
   be due to the timeout, in which case ERR will be "Operation
   Canceled".
 - "Download failed for url URL (ERR)" when there was an error
   downloading a picture from the network (ERR is the error message)
 - "Following redirect to URL" and "Following cached redirect to URL"
   when following a redirect (from network/from cache)
 - "Image successfully downloaded from URL" and "Image successfully
   loaded from cached url at URL" on success
 - "Possible cached/downloaded picture at URL could not be loaded" on
   ImageReader error

* Clarify that network cache is on disk

Also migrate "Delete Downloaded Image" to a "Clear" button right next to
the network cache size.

* Remove qPrintable

* Move pixmap cache settings to card sources

* qDebug().nospace()

* some formatting on debug messages

* format

* inverted condition

---------

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
2023-03-03 16:55:17 +01:00
.ci replace github release actions with the gh tool in bash (#4746) 2023-02-10 03:33:48 -05:00
.github set the target in the created release (#4758) 2023-02-23 01:11:41 +01:00
.husky Webatrice: husky (#4591) 2022-03-13 13:44:51 -04:00
.tx Add i18n for Oracle and fix Transifex 2022-01-22 00:17:29 -05:00
cmake Find OpenSSL on Windows (#4730) 2023-02-07 16:47:50 -05:00
cockatrice PictureLoader: Replace downloadedPics cache with QNetworkCache (#4756) 2023-03-03 16:55:17 +01:00
common Better support Double-Faced Cards (#4753) 2023-03-03 16:54:51 +01:00
dbconverter PictureLoader: Replace downloadedPics cache with QNetworkCache (#4756) 2023-03-03 16:55:17 +01:00
doc Oracle / card xml improvements (#3934) 2020-03-30 21:56:03 +02:00
oracle Better support Double-Faced Cards (#4753) 2023-03-03 16:54:51 +01:00
servatrice use qt6 in arch builds (#4691) 2022-10-31 23:26:13 +01:00
tests PictureLoader: Replace downloadedPics cache with QNetworkCache (#4756) 2023-03-03 16:55:17 +01:00
vcpkg@c30de8e136 Find OpenSSL on Windows (#4730) 2023-02-07 16:47:50 -05:00
webclient Add architecture image to webclient README (#4745) 2023-02-08 18:04:23 +01:00
.clang-format apply clang format to proto files (#4123) 2020-10-02 12:14:05 -04:00
.cmake-format.json rework formatting with cmake-format (#4627) 2022-06-08 21:14:26 -04:00
.codacy.yml yml config documentation (#2899) 2017-11-04 20:16:41 -04:00
.dockerignore Update CONTRIBUTING and more travis removing (#4179) 2020-11-28 03:14:15 -05:00
.gitignore Support Qt6, Min Qt5.8, Fix Win32, Fix Servatrice 2022-05-06 17:31:08 -04:00
.gitmodules CI: Fix up Windows builds and add GitHub Actions for Windows (#4193) 2020-11-30 23:54:50 -05:00
CMakeLists.txt rework formatting with cmake-format (#4627) 2022-06-08 21:14:26 -04:00
docker-compose.yml Disabled strict mode for MySQL on the docker-compose file (#4214) 2020-12-28 16:43:45 -05:00
docker-compose.yml.windows Docker-Compose support for Windows (#3974) 2020-05-08 15:22:39 -04:00
Dockerfile Update Dockerfile to include missing lib, not build dbconv, and use ENTRYPOINT (#3808) 2019-09-09 17:06:28 +02:00
format.sh fix typo in format.sh (#4647) 2022-07-05 15:49:19 -04:00
LICENSE repo cleanup (#2826) 2017-08-11 21:42:45 -04:00
README.md Find OpenSSL on Windows (#4730) 2023-02-07 16:47:50 -05:00
vcpkg.json Support Qt6, Min Qt5.8, Fix Win32, Fix Servatrice 2022-05-06 17:31:08 -04:00


Cockatrice | Download | Get Involved | Community | Translations | Build | Run | License



To get started, ⇢ view our webpage
To get support or suggest changes ⇢ file an issue (How?) To help with development, see how to get involved

Cockatrice

Cockatrice is an open-source, multiplatform program for playing tabletop card games over a network. The program's server design prevents users from manipulating the game for unfair advantage. The client also provides a single-player mode, which allows users to brew while offline. This project uses C++ and the Qt5 libraries.

Download Cockatrice Eternal Download Count

Downloads are available for full releases and the current beta version in development. There is no strict release schedule for either of them.

  • Latest stable release: Download from GitHub Releases DL Count on Latest Release

    • Stable versions are checkpoints featuring major feature and UI enhancements.
    • Recommended for most users!
  • Latest beta release: Download from GitHub Pre-Releases DL Count on Latest Pre-Release

    • Beta versions include the most recently added features and bugfixes, but can be unstable.
    • To be a Cockatrice Beta Tester, use this version. Find more information here!

Get Involved Discord Gitter Chat

Join our Discord community to connect with the project or fellow users of the app. The Cockatrice developers are also available on Gitter. Come here to talk about the application, features, or just to hang out.
For support regarding specific servers, please contact that server's admin or forum for support rather than asking here.

To contribute code to the project, please review the guidelines. We maintain two tags for contributors to find issues to work on:

  • Good first issue: issues tagged in this way provide a simple way to get started. They don't require much experience to be worked on.
  • Help wanted: This tag is used for issues that we are looking for a contributor to work on. Often this is for feature suggestions we are willing to accept, but don't have the time to work on ourselves.

For both tags, we're willing to provide help to contributors in showing them where and how they can make changes, as well as code review for changes they submit.

We try to be responsive to new issues. We'll provide advice on how best to implement a feature; alternately, we can show you where the codebase is doing something similar before you get too far along.

Cockatrice uses the Google Developer Documentation Style Guide to ensure consistent documentation. We encourage you to improve the documentation by suggesting edits based on this guide.

Community Resources

Translations Transifex Project

Cockatrice uses Transifex for translations. You can help us bring Cockatrice and Oracle to your language or just edit single wordings right from within your browser by visiting our Transifex project page.

Cockatrice Oracle
Cockatrice Translation Status Oracle Translation Status

Check out our Translator FAQ for more information about contributing!

Build CI Desktop CI Web

Detailed compiling instructions can be found on the Cockatrice wiki under Compiling Cockatrice

Dependencies: (for minimum requirements search our CMake file)

Oracle can optionally use zlib and xz to load compressed files:

To compile:

mkdir build
cd build
cmake ..
make

You can then run

make install

to get a cockatrice installation inside the release folder, or:

make package

to create a system-specific installation package.

The following flags can be passed to cmake:

  • -DWITH_SERVER=1 Whether to build the server (default 0 = no).
  • -DWITH_CLIENT=0 Whether to build the client (default 1 = yes).
  • -DWITH_ORACLE=0 Whether to build oracle (default 1 = yes).
  • -DCMAKE_BUILD_TYPE=Debug Compile in debug mode. Enables extra logging output, debug symbols, and much more verbose compiler warnings (default Release).
  • -DWARNING_AS_ERROR=0 Whether to treat compilation warnings as errors in debug mode (default 1 = yes).
  • -DUPDATE_TRANSLATIONS=1 Configure make to update the translation .ts files for new strings in the source code. Note: Running make clean will remove the .ts files (default 0 = no).
  • -DTEST=1 Enable regression tests (default 0 = no). Note: needs googletest, will be downloaded on the fly if unavailable. To run tests: make test.
  • -DFORCE_USE_QT5=1 Skip looking for Qt6 before trying to find Qt5
  • -DOPEN_SSL_PATH=C:/Path/To/Tools/OpenSSL/Win_x64/bin" Designate the OpenSSL Path if you're using non-standard directives

Run

Cockatrice is the game client
Oracle fetches card data
Servatrice is the server

Servatrice Docker container

You can run an instance of Servatrice (the Cockatrice server) using Docker and the Cockatrice Dockerfile.

First, create an image from the Dockerfile
cd /path/to/Cockatrice-Repo/ docker build -t servatrice .
And then run it
docker run -i -p 4747:4747/tcp -t servatrice:latest

Note: Running this command exposes the TCP port 4747 of the docker container
to permit connections to the server.

Find more information on how to use Servatrice with Docker in our wiki.

Docker compose

There is also a docker-compose file available which will configure and run both a MySQL server and Servatrice. The docker-compose setup scripts can be found in the servatrice/docker folder and vary only slightly from the default sql and server .ini files. The setup scripts can either be modified in place, or docker-compose can mount alternative files into the images, as you prefer.

To run Servatrice via docker-compose, first install docker-compose following the install instructions. Once installed, run the following from the root of the repository:

docker-compose build    # Build the Servatrice image using the same Dockerfile as above.
docker-compose up       # Setup and run both the MySQL server and Servatrice.

Note: Similar to the above Docker setup, this will expose TCP ports 4747 and 4748.

Note: The first time running the docker-compose setup, the MySQL server will take a little time to run the initial setup scripts. Due to this, the Servatrice instance may fail the first few attempts to connect to the database. Servatrice is set to restart: always in the docker-compose.yml, which will allow it to continue attempting to start up. Once the MySQL scripts have completed, Servatrice should then connect automatically on the next attempt.

Docker compose in Windows A out of box working docker-compose file has been added to help setup in Windows.

Docker in Windows requires additional steps in form of using Docker Desktop to allow resource sharing from the drive the volumes are mapped from, as well as potential workarounds needed to get file sharing working in Windows. This StackOverflow discussion sheds some light on it

License GPLv2 License

Cockatrice is free software, licensed under the GPLv2.