Commit Graph

73 Commits (b1dafe3a6a4d1eb92fb62cbe4a912ebe9a690763)

Author SHA1 Message Date
Josh Cooper 3f05859780 Revises manageJobStartedEvent, and adds comments 2022-03-12 11:33:27 -08:00
Josh Cooper c8e7869375 Fixes some build errors 2022-03-12 11:33:27 -08:00
Josh Cooper 524f1670ed Fixes missing namespace 2022-03-12 11:33:27 -08:00
Josh Cooper ba5710f263 Adds new event type NEW_UNIT_ACTIVE 2022-03-12 11:33:27 -08:00
Josh Cooper 6ace4b2cf8 Fixes mistake in EventManager::manageTickEvent 2022-03-12 11:33:27 -08:00
Josh Cooper b8ad0131ea Modifies EventManager::registerTick to retain old behaviour of re-registering tick events 2022-03-12 11:33:27 -08:00
Josh Cooper 1107c03b86 Modifies EventManager unit loops 2022-03-12 11:33:27 -08:00
Josh Cooper c550a6caf0 Updates EventManager job loops 2022-03-12 11:33:27 -08:00
Josh Cooper 07ffa0b8da Fixes bug in manageJobStartedEvent 2022-03-12 11:33:27 -08:00
Josh Cooper 24255d3195 Adds event type JOB_STARTED 2022-03-12 11:33:27 -08:00
Josh Cooper 48444afbd5 Fixes issue in manageJobCompletedEvent 2022-03-12 11:33:27 -08:00
Josh Cooper 3e72d549d1 Switches iterators to pre-increment instead of post for EventManager
My understanding is that iterators (.begin()/end()) are slightly faster with
pre-increment instead of post. Something about avoiding a copy if I recall correctly.
I replaced all `([:alpha:]+)\+\+` with `++$1` so non-iterators were switched as well - luckily there is no impact to pre/post aside from with iterators.
2022-03-12 11:33:27 -08:00
Josh Cooper f5ced46608 Refactors EventManager
- handler freq now works on an individual handler basis (set to 0 to fire as frequently as possible)
- tick events no longer need to be re-registered after every eventful tick
2022-03-12 11:33:27 -08:00
lethosor 08aeb6faeb Fix EventManager building ID type
The pointer to the building ID was sometimes not dereferenced properly.
Addressed by switching to an ID cast to a pointer type for consistency with
other types of events.

Fixes #1434
Ref #1003 (19695b4ee7)
Broken in #1253 (a7dfacd1c5)
2019-10-05 20:26:31 -04:00
lethosor 7a5e7c7c86 Rename unit_flags1.dead to killed, update submodules/changelog
Follow-up for dfhack/df-structures#247
2018-06-21 11:17:09 -04:00
lethosor aac892c560 Adapted to changed Units functions
Squashed version of #1307

Closes #1307
2018-06-14 10:30:35 -04:00
Ben Lubar 0a2ec30199
Remove or comment out unused code. 2018-04-05 16:48:11 -05:00
lethosor 2c95ac411e Update xml and all uses of job_handler 2017-11-25 00:59:59 -05:00
lethosor 19695b4ee7 EventManager/eventful: Pass building ID pointers to event handlers
Previously, there was some disagreement over whether event handlers such as
Buildings::updateBuildings() took building pointers or building IDs shoved
into pointers. It turned out to be the latter, which, unfortunately, did not
compile on x64. Passing building IDs isn't possible in all cases, because
building event handlers can be called for recently-deleted buildings too.
Pointers to building IDs do work reliably, though.

