51 Commits

Author SHA1 Message Date
RenechCDDA da2aaffffd Add quick setup option to clear map 2026-06-22 15:07:51 -04:00
GuardianDll bf8af078c3 Replace monattack targeting specific body part with monattack targeting specific body part type 2026-05-31 12:12:46 +02:00
dumb-kevin 4fca7bfe80 Allow cross-z-level melee attacks on matching stairs
Add map::on_matching_stairs() that checks whether two positions
are connected by stairs (same XY, 1 z-level apart, lower has
GOES_UP, upper has GOES_DOWN).

Exempt matching stairs from the four cross-z melee blocks:
- Character::melee_attack
- Character::can_reach_attack
- monster::attack_at
- monster::move z-gate

Rooftop and ledge attacks remain disabled.
2026-03-16 09:16:15 +04:00
RenechCDDA d883f5fe03 Remove reach attacks across z-levels 2026-03-11 09:29:42 -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
Andrew Krieger 0215b26cce Rewrite all tests to clear map without touching character map memory, for performance. 2026-02-08 23:05:55 -08:00
PatrikLundell 586cf5f1ce Mapify: character etc. sees + sundry others (#79699)
* Mapify: character etc. sees + sundry others

* demanded changes

* Corrected correction
2025-02-18 09:29:22 -06: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 99aeb7b990 Load npcs and deal with their bodies 2025-01-25 09:49:42 +01:00
PatrikLundell 537d9d12a1 Standardized get/set pos operations for talker/creature class hierarchy (#79206)
* Standardized get/set pos operations for talker/creature class hierarchy

* sort out merge failure
2025-01-20 08:20:58 +01:00
PatrikLundell befd4486d1 sundry typification (#78985)
* sundry typification

* demanded work around
2025-01-06 22:26:26 -06: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
Andrew Krieger 67c1ad039a Categorically fix type issues with restore_on_out_of_scope 2024-12-09 21:51:35 -08:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -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
Anton Simakov 1c19589bd8 purge not used hardcoded mattacks 2024-07-31 11:34:50 +02:00
PatrikLundell ec028a90be typified lightmap 2024-05-07 16:05:53 +02:00
Binrui Dong fa907827f1 Enable clang-tidy check readability-duplicate-include (#71826) 2024-02-19 17:09:24 +03:00
Qrox a98c0e5506 Fix monster attack test 2024-01-28 11:06:57 +08:00
Qrox 46202a92a6 Remove FOV_3D option and default to 3d FOV 2024-01-28 11:06:56 +08:00
Rewryte 0ef2fe12ca Fix visibility not updating properly when moving, peeking and autodriving (#68138)
* add visibility update

* vis update when peeking

* fix autodrive visibility

* revert visibility optimization

* only cache tile visibility on access

* use apparent_light_at to handle visibility cache

* Revert "use apparent_light_at to handle visibility cache"

This reverts commit 37f66fda9e.

* Revert "only cache tile visibility on access"

This reverts commit b52cd59827.

* pos and time visibility invalidation

Co-Authored-By: andrei <68240139+andrei8l@users.noreply.github.com>

* fix peek and look around

* fix tests

---------

Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>
2023-09-25 22:23:37 -04:00
Dillon Matchett 50471ecd91 Grab cleanup (#66732)
* Grab cleanup

* Didn't save my JSON changes woops

* actually clear effects on 1 mon

* Saving and clang
2023-07-09 22:55:21 -04:00
Venera3 0bdd97d252 Grab fixes and drag overhaul (#65774) 2023-06-24 22:11:21 -07: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
Fris0uman 4468cacbc0 Tiring dodges (#64224)
Co-authored-by: Kevin Granade <kevin.granade@gmail.com>
Co-authored-by: Fris0uman <sthapplz@gmail.com>
Co-authored-by: I-am-Erk <I-am-Erk@users.noreply.github.com>
2023-06-05 18:29:15 -07:00
Alexey 38a51888f8 Misc fixes for tests noise, log noise and missed vpart changes (#65765)
* Raise margin on grab tests

* Squelch wreck merging messages

* Use a couple more copy-froms in magiclysm vehicle parts
2023-05-22 09:55:43 -03:00
Venera3 f9caeb7025 Rework grabs (most of them, at any rate) (#64999)
* Grabs the first

C++ and documentation

* Tests, Tweaks, Docs

* Rebase fixes

* Update src/mattack_actors.cpp

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

* Src tweaks

Mattack proper, was_loaded

* JSON changes

Including WIP second grabs, mods, but no dinos

* Apply suggestions from code review

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

* Src oopsie

* Update src/mattack_actors.cpp

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

* Update src/mattack_actors.cpp

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

* Src Oopsie 2

* Backup WIP (don't ask)

* Dinomod part 1

* Dinomod Part Two

* Final?

* Apply suggestions from code review

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

* Clang

* Ampersin

* We used to talk, Basic Build

You could complain about more than a single file at once, back then

* Mamaaaa

* Update monster_attack_test.cpp

* Armor

* Teleport oopsie

* Clang?

* Plop

* Clang me up, Scotty

* Un-complexify the grab test

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Seguin <davidseguin@live.ca>
2023-05-04 11:15:50 +02:00
Venera3 e75cf05801 Expand mattacks to use the dialog condition system (#65229) 2023-04-23 15:28:50 -07:00
Venera3 c49b8e04a4 Expand monster special attack conditions (#64184) 2023-03-16 23:01:16 -07:00
Venera3 50bba798fe Add bodypart on-hit effects, unhardcode bleeding / blinding on damage, allow effects to modify limb scores (#62092)
* First

No JSON, Flexbuffers are mean

* JSON

* astyle, clang?

* Claaang

* It puts the astyle on its code or it gets the hose again

* Clang??

* Apply suggestions from code review

Co-authored-by: Anton Burmistrov <Night_Pryanik@mail.ru>

* Global?

* effect limb score modifiers

* WIP

* Doneish

* Tweak

* Monster attacks

* Test WIP

* Test fixes

* Tweak

* Clang

* Actually clang

* astyle

---------

Co-authored-by: Anton Burmistrov <Night_Pryanik@mail.ru>
2023-03-06 12:12:26 +01:00
akrieger 3b22d13aa9 Move scope helpers to cata_scope_helpers.h 2022-09-15 22:04:51 -07:00
John Bytheway 66746d1e9c Enable clang-tidy check modernize-avoid-c-arrays (#60191)
* Enable clang-tidy check modernize-avoid-c-arrays

Convert various arrays to std::array

* Fix more array warnings

These issues were found in CI due to it compiling with different
features than me.

* Don't us sizeof( std::array )

It's clearer to use .size().
2022-09-02 21:15:39 -03:00
John Bytheway c547b9923a Make monster_throwing_sanity_test less flaky (#59156)
This test was flaky because the variance in damage was pretty high.  We
didn't want to make the test slower by adding more samples all the time,
but luckily the test_statistics helper classes already have a function
to help with this issue.  Rather than unconditionally stopping after 100
samples, we continue sampling until the test is certain about whether
the average damage is contained within the specified range.

For the specific failing example I was testing with, this cause 22
additional samples (for a total of 122) and then the test passed.
2022-07-11 00:21:45 -04:00
andrei 262de91aa7 Partially revert #56231 (#57235)
This reverts commit 52d991bb44.
2022-05-04 10:45:44 -07:00
Mylie 52d991bb44 Monster cameras, vision optimizations, and an implementation through Slime (#56231)
* Added monster support and Slime Ocularium

Currently the Ocularium cannot be created, this is intentional - Slimewave is still useful through slime minions from Omnicellular

* Large camera and rendering changes

Makes cameras independent from player vision radius limits, dirties vision cache while cameras are active, and adds better vision falloff to cameras.
In addition, removes recalculation of seen_cache during long activities except on refresh frames - an optimization that arose from camera needs.

* Updates tests, bugfixes player half-seeing monsters

Player was able to detect a monster existed, especially on the compass, but not see their location, when the mosnter was outside of sight_max range (usually 9999, but sometimes much smaller for certain mutations and effects)

* Vision lightcasting now checks sightmax first

Also upped MYOPIC vision radius, preventing an adverse effect of excessive blindness - and somehow making a much nicer vision effect for short-sighted characters.

Mirrors were giving inaccurate vision ranges - also I nerfed mirrors because its now possible to nerf mirrors.

Co-authored-by: bombasticSlacks <dillon.matchett@gmail.com>
Co-authored-by: Kevin Granade <kevin.granade@gmail.com>
2022-03-26 19:35:26 -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
Kevin Granade 66f9ecfb96 Route feral human and other rock throwing through the throwing code (#51465)
* Route feral human and other rock throwing through the throwing code

Necessitated some touchups on the sanity test for same.

* Extend the rock throwing sanity test to check multiple ranges
2021-09-13 13:35:46 +03:00
eltank e396c41283 Migrate more monster fields to absolute coords
Change to tripoint_abs_ms:
- goal [was map-relative]
- wander_pos [was map-relative]
- patrol_route [was absolute but not typed]
Remove serialization for path.
Invalidate path on map shift.
Made goal optional, unset when reached.
Rename goal-related functions for consistency/readability.
2021-09-06 00:00:41 -07:00
Kevin Granade 7153384225 Prune some unecessary game.h inclusions 2021-08-27 09:24:15 -07:00
olanti-p be326d3398 Remove misc includes from headers 2021-07-22 13:56:11 -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
Kevin Granade c044e5d2f7 Add test characterizing how much damage feral humans deal with their thrown rock attack. 2021-06-18 17:17:43 -07:00
Kevin Granade e433ebe74d Apply suggestions from code review
Co-authored-by: Binrui Dong <brett.browning.dong@gmail.com>
2021-05-31 13:12:57 -07:00
Kevin Granade 421cefdea5 Add test for monster reach attacks 2021-05-10 00:53:38 -07:00
Kevin Granade 658212aa29 DRY up the vision reset code 2021-05-10 00:53:37 -07:00
actual-nh fb1d0ade24 Fix z-level melee attack difference problems (with testing code) (#48245)
* added sees check and debugmsg

(cherry picked from commit 752f0c444b)

* Update src/monster.cpp

Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>
(cherry picked from commit da7c76072f)

* excempt stairs&ramps from vision check

(cherry picked from commit 152980e928)

* monster::melee_attack returns false for zlvl violations

(cherry picked from commit cc7b3b7a5d)

* Require daytime for sees in monster_attack test.

Make sure there should be enough light for things to be visible;
weather might also need checking.

(cherry picked from commit 6d253c9f75)

* Set time to daytime.

It wasn't previously (see results of REQUIRE).

(cherry picked from commit 321404f26c)

* Move forward by 2 hours.

It gets set to daytime, but isn't?

(cherry picked from commit 592d0c1f43)

* See if can get info on hour of day.

(cherry picked from commit ea65b7e9bc)

* Try again on checking hour of day.

(cherry picked from commit 874bccf2f4)

* Blasted parenthesis.

In case you're wondering why I don't seem to be compiling locally
before sending things - even with everything else already present
as an object file, the version+ar+compiling the test+putting together
the test executable still takes something like 5-10 minutes...

(cherry picked from commit 23e1394c23)

* Template problem

I'm still learning my way around C++ where it differs from C.

(cherry picked from commit 1282f44ae3)

* Set weather, update sight limits

If this doesn't work, I'll try the steps in vision_test.cpp.

(cherry picked from commit 2062bbc71d)

* Wipe visibility, map caches in monster_attack

This is in case something is left over in one of these caches that's
causing problems.

(cherry picked from commit ce394e20c0)

* Set WEATHER_NULL for weather_override in tests

This sets weather_override to WEATHER_NULL in two places, namely after
(if no exceptions occur!) the monster_attack test and before the
weather realism test. The former should be replaced by
scoped_weather_override (#48227) after that's been merged.

(cherry picked from commit dcacb3d11e)

* Use scoped_weather_override in monster_attack test

Simply doing get_weather().weather_override = WEATHER_NULL at the end
is not sufficient, since it will not be run in the event of an
exception, such as from Catch2.

(cherry picked from commit 49d5f2473b)

* Wrong syntax for scoped_weather_override.

As mentioned before, I'm still learning regarding C++ differences
from C.

(cherry picked from commit c90ae42aa5)

* Start on unifying sees requirement with testing

This is a unification of most of #47993 with most of #48202, in an
attempt to remove problems (seen in #42845, which this hopefully
will fix) with players unable to see monsters on different z-levels
(and, as it turns out, the other way around) but they are still able
to attack the player. This is additionally complicated by that,
when fov_3d is enabled, the player can see the monsters and vice-versa,
and they should be able to attack each other (when at an appropriate
distance).

* Use is_adjacent with fov_3d for melee attacks

This changes the melee_attack code in melee.cpp for
Character::melee_attack to consider non-adjacent anything across
z-levels when fov_3d is false. (It is possible that an actual sees
check will be needed, but let's see how this does - no pun intended.)
reach_attack may be a problem still.

Co-authored-by: Jamuro-g <toenli.e@gmail.com>
Co-authored-by: Jamuro-g <76928284+Jamuro-g@users.noreply.github.com>
Co-authored-by: actual-nh <actual-nh@users.noreply.github.com>
2021-04-05 19:12:48 -07:00
actual-nh ed291cad9e Remove different behavior for debug_mode in Creature::sees() (#48048)
* Remove different behavior for debug_mode in Creature::sees()

Creature::sees(), if its parameter was a creature, was ignoring
a false fov_3d combined with different z-levels if debug_mode was
true. This is not true for Creature::sees() for a specific tripoint,
which is inconsistent, and having debug mode result in significantly
different in-game behavior is undesirable.

* Remove debug_mode check from monster attack test

This PR removes the relevance of `debug` to `sees`. Thus, capturing
its value is no longer needed.

Co-authored-by: actual-nh <actual-nh@users.noreply.github.com>
2021-03-23 11:20:43 +03:00
actual-nh 6cb9c7f2c7 Fix mis-setting of 3d fov in tests; check for status for monster attack test (#48040) 2021-03-16 09:29:18 +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