* typified a bit of map.h/cpp + dependents
* demanded changes
* demanded master changes drawn to its conclusion
* second int should be in corresponding location
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.
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.
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.
* 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++
* 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
* 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.
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.
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.
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.
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.
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.
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.