36 Commits

Author SHA1 Message Date
armaswiss 1a766244cb Merge pull request #87832 from armaswiss/Adjust-Alcohol-Displays-to-be-Uniform
Add DISPLAY_TYPE to Several Comestibles/Food, Changed Plural Strings
2026-06-29 21:09:20 -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 30b83d6c34 add needed includes 2025-02-13 09:15:16 +01:00
PatrikLundell 7bfa56fa99 Merge branch 'master' into mapify 2025-02-13 08:46:56 +01: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
Procyonae 2a922a6c59 Appease our clang overlords
Failing to remember Z before a strikes again
2025-01-10 20:14:36 +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
andrei b4b36bc40f item/tests: update tname tests 2024-01-18 20:09:08 +02: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
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
Alexey Kim ae1c1e6296 Damage symbols/colors/levels/etc now have 5 stages 2023-03-28 05:18:29 +03:00
andrei e875407488 item: colorize container contents (#63617) 2023-02-18 10:38:51 -05:00
David Seguin 7b60aa4472 Degradation of Vehicle Parts (#52744)
* Make items and vehicle parts degradable

Degradation accumulates as the item takes damage. Each time the item's damage level increases, the degradation increases by degradation_increments. The item can never be repaired beyond the degradation threshold.

A new optional json field "degradation_multiplier" can be used to control how aggressively the item degrades.

Next up:
- Displaying degradation to the player
- Documentation
- Unit tests

* Display degradation to player

- Display degradation as a vertical bar next to the items health level
- Set a random degradation based on the item's damage -> [0, damage]
- Minor additional fixes

* Documentation + clang-tidy fixes

* Unit tests and corrections

* Add tname tests

* Restrict degradation to vehicle parts

* Fix remaining item name tests
2021-12-19 09:35:17 -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
mqrause b8b7a022b8 adjust item::can_contain and item::best_pocket to match their item_contents variants 2021-07-12 17:36:59 +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
Aivean d7f6b571c1 switch to ">" symbol for nesting indication 2020-12-02 17:38:10 -08:00
Aivean 9e04cc27a1 fix test 2020-12-01 21:02:44 -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
Aivean c32a629ceb replace all item flag constants with static string_ids
remove adapter has_flag (and related) methods that took string argument
change all remaining method signatures where item flags were passed as strings
2020-10-18 19:56:40 -07:00
Kodi Arfer 8643c8b96a Display contained items like "water (plastic bottle)" instead of "plastic bottle of water" 2020-10-17 13:41:29 -04: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
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03:00
Kevin Granade 6d1841ac67 Precompiled Catch2 header (#42453)
* Hoist catch.hpp include to the top of files

* Precompile the catch header in tests
2020-07-29 01:28:26 +03:00
Kevin Granade e9064f1c9c Global reference migration part 31 2020-07-17 07:31:26 +00:00
meladath 8e60922d13 Decouple encumbrance, max_encumbrance and coverage in armor on a per bodypart_id basis (#41522) 2020-07-15 04:16:56 +00:00
Eric Pierce 4ad6757eb3 Show ammo_restriction info for non-MAGAZINE items (#41532)
* Show ammo_restriction info for non-MAGAZINE items

Non-magazine items with non-magazine pockets (including quivers), yet
having an ammo_restriction defined, were not indicating their capacity
in the item info panel.

This commit allows non-MAGAZINE item contents/pockets to indicate their
ammo_restriction-based capacity in the pocket section, labeled "Holds:"

Existing MAGAZINE-type containers (as well as GUN and TOOL items with
MAGAZINE pockets) continue to indicat their magazine capacity info in
the magazine section of the item info.

Add a test case covering this behavior using existing test items.

* Fix descriptions of ammo pouch and quivers

* Allow quivers to have ammo_remaining()

* Add display name tests for unloaded/loaded quiver

* Do not show capacity for ammo_restriction pockets
2020-06-26 08:45:53 +03:00
John Bytheway bfd1363cdb Rename empty_traits to clear_mutations
In common C++ libraries, empty is an adjective, not a verb.
2020-04-13 19:42:14 -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
Eric Pierce 7d30e76b33 Add item name tests covering tname and type_name functions (#38628)
* Add type_name tests: named items, blood, corpses
* Add conditional name test (broken); adjust named item
* Add tests for temp, hidden effectss, wet/filthy
* Add diamond katana test
* Only food has hidden effects
* Pluralization and truncation tests
* Test tname engine displacement and wheel diameter
* Add tests for item health bar and weapon fouling
Leave a TODO of tname tests for a future contributor
2020-03-14 07:28:36 +00:00
Jianxiang Wang (王健翔) 0490a5a025 Fix the alignment of many unicode strings (#34886)
* Fix alignment of unicode strings

* Update itemname_test.cpp
2019-10-21 08:33:10 +03:00
John Bytheway 4321c025d2 IWYU 20190629 (#31990)
* Add IWYU pragma: keep

* Run IWYU and astyle

* Run IWYU a second time

* Prevent #include <cxxabi.h>

Unclear why IWYU thinks this is needed.  It isn't, and it causes
problems on Visual Studio.
2019-07-01 12:25:53 +03:00
Brys Sepulveda 65a92b9fee Feature/cdda 30410 removing too big for normal char with tests (#30869)
* Adding tests to make sure the names of items are what we expect given their flags. We may need to expand this depending on how much we want to change
2019-05-28 15:31:48 -07:00