* 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++
* introduce `map_test_case`: a framework that simplifies tile-setting tests
refactor vision_test.cpp using `map_test_case` framework
add new vision test with thick smoke
* fix clang-tidy warnings
* another clang-tidy fix
* remove mutations that potentially affect vision
* narrow the scope of the overloaded operators
Failing to do so could break the crafting tests because extra items
might be available for crafting nearby, thus causing the crafting code
to need to ask the player which one to use (which triggers UI code which
aborts in test mode, since there's no UI).
* 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>
Call `game::place_critter_at` instead and fast-forward the existing monster by calling `monster::on_load`.
Note that the remaining code from `game::add_zombie` has been moved into `monster::on_load`.
Also note that `monster::spawn` is called from within `place_critter_at`, so the caller does not have to call it.
Change `Creature_tracker::add` accordingly.
Changes the handling of mounted creatures while vertical shifts:
- removes the mount manually to avoid it despawning into the map (and reloading later when the player comes back).
* 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.
* Fix missing declarations
Mark functions with no prior declarations as static, and remove the
unused ones.
* Move debug_is_safe_string definition
Put it inside !WIN32 since it's only used there.
For reliable vision tests we need to clear out things in zlevels above
zero to avoid shadows.
Adding that functionality to wipe_map_terrain so that it affects all
tests.
This has some modest performance impact, but I don't think it's too bad.
In clear_npcs, use game::cleanup_dead to deal with dead NPCs. This is
important so that g->num_creatures() returns the correct value, which is
checked by some tests.
This also removes them from the overmapbuffer, so we no longer need to
do that separately in this function.
Removing the NPCs this way is error-prone, because they still exist but
aren't in the caches, so other game entities can't find them. Better to
just remove them entirely.
After #30051 clear_creatures no longer clears NPCs. Add a call to do
that in these tests where it is needed.
Also, in clear_map, remove NPCs before vehicles to avoid unboarding
errors (as already hinted at in npc_test.cpp).
Simplify npc_test to use the new improved clear_map.
Ultimately, this is all a workaround for the fact that vehicle detaching
does not properly mark NPCs as not in the vehicle. That should also be
fixed.
* Use clear_npcs in clear_map
clear_map had a similar flaw to the one fixed in #30031 affecting
npc_can_target_player. Fix it in the same way.
This wasn't obviously affecting any tests, but it makes sense to fix it
pre-emptively.
* Before killing npcs, ensure correct ones loaded
Some tests
(default_overmap_generation_has_non_mandatory_specials_at_origin)
overwrite overmaps, which leads to orphaned NPCs. Unloading and
reloading the NPCs ensures that all the active NPCs are known to the
overmap.
The npc_can_target_player test was sometimes failing due to the hostile
NPC choosing to target another NPC instead of the player.
This, in turn, was caused by the clearing of NPCs not being done
properly. They were unloaded, but then loaded again, and not all were
killed.
Write a new clear_npcs in map_helpers.h which works more reliably, and
call that instead.
Was clearing the wrong z-levels, due to not understanding how
OVERMAP_DEPTH worked.
Clearing all of them is rather slow, so just clear the most relevant
ones.
The clear_map function also moved the player to level -2, which is a
little surprising. Move that functionality out to a new function.
For each of the places using clear_map, pick either the new or old
version to use as appropriate.
Also, clear fields in clear_map.
Specifically iterating over all the active npcs is now done via a dedicated `npc_range`.
Also adds a function `game::get_npcs_if` similar to `game::get_creatures_if`.
* origin/pr/22101:
Change projectile bouncing to consider all creatures around.
Remove unused function game::zombie
Replace game::num_zombies with game::num_creatures
Move removing dead monsters from the tracker into Creature_tracker.
Implement monster/creature iterator:
Call game::get_creature_if instead of iterating over all monsters manually.
Call game::get_creatures_if to get all matching monsters
Change mfactions to contain monster pointers instead of indizes
Avoid repeated calls to game::zombie
Use vector of pointers instead of indizes in mattack::upgrade.
Move get_creatures_if into class game.
Change game::despawn_monster to take the monster as reference
Instead of calling `game::num_zombies` and iteration of the range of valid monster indizes and getting the monster references via `game::zombie`, use a range class with iterator interface and range-based for loops.
Code like this:
`
for( size_t i = 0; i < g->num_zombies(); ++i ) {
monster &critter = g->zombie( i );
...
}
`
becomes this:
`
for( monster &critter : g->all_monsters() ) {
...
}
`
The later is much easier to read and to understand.
Change `Creature_tracker::find` to take the position of the monster instead. So instead of calling `mon_at` and passing the returned index to `find`, one calls `find` directly and gets the same data out of it.
Only three places called `game::mon_at`:
- `game::critter_at`: the code of `mon_at` has been inlined there.
- `game::shared_from`: it calls `Creature_tracker::find` with the position now.
- `game::serialize`: two functions `temporary_id` and `from_temporary_id` replace it here.