Commit Graph
100 Commits
Author SHA1 Message Date
Alexander WilmsandAlexander Wilms 6678aafbbb Update googletest submodule
Fixes the following warning, occurring during the linux-clang-test CI builds:

[824/832] Building CXX object test/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/src/gtest-all.cc:38:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest.h:65:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-death-test.h:43:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:47:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-matchers.h:48:
/home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-printers.h:532:9: warning: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Wimplicit-int-float-conversion]
  532 |     if (static_cast<int32_t>(val * mulfor6 + 0.5) / mulfor6 == val) return 6;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
/home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-printers.h:551:17: note: in instantiation of function template specialization 'testing::internal::AppropriateResolution<float>' requested here
  551 |   os->precision(AppropriateResolution(f));
      |                 ^
/home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-printers.h:544:9: warning: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Wimplicit-int-float-conversion]
  544 |     if (static_cast<int32_t>(val / divfor6 + 0.5) * divfor6 == val) return 6;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
2 warnings generated.
2024-08-02 15:09:48 +00:00
Alexander Wilms e2396d2a27 CI: Use URL relative to repo's owner for test data
This allows to easily run tests in forks
2024-07-23 01:43:26 +02:00
Alexander Wilms 6687d3b684 startExecutable(): Forward executable's output, so vcmiclient's stdout and stderr aren't hidden 2024-07-18 23:54:33 +02:00
Alexander Wilms 4f06aed631 CModListView::loadScreenshots(): Ensure a mod is selected in allModsView
Fixes #989
Fixes #3811
2024-07-18 22:33:48 +02:00
Alexander Wilms 187b7b0517 Show debug message instead of warning if no .qm file for selected language exists 2024-07-18 20:44:24 +02:00
Alexander Wilms 6599db4461 Less noise when switching languages in launcher
* Check if .qm file exists
* Don't call installTranslator() for English

Fixes #4277
2024-07-18 20:44:24 +02:00
Alexander Wilms 1b3fcbcd8d CMake.md: Use markdown list instead of HTML table 2024-07-17 18:17:55 +02:00
Alexander Wilms 5712c3f9f4 JsonNode change: Fix test 2024-07-17 15:20:18 +02:00
Alexander Wilms b605dea6db JsonNode::JsonNode(): Also use reference for fileName argument in method definition 2024-07-17 14:37:58 +02:00
Alexander Wilms 434371195d JsonNode constructors: Take fileName as argument
* Don't print JSON in JsonParser::parse() in case of errors
2024-07-17 13:50:59 +02:00
Alexander Wilms 1ca8e9b3ae JsonParser::parse(): Print JSON if there were errors while parsing
In cases where the file name was not specified, the warning messages were not very useful.

Example:

```json
File <unknown> is not a valid JSON file!
At line 33, position 1 warning: Comma expected!

{
        "name" : "New Old Heroes",
        "description" : "New heroes based on old 3DO artwork and other game appearances. Requires Horn of the Abyss.",
        "modType" : "Heroes",
        "version" : "1.2.0",
        "author" : "Aphra",
        "contact" : "",

        "heroes" :
        [
                "config/gwenneth.json",
                "config/balindar.json",
                "config/nicolas.json",
                "config/kastore.json",
                "config/kydoimos.json",
                "config/athe.json",
                "config/miseria.json",
                "config/areshrak.json",
                "config/pactal.json",
                "config/zog.json"
        ],

        "changelog" :
    {
        "1.0.0"   : ["Initial release"],
        "1.1.0"   : ["Added Nicolas Gryphonheart and Kastore"],
        "1.1.1"   : ["Bug fixes"],
        "1.2.0"   : ["Added some HotA portrait-only campaign heroes"]
    },

        "depends" :
                [ "hota.neutralCreatures" ]
        "keepDisabled" : true
}
```
2024-07-17 13:17:43 +02:00
Alexander Wilms f2a1b47229 CModListView::CModListView(): Set background color of QSplitter to window color for seamless appearance 2024-07-17 10:50:39 +02:00
Alexander Wilms 466318b77b JsonParser::error(): Don't add trailing newline 2024-07-15 23:58:56 +02:00
Alexander Wilms fb51dfb653 Add .directory files to .gitignore
KDE's file manager Dolphin will create a hidden .directory file in each folder one changes view properties for
2024-07-15 20:32:16 +02:00
Alexander Wilms 775b20bfe2 Remove .clangd config and add separate markdown file explaining some CMake options 2024-07-15 15:48:36 +02:00
Alexander Wilms 97c9cd483b Improve Linux developer documentation
* List CMake options in table
* Improve headline hierarchy
* Add .clangd config file so compile_commands.json gets found out-of-the-box
2024-07-15 15:47:37 +02:00
Alexander Wilms f9de3b2ffd startExecutable(): Restore error handling 2024-07-14 21:04:36 +02:00
Alexander Wilms 875a8cc11a startExecutable(): Use QProcess::start() instead of QProcess::startDetached() to fix the missing prompt after quitting vcmiclient or vcmieditor
vcmilauncher is now hidden while the child process is running, since it doesn't get repainted.

