62 Commits

Author SHA1 Message Date
Anton Simakov 7d2228f85a use item_location in use actions instead of item * (#89473) 2026-11-17 12:07:16 -06:00
dobbry-vechur c5d03ec220 NPCs light fires only in a hearth
- fire goes only in a hearth: fireplace, stove, brazier, fire ring or clay oven
- fuel is the NPC's own burnable firewood, or firewood or tinder in the hearth it may use
- a hearth that is a firewood pile, busy, off-limits, unburnable or full is skipped
2026-10-23 23:05:42 +04:00
dobbry-vechur ddac767b65 Fix free placement of traps with practice 2
- removed XOR practice factor from trap move cost
- moved trap move cost into place_trap_actor::data::move_cost
- added move cost test for practice, skill and proficiencies
2026-10-07 16:35:49 +04:00
Curtis Merrill 258b80d42b change visitable to item_location, remove item inheritance from visitable, and add item_location inheritance from visitable.
Co-Authored-By: dobbry-vechur <259678433+dobbry-vechur@users.noreply.github.com>
2026-09-30 21:34:09 -04:00
dumb-kevin 44937f1b60 Spill timed-transform result that no longer fits parent pocket
- invalidate carrier inventory after countdown_action fires
- drop_invalid_inventory then walks parent pockets via overflow
- result moves to first fitting ancestor pocket or to the ground
- added countdown-transform test item in TEST_DATA
- regression test covers spill to ground and stay-in-place
2026-05-11 12:04:56 +04:00
dumb-kevin 1e7f99e6b2 Block in-place transform when result wouldn't fit parent pocket
- gate iuse_transform::can_use on parent-pocket fit for the new item
- check character, map, and vehicle parents via try_form_loc helper
- propagate weight/volume/length with multiplier and rigid-pocket rules
- use replacement semantics: credit existing item footprint at each level
- regression test covers baton in 30 cm pocket and 60 cm pocket
2026-05-11 12:04:56 +04:00
thaelina ecb7ed024c Tests
Removed x_max x_cur x_bonus accesses outside of setters and getters in the character namespace
2026-03-02 03:17:11 -06:00
Andrew Krieger 0215b26cce Rewrite all tests to clear map without touching character map memory, for performance. 2026-02-08 23:05:55 -08:00
ShnitzelX2 41cd225e74 remove old use/can_use iuse_actor functions 2025-12-30 18:12:32 -05:00
ShnitzelX2 05ecab7851 replace unit-specific min/max with generic functions
definitions were redundant
make INDEFINITELY_LONG_DURATION constexpr
2025-03-02 17:36:43 -05:00
PatrikLundell f9900fccc2 Merge pull request #79670 from PatrikLundell/mapify
mapify: split ammo remaining into link and non link
2025-02-16 14:49:56 -06:00
PatrikLundell 7bfa56fa99 Merge branch 'master' into mapify 2025-02-13 08:46:56 +01:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08:00
PatrikLundell 0ac675121c mapified a little item prompting a lot of vehicle 2025-02-11 15:10:00 +01: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
PatrikLundell 537d9d12a1 Standardized get/set pos operations for talker/creature class hierarchy (#79206)
* Standardized get/set pos operations for talker/creature class hierarchy

* sort out merge failure
2025-01-20 08:20:58 +01:00
Procyonae 40f0b39e62 Merge branch 'master' into RemoveStringInitialisingItems 2025-01-10 17:00:48 +00: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 befd4486d1 sundry typification (#78985)
* sundry typification

* demanded work around
2025-01-06 22:26:26 -06:00
PatrikLundell ce52b295ea typified iuse & iuse_actor 2024-12-04 14:35:45 +01:00
PatrikLundell 5648f805dc typified a bit of map.cpp + dependents 2024-10-12 13:12:23 +02:00
Anton Simakov 9dfbd30a7a Sweep of sanification for electronic devices (#76029)
* sanify electronic

* more

* more

* fix few errors

* fix itemgroups after changes, fix battery test

* more test fixes

* add missed comment on heavy flashlight

* add shoulder strap because it's cool and it's part of irl item

* more test fixes

* Update tests/item_autopickup_test.cpp

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

* and more

* and more

* more

* more

* more

* further tweaks of heavy-duty flashlight

* more

* more

* more

* more

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-09-01 16:58:58 -05:00
PatrikLundell c120294d1f allow map_cursor to be made from abs pos (#75449) 2024-08-04 20:00:32 -04:00
PatrikLundell 4ba6a9f7a8 Typified parts of map.h/map.cpp + usages 2024-07-18 00:23:02 +02:00
Kamejeir d3ae4fd311 erk and knives (#73993)
* merger readability commit

* small kitchen knife

* large kitchen knife

* huge kitchen knife

* kitchen cleavers
2024-06-18 00:31:03 -05:00
PatrikLundell 4c6b91838c Removed one getlocal (#73940)
Co-authored-by: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com>
2024-05-25 16:18:25 -05:00
mqrause bd211963e6 move item_pocket::pocket_type to it's own header 2023-11-27 13:22:35 +01:00
Hirmuolio c6f8dc39db Update all active items to new tick action system and remove old system (#67352)
* remove bool t uses

* remove bool t uses

* remove bool t uses

* split multicooker

* split remoteveh

* remove bool t uses

* lint

* unused

* radiocaron

* radiocontrol

* foodperson

* ehandcuffs

* Update data/json/items/tool/radio_tools.json

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

* laptop music

* robotcontrol

* portable_game

* gasmask

* dive_tank

* unused

* mp3

* geiger

* noise_emitter

* fish trap

* remove bool t

* merge fix

* mods

* merge fix

* merge fix

* better music

* fix mp3

* better messages

* better messages

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-08-06 08:44:51 -05:00
Hirmuolio ffe5a45099 Carrier for items on ground is nullptr (#66292)
* remove forced player

* multicooker

* radio controller

* mp3

* manage_exosuit

* electricstorage

* incendiary grnd

* crater mapgen

* put avatar back

* geiger

* gasmask

* fishing trap

* astyle

* ehandcuffs

* dive_tank

* style

* message_iuse

* remove activation

* iuse_actor switch from references to pointers

* astyle

* worn items

* p checks

* put thing back

* merge fix

* astyle

* invoke

* can_use

* revert can_use

* transforming item in processing

* unused var

* throw activation test

* remove reference to nullptr

* fix previous commit

* fix fireweapon

* astyle
2023-07-11 15:29:16 -07: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
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
John Bytheway d6c0bc8b57 Support ret_val<void> and replace ret_val<bool> (#59468)
ret_val<T> is supossed to be a T value *and also* a bool (and optionally
a string message).  However, all uses of ret_val<bool> were setting the
two bool values to the same thing.  Really they wanted ret_val<void>,
but that didn't compile.

Make it so that ret_val<void> does work, and replace all uses of
ret_val<bool> with it.  I found zero instances of 'true' ret_val<bool>
where a bool was being conveyed in addition to the success/failure info.
2022-07-21 21:02:58 -04:00
Willenbrink dcfd78bf38 Refactor salvage_actor::cut_up (#58414)
* Refactor cut_up

Move mat_set outside of the loop
Invert if
Remove useless braces

* Move uniform distribution into own function

* Refactor into lambdas

Efficiency is calculated once and assigned to a const
The recipe is found in a separate function, more clearly separating that
functionality from what should be done if no recipe is found

* Move find_recipe into own function

* Commenting + renaming

* Hide cut_up and unify try_to_cut and valid_to_cut

* Remove cutter item from cut_up

* Remove one const from function declaration

* Rebalance fab skill, update comments

Fab skill now has a more severe effect but is completely eliminated at
lvl 5

* Unsalvageable or count_by_charges items unsalavgeable

* Check uncraft before crafting recipes

* Limit mass returned from cut up

* Combine num, efficiency into num_adjusted

* cut_up_comp handles eff, remove extra loop

* Add chance to always salvage smth

* Use items count_by_charges instead of discarding

* Formatting

* Check for salvageable before count_by_charges

* Fix error and always round yields down

* Fix usage of get_wielded_item
2022-07-18 17:14:58 -04:00
mqrause d688521e7b Character::i_add returns an item_location (#58191)
Co-authored-by: mqrause <martin@qrause.de>
2022-06-18 21:27:30 -04:00
Hirmuolio 0f3ea21bba Reloadability check refactoring (#53102)
* 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
2021-12-12 18:03:27 -08: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
David Seguin fcab0db51b Proportional Material (#52369)
* Read "material" as string tags or portioned objects
* Proportional damage resistance per material
* Use the highest "portion" material as the base
* Track insertion order for std::map
* Fix materials being accessed before loading mods
* Additional proportional effects for materials
Take the proportion of certain materials into account for:
- Glass breaking (from smashing, striking, throwing, etc.)
- Weapons can have up to 20% glass before not being able to counter
- Magnetic pull is less effective for items with lower metal content
2021-10-23 11:51:00 -07:00
Kevin Granade db4d92a523 Prune obsolete entities from before 0.F (#51309) 2021-09-04 13:01:22 -07:00
Kevin Granade 362a1f2bd8 Move critter_at() to creature_tracker 2021-08-26 08:55:28 -07:00
Eric 51520f6245 Move more player to character (#50971)
* player to character

* Update npc_talk_test.cpp
2021-08-23 00:58:51 -07:00
Menschheit eed09b9e80 Make result of cutting up less contradicting to recipes (#50463)
* rework cutting outcome

Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>
2021-08-14 14:05:23 -07:00
mqrause e1a3575a09 private contents member and remove most item_contents.h includes 2021-07-23 00:23:22 +02:00
mqrause 061329b3ce wrappers for item_contents::has_pocket_type and item_contents::has_any_with in item 2021-07-07 15:56:05 +02: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
actual-nh a675fabe7e Add clear_map to more tests.
Avoid errors from inability to place an npc or item.

See #46473 for further information.
2021-01-09 14:57:49 -05:00
Kevin Granade 809090501c Whoops add an include 2020-12-23 14:19:21 -08:00
Kevin Granade 9353bf8f9c Add some more items to validate cut-up yields
Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com>
2020-12-23 13:48:02 -08:00
Kevin Granade 438bb9073a Add test for cut_up yields 2020-12-06 15:05:27 -08:00
John Bytheway b285a13080 Make time_point( int ) constructor explicit
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.
2020-11-10 11:21:02 -08:00