39 Commits

Author SHA1 Message Date
kuutekitty 7f225f5c66 remove body part bleed and add it back to afs and iso protocol (#89300)
do the removal

add to iso protocol

remove current test

remove unused variable

iwyu

attempt to do tests

iwyu?

fix something that shouldnt have been removed

Update tests/effect_test.cpp

Update tests/effect_test.cpp

points for test mutation

actually give them the mutation in the test

change body part to test torso

fix body_part_test_torso error

style and fix torso?

another attempt to fix test_torso

remove connected to, recommended by snup

revert recommendation

fix typo pointed out by candleburry

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: mqrause <38702195+mqrause@users.noreply.github.com>
Co-authored-by: John Candlebury <johncandlebury@gmail.com>
Co-authored-by: Anton Simakov <67688115+GuardianDll@users.noreply.github.com>
2026-10-30 14:36:44 +01:00
RenechCDDA da2aaffffd Add quick setup option to clear map 2026-06-22 15:07:51 -04:00
Andrew Krieger 0215b26cce Rewrite all tests to clear map without touching character map memory, for performance. 2026-02-08 23:05:55 -08:00
Clarence "Sparr" Risher 318b79b0ca Update effect init tests to reflect constructor enforcement of rules 2025-08-09 12:40:16 -04:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08: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
PatrikLundell 327acb1d36 Ensure bleed test isn't failing due to clothing 2025-01-18 11:27:11 +01:00
Procyonae 4fd38ca71c Deal with /tests fallout 2025-01-16 16:03:19 +00:00
PatrikLundell c562eab8ab typified a-f 2025-01-14 14:14:48 +01:00
Procyonae 40f0b39e62 Merge branch 'master' into RemoveStringInitialisingItems 2025-01-10 17:00:48 +00:00
Procyonae 982df19d0f Change /tests remaining uses of raw string item initialisation to use itype_id s
"remaining uses" being somewhat of an understatement -_-
2025-01-10 15:31:15 +00:00
osuphobia f933c5295f weird failure 2025-01-01 02:06:12 +08:00
PatrikLundell fbf71a0f66 typified game.h and .cpp 2024-12-07 15:55:25 +01:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
inogenous 831f14af43 Fix: Show consistent healing quality
Fixes an issue where healing qualities shown when applying a bandage was
different than the applied quality.

The problem before was:
* For example, applying an adhesive bandage with "wound care"
  proficiency should give bandaging intensity 2, as returned from
  `get_bandaged_level` - this is correct.
* The `bandaged` effect as defined in `effects.json` specifies
  `int_dur_factor=6h`, so the intensity of this effect should be defined
  by setting its duration as multiples of `int_dur_factor`.
* When calculating the duration for the created effect, the code
  previously added `0.5f` to the desired intensity, likely to prevent it
  from getting 0. <- This was one part of the previous problem.
* In `effect::set_duration`, the intensity is calculated from how many
  multiples of `int_dur_factor` that the desired `duration` is. That
  calulation added 1 to the desired intensity, likely to also prevent it
  from being 0. <- This was the second problem before.
* In effect, instead of applying intensity 2 for an adhesive bandage,
  the code previously applied intensity 3.5 .

With this commit, we instead use `std::max(1, intensity)` to prevent
intensity from being 0.
2024-11-11 23:31:11 +01:00
PatrikLundell ef6b53acfb typified a little bit of map.h + dependents (#76340)
* typified a little bit of map.h + dependents
2024-09-27 15:10:36 -07:00
Fris0uman 5fa102a572 Enforce mon_ prefix for monster id (#72734)
* Test for mon_ prefix

* Replace LIXA_ with mon_

* deal with pseudo monsters

* Check for prefix in vanilla monster during data load

* better cpp

* fix hardcoded ids

---------

Co-authored-by: Fris0uman <fris0uman@users.noreply.github.com>
2024-04-09 18:33:44 -04: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
Alexey 41f05da39b Fix vitamins test flaking out, fingers crossed (#66083) 2023-06-09 14:18:52 -03:00
David Seguin 6141f7651e damage_type: jsonify damage types
It turns out that a lot of loading code depends on
the availability of certain damage types.

I see two ways to resolve this:
1) Juggle the loading order of JSON types so that damage
   types always load first.
2) Add deferred processing for every type with inline
   damage type definitions.

I went with option 2, which is better but still
not great since new code that loads damage/resistance
definitions would need to also call finalize_damage_map
in the finalizing stage. Option 1 would cause problems
for mods, especially because the load order would matter.

None of this can be done piecemeal, it has to all be ripped
out in one go unless we want commits that don't compile
on their own.
2023-04-24 01:38:15 -04:00
Zhilkin Serg e44f38af40 Remove excessive empty lines 2022-12-06 10:42:15 +03:00
Dillon Matchett 120b23cb32 Clearer Health and Vitamin Fixes (#59722)
* Basics all working

* debug info and formatting

* missed a UI append

* UI improvements and serialization

* linting

* remove some suggested stuff

Co-Authored-By: Paul Fenwick <12072+pjf@users.noreply.github.com>
Co-Authored-By: BevapDin <5095435+BevapDin@users.noreply.github.com>

* Update src/player_display.cpp

Co-authored-by: Paul Fenwick <github@pjf.id.au>

* Update src/debug_menu.cpp

Co-authored-by: BevapDin <tho_ki@gmx.de>

* consolidated RDA function

* think this is everything

* few final test suit things

* Update src/character.h

* set it closer to 100 per day

* open up the health test

* test fixes

* Apply suggestions from code review

* clang fixes

* mega robustify this test

* Update tests/stomach_contents_test.cpp

* try this for the test

* Apply suggestions from code review

Co-authored-by: Paul Fenwick <12072+pjf@users.noreply.github.com>
Co-authored-by: BevapDin <5095435+BevapDin@users.noreply.github.com>
Co-authored-by: Paul Fenwick <github@pjf.id.au>
Co-authored-by: BevapDin <tho_ki@gmx.de>
2022-08-05 01:41:52 -04:00
Venera3 6cc9079bf8 Expand monster special attack functionality (#58799)
* First round

Uncanny dodgeability, self-effects, refactoring monster attack effects

* Fixes

* Fix default effect bp, add random intensity to the mutant's spinneret

* Clang happy?

* Fix test?

* Clang

* Oops

* Apply suggestions from code review

Co-authored-by: David Seguin <davidseguin@live.ca>

Co-authored-by: Venera3 <Venera3@users.noreply.github.com>
Co-authored-by: David Seguin <davidseguin@live.ca>
2022-07-15 00:13:30 -04:00
John Bytheway 53a6cd9050 Apply auto transformations
Use the new clang-tidy check to replace all the auto variable types with
explicit types (where it makes sense to do so).
2022-07-01 07:11:27 -04: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
Venera3 ee43beb55d Adjust effect intensity decay (#51374)
* Effect test

* Tested, doc updated

Fungal spores and per venom works

* Have cake, eat it

Martial arts' funcionality is protected from intensity-based removal, docs updated

Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com>
2021-09-12 11:22:25 -07:00
Kevin Granade 362a1f2bd8 Move critter_at() to creature_tracker 2021-08-26 08:55:28 -07:00
Ramza13 56bb28b0ae Ding dong 2021-08-25 17:38:36 -04:00
Zhilkin Serg 8b615f02e1 Merge pull request #47291 from anothersimulacrum/marv
Expand effects infrastructure to vitamins and death
2021-07-03 20:22:10 +03: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
anothersimulacrum 578cdff414 Add vitamin and death effects tests
Add an effect impacting absorbtion and adding vitamin gain for use in
testing. Also, add the necessary vitamins to be impacted.
Add a food with high quantities of a vitamin to test the absorbtion.

Add an effect with varying levels of fatality, to test fatality of
effects.

Test character's vitamins were not previously being cleared, so make
sure to do that.

It feels a little unsafe to hang onto pointers of monsters that you may
be killing and keep doing things with them, but it appears to work so
I'll live with it.
2021-06-09 13:23:52 -07: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 e11b3057ab Fix max_effective_intensity for effects
The max_effective_intensity value for effects was not correctly limiting
the effect's scaling_mods as documented.

This commit adds:

- effect::get_max_effective_intensity() - get protected variable
- effect::get_effective_intensity() - get capped intensity level
- Use get_effective_intensity() when calculating scaling_mods
- Document the intensity fields a little better
- Add test case and test data for intended behavior

Fixes #45397
2020-11-15 20:23:12 -07:00
Alexey Kim 5b65d3aeb4 Add sources to effects 2020-10-09 06:53:18 +03:00
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03:00
Fris0uman 10e6058207 Remove body_part from effect (#42277)
* Effects use bodypart_id
* remove default value and unecessary overrides
* effect_map use bodypart_str_id, and replace num_bp with bp_null
2020-08-01 22:45:04 +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 7264a72dfa Use constant references in function parameters 2020-05-29 11:01:28 +03:00
Eric Pierce c6bfe18b83 Add effect test and some effect test data
Includes test cases focused on `effect` class functions, including:

- High-level: decay (invoked by Creature::process_effects)
- Duration: get_duration, set_duration, get_max_duration
- Permanence: is_permanent, pause_effect, unpause_effect
- Display: disp_name, get_speed_name, disp_short_desc
- Intensity: get_intensity, set_intensity, mod_intensity
- Body parts: get_bp, set_bp
- Modifiers: get_mod, get_amount

Example behaviors exercised:

- simple class initialization test
- minimum / maximum intensity level
- intensity tracks duration for duration-related effects
- decay reduces duration until the effect is removed
- displayed names can vary based on intensity
- pause and unpause effect permanence
- switch grab effect body part back and forth

Some related JSON attributes:

- "name": [ "A", "B", "C"] // multiple intensity names
- "speed_name": "@-name"   // as shown in the @ menu
- "base_mods": [ ... ]     // fixed mod to stats, healing, etc.
- "scaling_mods": [ ... ]  // intensity-based mods to stats, etc.
- "int_dur_factor": time   // for duration-based intensity

Includes some JSON test data to use for data-dependent checks.
2020-05-06 08:25:38 +00:00