1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-21 22:33:43 +02:00

87 Commits

Author SHA1 Message Date
Ivan Savenko
3f83ad1b40
Merge pull request #5726 from IvanSavenko/breath
Configurable multi-hex attacks
2025-05-21 17:10:59 +03:00
Ivan Savenko
e90d8c318d Configurable multi-hex attacks
- Added bonus type MULTIHEX_UNIT_ATTACK - configurable version of Dragon
Breath.
- Added bonus type MULTIHEX_ENEMY_ATTACK - configurable version of
Cerberi multi-headed attack that only hits enemies
- Added bonus type MULTIHEX_ANIMATION - optional bonus that does not
affects gameplay, but allows to define in which cases game should use
alternative attack animation.
- All existing multi-hex attack bonuses other than ATTACKS_ALL_ADJACENT
are presumable deprecated, but will be supported for now.
- It is now possible to precisely configure which hexes are targeted by
MULTIHEX_XXX bonuses. See docs for details.
- Unified logic of all multi-hex attacks, all existing bonuses are now
implemented as specific case of MULTIHEX_XXX bonus
- Added tests to cover Cerberi attack logic, and fixed incorrect edge
case of Dragon Breath
2025-05-20 15:08:59 +03:00
Ivan Savenko
95ac124dc9 Bonus-aware addInfo loading 2025-05-20 14:56:22 +03:00
Ivan Savenko
cc274c4d34 GameRandomizer is now in lib, add implementation 2025-05-19 18:51:42 +03:00
Ivan Savenko
54a46b77a9 Extract library entity randomization logic to separate class 2025-05-19 18:51:42 +03:00
Ivan Savenko
4d4da0454f map objects hierarchy now uses IGameInfoCallback 2025-05-14 18:33:20 +03:00
Ivan Savenko
6f20235d07 Merge CPrivilegedInfoCallback into CGameInfoCallback 2025-05-14 13:42:20 +03:00
Ivan Savenko
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
Ivan Savenko
35644da2b7 Reogranize callback-related classes on 1 file = 1 class basis 2025-05-12 22:07:09 +03:00
Ivan Savenko
4b30336d03 Fix issues detected by Sonar 2025-05-11 19:50:57 +03:00
Ivan Savenko
0212b6e37d Remove artifact from slot as reward 2025-05-06 17:28:12 +03:00
Ivan Savenko
283adc37d7 Unit stack rebalancing rework
- CStackInstance::count is now private with accessor methods
- CStackInstance::experience renamed to totalExperience and now stores
total stack experience (multiplied by stack size) to reduce rounding
errors
- CStackInstance::totalExperience is now private with accessors methods
- stack experience is now automatically reallocated on stack management
- Removed buggy BulkSmartRebalanceStacks pack, that mostly duplicates
BulkRebalanceStacks
- Renamed BulkSmartSplitStack to BulkSplitAndRebalanceStack to drop
unclear "smart" in name
- Reworked split-and-rebalance logic to correctly reallocate stack
experience
2025-05-01 18:18:30 +03:00
Ivan Savenko
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
Ivan Savenko
4d57a8ed36 Prefer to pass CGameState as reference instead of pointer 2025-04-27 14:57:31 +03:00
Ivan Savenko
896a7ec88e Better support for Adela specialty (+new modding functionality for it)
Fixes Adela specialty that was apparently broken back in #1518 and
replaced with logic that was clearly not tested - it was neither
functional, nor it was following H3 behavior.

- `HAS_ANOTHER_BONUS_LIMITER` now accepts `null` in place of bonus type,
for cases when limiting is needed by bonus source or bonus subtype. This
allows Adela Bless specialty to always work, irregardless of which
bonuses are provided by Bless.
- Implemented `DIVIDE_STACK_LEVEL` updater that functions same as
`TIMES_STACK_LEVEL`, but it divides bonus value, instead of multiplying
it (to make Adela specialty weaker for high-tier units, as in H3)
- Implemented `TIMES_HERO_LEVEL_DIVIDE_STACK_LEVEL` updater that
combines two existing updaters, to implement `val * heroLevel /
unitLevel` formula needed for Adela specialty
- Removed deprecated `ARMY_MOVEMENT` updater. Its functionality has
already been removed in 1.6.X releases, and it was remaining only as a
placeholder
- Updated modding documentation to account for these changes & to remove
some TODO's

Fixed regression from #777 that could led to either duplicated bonuses
or to multiple application of updaters. It introduced double-recursion -
node parents were gathered recursively, and then bonuses were also
collected recursively within each parent. This created situation where
updater could be applied different number of times. For example, hero
bonus that is propagated to unit in combat could be selected directly,
or via hero->combat unit chain, or via hero->garrison unit->combat unit
chains, leading to different calls to updaters if updater handles
garrison unit node type
2025-04-13 16:24:51 +03:00
Ivan Savenko
58a6aabd4c Switch list patching to more user-friendly 1-based indexing 2025-03-30 17:18:47 +03:00
Ivan Savenko
aeb6c0be26 Support for replacement of individual entries in json lists
It is now possible for mods to modify json lists precisely, without full
replacement. Supported options:
- `append`: appends a single item to end of list
- `appendItems`: appends multiple items to end of list
- `insert@NUM`: inserts a single item *before* item NUM (item counting
is 0-based)
- `modify@NUM`: allows editing of a single item NUM (item counting is 0-
based)

Example - addition of a new item into town hall slots:
```json
"hallSlots":
{
	"modify@4" : {
		"append" : [ "dwellingLvl7B", "dwellingUpLvl7B" ]
	}
},
```
This would modify 4th element (last row) by appending new entry to the
end of last row

