68 Commits

Author SHA1 Message Date
dobbry-vechur 07f34d9ddf Treat inverted tripoint_range bounds as empty
- made tripoint_range end on its first point when min is above max
- made tripoint_range::size() return 0 for inverted bounds
- added inverted bounds tests to map_iterator_test
- added off-map center tests for map::points_in_radius
2026-09-20 09:58:36 +04:00
Johnson 1f918518cd Merge pull request #88315 from Relvl/performance/few-performance-fixes-1
Performance/Improve few per-turn performance bottlenecks
2026-08-17 12:55:16 -05:00
GuardianDll 7a10e1cbe7 Revert "refactor death message, corpse spawn and death drops suppresion vars (#87680)"
This reverts commit 8bf230233d.
2026-07-07 16:46:06 +02:00
RenechCDDA da2aaffffd Add quick setup option to clear map 2026-06-22 15:07:51 -04:00
Anton Simakov 8bf230233d refactor death message, corpse spawn and death drops suppresion vars (#87680)
* refactor death message, corpse spawn and death drops suppresion vars

* Apply suggestions from code review

Co-authored-by: np4Huk <22.valiant@gmail.com>

* Fix test issues

---------

Co-authored-by: np4Huk <22.valiant@gmail.com>
2026-06-17 22:41:39 -05:00
Andrew Krieger 0215b26cce Rewrite all tests to clear map without touching character map memory, for performance. 2026-02-08 23:05:55 -08:00
PatrikLundell 586cf5f1ce Mapify: character etc. sees + sundry others (#79699)
* Mapify: character etc. sees + sundry others

* demanded changes

* Corrected correction
2025-02-18 09:29:22 -06:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -08:00
moxian e2f7aaf95f Modernize c headers (stddef.h -> cstddef &co)
Code size:
includes:
$ cat obj/tiles/*.inc | wc
 278247  556494 17375710
$ cat tests/obj/tiles/*.inc | wc
 163745  327490 10307041

post-processed source (clang -E):
./make_preproc.sh src/
65903054 170378741 2049783477
./make_preproc.sh tests/
38434408 100326802 1215849078
2025-02-10 13:56:09 -08: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
PatrikLundell 99aeb7b990 Load npcs and deal with their bodies 2025-01-25 09:49:42 +01:00
PatrikLundell f14346c5db Rename map:: get_global->get_abs, bub_from_abs->get_bub, omt_from_abs->get_omt (#79167)
* Renamed map:: getglobal->get_abs, bub_from_abs->get_bub, omt_from_abs->get_omt

* astyle
2025-01-16 09:15:04 +01:00
PatrikLundell ace7b0d8ee Don't try to GENERATE typed coordinates (#79137)
* Don't try to GENERATE typed coordinates

* Adjusted according to comments
2025-01-13 14:17:34 -08:00
PatrikLundell f2e3ee4988 typified map.h and dependents 2025-01-12 14:43:40 +01:00
Procyonae 40f0b39e62 Merge branch 'master' into RemoveStringInitialisingItems 2025-01-10 17:00:48 +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
PatrikLundell befd4486d1 sundry typification (#78985)
* sundry typification

* demanded work around
2025-01-06 22:26:26 -06:00
PatrikLundell 8ae88c96d5 typified stuff 2024-12-27 15:17:12 +01:00
Andrew Krieger 67c1ad039a Categorically fix type issues with restore_on_out_of_scope 2024-12-09 21:51:35 -08:00
PatrikLundell c4c4fea51c typified half of game.h (#78357) 2024-12-06 10:52:58 -08:00
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
PatrikLundell 456a199f5c typified a bit of map.cpp and dependents 2024-10-08 16:23:15 +02:00
PatrikLundell 8f19d8e971 typified map.h + dependents, end of first pass (#76888) 2024-10-07 13:23:18 -07:00
PatrikLundell 128e94132b typified a bit of map.h/cpp + dependencies (#76795)
* typified a bit of map.h/cpp + dependencies

* demanded changes

* sorted out merge mess
2024-10-06 22:42:35 -05:00
PatrikLundell c5c01140ba typified a bit of map.h/cpp + dependents (#76712)
* typified a bit of map.h/cpp + dependents

* demanded changes

* demanded master changes drawn to its conclusion

* second int should be in corresponding location
2024-10-02 23:34:12 -05:00
PatrikLundell ef6b53acfb typified a little bit of map.h + dependents (#76340)
* typified a little bit of map.h + dependents
2024-09-27 15:10:36 -07:00
PatrikLundell ab062c5e8b typified a bit of map.h/cpp + some dependents (#75125)
* typified a bit of map.h/cpp + some dependents

* Macro crasher found by one compiler!

* demanded changes

* stupid wokaround for demanded changes

* Sort out conflict mess
2024-09-10 09:42:54 -05:00
PatrikLundell 38267e0b54 Typified a bit of map.h/cpp (#74963)
* Typified a bit of map.h/cpp

* demanded changes
2024-07-10 21:45:20 -04:00
PatrikLundell 1e228cae8b typified submap.h/cpp (#74911) 2024-07-08 11:08:39 -07:00
PatrikLundell bf080d921a Typify a couple of activity actions (#74876)
* Typify a couple of activity actions

* coordinate_constants.h apparently included transitively
2024-07-04 09:48:33 -04:00
PatrikLundell 4c6b91838c Removed one getlocal (#73940)
Co-authored-by: RenechCDDA <84619419+RenechCDDA@users.noreply.github.com>
2024-05-25 16:18:25 -05:00
PatrikLundell f7e64c68d6 Made tinymap load take a tripoint_abs_omt parameter instead of untyped tripoint (#72145)
* Made tinymap load use omt coordinates (and thus alignment)
2024-03-19 19:32:24 -07:00
mqrause bd211963e6 move item_pocket::pocket_type to it's own header 2023-11-27 13:22:35 +01:00
Alexey 7cc39bbce7 More test state resets (#66173)
* Restore map's abs_sub after map_coordinate_conversion_functions

./tests/cata_test "map_coordinate_conversion_functions","Mattack dialog condition test"

* Rewind time in biometrics tests

./tests/cata_test "basal metabolic rate with various size and metabolism","mutations may affect character metabolic rate"

* Don't place avatar on invalid zlevels

./tests/cata_test "npc_compare_int","npc_can_target_player"
./tests/cata_test "npc_arithmetic","npc_can_target_player"

* Martial art test should clear map

./tests/cata_test "walls should connect to walls as end pieces","Martial art technique conditionals"

* Clear map in turrets test

./tests/cata_test "vehicle_ramp_test_61","vehicle_turret"

* Clear map in gun repair test

./tests/cata_test "cube_direction_add_om_direction","Gun repair with degradation"

* Fix bionic test order dependency

./tests/cata_test "fueled bionics"

* Build light cache in player_activities_test

./tests/cata_test "grenade_lethality_scaling_with_size","activity interruption by distractions"

* Clear map in pockets test

./tests/cata_test "character should lose moves when opening or closing doors or windows","multipocket liquid transfer test"

* Make explicit flag for crafting cache invalidation

* Clear more avatar fields

* Clear time in weary_recovery

./tests/cata_test craft_available_via_vehicle_rig,vision_see_wall_in_moonlight,vision_moncam_basic,weary_recovery
2023-06-15 11:08:46 -03:00
andrei a656c97589 active_items: mark death drops as active items 2023-03-22 05:26:58 +02:00
Binrui Dong 32774b37da Migrate from cata::optional<T> to std::optional<T> (#64333)
Co-authored-by: Kevin Granade <kevin.granade@gmail.com>
2023-03-20 20:11:23 -07:00
andrei a59501ecaa tests/active_items: don't prune stale actives during test (#64018) 2023-03-07 13:22:44 -05:00
andrei 468c87e019 map/item: add only active contents to active cache (#63233)
* map/item: add only active contents to active cache

* active items: remove redundant looping
2023-03-02 01:54:02 +03:00
andrei 6b8232d800 tests/map: fix setup for inactive_container_with_active_contents 2023-01-03 17:35:56 +02:00
andrei 2970e33326 map: update active items cache when removing contents 2022-12-28 19:56:14 +02:00
John Bytheway 49b8098672 Fix map coordinate conversion functions (#59252)
* Fix map coordinate conversion functions

The new map coordinate conversion functions added in #59187 were almost
all wrong.  They forgot that map::abs_sub has a z-coordinate, which was
getting mistakenly added to or subtracted from the coordinates involved.

This in particular broke all construction when not on zlevel 0.

Add a bunch of tests to verify that these coordinate conversion
functions behave properly, and fix them.
2022-07-14 10:32:31 -07:00
John Bytheway 2320732f3a Start porting map point types
Continuing the effort to move the game towards type-safe points.  The
last commit added coordinate systems relative to the reality bubble.
This origin gets the abbreviation bub, and four aliases point_bub_ms,
point_bub_sm, tripoint_bub_ms, and tripoint_bub_sm represent these
points.

As a starting point, I have converted all or most of the
construction-related code to these new point types.  This started in
construction.cpp and I followed the compiler errors and continues to
port code so long as it seemed construction related.

One big change is that lots of the map functions are getting extra
overloads taking these new point types.  During the period where we are
still porting code these overloads will exist in parallel with those
taking raw points.  However, the long term plan is to remove the old
overloads, and I've marked each with a TODO comment to that effect.

I didn't discover any bugs in the process of these changes and there
should not be any behavioural changes.
2022-07-11 20:13:09 -04:00
John Bytheway 69c506820e Verify that we never load overlapping maps
The mapgen coverage test was loading various OMTs via calling load on
tinymap.  This can break vehicle caching if the tinymap overlaps the
main map.

Add a sanity check in map::load to detect this issue.

Tweak the mapgen coverage test to avoid such OMTs.

Update some other tests to also avoid this issue.
2021-12-19 15:34:21 -05: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
Kevin Granade a5db697aed Fix grabded furniture/vehicle destruction feature and tests for same 2021-02-06 00:39:19 -08: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
John Bytheway 0a22b119fe Convert some more point types
Remove the tripoint overloads to map::load and game::load_map, and deal
with the fallout.
2020-07-21 07:50:56 -04:00
Kevin Granade cf21972870 Global reference migration part 21 (#41942) 2020-07-08 09:26:50 +03:00
Kevin Granade 1a6769da4e Map reference migration part seven 2020-06-28 20:24:43 +00:00