48 Commits

Author SHA1 Message Date
RenechCDDA cb924413e4 Move init_veh_status to an enum (oh god) 2026-05-17 23:11:41 -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 73ec6e4584 Merge branch 'master' into iwyu-l-27 2025-02-11 10:40:53 -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 4fb5f14234 make some vehicle operations map aware (#79599)
* make some vehicle operations map aware

* hid names of unused parameters

* Update src/vehicle.h

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

* equality, not assignment

* demanded change

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-02-08 22:06:31 -06:00
PatrikLundell 6a0cc1e154 made more vehicle stuff map aware (#79544)
* made more vehicle stuff map aware

* demanded change

* demanded change
2025-02-06 00:57:40 -06:00
PatrikLundell e64cd5b8a1 Start to make vehicle coordinates make sense 2025-01-31 17:16:47 +01:00
Maleclypse bf978d6366 Merge pull request #78994 from mqrause/split_test_fix
Fix vehicle_split_section test by only destroying the vehicle and not the terrain
2025-01-07 21:49:36 -06:00
mqrause f440bb7769 add map::destroy_vehicle and use it in vehicle_split_section test 2025-01-07 08:08:14 +01:00
PatrikLundell befd4486d1 sundry typification (#78985)
* sundry typification

* demanded work around
2025-01-06 22:26:26 -06:00
RenechCDDA 43c2abf54a Fix some tests that relied on previous ordering, maybe 2024-12-21 02:22:39 -05:00
Procyonae db5df8f04c Fix vehicle_turret test 2024-12-14 16:03:47 +00:00
PatrikLundell afb794bbc5 typified a bit of vehicle.h and dependents 2024-11-03 15:08:15 +01: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 4ba6a9f7a8 Typified parts of map.h/map.cpp + usages 2024-07-18 00:23:02 +02:00
PatrikLundell 1542a3ac1b typified activity_actor 2024-05-15 17:01:50 +02:00
PatrikLundell f7e64c68d6 Made tinymap load take a tripoint_abs_omt parameter instead of untyped tripoint (#72145)
* Made tinymap load use omt coordinates (and thus alignment)
2024-03-19 19:32:24 -07:00
PatrikLundell 37d4f59f59 Preparation for using typed tripoints consistently 2024-02-25 14:27:44 +01:00
irwiss 23b716288f Prune point add_vehicle overload 2023-06-20 11:03:40 +03:00
Clarence "Sparr" Risher af42e388eb Replace 15_degrees with vehicles::steer_increment (#64575)
The constant 15_degrees (and 6, which is 90/15) appears various places
in the code without explanation. Replacing it with a name should clarify
the intent and meaning of the places it is used.
2023-04-02 22:55:32 +03:00
Alexey Kim 90a8423d54 Tag loose vehicle test cases 2022-09-06 17:23:40 +03:00
Kevin Granade cb58750a05 Add test to exercise the case when a vehicle is split during mapgen. 2022-06-01 21:03:45 -07:00
Kevin Granade b8d4a352a1 Add some more vehicle splitting and skewing tests 2022-06-01 21:03:45 -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
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
Jianxiang Wang (王健翔) 9457601569 Fix dragged vehicle/furniture leaves a trail of memorized tiles in darkness (#47189) 2021-02-03 18:49:00 -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 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
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
Qrox 24d7d93f67 Remove moooar redundant drawing code 2020-06-06 18:09:52 +08:00
Hirmuolio 82636942d2 Wheel hub assemblies and wheel adjustments (#33520) 2019-08-29 22:32:07 -07: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 f42afc59d4 test includes 2019-05-21 10:25:49 -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 69de386614 Add in-vehicle sanity checks before setpos
After discovering that setpos can break the vehicle cache stuff, add
some sanity checks in various places in the tests where I'm concerned
they might unknowingly be moving a player out of a vehicle.
2019-05-05 10:38:24 +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
Mark Langsdorf cf9f06f53c vehicles: improve split logic
Adjust the mount point of the partsof forcibly split vehicles.  This
seems to keep their global pos3 where it should be instead of having
them jump around the map and ending up partially under the vehicle
they split off from.

Beef up the vehicle split test to check that the tripoints of all the
parts of the new vehicles are the same as the tripoints of the parts
of the original vehicle, and that no new vehicle shares a tripoint
with any other vehicle.
2019-01-10 07:57:27 -06: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
Mark Langsdorf 33f8218489 vehicle: create and use get_parts() variants
Replace the calls to get_parts() with get_avail_parts(), get_any_parts(),
get_available_parts(), and get_parts_included_carried(), as appropriate.

Replace some calls to get_parts with references to the appropriate caches.

Make the vehicle grab and split tests a little more robust and make it
clearer where failures are occurring.
2018-11-12 15:44:56 -06:00
ZhilkinSerg f8eb2acd05 Optimized includes (tests) 2018-11-07 03:55:47 +03:00
ZhilkinSerg 51142521bb Joined variable declaration and assignment 2018-11-06 13:48:52 +03:00
Mark Langsdorf af68cddd1e vehicles: make the vehicle split code more robust
Add some checks for removed parts in the damage and vehicle split code,
so the code doesn't process those parts.

Also remove the call to part_removal_cleanup() in
find_and_split_vehicles(), which should stop the size of the parts
vector from changing during vpart_range interations and causes the
size asserts in there to fail, catastrophically crashing CDDA.
2018-10-09 20:53:01 -05:00
Mark Langsdorf 64546cd076 vehicle split: add a flood fill algorithm to split a vehicle
Add a flood fill algorithm that finds up to 4 subvehicles that share no
connections other than a structural part at the excluded index.

If 2 or more subvehicles are detected, split the parent vehicle into
a parent vehicle and some subvehicles using the existing split_vehicles
code.

Include a couple of simple test cases to demonstrate the split algorithm
works correctly in the straightforward cases. In the actual game, the
presence of multiple caches makes this much more complicated.
2018-10-01 09:22:18 -05:00