```json
{
	"modify@4" : {
		"insert@1" : [ "dwellingLvl5B", "dwellingUpLvl5B" ]
	}
},
```
This would add new slot not in the end of last row, but before 1st item
(between 5th and 6th dwellings)
2025-03-27 19:22:50 +00:00
Ivan Savenko
7a3e1409d0 Remove old boost includes and defines 2025-03-19 08:03:56 +00:00
Ivan Savenko
645b95ba02 Renamed LibClasses * VLC to GameLibrary * LIBRARY 2025-02-21 16:54:56 +00:00
Laserlicht
0035b2346a optimized search input 2025-01-23 23:50:04 +01:00
Ivan Savenko
ca4227ba9d Add debug information for crash on object randomization 2025-01-07 15:06:49 +00:00
Ivan Savenko
fe51194e22
Merge pull request #5008 from Laserlicht/sprites_test
Tile animation for rivers with xbrz
2024-12-06 14:54:18 +02:00
Laserlicht
4b103fd63b code review 2024-12-05 23:31:03 +01:00
Laserlicht
e6cd3630e0 fix warning 2024-11-30 17:20:39 +01:00
Ivan Savenko
4945370fe3 Implemented validation of preset - removal of non-existing mods,
addition of newly installed mods
2024-11-26 13:55:46 +00:00
Ivan Savenko
e7bea6c3b8
Merge pull request #4852 from IvanSavenko/remove_vlc_entities_serialization
Remove remaining pointers to VLC entities from serializer
2024-11-06 22:01:11 +02:00
Ivan Savenko
6056d385ed Always load json configs from mod that references it
This should fix rather common problem with mods, where two unrelated mods
accidentally use same file name for a config file, leading to very unclear
conflict since this result in a file override.

Now all config files referenced in mod.json are loaded specifically from
filesystem of mod that referenced it. In other words, it is no longer
possible for one mod to override config from another mod.

As a side effect, this allows mods to use shorter directory layout, e.g.
`config/modName/xxx.json` can now be safely replaced with `config/
xxx.json` without fear of broken mod if there is another mod with same
path to config. Similarly, now all mods can use `config/translation/
language.json` scheme for translation files

Since this is no longer a problem, I've also simplified directory layout
of our built-in 'vcmi' mod, by moving all files from `config/vcmi`
directory directly to `config` directory.

- Overrides for miscellaneous configs like mainmenu.json should works as
before
- Images / animations (png's or def's) work as before (and may still
result in confict)
- Rebalance mods work as before and can modify another mod via standard
`modName:objectName` syntax
2024-10-31 14:49:11 +00:00
Ivan Savenko
d3af9f1c67 Removed pointer to VLC entity from CStackBasicDescriptor 2024-10-30 16:47:02 +00:00
Ivan Savenko
ec3acec8cc Implemented JSON5 line ending escapings 2024-10-26 14:21:23 +00:00
Ivan Savenko
604e3b5c67
Merge pull request #4763 from IvanSavenko/herohandler_split
Split CHeroHandler.cpp/.h into 1 file per class
2024-10-14 19:05:48 +03:00
Ivan Savenko
678e6b47f8
Merge pull request #4756 from IvanSavenko/sonar_fixes
Fix some of the new warnings from sonarcloud
2024-10-14 18:16:41 +03:00
Ivan Savenko
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
Ivan Savenko
a8e84c55f6 Fix some of the new warnings from sonarcloud 2024-10-11 10:45:29 +00:00
Ivan Savenko
6bed497f2c Fix mod validation reporting failure for well-formed mods 2024-10-10 21:18:43 +00:00
Ivan Savenko
2399a5a765
Merge pull request #4712 from IvanSavenko/detect_conflict
Detection of potential conflicts between mods
2024-10-07 17:57:52 +03:00
Ivan Savenko
8e4152bc81 It is now possible to define objects directly in mod.json instead of
using path to file with object definition
2024-10-06 19:42:15 +00:00
Ivan Savenko
d849e53499 Implement detection of mod compatibility patches 2024-10-06 16:11:32 +00:00
Ivan Savenko
d0aba56a5e Analyze json object modifications to detect mod conflicts 2024-10-06 13:58:41 +00:00
Ivan Savenko
e09fbe5ea4 Implement detection of typos in json using Levenshtein Distance 2024-09-15 20:14:08 +00:00
Ivan Savenko
82c37573fa Removed save compatibility with 1.4
All save compatibility checks targeting 1.4 saves have now been removed.
Saves from 1.5 can still be loaded in 1.6

Implemeted few TODO's in serialization that were postponed to avoid
breaking save compatibility in MP for 1.5.X releases.

Fixed missed case for loading black market object from 1.5 saves
2024-08-29 18:51:53 +00:00
Ivan Savenko
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
Ivan Savenko
2020d96070
Merge pull request #4071 from IvanSavenko/fix_rng_syncronization
[1.6] Fix potential desync if client uses different stdlib with different random number generators
2024-07-19 13:08:09 +03: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
c484244ba0
JsonNode::JsonNode(): Use reference for fileName argument
Co-authored-by: Ivan Savenko <saven.ivan@gmail.com>
2024-07-17 14:01:13 +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
Ivan Savenko
63bcf7d83c Replaced most of usages of CRandomGenerator with vstd::RNG in library 2024-07-16 13:13:07 +00:00
Ivan Savenko
60a51e98de Remove usage of std::function from CRandomGenerator 2024-07-16 13:13:07 +00:00
Alexander Wilms
f22a3d6168
JsonParser::error(): Use empty()
Co-authored-by: Andrey Filipenkov <kambaladecapitator@gmail.com>
2024-07-16 10:30:00 +02:00
Alexander Wilms
466318b77b JsonParser::error(): Don't add trailing newline 2024-07-15 23:58:56 +02:00