17 Commits

Author SHA1 Message Date
dumb-kevin 05ab42807e tests/: wrap TU-local test fixture types in anon namespaces
- addiction_test: wrap addict_effect_totals
- battery_density_test: wrap battery_chemistry_family
- comestible_test: wrap all_stats
- encumbrance_test: wrap add_trait
- invlet_test: fuse inventory_location + invlet_state + test_action enums
- throwing_test: fuse throw_test_data + throw_test_pstats, move operator<< inside anon-ns
- vehicle_test: wrap vehicle_preset, damage_preset, folded_item_damage_preset, fuse rack_activation + rack_preset
- vision_test: wrap vision_test_case
- water_movement_test: fuse 6 swimmer/swim structs into one block
- weakpoint_test: wrap weakpoint_test_data, weakpoint_expectation, weakpoint_report
2026-05-12 10:53:28 +04:00
LISPCoC 725161a038 [EoC] Some monster and map related update (#69405)
* monster eoc

* update

* test

* passable_only
2023-11-16 22:36:01 -06:00
LISPCoC 3c606a08c9 Fix GCC9 warnings "overloaded-virtual" (#68460)
* Fix GCC9 warnings "overloaded-virtual"

* kill tracker

* tests
2023-10-02 23:19:58 -05: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
John Bytheway b0ce494cdc Filter out non-empty invalid field values
event_field_transformation functions shouldn't need to be written
defensively against invalid inputs.  So, pre-check the arguments and
don't call the function if an argument is invalid and non-empty.

We're already relying on them supporting empty arguments, so we can't
filter those out.  Maybe in the future those empty arguments should be
replaced by null instead.
2020-10-12 08:20:34 -04:00
Kevin Granade 28db493b0d Troubleshooting for Xcode build issue (#43043)
* why brew why

* Add a number of event_subscriber tests

Helped to characterize a bizarre polymorphic dispatch bug that only seems to occur with XCode 10.1

* Set XCode version to 10.2

This version is not subject to the event_subscriber dispatch issue.
2020-08-24 09:05:32 +03:00
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03:00
Kevin Granade bc9a51e384 Remove event_subscriber declaration from event_bus.h 2020-08-03 22:09:45 +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
John Bytheway b83fc88b9e Convert itype_id to string_id<itype>
itype_id is (presumably) one of the oldest type ids in the game.  In
particular, it predates string_id, and was simply a typedef of
std::string.

This is bad for type safety.

Make it be a string_id specialization instead, and update the rest of
the code accordingly.
2020-05-19 21:07:40 -04: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 2a7604b02f Move event class into namespace cata
This is to avoid a clash with 'struct event' in
/usr/local/include/event2/event_struct.h on some MacOS systems.
2019-08-31 16:19:17 -04:00
John Bytheway a68d2f85d3 Move most memorial code to new memorial_logger
Create a new memorial_logger class responsible for the memorial file
(previously this responsibility lay with player).

Have this new class be a member of game, and subscribe to the event bus.

Nearly all memorial messages are now triggered by events, rather than
written directly in the places where the game logic is implemented.

This is intended to:
- Improve separation of concerns.
- Provide a much more thorough test of the event bus.

Some other changes that come along with this:
- Many more cata_variant types.
- Many many more event types.
- Added Character::get_bionics.

A handful of memorial messages are still sent directly to the
memorial_logger, rather than through the event bus.  These are the ones
that seem less significant, and I didn't think they were worth creating
an event for.
2019-08-25 18:09:03 -04:00
John Bytheway 8cfe3d9230 Update killing events
Make two kill events: one for Character victims and one for monster
victims.

Update their content to contain what's needed for the kill information
the game currently tracks.

Stop including the event name in the event_spec; plan to put that
elsewhere later.
2019-08-21 02:00:48 -04:00
John Bytheway 4f8354adb7 Add event class and simple event bus
This is intended to support loosely coupled interactions, in particular
for a scores / achievements system.

For now it's just a proof of concept with a single event type.

I'm using a generic event type with variants rather than explicit event
classes to simplify serialization, versioning, and generic queries.  For
example, I want to be able to define achievements in json based on
string field lookups.  This approach should make it straightforward to
define an achievement like "killed 100 skeletal juggernauts" without
hardcoding anything specific to that achievement.
2019-08-21 02:00:48 -04:00