23 Commits

Author SHA1 Message Date
dumb-kevin 8522605684 Use flat_set for item/itype/pocket flag storage
- Swap std::set<flag_id> for cata::flat_set<flag_id>
- Update FlagsSetType in item, itype, and pocket_data
- Replace emplace with insert on tag caches
- Adjust bionics_test cast to std::set<json_character_flag>
2026-04-24 18:33:04 +04:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08:00
moxian a66f0d6cd8 mechanically run IWYU on "simple" files (--safe_headers)
... three times, until it stops making new suggestions.
Run with --safe_headers (default) (i.e. headers can only
get new includes added, but can't get anything removed)
The code does not compile in current state (kinda expected),
manual fixups will follow.
--nosafe_headers commit would also follow afterwards

The "simple" files are those that don't have any sort of
define/if defined/ifndef conditional compilation in them.
Just plain old c++ with no preprocessor.

Code size:
includes:
$ cat obj/tiles/*.inc | wc
 290436  580872 17972230
$ cat tests/obj/tiles/*.inc | wc
 168196  336392 10510740
post-processed (clang -E):
cat ./out/pp/src/* | wc
69365093 179919823 2157445134
cat ./out/pp/tests/* | wc
40499273 106027071 1277878587

The code size increase is expected due to --safe_headers
2025-02-10 00:46:59 -08:00
Clarence "Sparr" Risher 964eb6ac19 Refactor repeated map.ter .furn .*_at calls 2024-11-02 19:14:21 -04:00
Brambor 602647da03 iwyu: run for src/ folder, A*-F* files
skipped some files since they were complicated
2024-04-15 23:32:46 +02:00
Binrui Dong 32774b37da Migrate from cata::optional<T> to std::optional<T> (#64333)
Co-authored-by: Kevin Granade <kevin.granade@gmail.com>
2023-03-20 20:11:23 -07:00
cakepie 5193300b79 vehicle cheevos: handle going in reverse (negative velocity) (#64359) 2023-03-19 17:34:13 -07:00
John Bytheway 87a51717d2 Allow fetching overmap specials for events (#59363)
Add a new event_field_transformation that fetches the overmap_special_id
of the special at particular OMT coordinates.

Use that to tweak the Last Homely House achievement to trigger on entry
into any refugee centre OMT, rather than just the one specific one.

Also, added a type safety check for achievement requirements because I
made that mistake while working on this PR.  That check revealed an
issue with the Xedra Evolved achievements, so fixed those.
2022-07-18 13:03:52 -04:00
John Bytheway 53a6cd9050 Apply auto transformations
Use the new clang-tidy check to replace all the auto variable types with
explicit types (where it makes sense to do so).
2022-07-01 07:11:27 -04:00
Zhilkin Serg 5cb2655590 Rename ter_bitflags to ter_furn_flag and make it class enum 2021-08-30 22:14:22 +03:00
John Bytheway 8cc6378fc5 clang-tidy modernize-use-emplace (#48661)
* Port code to emplace_back

This is clang-tidy making automated changes to convert push_back into
emplace_back whenever the argument to push_back is either a constructor
call for the type in question of an expression of a type implicitly
convertible to the type in question.

This should eliminate one move-construction of the inserted object for
each call.

* Enable clang-tidy modernize-use-emplace
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
Aivean 8176f28447 get rid of int_id<json_flag>
alias flag_id to flag_str_id (for now)
2020-11-08 14:07:37 -08:00
Ivan Zaitsev 9a619a6a22 Change item::item_tags, itype::item_tags, etc. to int/str id (part 4 of #44694) (#44823)
* change item flag type from std::string to flag_str_id/flag_id in the following entities: item::item_tags, itype::item_tags, Item_modifier::custom_flags, recipe::flags_to_delete, effect_type::flags, harvest_entry::flags, clothing_mod::flag, zone_priority_data::flags, pocket_data::flag_restriction, heal_actor::used_up_item_flags, jmapgen_spawn_item::flags, ma_requirements::req_flags

change item flag type method signatures where needed;
supplementary changes
2020-10-17 03:02:39 +00:00
Aivean e66387a377 refactor direct access to item::item_tags and itype::item_tags to accessor and mutator methods 2020-10-07 18:48:30 -07:00
John Bytheway 8729b19c32 Add event_field_transformation for itype flags
Add a json-accessible function for getting flags from an itype, similar
to the existing one which extracts flags from terrain.
2020-09-12 15:01:12 -04:00
Kevin Granade c029fc3e09 Iwyu (#42744)
* IWYU pass 1

* IWYU pass 2

* Manual fixups after IWYU
2020-08-07 02:58:51 +03:00
John Bytheway f652e94c72 event_field_transformation to extract oter_type
We want to be able to refer to oters without the direction suffix.  This
provides an event_field_transformation so e.g. achievements can do that.
2020-06-07 22:01:06 -04:00
John Bytheway 8fc0363ec3 Force statistic value constraints to be type-safe
Previously a value_constraint field could simply specify a string and it
would be compared against the content of the variant.  But this is not
very safe.  Require the relevant json to also specify the
cata_variant_type of the desired value, facilitating proper
type-checking.
2020-05-23 23:27:46 -07:00
Jason Jones 1689b1e4e8 Add new movement based achievements and statistics 2020-04-22 20:34:04 -08:00
John Bytheway ff57b78619 All event sources now publish their type
For event_statistic, add a type() method.  For event_transformation, add
a fields() method.

Consolidate the type of all these field lookup objects as
std::unordered_map<std::string, cata_variant_type> (previously some
places had used std::map).
2020-04-21 20:46:38 -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 2ff6b3b218 Enhanced event_transformation support
Two new features for event_transformations: the ability to drop fields,
and the ability to add new fields using new event_field_transformation
functions.

The only such function currently implemented is extracting species from
monster types.
2020-04-04 15:08:27 -04:00