Debian Codegraph @

Descent3/osiris_dll.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/osiris_dll.h $
21 * $Revision: 22 $
22 * $Date: 4/14/99 3:57a $
23 * $Author: Jeff $
24 *
25 * OSIRIS system header
26 *
27 * $Log: /DescentIII/main/osiris_dll.h $
28 *
29 * 22 4/14/99 3:57a Jeff
30 * fixed case mismatch in #includes
31 *
32 * 21 3/10/99 6:21p Jeff
33 * many fixes to demo system. Fixed IGC so cameras move...fixed osiris to
34 * be restored correctly, and it handles errors on restore
35 *
36 * 20 3/05/99 5:25p Jeff
37 * fixed saving demos in multiplayer...required adding a parameter to
38 * Osiris_LoadMissionModule() to pass in the name of the d3m file (for
39 * storage)
40 *
41 * 19 2/28/99 8:52p Jeff
42 * added functions to enable/disable creation events
43 *
44 * 18 2/18/99 11:06a Jeff
45 * added event masks (so you can enable/disable object/trigger/level
46 * events)
47 *
48 * 17 2/17/99 3:27a Jeff
49 * added game checksum function to handle out-of-sync dlls
50 *
51 * 16 2/10/99 3:29p Jeff
52 * extracted dll manager knows the difference between game hogs and
53 * mission hogs
54 *
55 * 15 1/22/99 8:54p Jeff
56 * added custom-default script overrides
57 *
58 * 14 1/22/99 5:15p Jeff
59 * added a key to toggle osiris debug messages
60 *
61 * 13 1/21/99 11:15p Jeff
62 * pulled out some structs and defines from header files and moved them
63 * into seperate header files so that multiplayer dlls don't require major
64 * game headers, just those new headers. Side effect is a shorter build
65 * time. Also cleaned up some header file #includes that weren't needed.
66 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
67 * manage.h and multi.h
68 *
69 * 12 1/16/99 10:39a Jeff
70 * added mission memory management to Osiris...only slightly tested. Need
71 * to solve game save/restore problem still
72 *
73 * 11 1/08/99 1:50p Jeff
74 * finished support on loading scripts from hogs
75 *
76 * 10 1/04/99 12:23p Jeff
77 * added to evt_use and support for mission module scripts
78 *
79 * 9 12/31/98 7:33p Jeff
80 * improved Osiris timers to have unique IDs, along with adding an
81 * EVT_TIMERCANCEL and a new flag to autodestruct the timer if a given
82 * object handle dies.
83 *
84 * 8 12/18/98 10:42a Jeff
85 * added timer support and auto-save memory manager for new osiris. New
86 * events evt_memrestore state added also
87 *
88 * 7 12/17/98 7:26p Jeff
89 * added memory manager for autosaving script data
90 *
91 * 6 12/17/98 5:43p Jeff
92 * created timer system for osiris and save restore events
93 *
94 * 5 12/17/98 12:08p Jeff
95 * first checkin of new implementation of OSIRIS (old OSIRIS no longer
96 * works)
97 *
98 * 4 12/16/98 10:16p Jeff
99 * added functions to call level and trigger events
100 *
101 * 3 12/16/98 10:58a Jeff
102 * checked in so Jason can use
103 *
104 * 2 12/14/98 11:32a Jeff
105 * started work on osiris load and bind functions
106 *
107 * 1 12/13/98 9:10p Jeff
108 *
109 * $NoKeywords: $
110 */
111
112 #ifndef __OSIRIS_H_
113 #define __OSIRIS_H_
114
115 #include "pstypes.h"
116 #include "object_external_struct.h"
117 #include "osiris_share.h"
118 #include "module.h"
119 #include "cfile.h"
120
121 extern uint32_t Osiris_game_checksum;
122 extern tOSIRISModuleInit Osiris_module_init;
123
124 // Osiris_InitModuleLoader
125 // Purpose:
126 // Initializes the OSIRIS module loader and handling system
127 extern void Osiris_InitModuleLoader(void);
128
129 // Osiris_FreeModule
130 // Purpose:
131 // Removes a currently loaded module from the OSIRIS system
132 extern void Osiris_FreeModule(int id);
133
134 // Osiris_ShutdownModuleLoader
135 // Purpose:
136 // Closes down the OSIRIS module loader and handling system
137 extern void Osiris_ShutdownModuleLoader(void);
138
139 // Osiris_FindLoadedModule
140 // Purpose:
141 // Given the name of a module, it returns the id of a loaded OSIRIS module. -1 if it isn't loaded.
142 extern int Osiris_FindLoadedModule(char *filename);
143
144 // Osiris_LoadLevelModule
145 // Purpose:
146 // Given a module name, it will attempt to load the module as a level module. If it succeeds
147 // it will return the id of the module where it has been loaded. If the module was already loaded
148 // before calling this function, it will return the id to where the module is, and will not reload
149 // the module. Returns -1 if the module does not exist. Returns -2 if the module couldn't initialize.
150 // Returns -3 if the module is not a level module. Returns -4 if no module slots are available.
151 extern int Osiris_LoadLevelModule(char *module_name);
152
153 // Osiris_UnloadLevelModule
154 // Purpose:
155 // Instead of saving the handle returned from Osiris_LoadLevelModule() and calling
156 // Osiris_UnloadModule() with that handle, you can just call this, instead of the call
157 // to Osiris_UnloadModule().
158 extern void Osiris_UnloadLevelModule(void);
159
160 // Osiris_LoadGameModule
161 // Purpose:
162 // Given a module name, it will attempt to load the module as a game module. If it succeeds
163 // it will return the id of the module where it has been loaded. If the module was already loaded
164 // before calling this function, it will return the id to where the module is, and will not reload
165 // the module. Returns -1 if the module does not exist. Returns -2 if the module couldn't initialize.
166 // Returns -3 if the module is not a game module. Returns -4 if no module slots are available.
167 extern int Osiris_LoadGameModule(char *module_name);
168
169 // Osiris_UnloadModule
170 // Purpose:
171 // Given a module id, it will decrement the reference count to that module by one. If the reference
172 // count becomes zero, the module will be unloaded from memory.
173 extern void Osiris_UnloadModule(int module_id);
174
175 // Osiris_LoadMissionModule
176 // Purpose:
177 // It will attempt to load the module as a game module. If it succeeds
178 // it will return the id of the module where it has been loaded. If the module was already loaded
179 // before calling this function, it will return the id to where the module is, and will not reload
180 // the module. Returns -1 if the module does not exist. Returns -2 if the module couldn't initialize.
181 // Returns -3 if the module is not a game module. Returns -4 if no module slots are available.
182 // This technically doesn't load a mission module, as it should already be loaded by
183 // Descent 3 prior.
184 extern int Osiris_LoadMissionModule(module *module_handle, const char *filename);
185
186 // Osiris_UnloadMissionModule
187 // Purpose:
188 // Instead of saving the handle returned from Osiris_LoadMissionModule() and calling
189 // Osiris_UnloadModule() with that handle, you can just call this, instead of the call
190 // to Osiris_UnloadModule().
191 extern void Osiris_UnloadMissionModule(void);
192
193 // Osiris_BindScriptsToObject
194 // Purpose:
195 // Call this function after an object has been created to bind all the scripts associated
196 // with it to the object. This function must be called near the end of it's initialization,
197 // to make sure that all fields have been filled in. This function does not call any events.
198 // This function will also load any dll's needed for it's game script.
199 // returns false if nothing was bound.
200 extern bool Osiris_BindScriptsToObject(object *obj);
201
202 // Osiris_DetachScriptsFromObject
203 // Purpose:
204 // Call this function when an object is about to be destroyed. This will unbind and remove
205 // all scripts associated with that object. This function does not call any events.
206 extern void Osiris_DetachScriptsFromObject(object *obj);
207
208 // Osiris_CallEvent
209 // Purpose:
210 // Triggers an event for an object. Pass in the event number and the associated
211 // structure of data. All events will be chained through the associated scripts of the
212 // object (as long as they are available) in the order: custom script, level script,
213 // mission script, and finally it's default script. The chain breaks if one of the scripts
214 // returns false on the call to their CallInstanceEvent().
215 extern bool Osiris_CallEvent(object *obj, int event, tOSIRISEventInfo *data);
216
217 // Osiris_CallLevelEvent
218 // Purpose:
219 // Triggers an event for a level script. Returns true if the default action should continue
220 // to process.
221 extern bool Osiris_CallLevelEvent(int event, tOSIRISEventInfo *data);
222
223 // Osiris_CallTriggerEvent
224 // Purpose:
225 // Triggers an event for a trigger script. Returns true if the default action should continue
226 // to process.
227 extern bool Osiris_CallTriggerEvent(int trignum, int event, tOSIRISEventInfo *ei);
228
229 // Osiris_ProcessTimers
230 // Purpose:
231 // This function checks all timers currently running, if any need to be signaled it signals them.
232 extern void Osiris_ProcessTimers(void);
233
234 // Osiris_CreateTimer
235 // Pupose:
236 // Adds a timer to the list to be processed. You'll receive a EVT_TIMER when the timer is signaled.
237 // Returns an id to the timer, which can be used to cancel a timer. -1 on error.
238 extern int Osiris_CreateTimer(tOSIRISTIMER *ot);
239
240 // Osiris_ResetAllTimers
241 // Purpose:
242 // Flushes all the timers
243 extern void Osiris_ResetAllTimers(void);
244
245 // Osiris_CancelTimer
246 // Purpose:
247 // Cancels a timer thats in use, given it's ID
248 extern void Osiris_CancelTimer(int handle);
249
250 // Osiris_TimerExists
251 // Purpose:
252 // Returns true if the timer is valid
253 extern uint8_t Osiris_TimerExists(int handle);
254
255 // Osiris_SaveSystemState
256 // Purpose:
257 // Saves the current state of the system (not the scripts!) to file
258 extern void Osiris_SaveSystemState(CFILE *file);
259
260 // Osiris_RestoreSystemState
261 // Purpose:
262 // Restore the state of the system from file (does not restore scripts!)
263 extern bool Osiris_RestoreSystemState(CFILE *file);
264
265 // Osiris_InitMemoryManager
266 // Purpose:
267 // Initializes the memory manager for the scripts, for buffers that the scripts want
268 // automatically restored/save.
269 extern void Osiris_InitMemoryManager(void);
270
271 // Osiris_CloseMemoryManager
272 // Purpose:
273 // Shuts down the Osiris memory manager, freeing any unfreed memory
274 extern void Osiris_CloseMemoryManager(void);
275
276 // Osiris_AllocateMemory
277 // Purpose:
278 // Allocates a chunk of memory to be associated with a script. It will automatically
279 // save this memory to disk on game save, and will pass the pointer to this memory on EVT_RESTORE
280 extern void *Osiris_AllocateMemory(tOSIRISMEMCHUNK *mc);
281
282 // Osiris_FreeMemory
283 // Purpose:
284 // Frees a chunk of memory that was allocated by Osiris_AllocateMemory().
285 extern void Osiris_FreeMemory(void *mem_ptr);
286
287 // Osiris_FreeMemoryForScript
288 // Purpose:
289 // Frees all memory allocated for a given script
290 extern void Osiris_FreeMemoryForScript(tOSIRISSCRIPTID *sid);
291
292 // Osiris_RestoreMemoryChunks
293 // Purpose:
294 // Restores the 'auto manage' from file, calls the EVT_MEMRESTORE
295 extern void Osiris_RestoreMemoryChunks(CFILE *file);
296
297 // Osiris_SaveMemoryChunks
298 // Purpose:
299 // Saves out the 'auto manage' script memory to file
300 extern void Osiris_SaveMemoryChunks(CFILE *file);
301
302 // Osiris_ExtractScriptsFromHog
303 // Given the handle of a loaded hog file, this extracts all the scripts out to a temp directory
304 // Pass false for the second parameter if it's a game hog (d3.hog for example)
305 extern int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog = true);
306
307 // Osiris_ClearExtractedScripts
308 // Deletes the temp files created when the scripts where extracted from the hog
309 // Pass false if you want it to remove _all_ extracted hogs...else only mission related ones
310 extern void Osiris_ClearExtractedScripts(bool misson_only = true);
311
312 // Initializes the Osiris Mission Memory System
313 extern void Osiris_InitOMMS(void);
314 // Shutsdown the Osiris Mission Memory System (frees all memory associated, call at end of mission)
315 extern void Osiris_CloseOMMS(void);
316
317 extern bool Show_osiris_debug;
318
319 #define OEM_OBJECTS 0x01
320 #define OEM_TRIGGERS 0x02
321 #define OEM_LEVELS 0x04
322 // Osiris_EnableEvents
323 // Purpose:
324 // Enables the passed in mask of event types to be called
325 extern void Osiris_EnableEvents(uint8_t mask);
326 // Osiris_DisableEvents
327 // Purpose:
328 // Disables the passed in mask of event types
329 extern void Osiris_DisableEvents(uint8_t mask);
330
331 // Osiris_DisableCreateEvents
332 // Purpose:
333 // Disables any events involved when an object is created. This is to be used for
334 // Loading games/viewing demos, as so not to re-initialize good data.
335 extern void Osiris_DisableCreateEvents(void);
336 // Osiris_EnablesCreateEvents
337 // Purpose:
338 // Enables any events involved when an object is created. This is to be used for
339 // Loading games/viewing demos, as so not to re-initialize good data. (call when done with
340 // Osiris_DisableCreateEvents())
341 extern void Osiris_EnableCreateEvents(void);
342
343 #endif