64 Commits

Author SHA1 Message Date
dumb-kevin 4063c6c653 Fix stacked integrated armor from cached enchantment mutations
Add the missing cached_mutations guard in update_cached_mutations
when old enchantment mutation cache is not empty. This prevents
re-adding enchantment mutations that are already cached.

Guard the corrupted counter update so enchantment-only traits are
not inserted into my_mutations by accident.

Make mutation_effect idempotent for integrated armor by skipping
wear_item when that integrated item is already worn.

Add regression tests covering both the cached mutation reapply path
and repeated mutation_effect calls for integrated fur armor.
2026-02-21 20:57:40 +04:00
moxian 2ee44002fd Mechanically IWYU the tests
python3 ~/github/include-what-you-use/iwyu_tool.py -j5 -p build $( find
src/ tests/ -maxdepth 1 -name '*.cpp' | grep -v -f
tools/iwyu/bad_files.txt )  --  -Xiwyu --comment_style=long -Xiwyu -
-max_line_length=1000 -Xiwyu --cxx17ns -Xiwyu
--mapping_file=../tools/iwyu/cata.imp   | tee out/iwyu/f-a-01.txt >
/dev/null

followed by

cat out/iwyu/f-a-02.txt | python3
~/github/include-what-you-use/fix_includes.py --reorder --nosafe_headers

followed by manual fixups of <stddef.h> -> <cstddef> and similar.

tests/generic_factory_test.cpp gets mangled very badly (IWYU bug) so
it's excluded from the list.

