29 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
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 befd4486d1 sundry typification (#78985)
* sundry typification

* demanded work around
2025-01-06 22:26:26 -06:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
PatrikLundell 8f19d8e971 typified map.h + dependents, end of first pass (#76888) 2024-10-07 13:23:18 -07:00
Procyonae e9f4fbd110 Remove extern ter ids (#72766) 2024-04-04 07:08:37 -07: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
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
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 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
Kevin Granade 264291e8d9 Global reference migration part 20 (#41935) 2020-07-08 08:50:38 +03:00
Mark Langsdorf c3cba8e66e options: remove the option to not use z-levels
Ground vehicle z-level transitions requires that z-levels be enabled,
and getting rid of this option will also allow much of the map code to
be dramatically simplified.
2020-06-30 20:50:36 -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
Oren Audeles 386d53df09 clang-tidy: fix error in 'clang-tidy CMake build with Tiles and Sound'
fixes error: Construction of 'tripoint' can be simplified using
overloaded arithmetic operators.
[cata-use-point-arithmetic,-warnings-as-errors]

Suggested fix by error output is to use:
  const tripoint &pt = tripoint_zero + tripoint(
    delta_x * wall_size,
    delta_y * wall_size,
    delta_z );

tripoint_zero is defined as tripoint(0, 0, 0), so arithmetic operations
would simplify further to just:
  const tripoint &pt(
    delta_x * wall_size,
    delta_y * wall_size,
    delta_z );

Further, while it does not cause an error to use a const reference here
it is unnecessary.
2019-10-22 14:05:41 -05:00
Mark Langsdorf bb41c0001e maps: rework collapsing to prevent weird lab collapses (#34866)
Fixes #34752

The solution to #32260 included in #34694 had three serious problems:
1. smashing a random floor tile would cause scores of nearby floor
tiles to collapse, possibly hundreds across multiple z-levels.
2. any vehicle that was above a collapsing floor would get bashed
into scrap metal
3. despite the collapse of all these floors and walls, the floors
on the next z-level up would remain.

So there was very weird behavior that didn't actually resolve the
issue of floating floors after the underlying level collapsed.

The solution is to substantially rewrite collapse_at(), as so:
1. collapse_at() is only called from bash_furn_ter() when a wall
supporting a roof collapses.
2. when a wall collapses, repeat the collapse check for any walls
on the z-level above it.
3. when a tile that is supporting a roof collapses, turn the tile
above it into open_air with no furniture but don't destroy it (which
might destroy any vehicles - unsupported vehicles should fall and
be destroyed that way).

Also, perform the collapse_at() checks for adjacent tiles during
bash_furn_ter() - collapse_at() already checks those adjacent tiles,
so that was doubling their chances of collapse.

collapse_check() now checks the terrain below the current terrain.
It is still possible for a wall supported on several sides but not
supported by anything below to not collapse, but it's less likely.
2019-10-22 00:54:06 -07:00
John Bytheway 7bda6884c3 Custom clang-tidy check to suggest use of named point constants (#33200)
* Initial version of UseNamedPointConstantsCheck

This is intended to convert hand-rolled point constants like
point( 0, 0 ) into point_zero.

* Apply refactoring pass

* Manual fixup of refactored code

Add various manual tweaks to the automatically refactored code where I
think it makes sense.

* Remove some unnecessary initializations
2019-08-13 23:04:51 +03:00
John Bytheway 4321c025d2 IWYU 20190629 (#31990)
* Add IWYU pragma: keep

* Run IWYU and astyle

* Run IWYU a second time

* Prevent #include <cxxabi.h>

Unclear why IWYU thinks this is needed.  It isn't, and it causes
problems on Visual Studio.
2019-07-01 12:25:53 +03:00
KorGgenT 3efa74a662 more avatar includes 2019-05-21 11:00:57 -04: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
Jason Jones ab7d8f0534 Add failing test for destroying floors with basements
Follows the example of the other tests for this problem area.
Doesn't run by default, and behavior will change depending on
ZLEVELS settings. Run with:

tests/cata_test --option_overrides=ZLEVELS:true "explosion_on_floor_with_rock_floor_basement"
2018-12-13 09:52:12 -09:00
John Bytheway f6af1d1c79 Tidy up map helpers
The clear_map function also moved the player to level -2, which is a
little surprising.  Move that functionality out to a new function.

For each of the places using clear_map, pick either the new or old
version to use as appropriate.

Also, clear fields in clear_map.
2018-11-16 22:32:27 +00:00
ZhilkinSerg d4f9f135ef Removed unused include directives (tests) 2018-11-07 17:02:14 +03:00
ZhilkinSerg f8eb2acd05 Optimized includes (tests) 2018-11-07 03:55:47 +03:00
mctynp 23f2bf9835 Test cases for issues 24707,23250 2018-10-10 15:22:30 -07:00