33 Commits

Author SHA1 Message Date
PatrikLundell 586cf5f1ce Mapify: character etc. sees + sundry others (#79699)
* Mapify: character etc. sees + sundry others

* demanded changes

* Corrected correction
2025-02-18 09:29:22 -06:00
moxian 8b6cbac614 Stop including catch.hpp directly
.. as suggested by the comment in cata_catch.h:

// To avoid ODR violations, it's important that whenever a file includes
// catch.hpp it also includes stringmaker.h, so that all specializations of
// StringMaker match.  Therefore, all test code should include catch.hpp via
// this file.

Honestly, i'm not exactly sure how valuable this is, given that we've
been running with the current odr-violating(?) setup for a while nand
not had many issues, but sure, why not.
2025-02-16 19:45:21 -08: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 99aeb7b990 Load npcs and deal with their bodies 2025-01-25 09:49:42 +01: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 ef6b53acfb typified a little bit of map.h + dependents (#76340)
* typified a little bit of map.h + dependents
2024-09-27 15:10:36 -07:00
mqrause 4c69e47b2a change target_handler::trajectory to std::vector<tripoint_bub_ms> and then fix errors until it compiles again (#76671)
Co-authored-by: mqrause <martin@qrause.de>
2024-09-27 12:10:50 -07: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
RenechCDDA 152c8bd42b Can throw if we have extra copies of the item 2024-05-04 15:11:17 -04:00
RenechCDDA 0aa60c9488 Rename a function for clarity 2024-05-03 22:10:02 -04:00
BalthazarArgall ebdd7b9026 Combat exoskeleton update (#68758)
* updated json flags

Updated json flags to accommodate for future items

* obsoleted exoskeleton helmets

Exoskeleton helmets serve no function anymore

* Update power_armor.json

Still very much WIP but the abstract exoskeleton item should give an idea of what I'm going for.

Also implemented abstract item for armor parts.

* Revert "Merge branch 'CombatExoskeletonUpdate' of https://github.com/BalthazarArgall/Cataclysm-DDA into CombatExoskeletonUpdate"

This reverts commit 7b9b9b66b6, reversing
changes made to 3d13b2ae66.

* Update power_armor.json

* Update power_armor.json

Definitive weight and volume for exoskeleton armor parts

* Obsoleted frame and generator frame

I don't see any point in them now that you can equip a backpack alongside exoskeletons and generator frames make little sense in my opinion.

* Update power_armor.json

Almost done with exoskeletons themselves, all I have to do is descriptions, touching up the flags and the salvaged version

* Update flags.json

Deleted unused exoskeleton flags

* Update power_armor.json

Final values in place, only the descriptions to do, maybe some flags

* Create power_armor.json

Added recipes for the armor parts

* Updated recipes and power_armor.json

* Solved all errors when launching with modified files

* Fixed spelling error "micromotors" to "micro motors".

* NO_UNLOAD flag removed from abstract exoskeleton
Users can now see/remove etc. the different exoskeleton attachments

* Added a volume_encumber_modifier of 0 to exoskeleton pockets to avoid insane amounts of encumbrance when wearing the armor parts
This may be the final commit, everything looks like it works, finally. I'm probably going to polish everything up, adjust values and changes a few descriptions.

* reworked, tested and polished the final version

* adjusted power consumption

* adjusted weight

* deleted unneeded plural names

* Double spaced the descriptions, re added plural names where needed

* updated description and carry weight bonus enchantment

* Revert "Revert "Merge branch 'CombatExoskeletonUpdate' of https://github.com/BalthazarArgall/Cataclysm-DDA into CombatExoskeletonUpdate""

This reverts commit 572fe896c3.

* Revert "Merge branch 'CombatExoskeletonUpdate' of https://github.com/BalthazarArgall/Cataclysm-DDA into CombatExoskeletonUpdate"

This reverts commit 7b9b9b66b6, reversing
changes made to 3d13b2ae66.

* Revert "Revert "Merge branch 'CombatExoskeletonUpdate' of https://github.com/BalthazarArgall/Cataclysm-DDA into CombatExoskeletonUpdate""

This reverts commit 6e1232e70f.

* Revert "Merge branch 'CleverRaven:master' into CombatExoskeletonUpdate"

This reverts commit e75fd82312, reversing
changes made to 0f10db9aa8.

* Revert "Revert "Merge branch 'CombatExoskeletonUpdate' of https://github.com/BalthazarArgall/Cataclysm-DDA into CombatExoskeletonUpdate""

This reverts commit 572fe896c3.

* Revert "Merge branch 'CombatExoskeletonUpdate' of https://github.com/BalthazarArgall/Cataclysm-DDA into CombatExoskeletonUpdate"

This reverts commit 7b9b9b66b6, reversing
changes made to 3d13b2ae66.

* Revert "Revert "Merge branch 'CombatExoskeletonUpdate' of https://github.com/BalthazarArgall/Cataclysm-DDA into CombatExoskeletonUpdate""

This reverts commit 572fe896c3.

* make code content identical to master

* deleting references to power armor

* replaced references to power armor

* sort lines alphabetically

* replaced references to depowered armor

* reworked the rework

* Repalced dots with ellipsis

* modified activation message

* fixed carry weight carry over and clarified effect description

* Adjusted encumbrance values, slightly adjusted and rounded energy consumption

* Adjusted encumbrance values slightly

* adjusted pocket sizes, adjusted armored zombie drops, deleted unused recipes, fixed armor recipes, added MOLLE/tactical pockets to a few items

* fixed armor pockets access cost

* fixed typo in flags, reverted pocket access cost

* Restart tests, just to make sure

* Maybe stuff is drying at the proper rate now

* adjusted battery stuff, integrated exertion modifer, made enchantments appear in the UI

* pockets probably cannot have holster while being MAGAZINE_WELL

* pockets probably cannot have holster while being MAGAZINE_WELL

* just revert the holster change

* update test, still failing

* Give exoskeletons their own itemgroup

* Adjust encumbrance values of reinforced armor and exoskeletons

* added welding requirements to reinforced armor

* Fix missing double space in description

* fix tests

* astyle formatting try 1

* astyle formatting try 2

* Are you happy now clang?

* clang, I swear to god...

* forgot to adjust crafting difficulty, slightly increased

* Restart tests, yes I changed my mind

* Update data/json/items/armor/combat_exoskeleton.json

Applied Drew suggestion for salvaged exoskeleton description

Co-authored-by: Drew4484 <57647637+Drew4484@users.noreply.github.com>

* Update data/json/items/armor/combat_exoskeleton.json

remove environmental flags from salvaged exoskeleton

Co-authored-by: Drew4484 <57647637+Drew4484@users.noreply.github.com>

* multiple changes, rough implementation

* multiple changes smoother implementation

* updated flag descriptions to accomodate combat exoskeletons

* updated reinforced versions crafting time

* remove exosuit management menu

* multiple changes, should be quite polished

* fixe a copy paste error

* fixes descriptions for exoskeleton armor

* anti-material typo

* Reload test

---------

Co-authored-by: Drew4484 <57647637+Drew4484@users.noreply.github.com>
2024-04-20 11:20:40 -05:00
Anton Simakov 7b1fec4ed5 Further receiver cleanups (#70473)
* further receiver cleanups

* lint

* fixing tests that use obsoleted guns in tests

* more fixing
2023-12-27 15:12:07 -06:00
mqrause bd211963e6 move item_pocket::pocket_type to it's own header 2023-11-27 13:22:35 +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
Ruminator24 d971500cbb UPS no longer automatically gets drained (#66020)
* Update electronics.json

* Update electronics.json

* Update electronics.json

* Update electronics.json

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

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

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

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

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

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

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

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

* Update electronics.json

* Update electronics.json

* Update electronics.json

* Update migration_items.json

* Update migration_items.json

* Update electronics.json

* Update vehicle_interact_test.cpp

* Update electronics.json

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

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

* Update data/json/obsoletion/migration_items.json

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

* Update tool_quality_test.cpp

* Update crafting_test.cpp

* Update npc_attack_test.cpp

* Update bionics_test.cpp

* Update electronics.json

* Update power_supplies.json

* Update activities_hobbies.json

* Update clothing.json

* Update gear.json

* Update defense_mode.json

* Update electronics.json

* Update lab_security.json

* Update locations.json

* Update locations_commercial.json

* Update main.json

* Update military.json

* Update science_and_tech.json

* Update shops_trades.json

* Update tools.json

* Update tool_armor.json

* Update microlab_special_tiles.json

* Update classes.json

* Update items_generic.json

* Update NC_SOLDIER.json

* Update robofac_intercom_missions.json

* Update nested.json

* Update tools_electronic.json

* Update electronics.json

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-09 09:24:55 -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
mqrause 979718d90a change return type of Character::get_wielded_item to item_location (#58666)
Co-authored-by: mqrause <martin@qrause.de>
2022-07-09 02:03:09 -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
Binrui Dong 30fabd94cb Reset player character position in NPC attack test (#55134) 2022-02-06 23:02:11 -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
NEricN 0e8dc72de4 Allow NPCs to toggle on power armor (and other things) during combat 2021-10-13 00:33:34 -07:00
Fris0uman aa69568ddc Make get_wielded_item() return a ref instead of a pointer (#51614) 2021-09-14 14:02:34 -07:00
Fris0uman da590d88ef Make weapon private (#50286)
* 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
2021-09-12 08:47:47 -07:00
Kevin Granade 362a1f2bd8 Move critter_at() to creature_tracker 2021-08-26 08:55:28 -07:00
Álvaro cd73ed43d5 Fix some of the NPC attacking logic (#49907)
* Fixes to NPC attack logic

* astyle

* Remove commented code

* Initialization list order

* Make -Werror happy

* Fix test compilation

* astyle again

* Make clang-tidy happier, I hope

* Add use_guns check for throwing items

* Update src/npc_attack.cpp

Co-authored-by: Curtis Merrill <curtis.r.merrill@gmail.com>

* Update src/npc_attack.cpp

Co-authored-by: Curtis Merrill <curtis.r.merrill@gmail.com>

* Changes from reviews/suggestions

* astyle again

* Add enemy_distance_to_ally() helper function

* Reworked tests and minor changes

* Clang-tidy & JSON linting

* Removed commented code

* Change SCENARIO to TEST_CASE so clang-tidy is happy

* Update src/npc_attack.cpp

Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>

* remove commented code

Co-authored-by: Curtis Merrill <curtis.r.merrill@gmail.com>
Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>
2021-07-26 19:25:31 -04:00
anothersimulacrum 0cdf6757f5 Fix NPC attack tests
Move the player so game::load_npcs will actually spawn the NPCs.

Add REQUIREs to make the game not crash on failing to spawn NPCs.

Remove the weather setting because it doesn't change the tests, and
causes vision tests failures due to side effects!

Adjust the values of the m16a4 test to start passing.
2021-07-10 18:33:38 -07:00
Kevin Granade d82731efce Guard against missing NPC when respawning it. 2021-07-10 14:18:03 -07:00
Curtis Merrill 8d721b4884 Npc attack (#47562)
* create npc_attack class

This implements a class that owns all of the logic for an npc evaluating the best weapon to use in the moment.

* Tests for npc_attack

* add a debug mode that shows potential values
2021-07-09 08:00:16 -07:00