Wargus / stratagus

The Stratagus strategy game engine
GNU General Public License v2.0
619 stars 119 forks source link

Check each trigger-condition in each cycle #626

Closed zzam closed 5 months ago

zzam commented 5 months ago

Run all check-functions of all triggers in each cycle. Also improve the API of the called functions to get the index of the trigger [0,n-1] instead of an (shifted) index into a lua-table of triggers.

Contrary to the documentation [1] only one trigger condition is run in every Cycle. This state is even saved to a saved game file.

[1] https://github.com/Wargus/stratagus/blob/838f82ec7f31234933c9f999150e17b59c754057/src/game/trigger.cpp#L412-L416

Jarod42 commented 5 months ago

Can you see if unit tests can be added for triggers? https://github.com/Wargus/stratagus/blob/master/tests/stratagus/test_depend.cpp might be a base.

zzam commented 5 months ago

Can you see if unit tests can be added for triggers? https://github.com/Wargus/stratagus/blob/master/tests/stratagus/test_depend.cpp might be a base.

I will try to write a test.