Fixes #2574
2024-07-14 21:04:36 +02:00
Alexander WilmsandAlexander Wilms 31e1d39f92 Fix issues introduced by fixing typos 2024-06-27 08:38:04 +00:00
Alexander Wilms 02e429e973 Fix typos using https://github.com/crate-ci/typos
Changes were reviewed manually
2024-06-24 03:47:19 +02:00
Alexander Wilms 820b1b446e Fix typo: TowmPortalFinder -> TownPortalFinder 2024-06-23 22:40:15 +02:00
Alexander Wilms ea48257100 Fix SonarCloud issues
Replace the use of "::value" with "std::is_abstract_v" and similar issues
2024-03-02 14:08:03 +01:00
Alexander Wilms 73a1a188d9 Update metainfo to conform to AppStream 1.0 spec 2024-02-23 19:26:38 +01:00
Alexander Wilms 06a56a0ec3 Try to fix compilation error:
/home/runner/work/vcmi/vcmi/test/../Global.h:700:36: error: no matching function for call to 'max'
                const Floating relativeEpsilon = std::max(std::abs(left), std::abs(right)) * epsilon;
                                                 ^~~~~~~~
/home/runner/work/vcmi/vcmi/test/JsonComparer.cpp:48:16: note: in instantiation of function template specialization 'vstd::isAlmostEqual<double, int>' requested here
                return vstd::isAlmostEqual(value.Float(), 0);
                             ^