Fixes #1003
2017-02-17 22:53:48 -05:00
lethosor 41a81f9021 Fix some more warnings (GCC 4.8) 2016-07-28 11:00:52 -04:00
expwnent f8ff447cb5 Add a check to the histfig fix and tweak NEWS. 2016-03-10 08:50:03 -05:00
expwnent fd132d3fe7 Fix persistent histfig crashbug. 2016-03-10 08:38:55 -05:00
lethosor 10cfef0553 Fix whitespace issues 2015-02-14 22:53:06 -05:00
expwnent 8f4b766107 EventManager: Fix a crash bug with EQUIPMENT_CHANGE event. 2015-01-15 18:13:19 -05:00
expwnent 83d3785735 Update xml. 2014-11-30 14:03:00 -05:00
expwnent 5e3bf9a494 Make it compile for OSX. 2014-11-14 22:21:03 -05:00
expwnent 4464d7318d EventManager: make REPORT events only trigger for new reports, not ones that already exist in the save. 2014-11-14 22:07:48 -05:00
expwnent 428fe6a400 interaction-trigger tweaks 2014-11-14 18:50:19 -05:00
expwnent 779ac3fd50 Updated interaction-trigger to work better. 2014-11-09 18:36:21 -05:00
expwnent fa401f8637 EventManager tweak. 2014-11-07 14:16:10 -05:00
expwnent dcdb6aae1b EventManager: properly deal with frame_counter getting reset. 2014-11-06 23:44:13 -05:00
Quietust 9435d8f4d9 Fix crashes caused by missing globals 2014-07-21 19:14:43 -05:00
expwnent 649dcd1413 EventManager tweak: make it report the correct invasion id. 2014-07-03 14:37:13 -04:00
expwnent d8c3a05f42 Made EQUIPMENT_CHANGE event trigger for new units. 2014-07-03 08:10:12 -04:00
expwnent 81c87d0921 EventManager: INTERACTION event for unit interactions. 2014-07-03 04:55:12 -04:00
expwnent 8f43b97284 EventManager tweaks. 2014-07-01 09:02:20 -04:00
expwnent 4ac32cfd74 EventManager: made UNIT_ATTACK trigger for severed body parts. 2014-07-01 08:58:48 -04:00
expwnent 961d033ade EventManager: unload event for convenience. 2014-06-29 10:03:55 -04:00
expwnent ceae634954 Squashed EventManager commented out thing I don't need anymore. 2014-06-28 02:41:00 -04:00
expwnent 8e7e87ac73 Added UNIT_ATTACK event to EventManager and exposed it to Lua. 2014-06-28 02:31:34 -04:00
expwnent c635632ae7 EventManager.cpp: fix indentation. 2014-06-27 22:09:01 -04:00
expwnent 7313c18a2a EventManager/eventful: added ON_REPORT event and exposed it to Lua. 2014-06-23 09:15:46 -04:00
Quietust 57fbb1004b Assorted cleanup 2014-04-23 08:23:34 -05:00
expwnent 329741f235 EventManager: added EQUIPMENT_CHANGE event and exposed it to lua. 2013-10-24 19:32:52 -04:00
expwnent 4dbcee9560 EventManager: be smarter about removing things while iterating. 2013-10-20 23:16:21 -04:00
expwnent c409289ee4 EventManager: TICK events should unregister correctly when requested and after they fire, other tweaks.
- fixed unregister to allow unregistering individual TICK events
 - make registerTick return the resulting freq you have to put back in to the handler in order for it to be unregisterable
- when TICK events fire, they now automatically remove themselves from handlers[TICK], as they should
- make sure manageTickEvent fires once per tick
2013-10-20 22:54:25 -04:00
expwnent 3594dc2eb8 EventManager: fixed the TICK event, and a few tweaks.
- redo tick event management to work with world->frame_counter
 - the freq of a TICK EventHandler is now ignored
 - unregistering for an individual TICK event is still broken
  - you would have to know the modified freq to even begin removing it
  - it is only removed from handleres[TICK], not from tickQueue
- redo unregisterAll to be more efficient
- use the map loaded/unloaded events instead of world loaded/unloaded for initializing/clearing event monitoring data
- get rid of silly unsigned variables
2013-10-20 21:48:28 -04:00
expwnent 9bf004d07f Several EventManager fixes and improvements.
- handle loading and unloading of saves better
  - made sure it never triggers bogus events on loading a save
    - plugins should now handle loading themselves with onStateChange
  - special case to make Buildings module keep track of all buildings correctly on load
- fixed syndrome detection
  - was broken because of the switch from ticks-since-the-dawn-of-time to world->frame_counter
  - added lastSyndromeTime global
- fixed possible off by one error when looking for new created items
- got rid of the unread lastTick global
- const'ed the function pointer array of eventManagers
2013-10-20 20:12:42 -04:00
expwnent f69fd1d528 EventManager: prevent eventspam just after loading a save. 2013-10-20 17:39:54 -04:00
expwnent d78a111f02 EventManager: Fixed the death event, fixed another problem with construction event, and made EventManager use world->frame_counter for scheduling event checking in order to make it work in arena mode. 2013-10-20 14:41:39 -04:00