1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00
Commit Graph

151 Commits

Author SHA1 Message Date
a8f9ac41e1 Fix no damage chance for catapult with no ballistics 2025-03-13 17:50:18 +01:00
a8a6be7ac1 Fix potential compatibility with C++20 / C++23 mode
This fixes several issues with compatibility with C++20. C++23 was also
tested, but apparently it does not have any additional breaking changes
compared to C++20 (or we don't have those).

VCMI still uses C++17 as before - goal is only to make potential
transition easier.

There were 2 cases that are deprecated in C++20 that we use:
- Floating point operations on enums are deprecated
- `this` can no longer be captured when using default capture by value
`[=]`

Both of those should now be replaced with code that works fine in both C+
+17 and in C++20 mode
2025-03-02 14:11:48 +00:00
645b95ba02 Renamed LibClasses * VLC to GameLibrary * LIBRARY 2025-02-21 16:54:56 +00:00
d8ec69bfaa Remove non-const iterators to BattleHexArray container
Replaced with several non-const methods to prevent modification of
internal storage without corresponding modification of internal flags
2025-01-29 23:02:51 +00:00
30bd975f95 Use unit->getHexes()
instead of battle::Unit::getHexes(stack->getPosition(), stack->doubleWide(), stack->unitSide())
2025-01-21 13:23:18 +01:00
ecdd394bb1 Use BattleHex as const ref wherever possible
Minor Fixes
Drop unused function from BattleHexArray
2025-01-21 13:23:17 +01:00
5bfc837a8f Fix regressions from battlehex PR (mostly related to towers) 2025-01-12 11:07:50 +00:00
dbe82b94f6 Changes following review:
- shared_ptr for destructibleEnemyTurns instead of raw pointer
- drop implicit int conversion for BattleHex class
  and implement toInt() instead
- implement necessary operators in BattleHex
- adjust code to work properly with JSON serializer
2025-01-08 07:24:43 +01:00
4031006317 Drop battle elapsed time measurement, restore avHexes.
Github validation report fixes.
2025-01-06 23:28:47 +01:00
dad6437661 Refactor BattleHex, remake the use of precomputed neighbouring tiles containers.
- Moved short, frequently used functions to the BattleHex header for inlining
- Made BattleHex a class with a private hex value
- Moved getClosestTile implementation back to BattleHex
- Enabled access to static precomputed data in BattleHexArray via BattleHex
(note: circular dependency prevented static precomputed containers being directly placed in BattleHex)
2025-01-06 23:28:46 +01:00
ac8104d56d SonarCloud recomendations.
Code review follow-up:
- Replace std::vector with boost::small_vector
- Rename function merge to insert
2025-01-06 23:28:45 +01:00
8c3a417527 Cleanup 2025-01-06 23:18:20 +01:00
a99274d72e BattleHexArray - new container for BattleHexes 2025-01-06 23:18:18 +01:00
10ad0fc760 Split CHeroHandler.cpp/.h into 1 file per class
All parts of CHeroHandler.cpp are now in lib/entities/hero
Adjusted includes to use new paths
No functionality changes
2024-10-13 14:01:09 +00:00
3dd4fa2528 Reduce usage of pointers to VLC entities
Final goal (of multiple PR's) is to remove all remaining pointers from
serializeable game state, and replace them with either identifiers or
with shared/unique pointers.

CGTownInstance::town and CGHeroInstance::type members have been removed.
Now this data is computed dynamically using subID member.

VLC entity of a town can now be accessed via following methods:
- getFactionID() returns ID of a faction
- getFaction() returns pointer to a faction
- getTown() returns pointer to a town

VLC entity of a hero can now be accessed via following methods:
- getHeroTypeID() returns ID of a hero
- getHeroClassID() returns ID of a hero class
- getHeroType() returns pointer to a hero
- getHeroClass() returns pointer to a hero class
2024-10-10 12:28:08 +00:00
c0f5c7c0ea Replace pointer with reference in pack apply functions 2024-10-07 14:59:46 +00:00
63b711758f Fix chain lightning wasting effect on creatures immune to magic 2024-09-28 17:22:26 +02:00
bb69ab1a1a Fix assert and condition for counting spell hexes 2024-09-22 18:25:18 +02:00
1a2d349267 Initial unconditionally working version 2024-09-22 15:07:44 +02:00
36c1ed670f Support for configurable town fortifications
Removed most of hardcoded checks for fort level or for presence of fort/
citadel/castle buildings.

It is now possible to define which parts of town fortifications are
provided by town buildings

Configuration for H3-like fortifications is provided in
buildingsLibrary.json and will be used automatically by mods as long as
mods have buidings named "fort", "citadel" and "castle".

Alternatively, mods can separately define:
- hitpoints of walls (shared value for all sections)
- hitpoints of central, upper and lower towers (separate values)
- presence of moat
- shooters for each tower (separate values)
2024-08-28 19:42:14 +00:00
2a05fbdd50 Unified handling of battle sides ID's
- Replaced BattleSide namespace-enum with enum class
- Merged two different BattleSide enum's into one
- Merged BattlePerspective enum into BattleSide enum
- Changed all places that use integers to represent battle side to use
BattleSide enum
- Added BattleSideArray convenience wrapper for std::array that is
always 2-elements in size and allows access to its elements using
BattleSide enum
2024-08-11 20:54:44 +00:00
4aa73b40c9 Split CTownHandler into smaller chunks 2024-07-21 18:21:48 +00:00
1aa391fdf8 Split CGeneralTextHandler file into 1 file per class form
All text processing code is now located in lib/texts.
No changes other than code being moved around and adjustment of includes

Moved without changes:
Languages.h           -> texts/Languages.h
MetaString.*          -> texts/MetaString.*
TextOperations.*      -> texts/TextOperations.*

Split into parts:
CGeneralTextHandler.* -> texts/CGeneralTextHandler.*
                      -> texts/CLegacyConfigParser.*
                      -> texts/TextLocalizationContainer.*
                      -> texts/TextIdentifier.h
2024-07-20 12:55:17 +00:00
63bcf7d83c Replaced most of usages of CRandomGenerator with vstd::RNG in library 2024-07-16 13:13:07 +00:00
60a51e98de Remove usage of std::function from CRandomGenerator 2024-07-16 13:13:07 +00:00
02e429e973 Fix typos using https://github.com/crate-ci/typos
Changes were reviewed manually
2024-06-24 03:47:19 +02:00
5dcef193a3 Block spellcasting if 0 creatures will be raised 2024-04-07 18:50:37 +03:00
41493d6f67 Implemented 'strict' json support 2024-02-26 12:55:49 +02:00
c0dc1040c2 Fixes crash on attempt to dynamic_cast AbilityCaster to Unit 2024-02-18 20:06:07 +02:00
3740f8b02f Moved bonus parsing to a new file 2024-02-14 15:48:06 +02:00
c3957c2c2a Moved json files to new directory, split on per-class basis 2024-02-14 13:08:24 +02:00
a9866bb5c6 Added RandomGeneratorUtil::nextItemWeighted convenience method 2024-01-31 00:17:40 +02:00
6e629a6a5f split getBonusLocalFirst into two distinct method:
- const method getFirstBonus that returns single matching bonusToString
- non-const method getLocalBonus that returns bonus from current node
2024-01-19 13:56:06 +02:00
bd5682ecc3 Merge remote-tracking branch 'vcmi/master' into develop 2024-01-19 13:49:54 +02:00
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
6e5da6c158 Fixed Coronius specialty applying from two locations in code 2024-01-15 23:16:53 +02:00
M
9ee526d202 Fixes from code review 2024-01-11 21:10:22 +01:00
250b1b69a8 Update accurate shot translation handling
Co-authored-by: Ivan Savenko <saven.ivan@gmail.com>
2024-01-10 23:57:29 +01:00
7283a4861e Initial version of ACCURATE_SHOT implementation 2024-01-04 22:27:51 +01:00
df78c9c6f1 Added workaround for crashes with outdated mods 2023-12-09 18:08:22 +02:00
f2e7791326 Fix crash on Earthquake cast 2023-11-27 14:09:08 +02:00
6b81012f31 Use variant identifier in netpacks where applicable 2023-11-08 14:00:23 +02:00
86a3806bec MetaString refactor to eliminate integer usage for identifiers
- entity names are now stored and serialized as text ID's
- added helper methods for convenience to get entities names to
metastring
2023-11-07 22:47:10 +02:00
184f5a72cc Use toEntity/toXXX methods in Identifier instead VLC objects access 2023-11-03 16:03:29 +02:00
e57276b7c5 Correctly initialize battleID for teleport action 2023-11-01 17:24:41 +02:00
5cbf5031ea move SetStackEffect to a separate file 2023-10-24 01:27:52 +03:00
b88a8da4e8 Split off some netpack structures into separate files 2023-10-23 13:59:15 +03:00
ac925bb786 Renamed new types for consistency with code style 2023-10-22 16:55:19 +03:00
b394158dc9 Bonus Source ID now uses metaidentifier 2023-10-22 16:55:18 +03:00
0a10fc30b8 (lib) Bonus subtype is now stored as metaidentifier that can store any
other identifier inside it
2023-10-22 16:54:43 +03:00