- do_turn marked every level's light dirty, so seen levels relit every
turn even when nothing had changed
- now only levels with a blinking lamp or a lit item relight each turn;
other sources already mark their level when they change
- the dawn, dusk and weather tint is keyed, since nothing marks it
- added a benchmark for a turn with creatures on three floors
- final visibility already rebuilds when its inputs change; the call
in do_turn only redid the same work
- clairvoyant fields were the one input outside the key; a field
change now moves its level's field revision, which the key reads
- other callers keep invalidate_visibility_cache for explicit refreshes
- removing a vehicle left its walls, shelter and floors cached, so
sight checks still hit walls that were gone
- opening an outdoor vehicle door kept its tile sheltered from fog;
shelter is now rebuilt along with transparency
- a scene change recasts only if it touched a tile some view reached,
including tiles hidden by a ledge
- floor changes always recast, however the floor cache got rebuilt
- a recast clears and scans only the levels that need it
- each level remembers what its visibility was built from: light,
view, aim, vision threshold and clairvoyance
- a level rebuilds only when one of those changes, replacing the one
dirty flag shared by all levels
- the published visibility variables always describe the requested
level
- sunlight is built into its own grid per level; each level's light
starts from it and adds only the sources standing on that level
- building one level no longer writes over another level's light,
such as its darkness fields
- levels the avatar or a camera sees get full light; the rest get
sunlight alone, as all levels did before
- open sky above the highest structure is one value, not a full grid
- each camera casts into its own grid, clips ledges from its own
height, then merges into the camera view
- cameras no longer see through the avatar's crouch cover or erase
each other's view at ledges
- camera moves, removal and battery loss are tracked per map
- the view keeps what its last cast read: position, range, eye height
and the mirrors and cameras of the vehicle it stands in
- posture, furniture height and vehicle parts recast the view without
any caller marking it dirty
- the avatar's own tile stays visible through the display logic
instead of a cache override
- vehicle caching always used the reality bubble's coordinates
- building another map's caches, as mapgen does, wrote its vehicles
into the wrong map, corrupted its vehicle list and could hang
- map::sees takes a trace: optical for sight (the default) or physical
for light and projectiles; flashes, projectiles, sonar and heat use
physical
- cached answers are dropped whenever the scene changes, not only when
the avatar's view does
- a check made between two builds first builds pending scene changes
- new sight caches hold what blocks sight: TRANSLUCENT terrain and
furniture stop sight but still pass light
- vehicle walls now block sight, light and creature zone flooding
- transparency notices weather, shelter and vehicle changes itself,
and records revisions that later caches key on
- rebuild_vision_caches_from_scratch builds every vision cache with no
history, as a reference for tests
- the oracle compares an incremental build after a real change (step,
door, weather, posture) with that rebuild, cache by cache
- hidden benchmarks time the same changes, to compare with master
- crouch cover and the always-visible own tile are overrides on the
avatar's copy of the transparency cache
- they were reapplied only when that cache was rebuilt, so they stayed
where the avatar had been; in fog a map shift showed a 4x3 patch
- each build now restores the cells it overrode last time and applies
the new ones; the manual dirty calls for crouching go away
* typified a bit of map.h/cpp + dependents
* demanded changes
* demanded master changes drawn to its conclusion
* second int should be in corresponding location
* add visibility update
* vis update when peeking
* fix autodrive visibility
* revert visibility optimization
* only cache tile visibility on access
* use apparent_light_at to handle visibility cache
* Revert "use apparent_light_at to handle visibility cache"
This reverts commit 37f66fda9e.
* Revert "only cache tile visibility on access"
This reverts commit b52cd59827.
* pos and time visibility invalidation
Co-Authored-By: andrei <68240139+andrei8l@users.noreply.github.com>
* fix peek and look around
* fix tests
---------
Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>
* 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>
In LLVM 16 this check was a lot more effective. So, it was briefly
disabled during the migration. This fixes all its warnings again, and
re-enables it.
* 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>