30 Commits

Author SHA1 Message Date
dumb-kevin 05ab42807e tests/: wrap TU-local test fixture types in anon namespaces
- addiction_test: wrap addict_effect_totals
- battery_density_test: wrap battery_chemistry_family
- comestible_test: wrap all_stats
- encumbrance_test: wrap add_trait
- invlet_test: fuse inventory_location + invlet_state + test_action enums
- throwing_test: fuse throw_test_data + throw_test_pstats, move operator<< inside anon-ns
- vehicle_test: wrap vehicle_preset, damage_preset, folded_item_damage_preset, fuse rack_activation + rack_preset
- vision_test: wrap vision_test_case
- water_movement_test: fuse 6 swimmer/swim structs into one block
- weakpoint_test: wrap weakpoint_test_data, weakpoint_expectation, weakpoint_report
2026-05-12 10:53:28 +04:00
Novacat 14382bee2d Changes Precipitation Tests 2025-12-18 11:38:46 -05:00
ehughsbaird 1f8dec63d0 Fix weather
I misunderstood the weather test and though it was a random calendar
related failure caused by it picking the wrong summer/winter points.

Reading the code further, this was wrong, and changing
time_past_new_year to include time in winter broke the weather code.

It is still picking the wrong summer/winter points, it seems (change it
to midsummer and midwinter, instead of the start of spring and end of
spring).

The weather code assumed time_past_new_year gave time since spring, so
it needed to be correctly offset to know when midwinter was.
2025-08-10 18:21:42 +00:00
ehughsbaird cedd8af571 Display time with months instead of seasons
Split the 364 day year up into months as so:
The seasons are
Dec, Jan, Feb, Mar -> Winter
Mar, Apr, May, Jun -> Spring
Jun, Jul, Aug, Sep -> Summer
Sep, Oct, Nov, Dec -> Autumn

The first month of each season has 31 days, and the first day of each
season is on the 20th of the first month (the last day on the 19th of
the last month).

For season settings other than 364 days, season display is broken and I
need to consider how to implement this correctly.

Some additional logic was needed for the year transition correctly on
Dec 31 -> Jan 1, because turn_zero is the first day of Spring.

The calendar code isn't too gross, but is still gross.
2025-08-05 14:25:08 +00:00
moxian c44d65a8ae Run IWYU again to pick up the changes 2025-02-11 13:02:19 -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
Clarence "Sparr" Risher 8b27b967ae Replace point constants with static class members 2024-11-26 10:14:26 -05:00
Alexey 07356b65a5 Normalize TEST_CASE names (#66241)
* 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)
2023-06-17 13:57:19 -03:00
Eric 195b437e4d Create a context variable with tile location during weather checking. To be used for portal storms centers (#65491)
* First

* Second

* Works

* Uses context now

* Update WEATHER_TYPE.md
2023-05-06 11:24:30 -04:00
Hirmuolio 042fff658a Add units::temperature_delta (#62452)
Co-authored-by: Fris0uman <41293484+Fris0uman@users.noreply.github.com>
2023-04-25 15:55:38 -07:00
akrieger 3b22d13aa9 Move scope helpers to cata_scope_helpers.h 2022-09-15 22:04:51 -07:00
Hirmuolio e547ae781f Make environment temperature to use units::temperature (#58852)
* update get_temperature

* update print_temperature

* tests

* get_local_windchill

* tests run

* make tests pass

* astyle

* cleanup

* weather_generator temperature

* astyle

* cleanup

* get_heat_radiation

* get_convection_temperature

* map temperature mod

* astyle

* weather.temperature

* avoid integer division

* clean get_local_windchill

* unused converts

* get_water_temperature

* unused converts

* windchill tests

* delta F corrected

* wrong unit

* astyle

* dTand wetness morale

* misc cleanup

* astyle

Co-authored-by: Fris0uman <41293484+Fris0uman@users.noreply.github.com>
2022-08-17 12:43:54 +02:00
John Bytheway d7f4a3e8a1 Fix eternal season affect on weather (#54100)
Fixes #26756.

Use the same trick as I previously used for the sunlight angle in
eternal season mode where it just repeats the same weather from the
first game day.  A twist here is that we still use the true timestamp
for the simplex noise parameter, because otherwise the weather would be
exactly the same from day to day.
2022-01-07 14:10:37 -08: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
Eric b00bf5533b Change weather to use effect_on_conditions (#48178)
* Move weather into effect_on_conditions

* Update effect_on_condition.json

* LGTM issue
2021-07-03 07:42:04 -07:00
actual-nh 4537a34a7d Make sure no weather_override for weather test
It is possible for an earlier test to set weather_override, which could
interfere with weather_test.cpp's weather generation test. This patch
prevents this. (It was previously part of #48245.)
2021-03-31 10:12:35 -04:00
Binrui Dong 9fdb7ef59c Run IWYU
* 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++
2021-02-06 00:18:41 -05:00
John Bytheway b285a13080 Make time_point( int ) constructor explicit
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.
2020-11-10 11:21:02 -08:00
John Bytheway 51ddbd5661 Convert existing uses of auto caught by new check 2020-09-01 06:54:06 -04: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
Eric 5437b2a0bb More json weather requirements (#42138) 2020-07-21 07:07:21 +00:00
Ramza13 680685f7f6 Generic factory 2020-07-07 17:34:10 -04:00
Ramza13 714b583a13 Code review 2020-07-07 17:33:27 -04:00
Ramza13 a4e59217bf First batch of code review work 2020-07-07 17:32:45 -04:00
Kevin Granade 438774d386 Global getters (#41347)
* Make Character::stat into a standalone enum class

Enables forward declaration

* Remove player centric overload and unecessary include

* Remove player.h dependency from trap.cpp

* Add singleton-like accessors for avatar, map, weather and event_bus

* use accessors to remove includes of game.h
2020-06-16 16:48:45 +03:00
Eric Pierce 8be44fd860 Add test case for get_local_windchill and improve function docs (#39431)
* Use better variable names

* Document windchill declaration; floor return value

* Use std::ceil instead of std::floor

Based on the results of 33 test assertions, the implicit return cast to
int here is using `std::ceil` rather than `std::floor`.

* Reduce NorAm/UK windchill cutoff from 4F to 3F

According to Wikipedia, 3.0 is the cutoff for this model.

* Add windchill test for North America/UK model

* Flesh out Australian apparent temperature test
2020-04-10 12:19:58 +03:00
John Bytheway e189957ff2 Run IWYU 20200408 (#39364)
* 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>
2020-04-10 12:16:19 +03:00
Kodi Arfer d9b5949080 Astyle 2019-10-28 16:09:25 -04:00
Kodi Arfer fa03e068bb Add tests of weather realism 2019-10-28 16:08:40 -04:00