50 Commits

Author SHA1 Message Date
RenechCDDA da2aaffffd Add quick setup option to clear map 2026-06-22 15:07:51 -04:00
dumb-kevin 7cd3f3a7f6 Make morale recovery non-destructive, init mutation state on load
check_and_recover_morale() was replacing the entire morale object when
it found a permanent-point inconsistency, wiping all temporary morale
(food, music, social, etc.). Players would go from +48 to +2.

Two fixes:

1. Add sync_permanent() that replaces only permanent morale points and
   non-point state (prozac, pain, radiation, mutations, body parts),
   preserving temporary morale. Use it instead of full replacement.

2. After morale->load() in save loading, activate mutations in morale's
   internal tracking. Without this, has_mutation() returns false for all
   traits, so update_constrained_penalty() and update_masochist_bonus()
   compute wrong values when triggered by item equips or stat changes.
2026-03-17 11:32:59 +04:00
dumb-kevin cf90990753 Fix flaky player_morale_ranged_kill_of_unaware_hostile_bandit test
Add clear_map() to reset terrain, items, fields, and lighting state
before the visibility-at-midnight check. Without it, stale light
sources from previous tests can illuminate the player position,
making ambient_light_at() exceed natural_light_level_cache and
giving the NPC full sight range at midnight.
2026-02-19 11:29:48 +04:00
Kevin Granade 460a215bbe Nuke the stylish trait from orbit (#79745)
* Nuke the stylish trait from orbit

* Please tests

---------

Co-authored-by: Anton Simakov <67688115+GuardianDll@users.noreply.github.com>
2025-02-20 11:55:10 +01: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 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 278c26a11d Convert some vehicle operations to be map aware (#79477)
* Convert some vehicle operations to be map aware

* Oops, forgot to carry the parameter through

* removed unused operation
2025-02-03 07:54:29 +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
Anton Burmistrov 7e2fb195b7 Added test for morale check for ranged kill of unaware hostile bandit (#78593) 2024-12-30 10:10:34 -06:00
PatrikLundell 26eb173d36 typified character.h + npc.h (#78623)
* typified character.h + npc.h

* demanded collateral change

* demanded collateral change
2024-12-18 20:03:41 -06:00
Procyonae fa1e64ec8f Remove the redundant includes bc I were just being lazy 2024-06-05 11:38:35 +01:00
Procyonae 47eb971c97 Forgot /tests 2024-05-31 21:48:49 +01:00
RenechCDDA 0b48c3d469 Oops, actually set faction, not just the faction id 2024-02-27 07:39:20 -05:00
RenechCDDA fb2653f68c Test case for hostile bandit 2024-02-27 07:33:38 -05:00
RenechCDDA 507fb31ba0 basic test case when an innocent is killed unprovoked 2024-02-27 07:31:10 -05:00
John Bytheway e95a4fc9b8 Promote string_id constants to global statics
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.
2021-11-19 19:10:09 -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 502985754f Audit FANCY flag use, remove from questionable articles (#49078)
* Audit FANCY flag use, remove from questionable articles

* Tweak morale test to match adjustments from FANCY audit

* astyle
2021-06-17 18:19:46 -07:00
haveric c380afc798 Fix spelling issues (#45878)
* JSON description spelling fixes
* Markdown + txt spelling fixes
* Fix FLAMMABLE_ASH flag for butchering rack
* Fix result spelling of southwest
* Fix cephalopod achievement id spelling
* unsually is probably unusually
* Fix spelling in dynamic line
* Simple comment/text spelling fixes
* Fix variable/enum spellings
* Fix function spelling issues
2020-12-08 16:46:14 -08: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 cb76d6c009 Refactor morale_test
Split this one massive test into a bunch of smaller ones.

This test was big enough to trigger the readability-function-size
warning.
2020-08-26 20:30:43 -04:00
Fris0uman 10e6058207 Remove body_part from effect (#42277)
* Effects use bodypart_id
* remove default value and unecessary overrides
* effect_map use bodypart_str_id, and replace num_bp with bp_null
2020-08-01 22:45:04 +00: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
CodeBandit a16209f50c Update masochist tests 2020-04-30 18:21:28 -04:00
John Bytheway aff4636618 Run IWYU
Having refactored the type ids into a single header, IWYU is now able to
find many places where other headers can be removed.
2019-05-06 22:47:10 +01:00
John Bytheway e3e7700aef Apply IWYU changes
This is a run of IWYU followed by astyle.
2019-04-22 11:42:51 +01:00
Isaac Freund f8092db4f7 Fix bug morale tests
- apply the +/- sign after taking the sqrt
- constify a thing
- correct "temporary morale (food)" test values
- add new "stacking of bonuses" test
2019-04-11 15:38:12 +02:00
Angela Graves 07382221d9 Merge pull request #27396 from Siersha/Optimism
Optimist and Bad Temper Rebalance
2019-01-12 00:15:36 -06:00
ZhilkinSerg c0bce91fa1 Used const where appropriate 2019-01-06 23:00:08 +03:00
John Bytheway b0576393e3 Sort headers according to IWYU conventions
A first step towards IWYU support.  Doing the sorting first because it
makes reviewing any additions or removals of headers much simpler.

The IWYU order is:
- Associated headers
- Misc system headers
- C++ STL headers
- Other project headers

The biggest change is moving system headers before project headers (they
are usually afterwards in Cata at the moment.

The associated header for a cpp file is the header file which declares
the functions defined in that cpp file.  Normally that's the one which
shares the same name (up to extension), and if so IWYU figures it out
automatically.

However, in this project there are many corner cases, so we need to use
IWYU pragma: associated to tell it which header (or, in some cases,
which headers) is the associated header.  We are unusual in having
multiple associated headers for some files, which might lead to
discovering some interesting IWYU bugs later, but in theory it is
supported.
2019-01-05 14:03:31 +00:00
Siersha 0ed9bbbd2b Optimist and Bad Temper rebalance 2019-01-01 20:30:21 -05:00
Siersha 9f3c213287 Master changes revert 2019-01-01 20:09:50 -05:00
Siersha 0db386deff Optimist and Bad Temper rebalances 2018-12-30 22:57:25 -05:00
ZhilkinSerg f8eb2acd05 Optimized includes (tests) 2018-11-07 03:55:47 +03:00
BevapDin 929524992e Fix wrong assumption that morale system uses minutes as time units. 2018-04-16 13:18:41 +02:00
BevapDin f6f3c6b4c8 Change morale system to use time_duration 2018-04-16 13:18:41 +02:00
Kevin Granade b511530b28 Update name of mutation in morale test. 2017-05-25 02:45:20 +00:00
Kevin Granade dbf94ea324 Explicitly initialize string_id template instances to make clang happy. 2017-05-17 00:04:11 -07:00
BevapDin 49620e189a Fix test to use new trait_id 2017-05-05 12:55:53 +02:00
codemime bd38afde27 Use 'class enum' for the side type 2016-12-11 17:41:35 +03:00
codemime 436df4bc60 Update test cases for temperature morale 2016-04-28 16:09:13 +03:00
codemime c1e1f2a4ab Update test cases for stylish morale 2016-04-28 16:09:05 +03:00
codemime 2758bf7d72 Minor code changes 2016-04-09 01:55:49 +03:00
codemime 9186cf4e78 Code refinements 2016-04-07 12:27:37 +03:00
codemime e430c0c7cc Extend unit tests 2016-04-06 21:20:20 +03:00
codemime 5b277c4048 Extend unit tests to test body temp morale 2016-03-07 18:59:01 +03:00
codemime a9285e3c17 Add unit tests for the 'player_morale' 2016-03-07 16:44:43 +03:00