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

Function Osiris_CallLevelEvent

Descent3/OsirisLoadandBind.cpp:1959–2012  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1957// Triggers an event for a level script. Returns true if the default action should continue
1958// to process.
1959bool Osiris_CallLevelEvent(int event, tOSIRISEventInfo *data) {
1960 if (!Osiris_level_script_loaded)
1961 return true;
1962
1963 if ((Game_mode & GM_MULTI) && (Netgame.local_role != LR_SERVER)) {
1964 // no scripts for a client!
1965 return true;
1966 }
1967
1968 if (!(Osiris_event_mask & OEM_LEVELS))
1969 return true; // level events are disabled
1970
1971 if (!Osiris_IsEventEnabled(event))
1972 return true;
1973
1974 int aux_event = -1;
1975 if (event == EVT_AI_NOTIFY) {
1976 switch (data->evt_ai_notify.notify_type) {
1977 case AIN_GOAL_COMPLETE:
1978 aux_event = EVT_AIN_GOALCOMPLETE;
1979 break;
1980 case AIN_GOAL_INVALID:
1981 aux_event = EVT_AIN_GOALFAIL;
1982 break;
1983 case AIN_GOAL_FAIL:
1984 aux_event = EVT_AIN_GOALFAIL;
1985 break;
1986 case AIN_GOAL_ERROR:
1987 aux_event = EVT_AIN_GOALFAIL;
1988 break;
1989 }
1990 }
1991
1992 if (tOSIRISCurrentLevel.level_loaded) {
1993 // there is a loaded level, get it's dll id and call it's event
1994 int dll_id = tOSIRISCurrentLevel.dll_id;
1995 void *instance = tOSIRISCurrentLevel.instance;
1996
1997 if (instance) {
1998 data->me_handle = OBJECT_HANDLE_NONE; // its a level script!...no me
1999 int16_t ret;
2000
2001 ret = OSIRIS_loaded_modules[dll_id].CallInstanceEvent(0, instance, event, data);
2002 if (aux_event != -1) {
2003 // call child event
2004 ret = OSIRIS_loaded_modules[dll_id].CallInstanceEvent(0, instance, aux_event, data);
2005 }
2006
2007 return (bool)((ret & CONTINUE_DEFAULT) != 0);
2008 }
2009 }
2010
2011 return true;
2012}
2013
2014// Osiris_CallTriggerEvent
2015// Purpose:

Callers 15

GameFrameFunction · 0.85
AINotifyFunction · 0.85
KillPlayerFunction · 0.85
EndPlayerDeathFunction · 0.85
InitLevelScriptFunction · 0.85
FreeLevelScriptFunction · 0.85
DoObjProdMethod · 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