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

146 Commits

Author SHA1 Message Date
716da918f8 Completely remove IGameCallback class
- CClient now inherits directly from CPrivilegedInfoCallback, like
IGameCallback did before. However CClient no longer needs dummy
implementation of IGameEventCallback
- CGObjectInstance hierarchy now uses CPrivilegedInfoCallback for
callback. Actual events can only be emitted in calls that receive
IGameEventCallback pointer, e.g. heroVisit
- CGameHandler now inherits directly from both CPrivilegedInfoCallback
and IGameEventCallback as it did before via IGameCallback
2025-05-14 13:39:41 +03:00
35644da2b7 Reogranize callback-related classes on 1 file = 1 class basis 2025-05-12 22:07:09 +03:00
700eeb6bd4 Implemented HERO_SPELL_CASTS_PER_COMBAT_TURN bonus 2025-05-08 00:25:07 +03:00
279d89f971 Merge pull request #5659 from IvanSavenko/artifact_split
Reorganized artifact-related classes
2025-04-30 13:23:41 +03:00
f70ad2c15b Reorganized artifact-related classes
- files now generally contain only 1 class (except for tightly coupled
classes)
- files are now located in lib/entities/artifact directory
- removed excessive includes

No changes to functionality
2025-04-29 13:29:08 +03:00
5550edeb9a Fix inability of unit to cast spell after receiving morale 2025-04-29 12:12:51 +03:00
4e8e85e3e4 Fix issues reported by Sonar, review fixes 2025-04-27 14:57:31 +03:00
ce436bd63e Fix regressions in combat 2025-04-27 14:57:31 +03:00
93b18ee94b Fix some issues detected by Sonar & code review, fix build 2025-04-27 14:57:31 +03:00
f03cc06176 Battle Info uses ObjectInstanceID's instead of pointers 2025-04-27 14:57:31 +03:00
63d00b080e Removed pointer to army from StackInstance 2025-04-27 14:57:30 +03:00
71bc1054d0 BattleStart pack now uses unique_ptr 2025-04-27 14:57:30 +03:00
0101d5ff67 BattleInfo stacks are now unique_ptr's 2025-04-27 14:57:30 +03:00
417ea6451a Remove ConstTransitivePtr from hero and town instances 2025-04-27 14:57:30 +03:00
645b95ba02 Renamed LibClasses * VLC to GameLibrary * LIBRARY 2025-02-21 16:54:56 +00:00
ecdd394bb1 Use BattleHex as const ref wherever possible
Minor Fixes
Drop unused function from BattleHexArray
2025-01-21 13:23:17 +01:00
e829d723b2 Replace global bonus tree change counter with per-node counter 2025-01-12 12:23:07 +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
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
a99274d72e BattleHexArray - new container for BattleHexes 2025-01-06 23:18:18 +01:00
95a07ee5cb Use bonus system cache whenever possible 2024-12-21 18:47:11 +00:00
c98ac01e7a Replaced public artType member of ArtifactInstance with getter 2024-10-30 16:47:01 +00:00
59a15c5ff0 Merge pull request #4790 from kodobi/bugfix/fix-incorrect-battlefield-while-attacking-town-without-fort
Fix battle setup for sieges without forts
2024-10-28 08:38:14 +01:00
ee59bc4e71 Add bonus description generation for map objects 2024-10-25 18:36:02 +00:00
c576438a95 Fix battle setup for sieges without forts
- Update the if statement in BattleProcessor::SetupBattle to allow
  obstacles in battlefields during sieges without forts.
- Ensure towns without forts use the native battlegrounds.
- Refactor variable name from curB to currentBattle for clarity.
2024-10-17 14:54:01 +02: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
90733cfe0e Do not place obstacles during sieges 2024-09-14 11:02:23 +00:00
45c8553ecb Remove old code 2024-09-12 12:11:18 +00:00
2ee4e42348 Implement placeholders for creature banks messages 2024-09-12 12:11:18 +00:00
39a2c29c97 Removed creatureBank flag from battle, battles now receive BattleLayout
struct that defines how units are placed in combat
2024-09-12 12:11:18 +00: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
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
58b1e74342 Workaround - check also for valueType when updating bonuses
We should not assume that spells always have a single bonus with same
type/subtype
2024-05-28 17:01:30 +00:00
9e49587749 Replace bonus string description with metastring that can properly
handle translations
2024-04-09 16:13:30 +03:00
6e399eb21a Make some non-const static variables const or constexpr 2024-02-12 13:22:54 +02:00
a9866bb5c6 Added RandomGeneratorUtil::nextItemWeighted convenience method 2024-01-31 00:17:40 +02:00
ffd604c114 Removed unnecessary access to IHandler::objects 2024-01-19 13:56:06 +02:00
9af7c63a26 Fix build 2024-01-19 13:56:05 +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
f3277b7953 Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
b58301849b Pass functor via reference to avoid costly copies 2023-11-18 19:43:11 +02:00
b88a8da4e8 Split off some netpack structures into separate files 2023-10-23 13:59:15 +03:00
3880ea58b9 Merge branch 'josch/dos2unix' into develop 2023-10-22 18:39:03 +03:00
ac925bb786 Renamed new types for consistency with code style 2023-10-22 16:55:19 +03:00
80e6485965 MetaIdentifier now uses std::variant internally 2023-10-22 16:55:19 +03:00
b394158dc9 Bonus Source ID now uses metaidentifier 2023-10-22 16:55:18 +03:00