|
| static int | hooks_executeParam (const char *stack, const HookParam *param) |
| static void | hooks_updateDateExecute (ntime_t change) |
| | Updates date hooks and runs them if necessary.
|
| static void | hook_rmRaw (Hook *h) |
| | Removes a hook.
|
| static void | hooks_purgeList (void) |
| | Purges the list of deletable hooks.
|
| static Hook * | hook_get (unsigned int id) |
| | Gets a hook by ID.
|
| static unsigned int | hook_genID (void) |
| | Generates a new hook id.
|
| static Hook * | hook_new (HookType_t type, const char *stack) |
| | Generates and allocates a new hook.
|
| static int | hook_parseParam (const HookParam *param) |
| | Parses hook parameters.
|
| static int | hook_runMisn (Hook *hook, const HookParam *param, int claims) |
| | Runs a mission hook.
|
| static int | hook_runEvent (Hook *hook, const HookParam *param, int claims) |
| | Runs a Event function hook.
|
| static int | hook_run (Hook *hook, const HookParam *param, int claims) |
| | Runs a hook.
|
| static void | hook_free (Hook *h) |
| | Frees a hook.
|
| static int | hook_needSave (Hook *h) |
| | Checks if a hook needs to be saved.
|
| static int | hook_parse (xmlNodePtr base) |
| | Parses an individual hook.
|
| int | hook_save (xmlTextWriterPtr writer) |
| | Saves all the hooks.
|
| int | hook_load (xmlNodePtr parent) |
| | Loads hooks for a player.
|
| static Mission * | hook_getMission (Hook *hook) |
| | Gets the mission of a hook.
|
| static int | hq_add (HookQueue_t *hq) |
| static void | hq_free (HookQueue_t *hq) |
| | Frees a queued hook.
|
| static void | hq_clear (void) |
| | Clears the queued hooks.
|
| void | hook_exclusionStart (void) |
| | Starts the hook exclusion zone, this makes hooks queue until exclusion is done.
|
| void | hook_exclusionEnd (double dt) |
| | Ends exclusion zone and runs all the queued hooks.
|
| unsigned int | hook_addMisn (unsigned int parent, const char *func, const char *stack) |
| | Adds a new mission type hook.
|
| unsigned int | hook_addEvent (unsigned int parent, const char *func, const char *stack) |
| | Adds a new event type hook.
|
| unsigned int | hook_addTimerMisn (unsigned int parent, const char *func, double ms) |
| | Adds a new mission type hook timer hook.
|
| unsigned int | hook_addTimerEvt (unsigned int parent, const char *func, double ms) |
| | Adds a new event type hook timer.
|
| unsigned int | hook_addTimerFunc (int(*func)(void *), void *data, double ms) |
| | Adds a function hook to be run.
|
| unsigned int | hook_addFunc (int(*func)(void *), void *data, const char *stack) |
| | Adds a function hook to be run.
|
| void | hooks_updateDate (ntime_t change) |
| | Updates the time to see if it should be updated.
|
| unsigned int | hook_addDateMisn (unsigned int parent, const char *func, ntime_t resolution) |
| unsigned int | hook_addDateEvt (unsigned int parent, const char *func, ntime_t resolution) |
| void | hooks_update (double dt) |
| | Updates all the hook timer related stuff.
|
| void | hook_rm (unsigned int id) |
| | Removes a hook.
|
| void | hook_rmMisnParent (unsigned int parent) |
| | Removes all hooks belonging to parent mission.
|
| void | hook_rmEventParent (unsigned int parent) |
| | Removes all hooks belonging to parent event.
|
| int | hook_hasMisnParent (unsigned int parent) |
| | Checks to see how many hooks there are with the same mission parent.
|
| int | hook_hasEventParent (unsigned int parent) |
| | Checks to see how many hooks there are with the same event parent.
|
| int | hooks_runParamDeferred (const char *stack, const HookParam *param) |
| | Runs all the hooks of stack in the next frame. Does not trigger right away.
|
| int | hooks_runParam (const char *stack, const HookParam *param) |
| | Runs all the hooks of stack.
|
| int | hooks_run (const char *stack) |
| | Runs all the hooks of stack.
|
| nlua_env | hook_env (unsigned int hook) |
| | Gets the lua env for a hook.
|
| int | hook_runIDparam (unsigned int id, const HookParam *param) |
| | Runs a single hook by id.
|
| int | hook_runID (unsigned int id) |
| | Runs a single hook by id.
|
| void | hook_cleanup (void) |
| | Gets rid of all current hooks.
|
| void | hook_clear (void) |
| | Clears the hooks.
|
| void | hook_clearMissionTimers (unsigned int parent) |
| | Clears the timer hooks for a mission.
|
| void | hook_clearEventTimers (unsigned int parent) |
| | Clears the timer hooks for an event.
|
Handles hooks.
Hooks have a major issue, they are sort of like a poor man's threading. This means get all the issues related to threading. The main issues here are the fact that the hooks can mess with the game state during the update and break everything. The solution is to handle hooks either before the update stage (input stage) or after update stage (render stage). This leaves the update stage as sort of an atomic block that doesn't have to worry about state corruption.
The flaw in this design is that it's still possible for hooks to bash other hooks. Notably the player.teleport() is a very dangerous function as it'll destroy the entire current Naev state which will most likely cause all the other hooks to fail.
Therefore we must tread carefully. Hooks are serious business.
Definition in file hook.c.