46 Commits

Author SHA1 Message Date
Anton Simakov 7d2228f85a use item_location in use actions instead of item * (#89473) 2026-11-17 12:07:16 -06:00
GuardianDll 7a10e1cbe7 Revert "refactor death message, corpse spawn and death drops suppresion vars (#87680)"
This reverts commit 8bf230233d.
2026-07-07 16:46:06 +02:00
RenechCDDA da2aaffffd Add quick setup option to clear map 2026-06-22 15:07:51 -04:00
Anton Simakov 8bf230233d refactor death message, corpse spawn and death drops suppresion vars (#87680)
* refactor death message, corpse spawn and death drops suppresion vars

* Apply suggestions from code review

Co-authored-by: np4Huk <22.valiant@gmail.com>

* Fix test issues

---------

Co-authored-by: np4Huk <22.valiant@gmail.com>
2026-06-17 22:41:39 -05:00
RenechCDDA cb924413e4 Move init_veh_status to an enum (oh god) 2026-05-17 23:11:41 -04:00
dumb-kevin 05ab42807e tests/: wrap TU-local test fixture types in anon namespaces
- addiction_test: wrap addict_effect_totals
- battery_density_test: wrap battery_chemistry_family
- comestible_test: wrap all_stats
- encumbrance_test: wrap add_trait
- invlet_test: fuse inventory_location + invlet_state + test_action enums
- throwing_test: fuse throw_test_data + throw_test_pstats, move operator<< inside anon-ns
- vehicle_test: wrap vehicle_preset, damage_preset, folded_item_damage_preset, fuse rack_activation + rack_preset
- vision_test: wrap vision_test_case
- water_movement_test: fuse 6 swimmer/swim structs into one block
- weakpoint_test: wrap weakpoint_test_data, weakpoint_expectation, weakpoint_report
2026-05-12 10:53:28 +04:00
dumb-kevin e4bb943d3b Fix CI skip-detection job refs, Makefile parallel safety, and test tag syntax
- matrix.yml SKIP condition referenced non-existent job names
  (skip-duplicates, skip-duplicates-mods); corrected to match declared
  jobs (skip-duplicates-code, skip-duplicates-data). Same fix for the
  commented emscripten block.
- tests/Makefile batch runs now use --user-dir with a unique PID-based
  path so parallel shard execution doesn't collide on filesystem state.
- Normalized comma-separated TEST_CASE tags to space-separated across
  9 test files (25 declarations). Comma syntax is deprecated in Catch2
  v2 and removed in v3. Also fixed a missing space between adjacent
  tags in throwing_test.cpp.
2026-02-24 21:24:24 +04:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08:00
moxian e2f7aaf95f Modernize c headers (stddef.h -> cstddef &co)
Code size:
includes:
$ cat obj/tiles/*.inc | wc
 278247  556494 17375710
$ cat tests/obj/tiles/*.inc | wc
 163745  327490 10307041

post-processed source (clang -E):
./make_preproc.sh src/
65903054 170378741 2049783477
./make_preproc.sh tests/
38434408 100326802 1215849078
2025-02-10 13:56:09 -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 99aeb7b990 Load npcs and deal with their bodies 2025-01-25 09:49:42 +01:00
osuphobia 818c74388a shot dispersion refactor 2025-01-17 23:33:31 +08: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
PatrikLundell c380147ab2 typified creature.h and monster.h (#78565)
* typified creature.h and monster.h

* Update src/monmove.cpp

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

* Update src/monster.h

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

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-12-16 22:16:00 -06:00
PatrikLundell c5c01140ba typified a bit of map.h/cpp + dependents (#76712)
* typified a bit of map.h/cpp + dependents

* demanded changes

* demanded master changes drawn to its conclusion

* second int should be in corresponding location
2024-10-02 23:34:12 -05: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 0c7dd6a4c3 Use ammo_effect_str_id instead of std::string (#73931)
* Use ammo_effect_str_id instead of std::string

* replace RECOVER_ flag with a new field

* Update json

* Update doc

* remove unused ammo_effect

* update mods

* fix ids for clang

---------

Co-authored-by: Fris0uman <fris0uman@users.noreply.github.com>
2024-06-14 22:44:11 -04:00
Kevin Granade 214ada7997 Fix infinite looping in msvc builds in fragment test function
My debug code in #71585 introduced a divide by zero, resulting in infinite fragmentation density.
It seems the msvc std::poisson_distribution constructor doesn't like infinite values.
2024-02-17 10:39:04 -08:00
Kevin Granade 82a35ce26a Tune up grenade fragments, fragment generation in general, and fragment test
This also restores the ability of bomb fragments to pass through occupied tiles.
2024-02-07 00:19:43 -08:00
Hirmuolio c6f8dc39db Update all active items to new tick action system and remove old system (#67352)
* remove bool t uses

* remove bool t uses

* remove bool t uses

* split multicooker

* split remoteveh

* remove bool t uses

* lint

* unused

* radiocaron

* radiocontrol

* foodperson

* ehandcuffs

* Update data/json/items/tool/radio_tools.json

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

* laptop music

* robotcontrol

* portable_game

* gasmask

* dive_tank

* unused

* mp3

* geiger

* noise_emitter

* fish trap

* remove bool t

* merge fix

* mods

* merge fix

* merge fix

* better music

* fix mp3

* better messages

* better messages

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-06 08:44:51 -05:00
Hirmuolio ffe5a45099 Carrier for items on ground is nullptr (#66292)
* remove forced player

* multicooker

* radio controller

* mp3

* manage_exosuit

* electricstorage

* incendiary grnd

* crater mapgen

* put avatar back

* geiger

* gasmask

* fishing trap

* astyle

* ehandcuffs

* dive_tank

* style

* message_iuse

* remove activation

* iuse_actor switch from references to pointers

* astyle

* worn items

* p checks

* put thing back

* merge fix

* astyle

* invoke

* can_use

* revert can_use

* transforming item in processing

* unused var

* throw activation test

* remove reference to nullptr

* fix previous commit

* fix fireweapon

* astyle
2023-07-11 15:29:16 -07:00
Hirmuolio 35a64b772c Refactor timer items to be a bit more time based (#66161)
Co-authored-by: Brambor <tondadrd@seznam.cz>
2023-06-17 14:15:15 -07: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
RipleyTom 1264425026 remove unused variables (nfc) (#61997) 2022-10-31 19:04:04 -04:00
Kevin Granade 32514b039b Make bomb fragment damange bullet type
add a test validating that target size doesn't impact damage
2021-10-26 09:04:57 -07:00
Kevin Granade b406093ea9 Make bomb fragment strikes size-aware 2021-07-17 23:36:09 -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
Zhilkin Serg 41b5faddfa Remove unused static variables (#49351) 2021-06-21 15:45:39 -04:00
eso 280c9fd44a partial vehicle damage reduction hotfix (#49080)
* partial vehicle damage reduction hotfix

trying to make vehicles less immortal. also removed ridiculous recipe for "hard plating"

* rescale rams to 1.25* durability/dr of their respective plates

* add a small amount of dr to some otherwise fragile components

* linting

* fix explosion damage test to look at total vehicle hp

also added additional test cases

* car stereos shouldn't do the star trek console explosion thing either
2021-06-11 10:19:19 -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
andrei fd384f1f73 game: defer explosions (#45693)
* game: defer explosions
trigger explosions after processing all items
fixes #45662
* tests: update explosion test
2020-12-04 19:14:16 -08:00
John Bytheway 2c04d796ef Add units::angle and port various code to use it (#44805)
* Add units::angle and port various code to use it

Add a typesafe angle type.  Partly for general type safety but also to
avoid confusion between different measures of angle (radians, degrees,
and arcmin are all used in this codebase.

Convert tileray to use the new type, and deal with the fallout from
other things that depend on tileray.

Most of the changes relate to changing vehicle facing to the new type.

Note that this changes vehicle facing from an integer to a floating
point type, which could cause some behavioural change.

* Include math_defines.h for Window build
2020-10-18 21:24:56 +00:00
Kevin Granade 0a386cdc40 Suppress spawning monster items on death in test 2020-09-20 07:43:52 +00:00
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03: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
John Bytheway 4f597dc72a Make closest_points_first work for all point types
Previously we had separate functions closest_points_first and
closest_tripoints_first.  We'd like to extend this functionality to
coord_point, but it's easier to do if both the raw underlying functions
have the same name (so the generic wrapper can be the same).

To that end, rename closest_tripoints_first to closest_points_first
(they are chosen between based on overload resolution), and add a
wrapper to allow coord_point to be used similarly.
2020-07-08 21:30:13 -04:00
Kevin Granade 1a6769da4e Map reference migration part seven 2020-06-28 20:24:43 +00:00
Michael ab977f7074 Encapsulate vehicle parts. (#41338)
* Encapsulate vehicle parts.

* Fix size_t vs. int

* Fix assert comparison
2020-06-17 10:22:50 +03:00
Kevin Granade 6b69cbef41 Optimize explosion code a little 2020-05-22 06:33:09 +00:00
John Bytheway 9034951f0c Stop supporting comparing string_id wiwth literals
There was an overload for operator== between string_id and const char*,
allowing direct comparison with literals.  This goes against most of the
other properties of string_id in that you must usually be explicit about
conversions between it and strings.

Also, it hampers refactoring, because you might not notice that a
comparison has become incorrect when changing the type of a variable.

Remove that operator overload and update code using it accordingly.
2020-05-14 20:40:01 -04:00
John Bytheway e189957ff2 Run IWYU 20200408 (#39364)
* Helper script to run IWYU

* Run IWYU

* Update deprecated headers

* Run IWYU again

* Re-suppress cxxabi.h

This pragma got accidentally removed because it was deemed to be a
comment attached to a #include.

* Remove extra SDL header includes

* Fix ime.cpp headers

Some tweaks to help IWYU not break this file by messing with
platform-specific stuff not relevant on Linux.

* Update game.h

* Move new point.h includes inside #ifdef

* Re-add platform_win.h to mapsharing.cpp

* Apply suggestions from code review

Co-authored-by: ZhilkinSerg <ZhilkinSerg@users.noreply.github.com>
2020-04-10 12:16:19 +03:00
Eric Pierce 721581d9ba Tag slow-running test cases
Based on running `tests/cata_test -d yes` to see durations:

22.254 s: grenade_lethality
9.236 s: starting_items
7.887 s: starve_test
5.416 s: all_nutrition_starve_test
2.904 s: starve_test_hunger3
1.496 s: unskilled_shooter_accuracy
1.490 s: an unskilled shooter with an inaccurate shotgun
1.167 s: default_overmap_generation_always_succeeds
0.953 s: default_overmap_generation_has_non_mandatory_specials_at_origin
2020-04-02 15:46:20 -06:00
John Bytheway 3d7a03bbe0 Fix a couple of rare test failures (#38327)
* Ignore damage to battery_car in explosion_balance

After seeing a test failure for this test, and looking into it, I think
the damage is simply because the explosion got an unusually high amount
of damage by chance.  So I've added battery_car to the whitelist of
things we'll ignore if they're damaged.

* Fix test ordering dependency

npc_talk_conditionals relied on a previous test setting player cash.
Have it do so locally.
2020-02-25 19:23:00 +03:00
Brian-Otten 6d26b222a5 Adjust grenade values (#37585) 2020-02-11 05:26:37 +00:00
ZhilkinSerg fbaae72067 Refactor closest_(tri)points_first functions (#37108)
* Refactored `closest_(tri)points_first` functions
- moved into `point` file;
- rearranged function parameters;
- removed duplicate code;
- get rid of some `auto` and one time use variables;
2020-01-17 07:57:04 +00:00
John Bytheway ba319e75d8 Rename test files for consistency
Have all files containing tests be named *_test.cpp.
2020-01-11 11:05:54 -05:00