- bind item_location by const ref in zone drop debug log loop in activity_actor.cpp
- bind mission_type::get_all() result by const ref in mission-add debug menu
- bind selected dialogue topic by const ref in talk-topic debug menu
- NOLINT outfit_component copy near who.takeoff; takeoff can invalidate worn_item before force_insert_item runs
- matrix.yml SKIP condition referenced non-existent job names
(skip-duplicates, skip-duplicates-mods); corrected to match declared
jobs (skip-duplicates-code, skip-duplicates-data). Same fix for the
commented emscripten block.
- tests/Makefile batch runs now use --user-dir with a unique PID-based
path so parallel shard execution doesn't collide on filesystem state.
- Normalized comma-separated TEST_CASE tags to space-separated across
9 test files (25 declarations). Comma syntax is deprecated in Catch2
v2 and removed in v3. Also fixed a missing space between adjacent
tags in throwing_test.cpp.
* refactor wield
* refactor wield
* rename wield_new, replace tests
* return early
* fix test and .h var name
* add unwield from game.wield
add_msg_if_player
* remove references to u.
* small fixes
* missing ;
* fix unwield
* fix test
* remove_old for compatibility
* wrong paranthesis
* correct wield_new
* use more wield_new, remove some reminder comments
* fix craft
* fix wielding from reloading
* remove commented out code
* rename weapon -> wielded
* IWYU
* fix wrong move cost
use correct wield for 'one of the bottles is wielded' test
* remove debug msg
* fix tests / clang-tidy
* I hate those tests
* fex 2/3 tests
* please let this be the last test
* clang-tidy
* apply some reviews, remove reminder comments
* re-work; overload item_location from item,
* fix missing item replacement
* fix using item after removing
* revert unecessary changes
* fix missed revert
* move steal check to avatar overload
* this time for real
* extend wield( item_location loc)
* fix
* forgot to do the actual wielding
* fix moves test, apply clang-tidy
* correct obtain cost, doc
* clang-tidy, cleaner conditional
* ordering
* move to std::optional instead of default
* fix optional
* fix 2
---------
Co-authored-by: marilynias <marilynias57+github@gmail.com>
* typified a bit of map.h/cpp + some dependents
* Macro crasher found by one compiler!
* demanded changes
* stupid wokaround for demanded changes
* Sort out conflict mess
* replace modular m4 carabin item with respective itemgroup
* fix incorrect syntax in vehicle spawn
* fix wrongdoing of find and replace
* make test version of m4 carbine with reveiver to handle test
* fix debug item version having lack of name
* fix even more tests
* more test fixes
* add modular_m4_carbine to dps tests
* sort itypes in reload_magazine_test
* Should not reload a gun without ammo defined.
* Update src/item_location.cpp
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Cache results of `has_item_with_flag` and `all_items_with_flag`
Adds new functions `add_to_flagged_item_cache` and `remove_from_flagged_item_cache`, as well as new overloads in `visitable` to accomplish this
* Replace some `items_with` with `all_items_with_flag`
* Add special handling for the unique LIGHT flag
* Handle flagged item cache in `item::convert`
* Add note to flag_LIGHT that it's not a real flag
* Open the cache up to expansion beyond just `flag_id`s
* Rename "cache" to "caches"
* Add function `all_items_with` for inventory searches. Replaces `all_items_with_flag`.
There are three overloads for this function. One searches for an item flag, as `all_items_with_flag` did. One searches for all items that pass a specified boolean function. The last one does both. All three add the results to the cache.
* Fix cache handling for item contents
* Embed cache clearing into more item removal functions
Replaces `Character.worn.clear()` with `Character.clear_worn()`. `Character` is now a friend of `outfit` to accomplish this
* Use inv search cache for seeds
* Use inv search cache for cash cards
* Use inv search cache for npc food
* Update some implementations of `all_items_with`
* Use inv search cache for relic processing
* Change cache names to use the function name for simplicity
* Use `all_items_with` for relics in `recalculate_enchantment_cache`
* Include `set` in iexamine
* Use `on_item_acquire` in `convert`
* Handle `i_add` with charged items directly in the function itself
This lets us always assume that calls to the `try_add` overload with copies should, in fact, be doing so
* Adjust `try_add` copies to add all added items to the cache
It used to only add the first item. There's a CPU impact of this change when spawning huge amounts of items, but it's very slight
* Use `has_item_with_flag` instead of `all_items_with` in `link_up_actor`
* Use `all_items_with` for bionic cable functions
* Make `get_cable_vehicle` const
* Make `all_items_with` key use a const reference
* Add `clear_inv` for clearing Character's inventory and cache
* astyle invlet test
* Revert "Add `clear_inv` for clearing Character's inventory and cache"
This reverts commit 944d768dd1.
* Make cache use vectors of items instead of sets
* Deduplicate code in `all_items_with` overloads
Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>
* Fix iteration in `remove_from_inv_search_caches`
Temporary measure while I rethink how the cache works. Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>
* Greatly rework the item search cache and all its functions
The cache now uses safe references rather than direct item pointers. `all_items_with` replaced with `do_on_items_with`, a function that iterates through the cache, applying a given function to the items and removing invalid item pointers as it goes. There's also an overload that gives the function a boolean `abort` parameter that, if ever set to true, exits the loop immediately and returns true. Also adds `get_items_with` for creating a vector of all the cached item pointers.
* Remove `remove_from_inv_search_caches`
Also reverts changes that were made earlier to accomodate manual cache removal
* Replace `has_item_with_flag` with `has_any_item_with`
I went with a unique function name rather than overloading `read_only_visitable::has_item_with` since visitable can't use the caches, so they're worth differentiating
* Consolidate `do_to_items_with_until` and `has_any_item_with`
They basically did the same thing
* Leftover debug line
* Add `do_and_check_func` to `get_items_with`. Adds const versions
* Rename `get_items_with` to `all_items_with`
* Make `has_any_item_with` use const item references.
The const_cast added to radiocontrol is temporary
* Fix returns
* Fix radio control handling
Specifically, fixes the game letting you activate an RC with a bomb in your inventory (it doesn't activate but it also doesn't warn you). Adds a const version of the item pocket chain's `get_item_with`s to accomplish this
* Add additional overload to inv search functions that looks for an item type id
* Only cache flags of the item's type, not the item specifically.
We should only use const flags for caches, not ones that can be set/unset
* Add `can_link_up` for optimizing cable finding
* Implement inv search cache functions
* Temporary fix for item tests
I need to think about how to handle non-type flags
* Change all the item search function names to specifically mention the cache
I grew to dislike the "almost but not quite the same as visitable" names I've been using. These names are clearer
* Make separate const versions of `cache_visit_items_with`
It's better design to do this; `inv_search_caches` being mutable was causing ambiguity
* Bring back `has_item_with_flag`
Now that `cache_visit_items_with` only accepts item type flags, the original functionality to check for non-type flags like WET has been lost. This brings that back.
* Unused lambda captures
* Reference the references
---------
Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>
* Convert integer parsing test to use normal TEST_CASEs
* Rename test name too similar to another
* Test to enforce normalized test names
* Normalize TEST_CASE names (scripted)
* use item instead of item_id
* watertight containers are reloadable
* mods are reloadable, same_contents checks contents of contents
* add large number of new tests
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.
* Make `weapon` private
* Update tests
* Rebase
* Appley suggestions
* Fix weapon dorping
* fix weapon saving
* Rename to get_wielded_item
* rename to set_wielded_item
* fixes
* Post rebase fixes
* fixes
* fix weapon saving
* fixes
* more rebase and fixes
* Apply suggestions
* post rebase fixes
* 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
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++
Resolves a TODO on that constructor, and one more TODO elsewhere due to
the resulting refactoring.
time_point was implicitly convertible from int. This led to unclear
code. In particular, the item constructor took a time_point and a
quantity, and these two ints appeared adjacent with no obvious way to
see what they meant at call sites.
Make the constructor explicit, so the conversion is no longer implicit.
Update the rest of the code accordingly.
In most cases switched from 0 to calendar::turn_zero, which is
equivalent. In a couple of places, used start_of_cataclysm instead,
when it seemed more appropriate (such as birthday of toilet water).
It's possible there are more cases which should have been something
other than turn_zero.