* Rip out tr_ledge hack
* Make non Character creatures fall again
* Typify and rename ledge -> try_fall
* Add tr_ledge obsoletion
* Remove t_hole
* Fix climbing down triggering falling first resulting in you burying yourself
* Update map.cpp
* Fix being grapple pulled off a roof sending you into the ground
* Fix spawned NPCs not falling until they move
* Fix spawned monsters not falling until they move
Not the most ideal looking spot for this but its the only place all the calls I could find filter down to
* Fix a test expecting spawned NPCs to float
* Another test that expects floating to be fine
* Appease our clang overlords
* More appeasement
* Did you know stashing changes for one branch on another by accident and forgetting about them is not great?
* More fixes
* Appease our clang overlords
* Fix some since typified stuff
Light map is only built on the player character's z level even with 3D FOV on, and building the light map on all NPCs' levels might be too expensive, so simply let NPCs finish their business when not on the player character's z-level for now, like what was done for non-3D-FOV mode.
* 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>
* 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)
* initial commit
* no message
* improve calculations, currently uses test values
* oops
* no message
* no message
* fixing the wrong values, remove debug message
* tests: override weather in tests that need clear vision
* Andrei's fix of vision test
* vision_junction_reciprocity fix
* weather realism test fix
---------
Co-authored-by: andrei <a12l+git@runbox.com>
* Added monster support and Slime Ocularium
Currently the Ocularium cannot be created, this is intentional - Slimewave is still useful through slime minions from Omnicellular
* Large camera and rendering changes
Makes cameras independent from player vision radius limits, dirties vision cache while cameras are active, and adds better vision falloff to cameras.
In addition, removes recalculation of seen_cache during long activities except on refresh frames - an optimization that arose from camera needs.
* Updates tests, bugfixes player half-seeing monsters
Player was able to detect a monster existed, especially on the compass, but not see their location, when the mosnter was outside of sight_max range (usually 9999, but sometimes much smaller for certain mutations and effects)
* Vision lightcasting now checks sightmax first
Also upped MYOPIC vision radius, preventing an adverse effect of excessive blindness - and somehow making a much nicer vision effect for short-sighted characters.
Mirrors were giving inaccurate vision ranges - also I nerfed mirrors because its now possible to nerf mirrors.
Co-authored-by: bombasticSlacks <dillon.matchett@gmail.com>
Co-authored-by: Kevin Granade <kevin.granade@gmail.com>
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.
* Make turn_zero constexpr
* Add features to rl_vec3d
* Construct from rl_vec2d and z-coord
* Extract xy as rl_vec2d
* In-place scaling
* StringMaker support for rl_vec2d
* Add StringMaker specialization for time_point
* Add atan2( rl_vec2d ) overload
* Add units::asin returning units::angle
* Add sunlight angle calculation and tests
This is an initial implementation of sunlight_angle, which should work
OK for the first few days, but will break down before the end of the
first year.
One test plots the path of the sun through the sky at each solstice and
an equinox. This is intended as a simple smell test that's easy for a
human to see when something has gone wrong with the sun angle algorithm.
* Add analemma unit test
* Tweak sunlight calculation away from reality
Because the game years don't match real-world years, we need to make
some adjustments to the sunlight angle calculations to allow for that.
* Use logical origin of sidereal time
We had an origin of 177, but 180 makes logical sense, so switch to that
as it's easier to understand.
* Derive sidereal time from angle_per_day
Removing one magic constant.
* mean_long, mean_anomaly in terms of angle_per_day
Remove more arbitrary constants from the calculation, and document those
which remain.
* Use game year length, not real-world one
This removes one more arbitrary constant and means that the sunlight
angle calculations ought to work for other season lengths.
* Unit test for handling season length
* Base sunrise and sunset on astronomical maths
This is the first change that allows the sun angle calculations to
actually influence the game.
We switch the sunrise and sunset times to match the sun positions as
calculated by the astronomical equations surrounding the location of the
sun.
This requires changing a few other places in the code, and updating a
lot of tests.
Heavinly inspired by Hirmuolio's work in #47570, but reimplemented
rather than cherry-picked.
Co-authored-by: Hirmuolio <hirmuolio@gmail.com>
* Support eternal season for new Sun calculations
When eternal season is set, always have the Sun behave as it does on
whatever day the game starts.
* Update some comments in sun_test.cpp
* Appease clang 3.8
* Improve comments and variable names
Based on Github review.
Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com>
* Fix clang-tidy issues
* Assume solar time rather than timezone
Previously the sunlight angle code required you to pass a timezone.
Now, instead, it assumes the timezone is local solar time (determined by
the longitude). This makes some of the calculations simpler and the API
less confusing.
It does mean that the test cases have drifted a little further from the
'true' Boston sunrise and sunset times, but they're still fairly close.
Co-authored-by: Hirmuolio <hirmuolio@gmail.com>
Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com>
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++
Add tests covering the Ursine Vision and impaired-while-blindfolded
fixes, as well as for several related aspects of Character sight
functions, including:
- sight_impaired: true if mutations/effects/clothing impair sight
- recalc_sight_limits: compute max_sight adjusted for such effects
- unimpaired_range: return max_sight, or 60 at most
- sight_range: atmosphere-attenuated vision range, max_sight at most
- fine_detail_vision_mod: crafting time multiplier based on light