2024-02-18 23:32:12 +01:00
Alexander Wilms fc1e9f70f9 Fix float comparison 2024-02-18 23:16:11 +01:00
Alexander Wilms 2ea78a5883 Fix float comparisons
Replace this "==" with a more tolerant comparison operation.
Floating point numbers should not be tested for equality cpp:S1244
2024-02-14 23:30:29 +01:00
Alexander Wilms a8f79ad9d8 Try to fix CMake warning:
-- Found SDL2: /usr/lib/x86_64-linux-gnu/libSDL2.so (found version "2.0.20")
CMake Warning (dev) at /usr/local/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SDL2main)
  does not match the name of the calling package (SDL2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake_modules/FindSDL2.cmake:318 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:473 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.
2024-02-14 09:32:34 +01:00
Alexander Wilms c65794b9e3 Fix typos 2024-02-13 15:23:30 +01:00
Alexander Wilms 678cacbd25 Remove more redundant virtual specifiers
`grep -nr "virtual " | grep -v googletest | grep " override" | grep -v overriden > ../redundant_virtual.txt`

```python
import os

with open("../redundant_virtual.txt") as f:
    for line in f:
        print()
        line: str = line.strip()
        print(line)
        tmp = line.split(":",2)
        file = tmp[0].strip()
        code = tmp[-1].strip()
        print(file)
        print(code)
        new_code = code.replace("virtual ", "", 1)
        # https://superuser.com/a/802490/578501
        command = f"export FIND='{code}' && export REPLACE='{new_code}' && ruby -p -i -e \"gsub(ENV['FIND'], ENV['REPLACE'])\" {file}"
        os.system(command)
```
2024-02-13 15:21:30 +01:00
Alexander Wilms 95b35a1063 CI: Accept JSON with comments, but not JSON5 in its entirety 2024-02-12 00:49:57 +01:00
Alexander Wilms 1fa3447ee7 CI: Fix Ccache for branches other than develop in forks of vcmi/vcmi 2024-02-12 00:49:45 +01:00
Alexander Wilms 54b44aa5e8 Re-add virtual that was accidentally removed 2024-02-10 20:46:23 +01:00
Alexander Wilms 522cb571b3 Remove redundant virtual specifiers
`grep -nr virtual | grep -v googletest | grep override > ../redundant_virtual.txt`

```python
import os

with open("../redundant_virtual.txt") as f:
    for line in f:
        print()
        line: str = line.strip()
        print(line)
        tmp = line.split(":")
        file = tmp[0].strip()
        code = tmp[-1].strip()
        print(file)
        print(code)
        new_code = code.replace("virtual ", "", 1)
        # https://superuser.com/a/802490/578501
        command = f"export FIND='{code}' && export REPLACE='{new_code}' && ruby -p -i -e \"gsub(ENV['FIND'], ENV['REPLACE'])\" {file}"
        os.system(command)
```
2024-02-10 20:46:13 +01:00
Alexander Wilms a7c29e2a95 CI: Only use json5 Python package for validation
This simplifies the script and makes the output more readable
2024-02-08 21:13:20 +01:00
Alexander Wilms efb021333b Building_Linux.md: Use cmake -S ../vcmi instead of cmake ../vcmi 2024-02-05 22:32:45 +01:00
Alexander Wilms a2bd3f5b46 Add more patterns to .gitignore
These were needed for files created by
`cmake ../vcmi && cmake --build .`
2024-02-05 22:32:41 +01:00
Alexander Wilms 0495c52cf4 Don't call ScreenHandler::onScreenResize() when the window has been (un)maximized to avoid creating a huge texture and crashing 2024-02-05 18:59:55 +01:00
Alexander Wilms caa22ad9d8 Don't call recreateWindowAndScreenBuffers() in ScreenHandler::onScreenResize() to fix crash due to a huge texture being created 2024-02-02 08:52:59 +01:00
Alexander Wilms 5222495701 Run CI on every push to develop branch instead of on a schedule
Also remove logic to skip CI if it already ran for the same commit

This prevents the CI badge in the README from showing a failure due to a skipped CI run and
results in more up-to-date ccache caches for each PR's initial CI run
2024-01-30 20:51:27 +01:00
Alexander Wilms 6085893c0d CVideoPlayer: Make overlay an argument of playVideo() instead of an attribute 2024-01-29 20:27:00 +01:00
Alexander Wilms 70ce090bc4 CVideoHandler: Use EVideoType::INTRO and EVideoType::SPELLBOOK 2024-01-29 16:08:53 +01:00
Alexander Wilms 33e170d562 CVideoHandler: Call SDL_RenderClear() when playing intro, call SDL_RenderFillRect() for spellbook animation 2024-01-28 22:53:51 +01:00
Alexander Wilms 1975a08a3c Retry cpack until it succeeds 2024-01-23 14:13:35 +00:00
Alexander Wilms d937d26b80 CPack isn't used for iOS builds, so only kill XProtect if we're building for macOS
Also wait at most 10 s for XProtect to be killed
2024-01-23 12:45:49 +00:00
Alexander Wilms 81c3339199 Add second workaround for CPack issue on macOS 2024-01-22 23:25:23 +00:00
Alexander Wilms b364f707cd Fix issues introduced by automated replacement of redundant types 2024-01-17 20:12:57 +00:00
Alexander Wilms 7a1cee1a60 Fix error: 'auto' not allowed in non-static struct member 2024-01-17 14:49:28 +00:00
Alexander Wilms 57c51b62fd Fix CGameHandler.cpp:1026:4: error: function 'getAllowedSpells' with deduced return type cannot be used before it is defined 2024-01-17 14:41:53 +00:00
Alexander Wilms 271eeca11b Fix BattleEvaluator.cpp:286:32: error: function 'battleGetAllObstacles' with deduced return type cannot be used before it is defined 2024-01-17 14:41:47 +00:00
Alexander Wilms f08c6d1ce9 Fix issues created by type replacement script 2024-01-17 14:33:02 +00:00
Alexander Wilms 73019c204d Replace redundant types with auto for the lvalues of template factory functions for smart pointers
grep -r --include \*.h --include \*.cpp "= std::" * | grep -v auto | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return" | grep -v double | grep -v si64 | grep -v si32 | grep -v ui32 | grep \< | grep -v float | tr -d '\t' | grep -v assert > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = ":".join(line.split(":")[1:]).strip()

        print()
        print(path)
        print(original_code)
        prefix = "auto "
        if original_code.startswith("static"):
            static = True
        else:
            static = False

        cpp_type = " ".join(original_code.split("=")[0].strip().split(" ")[0:-1])
        print(cpp_type)

        if static:
            new_code = "static auto "+ " ".join(original_code.split(" ")[2:])
        else:
            new_code = "auto "+ " ".join(original_code.split(" ")[1:])
        print(new_code)

        if True:
            with open(path, "r") as f:
                filedata = f.read()

            filedata = filedata.replace(original_code, new_code)

            with open(path, "w") as f:
                f.write(filedata)
2024-01-17 12:50:00 +00:00
Alexander Wilms 24b5f3f552 Fix CQuest.h:101:2: error: 'auto' not allowed in non-static class member 2024-01-16 21:46:25 +00:00
Alexander Wilms 1b85abb508 Use auto instead of redundant type in initializations using new
grep -r --include \*.h --include \*.cpp "=" * | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return\|{\|}\|= \"\|= tr(\|virtual\|void" | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "float\|nullptr" | grep "new" | grep -v "AI/FuzzyLite" | grep \( | grep "= new" > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = line.split(":")[1].strip()
        if "new " in original_code:

            cpp_type = original_code.split(" ")[0]
            if original_code.count(cpp_type) == 2:
                print()
                print(path)
                print(original_code)
                new_code = "auto "+" ".join(original_code.split(" ")[1:])
                print(new_code)

                with open(path, "r") as f:
                    filedata = f.read()

                filedata = filedata.replace(original_code, new_code)

                with open(path, "w") as f:
                    f.write(filedata)
2024-01-16 21:40:53 +00:00
Alexander Wilms 558ead41fe Add missing semicolon after macro usage 2024-01-16 20:18:18 +00:00
Alexander Wilms ccac73fb69 Remove trailing semicolons from more macros 2024-01-16 19:46:21 +00:00
Alexander Wilms cca08e29da Remove duplicate semicolons 2024-01-16 19:02:39 +00:00
Alexander Wilms cb82fcd954 Try to work around macOS CPack error 2024-01-15 13:00:41 +00:00
Alexander Wilms 9dd09d0a7e Make CI badge link to scheduled builds 2024-01-15 12:24:04 +00:00
Alexander Wilms 58f0dbc38b CI: Remove act10ns/slack action, since Slack's own GitHub app is sufficient 2024-01-15 11:11:24 +00:00
Alexander Wilms 03b20b5d58 CI: Add empty lines between steps in workflow file 2024-01-15 11:11:18 +00:00
Alexander Wilms 7c836f1320 Removed the unused EthanSK/git-branch-name-action@v1 action from CI workflow 2024-01-15 10:37:06 +00:00
Alexander Wilms bc781c28e0 Remove trailing semicolon from NET_EVENT_HANDLER macro 2024-01-14 14:49:25 +00:00
Alexander Wilms d2b105f216 CLoggerBase: Use IvanSavenko's single-statement macro so that ct100 is not immediately destroyed 2024-01-14 14:48:48 +00:00
Alexander Wilms a0565e522b Add Dependabot configuration to update GitHub Actions 2024-01-14 00:59:51 +00:00
Alexander Wilms 09ce8cef96 CI badge: Only report status of vcmi/vcmi, ignore statuses of PRs
Show status of latest scheduled CI run on the develop branch.
Until now, the status of the latest CI run was shown, even if that was triggered by a PR
2024-01-13 23:05:14 +00:00
Alexander Wilms f81a0cb4b6 CLoggerBase: Remove semicolon from RAII_TRACE definition
Fixes the following SonarCloud issue:

Modify the macro definition so that it needs to be followed by a semicolon, or remove this empty statement.
Empty statements should be removed cpp:S1116
https://sonarcloud.io/organizations/vcmi/rules?open=cpp%3AS1116&rule_key=cpp%3AS1116
2024-01-13 18:13:56 +00:00
Alexander Wilms c0c16fed75 Move FPS counter to bottom left, set width of black background to suffice for 3 digit FPS
Fixes #3171
2023-11-13 02:52:19 +01:00
Alexander Wilms eee1a4d061 CVideoHandler.cpp: Clear screen before rendering each frame of the intro
This way, the background is black instead of showing glitchy artifacts when one resizes the window
2023-11-10 03:37:42 +01:00
Alexander Wilms 096a1d74f5 Docs: Fix CMake commands for enabling Ccache 2023-11-10 02:40:10 +01:00
Alexander Wilms 8d1b5e24dd Add russian translation for connection error message 2023-10-11 18:49:47 +02:00
Alexander Wilms 7c627d8163 Show info dialog when connection to multiplayer server fails 2023-10-10 18:11:11 +02:00
Alexander Wilms 9bbd2a58bc Improve docs 2023-10-09 22:41:11 +02:00
Alexander Wilms ec094006c8 Add separate CMake preset for MSVC build with ccache 2023-10-09 21:51:17 +02:00
Alexander Wilms 3f83d54dc1 Set ENABLE_CCACHE to OFF by default 2023-10-09 21:22:11 +02:00
Alexander Wilms b36767904a Mention ccache in developer docs 2023-10-08 21:26:11 +02:00
Alexander Wilms 732c39fcc6 Fix build 2023-10-07 00:08:22 +02:00
Alexander Wilms c8f1512a3f Use correct address to decide whether we're connecting to a remote server or a local one 2023-10-06 23:33:51 +02:00
Alexander Wilms 3255b4232c Move ccache wrappers for macOS and iOS builds to apple/ dir 2023-10-06 21:08:45 +02:00
Alexander Wilms 19f8560456 Improve comment 2023-10-06 19:58:32 +02:00
Alexander Wilms 2bee8b5109 Make suggested changes 2023-10-06 19:55:40 +02:00
Alexander Wilms 4bed3c4726 Check CMAKE_GENERATOR, move iOS options to top level 2023-10-06 19:39:32 +02:00
Alexander Wilms c5378f560e Mark ccache as required if ENABLE_CCACHE is ON, set ENABLE_CCACHE to ON by dafault instead of setting it in CMakePresets.json 2023-10-06 12:44:56 +02:00
Alexander Wilms 510fb205e7 Add CMake option for enabling ccache for IOS and MSVC build 2023-10-06 01:06:10 +02:00
Alexander Wilms b58cca7770 100 connection attempts is not always enough 2023-10-03 22:06:32 +02:00
Alexander Wilms a66d8ecb8f Use ui16 instead of uint for connectionAttemptCount to fix MinGW build 2023-10-03 22:06:32 +02:00
Alexander Wilms e1401d26c5 hostAddress can be localhost, return from justConnectToServer() is maximum number of attempts is exceeded 2023-10-03 22:06:32 +02:00
Alexander Wilms 39427d6658 Use different delay and maximum number of connection attempts for local and remote servers 2023-10-03 22:06:32 +02:00
Alexander Wilms 9f9930a9dd CServerHandler::justConnectToServer(): Read settings only once 2023-10-03 22:06:32 +02:00
Alexander Wilms 614d000376 Sleep for 10 ms instead of 1000 ms while waiting for server connection 2023-10-03 22:06:32 +02:00
Alexander Wilms c7523326a0 Make ccache work with MSVC build 2023-10-02 12:36:47 +02:00
Alexander Wilms 65354da5f1 Add CMake preset for iOS build without precompiled headers, which is required for ccache 2023-10-02 05:43:38 +02:00
Alexander Wilms d14c872164 iOS CI build: Make XCode work with ccache 2023-10-02 05:43:33 +02:00
Alexander Wilms 46d785c371 Fix iOS build with ENABLE_PCH=OFF
https://github.com/vcmi/vcmi/issues/2991#issuecomment-1742066891

Fixes #2991
2023-10-01 18:16:41 +02:00
Alexander Wilms 71ea057ad1 CI: Install all packages at once on Linux 2023-09-30 01:27:30 +02:00
Alexander Wilms be17ed1b62 Enable ccache for CI 2023-09-29 23:55:12 +02:00
Alexander Wilms f52562eeb7 Fix freezing of hero and long enemy turns without sleeping in FramerateManager::framerateDelay() 2023-09-27 16:09:52 +02:00
Alexander Wilms 0d11c5197d Remove superfluous vsyncEnabled attribute 2023-09-26 23:48:53 +02:00
Alexander Wilms ecc7648ef8 Use display index from settings 2023-09-26 23:05:48 +02:00
Alexander Wilms e2eeec96a9 Fix stuttering animations when using high frame rate limit or vsync 2023-09-26 22:53:45 +02:00
Alexander Wilms e33127a1f7 Launcher setting: Disable spinBoxFramerateLimit if VSync is enabled 2023-09-26 18:55:25 +02:00