58 Commits

Author SHA1 Message Date
Tektolnes 3015a27a34 Partial dodge and limb shielding/deflection (#89470)
Co-authored-by: Maya Granade <kevin.granade@gmail.com>
Co-authored-by: Thelis Stambolliu <110344314+FarFarLakeSea@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-17 21:10:30 +01:00
RenechCDDA da2aaffffd Add quick setup option to clear map 2026-06-22 15:07:51 -04:00
dumb-kevin 31a56ef77d Fix flaky melee damage type effectiveness test
Increase iterations (1000 -> 1500) and epsilon (0.05 -> 0.06)
for the monster-targeting check_damage_from_test_fire to reduce
flake probability from ~1/350 to ~1/42000.
2026-03-06 01:35:09 +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
RenechCDDA c0ec9cf617 Cannot trap a monster and use it as an infinite training dummy 2025-07-24 19:36:43 -04:00
andrei 2cce541b4b math/tests: fix math tests for data types 2025-04-08 09:23:00 +03: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
Procyonae 4fd38ca71c Deal with /tests fallout 2025-01-16 16:03:19 +00:00
Procyonae bd591a89b6 Typify standard_npc constructor raw clothing strings 2025-01-10 16:43:09 +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
PatrikLundell 26eb173d36 typified character.h + npc.h (#78623)
* typified character.h + npc.h

* demanded collateral change

* demanded collateral change
2024-12-18 20:03:41 -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
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
Anton Simakov cf579ac306 get rid of npctalk_var_ prefix for eoc variables (#77515)
* get rid of npctalk_var_ prefix for eoc variables

* cleanup after #77055

* deprecate more of type and context

* migrate item vars, make migration happen only once

* doc updates

* migrate u/npc/monster variables

* fix context var migration

* remove `substr( 12 )` in math parser

* move migration to a single function where possible

* no auto

* please clang

* Please clang more

* fix submap load test

* clean up after #77656

* cleanups after #77520
2024-11-16 22:58:03 -06: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
Andrew Krieger b26a7b024b Make eoc melee test stop failing for the wrong reason 2023-09-25 19:43:16 -07:00
Dillon Matchett 15f392c113 on_damage EOCs (#66752)
* on_damage EOCs

* Make separate test

* Update tests/melee_test.cpp

* Update tests/melee_test.cpp

* Update tests/melee_test.cpp

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

* Simplify test

* CLANG

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Maleclypse <54345792+Maleclypse@users.noreply.github.com>
2023-07-25 15:22:46 -04:00
anoobindisguise 7dba942d24 Nerf lycra (#66737)
* nerf protection of lycra

* zentai has less prot now

* nerf zentai

* Update coverage_test.cpp
2023-07-07 23:44:41 -05: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 4b87d7a0c0 Raise melee test margin (#66069) 2023-06-08 10:40:54 -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
David Seguin 06f8b689e8 damage_type: damage type tests 2023-04-24 01:38:21 -04:00
Venera3 90b951a380 Automatically cap melee skill gain from monsters (#63773)
* First

* Testing

* Check, please

* Clang
2023-03-03 11:29:04 -04:00
mqrause 979718d90a change return type of Character::get_wielded_item to item_location (#58666)
Co-authored-by: mqrause <martin@qrause.de>
2022-07-09 02:03:09 -04:00
John Bytheway 2fd2d7453c Move large functions out of headers
Generally speaking, we don't want large functions in headers.  They
increase compile time, not just because the function itself is compiled
many times over but also because they need extra headers to be included.

Using a new clang-tidy check (added in the next commit) find all
functions in headers with more than five statements, and move them into
cpp files.

Also, some static functions in cpp files were marked inline.  This
serves no real purpose; the compiler will already do a good job of
inlining static functions, so stop that.
2022-07-06 13:44:54 -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
Fris0uman da590d88ef Make weapon private (#50286)
* Make `weapon` private

* Update tests

* Rebase

* Appley suggestions

* Fix weapon dorping

* fix weapon saving

* Rename to get_wielded_item

* rename to set_wielded_item

* fixes

* Post rebase fixes

* fixes

* fix weapon saving

* fixes

* more rebase and fixes

* Apply suggestions

* post rebase fixes
2021-09-12 08:47:47 -07: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
MarlossCDDA 1d88a75bdf Replace "two-by-four" with "plank" in user-facing strings (#47709)
* s/two by four/plank

there are still some translations that refer to "two by" "four" across
two lines, leaving those alone for now because I'm lazy

* fix id in doc/VEHICLES_JSON.md, revert translation changes
2021-07-03 07:42:04 -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
Kevin Granade 119d3ff00b Automatically fail to dodge monster attacks when effective dodge is 0 (#43405)
* Automatically fail to dodge monster attacks when effective dodge is 0

* Add simple dodging tests
2020-09-10 11:52:12 +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
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
Fris0uman 8ef3706eaa Move melee related functions from player to Character (#39404)
* Move block_hit(), and associated functions, from player to Character

* Move apply_damage, deal_damage and related functions

* fix

* astyle

* remove excedent slime
2020-04-15 20:43:10 -07: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
John Bytheway 35d93e3460 Set standard_npc position at construction time
This allows tests to avoid calling set_pos on such, which is not safe,
since it assumes the npc is a 'real' one.
2020-01-11 21:27:53 -05:00
John Bytheway 095bd51974 Use C++-style includes
Convert all C library includes to their C++ equivalents (stdio.h ->
cstdio, etc.).
2019-12-24 17:04:16 -05: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 5e20851c5b Second pass of IWYU changes
IWYU is not entirely idempotent; these are the changes from a second
pass of running it.
2019-04-22 12:02:41 +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
John Bytheway cc0c21aed9 Restore missing test check
Looks like it was accidentally lost in 6552e4ac
2018-12-01 12:03:39 +00:00
ZhilkinSerg 410a32c031 Refactored C-style ( T ) ( x ) casts to static_cast<T>( x ) 2018-11-07 14:19:56 +03:00
ZhilkinSerg f8eb2acd05 Optimized includes (tests) 2018-11-07 03:55:47 +03:00
Kevin Granade fc2ad6c76a Astyle-O 2017-08-06 06:11:00 +00:00