18 Commits

Author SHA1 Message Date
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
moxian 077af7f886 Remove ghc/filesystem polyfill now that we are on C++17 (#79092)
* Remove ghc/filesystem shim now that we are on C++17

* fixies

* astyle

* teach clang-tidy about <filesystem>
2025-01-13 09:17:22 +01:00
Karol1223 d77e36da76 Decentralize `small_animal and fish` factions (#75993)
* mammals

without bat, I wanna give that nerd a bird faction

* fix dinomod

* birds + bat

* reptile + amphibian

* Update monfactions_test.cpp

* some test fixing

* fish + molerat faction cleanup

* predatory waterfowl + dachshunds

* Update monster_factions.json

* Update monster_factions.json

* Update monster_factions.json

* Update monster_factions.json

* Update monster_factions.json
2024-09-06 15:03:16 -05:00
Jianxiang Wang (王健翔) 719e63678e Add clang-tidy check to enforce use of fs::u8path and fix path encoding error (#65223)
* Add clang-tidy check to ensure fs::u8path is used to construct path from utf-8 string

* Fix fs::u8path and nullptr warnings

* Print error instead of showing a popup in test mode in write_to_file

* Remove cata::fstream wrappers
2023-05-17 08:52:46 -03:00
Zhilkin Serg e44f38af40 Remove excessive empty lines 2022-12-06 10:42:15 +03:00
Venera3 e9cb0c11ad Add a common zombification route to mutant fauna (#60605)
* Meat cocoon first

* Meat cocoon second

* WIP

Weakpoints, groups, monsters

* Weight tweaks, zombification, faction changes

* Rebranding, snippets, tweaks

* Spellcheck

* Tweak, rebrand part two

* Combat tests

* Ling

* Apply suggestions from code review

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update MONSTERS.md

* Fix chill spiders

Free for all means free for all

* Update zed_amalgamation.json

Co-authored-by: Venera3 <Venera3@users.noreply.github.com>
Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>
2022-11-14 17:29:22 +01:00
John Bytheway 53a6cd9050 Apply auto transformations
Use the new clang-tidy check to replace all the auto variable types with
explicit types (where it makes sense to do so).
2022-07-01 07:11:27 -04:00
David Seguin e81f21ad7a Extend monfaction: unit test 2022-04-04 22:28:13 -04: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
actual-nh e6e68ea674 Monfaction reciprocity test + fix (#51676)
* Add a test to check for monfaction reciprocity

It is possible for monfaction A to have a relationship of FRIENDLY or
NEUTRAL to monfaction B, which has a relationship of BY_MOOD or HATE
vs monfaction A. This leads to B attacking A without the possibility
of the reverse.

* Reformatting, possibly refactoring test

* Use c_str() instead of str() for printf.

* Fix non-reciprocal monster faction relationships

These are my current proposed changes to remove the monster faction
relationship reciprocity problems. @candlebury, I needed to alter
the player _monster_ faction (which does not affect, AFAIK, the
behavior of NPCs, much less the avatar) so that it would be at least
neutral to the robofac_spy; to avoid needing to do this for the larger
human monster faction (which includes exodii), I removed friendly
towards humans from the robofac_spy.

* Try to satisfy clang-tidy.

* Fix was wrong way around re mi-go and slime

Slime, instead of being neutral vs mi-go as a nether-derived faction,
was being by_mood, as per nether?

Co-authored-by: actual-nh <actual-nh@users.noreply.github.com>
2021-09-20 21:20:00 -07:00
Qrox fcf75c69be Handle path encoding correctly on Windows 2021-09-02 23:22:34 +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
actual-nh d103a0c7a3 [READY] Adjust problematic monster faction relationships (possible attack without counterattack) (#48077)
* Check reverse attitudes for monfactions_test matrix

It is desirable for attitudes and reverse attitudes between monster
factions to be congruent. Most troublesome is when one has
MFA_FRIENDLY or MFA_NEUTRAL and the other has MFA_BY_MOOD or
MFA_HOSTILE, whereupon the second will attack the first but the
first does not retaliate.

* Eliminate monster faction contradictions

Fixes #48071.

* Make fish and most others neutral vs each other

This removes land-based animals from being potential attackers of fish,
and vice-versa, avoiding possible problems due to their visibility as
pointed out by Venera3.

* Fix more fish faction relationships.

Limit non-neutral by/vs fish further to prevent either too much fish
death or fish attacking without retaliation.

* Adjust small_animal<->animal

Should default to neutral, as per the test.

* Take care of otter, razorclaw, exodii

Otters (and all other factions in obsolete.json) still show up on the
listing (can an "obsolete" flag or something be checked for?); removed
by_mood for them vs fish. Razorclaws are now neutral toward fish (and
vice-versa). Exodi are now by_mood vs (other) humans (and vice-versa).

* Fix test; bear/big_cat to by_mood vs fish

Swapped out dog for bear in monfactions_attitude test - has the same
pattern. I also changed bear and big_cat to by_mood vs fish.

* Fix infighting by human snails, amigara horrors

Amigara horrors and human snails were down as of the "mutant" faction,
which has by_mood toward itself, resulting in fighting within the
spawned groups. Changed amigara horror to mutant-derived faction
"amigara"; since human snails spawn with vortices and twisted bodies,
changed human snails and twisted bodies to "vortex". As a precaution,
also put shadows (including mon_darkman) and breathers (both) into
their own (nether-derived) factions.

* Remove unneeded breather and shadow factions.

I got mixed up; not needed, just "nether" does fine.

* Move slime back to neutral vs nether; cleanup

* Make mi-go/slime/nether NEUTRAL vs each other

Because they all spawn in the same groups (monstergroups/nether.json);
previously, they were NEUTRAL one-way and BY_MOOD the other in some
pairings, and I had put them as BY_MOOD both ways.

* Put human snail, twisted body in own faction

This prevents infighting between them when they appear together
(spiral) and they are made NEUTRAL to vortex and vice-versa.

* Fix Aftershock monster factions

Some Aftershock monster factions had BY_MOOD|HATE versus other factions
that had NEUTRAL/FRIENDLY toward them. This, upon an encounter, would
result in the first potentially (or definitely) attacking the latter,
while the latter would not retaliate. See #48077 for further
information.

* Hevel as herbivore, venandi as wolf

Also changes hevel, herbivore so NEUTRAL instead of friendly to other
one.

* Aftershock cryo adjustments; bloated corvid fix

* As per @Maleclypse, BY_MOOD changes for cryo

Changed cryo to BY_MOOD for herbivore/carnivore (which essentially
means just having "animal" in "by_mood"). Currently, insects are still
in HATE; I don't know if this is preferable or not.

* Change beavers from small_animal to herbivore.

One distinction between small_animal and larger is that the former are
not of interest to zombies, because they can't zombify. Beavers can,
and at ~20 kg are above the weight of the largest creature that can't
zombify (chonker cats).

* Start on fixing DinoMod factions

This has some example age-divided factions, various sizes of
predator, and no potential attacks without counterattack.

* Added monfactions.txt to .gitignore

Avoid accidental upload of a test-result file.

* Split up mosasaurus by ages

This splits up mosasaurus into mosasaurus and mosasaurus_young. THe
latter has both hatchlings and juveniles. (One problem I noticed with
the hatchlings - they have fins, and are AQUATIC... but are said to
be indistinguishable from others. That will need to be fixed in
0.F-dev (the description would need translating).

* Use copy-from for modifying base monster factions

From testing, it is possible for two mods that are both changing
the same base/vanilla monster factions to both work, provided both are
using copy-from. Change Aftershock to do so.

* Use copy-from in DinoMod vanilla faction changes

Mods that need to make changes in the same vanilla factions, generally
due to base_faction's copying of the base faction's attitude toward
itself, need to use "copy-from" in order not to conflict.

* Behavioral adjustments to dinosaurs.

Remove ATTACKMON - should not be needed with fixes to factions. Have
added PUSH_MON to some (the ones of very large size and/or DESTROYS),
to represent that they may push other monsters aside. I have also
removed STALK from the anger triggers for those not expected to be
berserk; this is partially to compensate for the MEAT pacification
trigger no longer being functional.

* Remove WARM from hatchling/juvenile mosasaurus.

They aren't large enough to have significant warmth retained without
specific mechanisms promoting this, and that would not be advantageous
in swimming - see <https://scholar.google.com/scholar_lookup?journal=Nature+Ecology+&+Evolution&title=A+general+scaling+law+reveals+why+the+largest+animals+are+not+the+fastest&author=MR+Hirt&author=W+Jetz&author=BC+Rall&author=U+Brose&volume=1&publication_year=2017&pages=1116-22&pmid=29046579&>.

* Adjust abilities of some tyranids + deinonychus

Adjusted abilities of tyrannids to take into account faster turning
speed. Also gave deinonychus max_dist for pathing of 10 (may need to
be higher), to allow for more intelligent routing.

* Adjust hadrosaurs, juvenile tyrannids, sauropods

Juvenile tyrannids: Dodge increased to reflect greater agility; still
not as high as adult (need to check on why "STUMBLES" is there).
Juvenile sauropods: Massive ones should not be quite as nervous as
other juveniles, particularly in a group (all appear in monstergroups
with a pack_size); gave GROUP_MORALE.
Hadrosaurs: Decreased agility -> decreased melee skill (dodge already
zero); see <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6387760/>.

* DOGFOOD vs CATFOOD

Co-authored-by: LyleSY <lyle.sollayates@Gmail.com>

* Remove "STUMBLES"

Co-authored-by: LyleSY <lyle.sollayates@Gmail.com>

* Remove remainder of STUMBLES from juveniles

* Remove plpaceholder monsters for obsolete factions

* Make Moxies concentrate on humans, etc if they're around.

* Implement fix from #48588 for Deinonychus

I had added PATH_AVOID_DANGER_2 to Deinonychus, to be more appropriate
to their capabilities; there turns out to be a bug in it - this is
a fix (although it can be improved once there's something for avoiding
obvious fields).

Co-authored-by: actual-nh <actual-nh@users.noreply.github.com>
Co-authored-by: LyleSY <lyle.sollayates@Gmail.com>
2021-05-20 10:58:59 -07:00
actual-nh cebcc044f8 Check reverse attitudes for monfactions_test matrix (#48069)
* Check reverse attitudes for monfactions_test matrix

It is desirable for attitudes and reverse attitudes between monster
factions to be congruent. Most troublesome is when one has
MFA_FRIENDLY or MFA_NEUTRAL and the other has MFA_BY_MOOD or
MFA_HOSTILE, whereupon the second will attack the first but the
first does not retaliate.
2021-03-18 23:03:46 +03: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
Venera3 7c4c07043d Adjust monster factions (#47152)
Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com>
2021-02-03 21:40:37 -08:00
Ivan Zaitsev 72f2e60350 Switch monfactions to generic factory (refactoring + minor perf improvement) (#45376)
* switch monfactions to generic factory
speedup monfaction::attitude by changing the underlying data structure to vector
add missing factions to json
add basic unit tests
2020-11-19 00:33:14 -08:00