MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / Osiris_CallTriggerEvent

Function Osiris_CallTriggerEvent

Descent3/OsirisLoadandBind.cpp:2018–2074  ·  view source on GitHub ↗

Osiris_CallTriggerEvent Purpose: Triggers an event for a trigger script. Returns true if the default action should continue to process.

Source from the content-addressed store, hash-verified

2016// Triggers an event for a trigger script. Returns true if the default action should continue
2017// to process.
2018bool Osiris_CallTriggerEvent(int trignum, int event, tOSIRISEventInfo *ei) {
2019 if ((Game_mode & GM_MULTI) && (Netgame.local_role != LR_SERVER)) {
2020 // no scripts for a client!
2021 return true;
2022 }
2023
2024 if (!(Osiris_event_mask & OEM_TRIGGERS))
2025 return true; // trigger events are disabled
2026
2027 if (!Osiris_IsEventEnabled(event))
2028 return true;
2029
2030 if (trignum < 0 || trignum >= Num_triggers)
2031 return true;
2032
2033 if (!tOSIRISCurrentLevel.level_loaded)
2034 return true;
2035
2036 int dll_id, script_id;
2037 int aux_event = -1;
2038 void *instance;
2039
2040 if (event == EVT_AI_NOTIFY) {
2041 switch (ei->evt_ai_notify.notify_type) {
2042 case AIN_GOAL_COMPLETE:
2043 aux_event = EVT_AIN_GOALCOMPLETE;
2044 break;
2045 case AIN_GOAL_INVALID:
2046 aux_event = EVT_AIN_GOALFAIL;
2047 break;
2048 case AIN_GOAL_FAIL:
2049 aux_event = EVT_AIN_GOALFAIL;
2050 break;
2051 case AIN_GOAL_ERROR:
2052 aux_event = EVT_AIN_GOALFAIL;
2053 break;
2054 }
2055 }
2056
2057 dll_id = tOSIRISCurrentLevel.dll_id;
2058 script_id = Triggers[trignum].osiris_script.script_id;
2059 instance = Triggers[trignum].osiris_script.script_instance;
2060
2061 if (instance) {
2062 int16_t ret;
2063 ret = OSIRIS_loaded_modules[dll_id].CallInstanceEvent(script_id, instance, event, ei);
2064
2065 if (aux_event != -1) {
2066 // call child event
2067 ret = OSIRIS_loaded_modules[dll_id].CallInstanceEvent(script_id, instance, aux_event, ei);
2068 }
2069
2070 return (bool)((ret & CONTINUE_DEFAULT) != 0);
2071 }
2072
2073 return true;
2074}
2075

Callers 7

osipf_CallTriggerEventFunction · 0.85
CheckTriggerFunction · 0.85
Osiris_ProcessTimersFunction · 0.85
Osiris_CancelTimerFunction · 0.85
Osiris_SaveSystemStateFunction · 0.85

Calls 1

Osiris_IsEventEnabledFunction · 0.85

Tested by

no test coverage detected