* 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.
* 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)
* 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
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.
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.
* 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
* 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>
* 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
* 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.
* 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