107 Commits

Author SHA1 Message Date
Fris0uman 06fbf8717c Obsolete and migrate cash cards (#89166)
* cash card empty, no money

remove money from cash cards in vanilla

* remove unused flags

* preserve cash card stacking test

* obsoletion and migration of cash cards

* Preserve money ammo type for aftershock

* no free threads sorry

* put money in the test data

* don't duplicate money ammo in aftershock

* fix unloading non empty components test

* fix for clang

---------

Co-authored-by: Fris0uman <fris0uman@users.noreply.github.com>
2026-11-16 23:11:50 -06:00
Matthew Richmond 90d7e65f0a Fix sided one-per-layer ring wearing limits (#88689)
* Fix sided one-per-layer ring wearing limits

* Allow sided rings to swap hands without self-conflicts

* Resolve linter failures
2026-09-17 00:20:23 -05:00
Anton Simakov eeee688bdd Put ammonia hydroxide in bottles (#87929)
* Put ammonia_hydroxide in bottles

* add "display_type": "BY_VOLUME", remove from bad density list

* Remove ammonia_hydroxide from default container test

* Please clang tidy
2026-07-08 13:56:56 -05:00
armaswiss a23b215056 Fix powder/chemical spawns causing multiple containers containing 1 unit (#87554)
* Update supplies.json to fix powder loot generation. Create item groups

Similar to GuardianDLL's fix for graphite, we've just created item groups for the affected chemical powders ingame to be called instead of items

* Created Glass flask itemgroups for Zinc used in MoM spawning

* Change chemical powder items to groups outlined in supplies

Changed any instances of any item groups made in supplies to reference the item group and not the item that spawns as charges, using the method GuardianDLL used to correct the weird graphite spawning issue

* Replaced zincpowder item to zinc powder glass flask item group

* Update items to itemgroup that were changed in supplies

* Updated items to item groups in supplies

* Fixed Magnesium probability from 10 to 12

* Update Detergent Item to itemgroup

* Update Detergent Item to itemGroup

* Update Detergent from Item to itemgroup

* Update Detergent to ItemGroup

* Update supplies.json

* Corrected detergent box to have detergent in it

* Update items to item groups

* Changed comments on zinc powder glass flask

* Fixed missing comma

* Removed default containers

* Removed container from magnesium

* Fixed stray commas breaking things

* Fixed missing whitephosphorous

* Fixed amounts to conform to volume and weight restrictions

* Apply space between probability factor and end of line

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

* Lint

* Remove offensive line in test

* Remove Tests with Detergent

* Correct Spelling Mistakes in Item-Group names

Unfortunately cannot touch the item-ID as of right now as that would break too many recipes that are currently dependent on the current misspelling of phosphorous.

* Correct spelling of red/white phosphorus

* Correct spelling errors in Red/White Phosphorus Item-Group Names

* Update nests_itemgroups.json with updated Manganese_Dioxide spawn to correct spawning multiple containers with 1 unit in each

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Simakov <67688115+GuardianDll@users.noreply.github.com>
2026-06-11 11:17:14 +02:00
dumb-kevin 22eb2f92b4 Include installed gunmod/toolmod prices in item::price
- sum gunmods() prices for guns
- sum toolmods() prices for tools
- add test for gun + gunmod price summation
2026-05-03 00:58:48 +04:00
dumb-kevin 54afc7d3e7 Reduce occupied_ememory cost on the stacks_with hot path
- Sum efile ememory directly instead of building intermediate containers
- Skip EMEMORY segment for non-estorage pairs in stacks_with
2026-04-26 11:15:51 -07:00
dumb-kevin e7c80f23fe Cache recipe count on efile_recipes to skip stacking validation
- Write EIPC_RECIPES_count alongside EIPC_RECIPES in set_saved_recipes
- Read cached count in ememory_size with lazy refill on miss
- Short-circuit ememory_size to zero when broken_on_active
- Exclude EIPC_RECIPES_count from stacks_with VARS comparison
- Add regression tests including malformed CSV dedupe and broken-write
2026-04-26 11:15:51 -07:00
dumb-kevin 304034cdd3 Cache photo count on efile items to skip stacking JSON reparse
- Write CAMERA_*_PHOTOS_count alongside JSON in write_extended_photos
- Read cached count in total_photos with lazy refill on miss
- Exclude photo count vars from stacks_with VARS comparison
- Add regression tests for cache, mixed state, and aggregated EMEMORY
2026-04-26 11:15:51 -07:00
Anton Simakov 0d865a8ca8 fix incorrect string format (#85507) 2026-02-23 14:26:18 -08:00
Anton Simakov 60f72f590b Remove units::abs() for temperature only, rename units::fabs() to units::abs() (#85313) 2026-02-22 22:35:33 -06:00
GuardianDll 97b822063f Prevent integer overflow in uncraft test 2026-02-14 17:34:29 +01:00
Anton Simakov bd01b89f78 Use miligrams in bad density test (#84555)
* use miligrams in bad density test

* add missed item from magiclysm

* add test_napalm also
2026-01-10 23:42:09 -06:00
BalthazarArgall e9a39c6a56 Update drink containers (#83710)
* initial commit

* change itemgroups

* fix everything

* remove the sources from the code

* remove pale_ale from tested items in item_test.cpp

* remove more default containers

* fix morale test?

* annoying itype name conventions

* bruh

* fix UHT milk default container
2025-11-13 22:05:34 -06:00
Anton Simakov 6cb83f6e0a Clarify uncraft test (#83700)
* Clarify uncraft test

* false -> true
2025-11-10 18:44:03 -06:00
GuardianDll 8faca26ead Improve uncraft test 2025-10-18 11:38:19 +02:00
ehughsbaird 950b87d41f Give robot a volume
This is a bit odd, but as far as I can tell volume was never initialized
(UB), but had a non-zero value and so did not trigger any issues with
the test.

Now that optional always initializes it (to 0), it produced issues. Just
assign it to 100 L.
2025-08-21 17:20:53 +00:00
mqrause ef42d91764 remove failure limit from item density test 2025-07-26 11:27:24 +02:00
GuardianDll c062762c26 Implement uncrafting test 2025-07-17 17:44:47 +02:00
Anton Simakov 21a27b377f Getting rid of "container" field + general item and itemgroups cleanup, 1/? (#79999)
* start fighting the container field

* part 2

* return accidentally removed field

* use cardboard roll for medical tape, resolve test errors

* please clang

* equalize medical_tape stats same as duct_tape

* correctly sanify tape stats

* please tests

* fix itemgroup
2025-03-10 07:53:06 -05:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -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
ShnitzelX2 2861751263 fix map segfault, remove omt tripoints from map operations
this is because EOCs generally only support reading ms tripoints
2025-02-04 13:25:13 -05:00
ShnitzelX2 a594545fa7 replace software, e-book functions with e-file
item categories for software, files
2025-01-24 12:26:12 -05:00
ShnitzelX2 672a2b7253 minimally remove legacy software tests 2025-01-20 22:19:47 -05:00
moxian f6c71bc5e9 update paths to moved docs 2025-01-14 12:39:38 -08:00
Procyonae 982df19d0f Change /tests remaining uses of raw string item initialisation to use itype_id s
"remaining uses" being somewhat of an understatement -_-
2025-01-10 15:31:15 +00:00
PatrikLundell dfb22cab75 resolved merge conflicts 2024-11-26 23:30:46 +01:00
PatrikLundell 580e60acc3 typified item.h + cpp 2024-11-25 14:44:12 +01:00
Anton Simakov 15a586677f migrate miner hat to hard hat with flashlight (#75844)
* migrate miner hat to hard hat with flashlight

* add count to flashlight migration
2024-08-21 22:52:29 -05:00
Procyonae 92df28527a Appease clang and improve error formatting 2024-06-16 18:42:01 +01:00
Procyonae c0fdfd4c09 Fix a couple of GAME_BALANCE references 2024-06-16 15:14:45 +01:00
Procyonae 1566d4b56e Make new to_hit mandatory 2024-06-16 00:32:51 +01:00
Zack Shoylev 73bcb0a906 Replace ITEM_BROKEN flag on emp and watter affected items with faults 2024-03-05 05:08:36 -06:00
GuardianDll d43da76986 obsolete the obsoletion 2024-02-11 23:53:50 +01:00
andrei b4b36bc40f item/tests: update tname tests 2024-01-18 20:09:08 +02:00
Anton Simakov dd9e62c88a Density cleanup + minor stuff (#70176)
* I went too far

* do not remove hydrocarbons

* Cleanup what i fixed, but forgot to cleanup

* use new values for test_mp3 wetness

* Move test material to core to prevent order dependency errors

* EOL

* move test_material again, now to vanilla

* revert material back to test_data file since ehughsbaird fixed the order dependancy issues
2023-12-14 23:46:07 -06:00
mqrause bd211963e6 move item_pocket::pocket_type to it's own header 2023-11-27 13:22:35 +01:00
inogenous 8c8362c301 Categorize containers by their contents
* Updates containers so that more are categorized by their contents.
* Make rotting items stack with each other, regardless of how rotten they are.

For example: a paper wrapper contains butter of varying degrees of rotting.
* Before: it would be categorized as "container"
* After: it is now categorized as "food"

Containers were already categorized by their contents even before this commit,
but only if all contained items were of the **same type** and could be stacked.
With this commit, the condition "all contained items are of the same type" is
instead changed to "all contained items are of the same category".

Another example: a canvas bag contains a screwdriver and a hammer.
* Before: the canvas bag would be categorized as "container"
* After: the canvas bag will be categorized as "tools"

More advanced example: `plastic_bag { wrapper { butter }, wrapper { butter } }`
* Before: plastic_bag would be categorized as "container"
* After: plastic_bag is now categorized as "food"

Situations where "categorized by their contents" does not apply:
* Only applies to "containers". So for example, a pair of jeans that has butter
  in its pockets will still be categorized as "clothing" and not "food".
* Containers that contain items from more than one category will be
  categorized as "container". For example, a canvas bag that has both a
  watermelon and a glock - will be categorized as "container".

This commit makes rotting food stack with each other if possible regardless of
how far in the rotting process the item has come. Specifically,
`item::stacks_with` calculates `get_shelf_life() - rot`, which will be negative
if the item is rotten. And doing `clipped_time()` does not work well on
negative values: it clips to seconds and therefore only partitions into
"buckets" of 1s each. This commit therefore clamps all rotten freshness-values
to the 0-bucket for `item::stacks_with`.

In effect, food that has just started to rot will now be stacked with food that
has been rotting for quite a while. Before, they would be different stacks.
2023-11-02 16:38:21 +01:00
Kamayana 6a46c5a421 Cache results of item search functions (#67835)
* 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>
2023-09-04 23:47:42 -05:00
Alexey 07356b65a5 Normalize TEST_CASE names (#66241)
* 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)
2023-06-17 13:57:19 -03:00
andrei cc6b43c11c avatar/item: update cached flags when transforming items (#64949) 2023-04-10 11:18:19 -04:00
Clarence "Sparr" Risher f93cbc35a6 Refactor city.cpp/.h out of overmap.cpp/.h 2023-03-31 18:47:42 -04:00
Karol1223 50cbbed74d Misc Item Changes Again (#63909)
* first wave

* I sure hope this doesn't explode

* Revert "I sure hope this doesn't explode"

This reverts commit 0a3915fef8.

* wave 1 fixes

* I may be stupid

* children and itemgroups

* I am quite stupid

* item: allow specifying source monster for corpse items

* c++ oooooh boy

* wave 2 and my sanity

* weapon balancing

* moar fixes

* wave 3

* reversion

* bark fixes

* wave 4

* wave 5 and done!

* hope this works

* fixes for the fix god

* please just let it get merged

---------

Co-authored-by: andrei <a12l+git@runbox.com>
2023-03-05 19:58:42 -05:00
andrei 286f1fc4c8 item: fix category for contents without charges (#63710) 2023-03-02 09:48:29 -04:00
Zhilkin Serg e44f38af40 Remove excessive empty lines 2022-12-06 10:42:15 +03:00
mqrause 1f4efdbfd0 jsonize test data (#62024)
Co-authored-by: mqrause <martin@qrause.de>
2022-11-13 23:25:50 -05:00
mqrause 8a8e18f977 jsonify known_bad list 2022-08-12 11:47:50 +02:00
mqrause d9b09bdc88 Update tests/item_test.cpp
Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>
2022-08-12 11:46:48 +02:00
mqrause e13a514597 - remove !mayfail and fixed items
- improve info message
2022-08-12 11:46:48 +02:00
catdach fa4fdfeae3 Fix ammo belts not scaling volume/weight with current amount of ammo (#58093)
* ammo belts weight an volume changes

Changed both weight and volume of the base magazine belt to 0. Changed all child belts to " 'rigid:' false " so that the volume changes depending on how many bullets are in it.

* adjust pouches to fit new ammo belt sizes/weights

* remove belts from list

remove the relevant ammo belts from the known_bad list as described by the comment in the density test.
2022-08-11 10:18:47 +02:00