35 Commits

Author SHA1 Message Date
Kai Maier 57d2a3a010 - Moved the marloss and mycus stuff to EOC's
- Since the marloss stuff did a lot of stuff i had to add a few new affects to not change the old logic
- These include: u_add_addiction, u_lose_addiction, u_vomit (that one is evil :o ), u_fall_asleep, u_heal_all, u_hurt_all, u_set_hunger, u_mod_healthy, u_fil_stomach, u_marlossify (i went of the name already existing for that) and u_add_memorial
- I also added what they do to the documentation EFFECT_ON_CONDITION.md

- The reason for that is that the callback functions that triggered the effect on eating a seed or beery were not called anymore aka dead code

- I also saw that the EOC's for the addictions already existed and used those.
- This allowed me to remove the old / dead code from the iuse.h and iuse.cpp. Same thing in the item_factory.cpp

- The f_map_is_passible function in condition.cpp is supposed to make the spores skip walls like the old code does

- Ah yes and a few tests so i dont go insane testing it manually

- I am also very thankful (!) to the Magiclism and Mind over Matter people since i was able to use that as a reference
- Also whoever made the Docs is amazing too!

This took in fact 9 hours of my life... just for anyone wondering

Changes after feedback:

Fixed the janky broken map logic i created to keep the iuse rng logic
Removed the boolean parameter for vomit and marlossify since it did nothing
Moved the daily_health and hunger assertions to math like suggested
Fixed the eating order issue and now it uses a MARLOSS guard in the can_eat function like suggested
Renamed the NPC_AUTOCONSUME flag to MARLOSS to better reflect the actual usage
Adjustd my existing tests and also added for the order of eating and blacking out. This now uses the time_in_future to keep it in a safe order
Also added a test for the marloss refusal
Added tests in for the new hunger and daily heath math parsers
2026-09-24 19:10:29 +02:00
dumb-kevin a45b34a147 Add event_statistic() to math parser
New global-scope dialogue function: event_statistic('stat_id')
Reads event_statistic values via stats_tracker::value_of().
2026-03-10 06:40:54 +04:00
andrei 14b4a68187 math: implement dot operator for tripoints 2025-05-05 12:50:46 +03:00
andrei ee1b28a876 math: rewrite tokenizer 2025-05-02 17:15:51 +03:00
andrei 2cce541b4b math/tests: fix math tests for data types 2025-04-08 09:23:00 +03:00
andrei 2891f0ea15 math: restore validation of func. assign target 2025-04-08 09:02:15 +03:00
andrei 8a69be3b13 math/diag: restore unused kwarg validation
require explicit list of allowed kwargs in function declaration
2025-04-05 17:05:02 +03:00
andrei 99140e80e5 math: un-lambda-ify dialogue functions 2025-04-05 17:05:02 +03: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
andrei 9f387d1651 math: use sstream for number conversion 2024-12-06 06:39:24 +02:00
andrei 7739d799a0 math: standardize error severity 2024-11-23 08:51:00 +02:00
andrei 3b873fc3fa math: handle increment ops in the most shameful manner 2024-11-21 11:01:02 +02:00
andrei 635b5cdfdc math: fix validation of empty array 2024-11-21 11:01:01 +02:00
andrei ab7c554de6 math: implement assignment operators 2024-11-21 11:01:01 +02:00
Anton Simakov cf579ac306 get rid of npctalk_var_ prefix for eoc variables (#77515)
* get rid of npctalk_var_ prefix for eoc variables

* cleanup after #77055

* deprecate more of type and context

* migrate item vars, make migration happen only once

* doc updates

* migrate u/npc/monster variables

* fix context var migration

* remove `substr( 12 )` in math parser

* move migration to a single function where possible

* no auto

* please clang

* Please clang more

* fix submap load test

* clean up after #77656

* cleanups after #77520
2024-11-16 22:58:03 -06:00
GuardianDll f08d4d51a2 fix missed header in math_parser_test 2024-08-25 17:54:23 +02:00
Anton Simakov 7f16ac8925 calorie related math effect (#73136)
* Add `calories()` math function

* add assigning function

* remove u_val version of the kcal checks

* replaces all instances of u_val('kcal') with new function

* document change

* fix clang tidy error

* Update src/math_parser_diag.cpp

Co-authored-by: mqrause <38702195+mqrause@users.noreply.github.com>

* Update src/math_parser_diag.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* resolve the rest of shiv, fix (potentially) few tests

* missed the zero

* remove percent calories assigning since you can't assign calories as percent anymore

* remove math kcal test because it's not a shim

* the way this test is made drive me insane

* i was told this can fix the test

* spare me

* now this one is my fault

* fix MoM using old syntax

* Do floating point math

Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>

* get rid of magic number

* revert `Do floating point math` because i don't want static cast all the returns in the function.
better approach would be divide this function in two, one for raw value that return int, one for percent value that return double
or function that return healthy kcal directly

* add `-> double`

* Update src/math_parser_diag.cpp

Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>

---------

Co-authored-by: mqrause <38702195+mqrause@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: anothersimulacrum <anothersimulacrum@gmail.com>
2024-04-22 23:05:34 -05:00
andrei 1ccd2f3d41 eoc/math_parser: migrate all shimmed functions to native 2024-01-26 06:08:27 +02:00
andrei 960997f89c eoc: port u_val time to math 2024-01-24 03:24:00 +02:00
andrei 891154a92c math_parser: add time function 2024-01-24 02:51:44 +02:00
andrei ccb1993b62 math_parser: add has_var() and value_or() 2024-01-16 23:45:45 +02:00
andrei f55fd1d400 eoc/math: port arithmetic power to math 2024-01-15 22:48:57 +02:00
andrei 06dc3b3e27 math_parser: implement support for array arguments (#69539)
* math_parser: move diag_value to a separate unit

* math_parser: implement support for array arguments
2023-11-22 22:06:43 -06:00
andrei 6956921710 math: minor cleanup for inline bool ops (#67264) 2023-07-29 19:40:22 +03:00
andrei d699fc08ed math_parser: implement ternary operator (#66180)
* math_parser: add boolean operators

* math_parser: implement ternary operator
2023-06-14 12:30:10 -03:00
andrei c63c85f6cb math_parser: improve handling of dialogue functions (#65980)
* math_parser: implement real kwargs

* options/eoc: fix segfault in game_option()

* math_parser: hold diag functions in a map

map::find is more efficient for a container of this size

also reduces churn when adding functions
2023-06-05 09:20:26 -03:00
andrei aa3b581529 math_parser: evaluate variables in diag. functions (#65467) 2023-05-19 00:10:09 -04:00
Dillon Matchett 2c393f6d88 Context Vars (#65307)
* Documentation

Update NPCs.md

Update EFFECT_ON_CONDITION.md

Event Docs

* Code

Clang fix

progress

compiles

start of tests

cleanup the rebase

Apply suggestions from code review

Remove copy_dialogue

fixes for constructors

fixes

Update src/math_parser.cpp

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-Authored-By: andrei <68240139+andrei8l@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>
2023-05-01 21:09:21 -04:00
andrei 7fbae15dbc math_parser: force classic locale before parsing (#65352) 2023-04-29 20:31:15 -04:00
andrei f1701db631 eoc: untemplate all EOC code (#65069)
* eoc: obsolete mission_goal_condition_context

* eoc: untemplate all EOC code

* condition: post-untemplating cleanup

fix some errors that clang-tidy can catch now that the code isn't templated
2023-04-16 13:35:01 -03:00
andrei 328960dd57 math_parser: properly handle too many arguments for nullary 2023-04-13 20:23:25 +03:00
Zhilkin Serg 543496850d Merge pull request #64973 from andrei8l/math_parser-more-doc
math_parser/doc: add more var and shim examples
2023-04-12 13:09:09 +03:00
andrei 3b674c58b0 math_parser: add more common math functions (#64984)
clamp, floor, trunc, ceil, and round
2023-04-11 09:11:50 -03:00
andrei 8151c98a4b math_parser: validate strings and var names
don't allow inner spaces or quotation marks
2023-04-11 14:39:38 +03:00
andrei 385b949874 tests/math_parser: add a test unit 2023-04-02 22:41:25 +03:00