Code size:
includes:
$ cat obj/tiles/*.inc | wc
 288068  576136 17898260
$ cat tests/obj/tiles/*.inc | wc
 167044  334088 10465766

post-processed source (clang -E):
./make_preproc.sh src/
68567896 177775140 2134075721
./make_preproc.sh tests/
39341957 102891720 1243323710
2025-02-10 00:46:57 -08:00
ehughsbaird e44c61fd57 Show different map info for omts based on vision
Now that there's different levels of overmap vision, change the
displayed map information based on it.

To reduce the load of specifying this data for all of the overmap
terrains, this is specified in a separate oter_vision type that overmap
terrains reference. For a given vision level, the name, symbol, and
color level of the terrain will be replaced with those specified in the
oter_vision it references. If the oter_vision doesn't have an entry for
that vision level, the information from the overmap terrain will be
shown. If the oter_vision specifies that it should blend with adjacent
tiles at that vision level, a suitable adjacent tile will be chosen
instead, and the information for that tile (depending on vision level)
will be shown.

The prefixing used for tileset ids is messy, but it's constrained and
the tiles overmap works.

Adjust the code that reveals tiles to reveal at these various different
levels. It's nothing exciting, and there are a lot of improvements to be
made, but it works well enough to showcase the feature.
2024-07-27 13:25:34 +00:00
Maleclypse 0bfb3a8ba5 Remove special casing test for Alpha and increase vitamin max/thresbreach (#74101)
* Remove Alpha special casing

* Adjust vitamin requirement to break threshold

* Increase max vitamin dose of alpha

* Apply suggestions from code review
2024-05-27 09:29:47 -04:00
Venera3 6dcf0b23f2 Allow the Chimera thershold trait as a wildcard for most postthresh traits (#72994)
* Substitutes, tests

* Clang

* Stricts
2024-04-17 23:28:32 -05:00
anoobindisguise 19c72cac49 Apply Kamayana's style suggestions
Co-authored-by: Kamayana <pigbuster@gmail.com>
2024-03-24 01:47:39 -07:00
anoobindisguise 23d1beecb4 fix for toggle_trait / set_mutation conflict 2024-03-15 13:30:53 -07:00
anoobindisguise 2d09fcf6a4 add an extra sanity check 2024-03-15 11:24:59 -07:00
anoobindisguise 81b7f5bb26 more test fixes 2024-03-15 07:58:31 -07:00
anoobindisguise 46df05cdb1 fix issue with when/then clearing muts 2024-03-15 02:10:44 -07:00
anoobindisguise 9153fb9e9d fix more missing decs 2024-03-15 00:04:15 -07:00
anoobindisguise 0c07672e0b Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-14 23:52:45 -07:00
anoobindisguise 1cf71fcd99 declare missing variables 2024-03-14 23:51:23 -07:00
anoobindisguise 639ecc5f30 Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-14 23:36:54 -07:00
anoobindisguise 05d6d7b2c5 rewrite instability test 2024-03-14 21:06:35 -07:00
Anton Simakov 71ed5cde9c Port some mutation/cbm specific fields to enchantments, part 3 (#72173)
* remove weakness_to_water, add WEAKNESS_TO_WATER as replacement, fix it not working with negative values

* remove fat_to_max_hp, make FAT_TO_MAX_HP as replacement

* remove healthy_rate, create HEALTHY_RATE as a replacement

* remove scent_mask, adds SCENT_MASK to replace it

* remove consume_time_modifier, make CONSUME_TIME_MOD as replacement

* remove reading_speed_multiplier

* remove overmap_sight and overmap_multiplier

* remove sweat_multiplier, add SWEAT_MULTIPLIER as replacement

* remove vomit_multiplier

* remove stamina_regen_modifier, make STAMINA_REGEN_MOD as replacement

* remove fatigue_regen_modifier, make FATIGUE_REGEN as replacement

* remove fatigue_modifier

* remove noise_modifier

* remove crafting_speed_multiplier

* remove casting_time_multiplier

* remove bionic_mana_penalty

* remove mana_regen_multiplier

* remove mana_multiplier

* remove mana_modifier

* refine water damage to allow float values, make it tick once per second instead of once per minute

* lintin and fixin

* Astyle

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* clang tidy

* Astyle

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* more

* more

* data types are hard

* ill squash it in the future, believe me

* Astyle

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* refine crafting speed calculations

* update tests

* Update tests/mutation_test.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* add identifier to enchantment

* int to double?

* refine mutation OM vision test to check actual OM vision

* Update src/character.cpp

Co-authored-by: mqrause <38702195+mqrause@users.noreply.github.com>

* the last bist of sight test

* final test tweaks

* fix widget test mismatch

* add escape character to fix test

* fix two nocturnal trait

* fix multiple errors

* make new overmap sight test use test mutations, that work all the time (eagleeyed doesn't work at night)

* fix field duplication

* more fixes after merge

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: mqrause <38702195+mqrause@users.noreply.github.com>
2024-03-09 17:39:06 -06:00
Alexey 07356b65a5 Normalize TEST_CASE names (#66241)
* Convert integer parsing test to use normal TEST_CASEs

* Rename test name too similar to another

* Test to enforce normalized test names

* Normalize TEST_CASE names (scripted)
2023-06-17 13:57:19 -03:00
actually-a-cat b1e0a826c3 Remove unnecessary test point from instability test (#64361) 2023-03-23 18:37:10 -07:00
John Bytheway dd5b7af626 Apply clang-tidy fixes for C++17
A few small changes in C++17 mean that clang-tidy is now able to apply a
few more fixes.  Do so.
2023-03-14 19:26:16 -04:00
Venera3 1b52d5b759 Allow mutations to remove starting traits, unhardcode more mutation functionality (#63974) 2023-03-11 23:48:19 -08:00
Zhilkin Serg e44f38af40 Remove excessive empty lines 2022-12-06 10:42:15 +03:00
Zhilkin Serg c94333399d Merge pull request #61394 from actually-a-cat/breach-test
Remove upper bound of mutation threshold breach power test
2022-10-15 20:42:29 +03:00
Ava d32ee0f13c Mutation system refinements, take two (#61036)
* Mutation system refinements, take two: squashed edition

created with copious amounts of agony and ice cream

* proofreading, resolve test failure

* I realy should try magiclysm one of these days

* on second thought, no popups for now

* the github test run took TWO HOURS. AAAAH

* [wailing]
2022-10-07 05:03:02 -04:00
actually-a-cat 90f0727cbe Remove upper bound of mutation threshold breach power test 2022-10-01 20:49:22 +02:00
Christian Stadler 7455393789 Flagify COLDBLOOD mutations (#60052)
* Flagify COLDBLOOD mutations

* Documented the new flags in JSON_FLAGS.md

* Test cases for some mutations I flagified

* Apply astyle fixes

* Clang tidy corrections

* And astyle again ;_;
2022-08-17 20:32:13 -04:00
actually-a-cat d63eeb9c32 Bad mutation chance vs instability test 2022-07-06 14:26:55 +02:00
Mylie b0b5bcf2c2 Mutation infrastructure and a Threshold calculation revamp (#56421)
* Tear down entire threshold calcs + rebuild them
* Debug options for testing mutation categories
* New character menu properly removes mutations
* Adds mutations to Nerd- I mean Manatouched
Co-authored-by: Maleclypse <54345792+Maleclypse@users.noreply.github.com>
2022-04-04 10:25:47 -07:00
Mylie d6f5cff566 Reworks mutagens to take time and use fully customizable EOCs (#55233)
* Migrate mutations to a weighted vitamin based EOC-run system
* Human Mutagen and Mutagen Chelator

Human mutagen (aka purifier) has no overdose effect at the moment, but is set up for later when it will trigger terrible overdose effects if you have any threshold.
Mutagen Chelator does not currently appear anywhere legitimately, would love some feedback on where it should be and how/if it should be created.

Co-authored-by: Mikenyes <25803648+Mikenyes@users.noreply.github.com>
Co-authored-by: Fris0uman <41293484+Fris0uman@users.noreply.github.com>
Co-authored-by: Venera3 <72006894+Venera3@users.noreply.github.com>
2022-02-24 22:07:44 -08:00
Eric Pierce 3b4a722baf Eliminate the SELFAWARE trait from code and data
- src: Factor out all code references to SELFAWARE trait
- data: Remove SELFAWARE from starting traits
- data: Change SELFAWARE to OPTIMISTIC for Meditation hobby
- data/mods: Remove SELFAWARE from all mods
- tests: Remove SELFAWARE from test that doesn't need it
2021-12-28 08:34:52 -07:00
John Bytheway e95a4fc9b8 Promote string_id constants to global statics
Our string_id constants were a mixture of temporaries, locals, and
globals.  Pull them all out as globals, for consistency and efficiency.
The efficiency comes from the fact that each string_id instance caches
its respective int_id, and sharing one instance means that value need
not be recomputed.
2021-11-19 19:10:09 -05:00
Eric 51520f6245 Move more player to character (#50971)
* player to character

* Update npc_talk_test.cpp
2021-08-23 00:58:51 -07:00
John Bytheway ebd549b300 Fix StringMaker ODR violations in tests
Catch2 provides a customization point for converting our types to
strings by specializing the StringMaker template.

We have some specializations in stringmaker.h, but this feature was only
working intermittently.  I finally figured out that was due to an ODR
violation.  The test files that didn't include stringmaker.h were
compiling a different specialization than the ones that did.

Re-jig the test includes so that any file including catch.hpp also
includes stringmaker.h, thereby ensuring that the custom
specializations are used everywhere and there is no ODR violation.

I achieved this by adding a new cata_catch.h header and making all
existing headers include catch.hpp via the new header.
2021-07-03 07:42:06 -07:00
Fris0uman 36b9376843 Setup tests of the various type of automatic trigger for mutations (#47873) 2021-03-08 23:24:35 +03:00
Binrui Dong 9fdb7ef59c Run IWYU
* Change _ctype.h and __locale to cctype and clocale

* Change _wctype.h to cwctype in game.cpp

* Change __functional_base to functional

* Remove libcxx internal headers

* Remove UNIX system headers

* Fix clang-tidy error with -nostdinc++
2021-02-06 00:18:41 -05:00
Eric Pierce c9d731b19e Improve and document mutation tests
The intended purpose of these mutation tests was somewhat obscure, and
the output on failure could be difficult to interpret. This commit aims
to improve them in the following ways:

- Add a new test focused on a simple example with only 3 mutations
- Add explanatory comments to each test, to clarify the intent
- Replace 'auto' variables with explicit types, to aid static analysis
- Reduce the number of unnecessary assertions, to make output cleaner
2020-09-08 03:50:54 +00:00
Kevin Granade 0efd93fbfa Merge pull request #43983 from jbytheway/cpp_declarations
More stringent check forcing file-local things to be static
2020-09-08 01:42:07 +00:00
Kevin Granade b607788eb8 Wip mutation category (#44010)
* Add documentation for mutation_category JSON entity

* Misc doc fixes

* Add flag to suppress consistency checking of unfinished mutation categories
2020-09-07 08:43:03 +03:00
John Bytheway bf910e50e3 Declare lots of things static
Use the new clang-tidy check to convert a bunch of declarations to
static.

In a few cases, there were 'secret' dependencies being exposed without
headers.  Convert those to work via headers instead.
2020-09-05 23:13:04 -04:00
John Bytheway d63d3bd35a Make mutation_category ids be string_ids
The mutation_category_trait objects have ids, but they were just
std::strings.  Make them be a string_id<mutation_category_trait>
instead.

This is a general move towards type safety, although the specific goal I
wanted to achieve was better validity checking of cata_variants.
2020-09-03 07:39:35 -04:00
Eric Pierce 8e8ed7fdb4 Allow Scout trait to work with Self-Aware trait
Correct the "overmap_sight" mutation value map to be additive, rather
than multiplicative. Include a regression test that failed before this
change, and passes afterward.

Fix #42853

For reasons I do not understand, using "multiplicative" here caused the
"Self-Aware" trait to nullify the overmap sight adjustments from both
the "Scout" and "Topographagnosia" traits.
2020-08-14 21:17:31 -06:00
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03:00
Kevin Granade 2684dcbcf1 Merge pull request #42480 from ZhilkinSerg/sa-2020-06-29
Code optimizations reported by static code analysis (2020-06-29)
2020-07-29 23:55:24 +00:00
Kevin Granade 6d1841ac67 Precompiled Catch2 header (#42453)
* Hoist catch.hpp include to the top of files

* Precompile the catch header in tests
2020-07-29 01:28:26 +03:00
ZhilkinSerg 6a96a7ffdb Get rid of autos (+ constify) 2020-07-28 22:08:34 +03:00
Fris0uman 68e91cfe72 Move encumbrance to bodyparts (#41860) 2020-07-08 09:37:37 +03:00
John Bytheway f3049e5eea Fix missing declarations (#30739)
* Fix missing declarations
Mark functions with no prior declarations as static, and remove the
unused ones.
* Move debug_is_safe_string definition
Put it inside !WIN32 since it's only used there.
2019-05-22 11:00:54 -07:00
John Bytheway aff4636618 Run IWYU
Having refactored the type ids into a single header, IWYU is now able to
find many places where other headers can be removed.
2019-05-06 22:47:10 +01:00
John Bytheway e3e7700aef Apply IWYU changes
This is a run of IWYU followed by astyle.
2019-04-22 11:42:51 +01:00
ZhilkinSerg c0bce91fa1 Used const where appropriate 2019-01-06 23:00:08 +03:00
John Bytheway b0576393e3 Sort headers according to IWYU conventions
A first step towards IWYU support.  Doing the sorting first because it
makes reviewing any additions or removals of headers much simpler.

The IWYU order is:
- Associated headers
- Misc system headers
- C++ STL headers
- Other project headers

The biggest change is moving system headers before project headers (they
are usually afterwards in Cata at the moment.

The associated header for a cpp file is the header file which declares
the functions defined in that cpp file.  Normally that's the one which
shares the same name (up to extension), and if so IWYU figures it out
automatically.

However, in this project there are many corner cases, so we need to use
IWYU pragma: associated to tell it which header (or, in some cases,
which headers) is the associated header.  We are unusual in having
multiple associated headers for some files, which might lead to
discovering some interesting IWYU bugs later, but in theory it is
supported.
2019-01-05 14:03:31 +00:00