Debian Codegraph @

netgames/hyperanarchy/HyperAnarchy.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
19 #ifndef __HYPERANARCHY_APP_H_
20 #define __HYPERANARCHY_APP_H_
21
22 #include "osiris_share.h"
23 #include "d3events.h"
24
25 //!!!!!!!ADD YOUR EVENT HANDLER OVERRIDES HERE!!!!!!!!!!!
26 void OnInterval(void);
27 void OnHUDInterval(void);
28 void OnKeypress(int key);
29 void OnServerGameCreated(void);
30 void OnServerLevelStart(void);
31 void OnClientLevelStart(void);
32 void OnClientLevelEnd(void);
33 void OnGameStateRequest(int player_num);
34 void OnPlayerConnect(int player_num);
35 void OnServerCollide(object *me_obj, object *it_obj);
36 void OnClientCollide(object *me_obj, object *it_obj);
37 void OnClientPlayerKilled(object *killer_obj, int victim_pnum);
38 void OnPLRInterval(void);
39 void OnPLRInit(void);
40 void OnServerPlayerDisconnect(int player_num);
41 void OnClientPlayerDisconnect(int player_num);
42 void OnSaveStatsToFile(void);
43 void OnLevelEndSaveStatsToFile(void);
44 void OnDisconnectSaveStatsToFile(void);
45 void OnPrintScores(int);
46 void OnPlayerEntersObserver(int pnum, object *piggy);
47 extern IDMFC *DMFCBase;
48
49 // These next two function prototypes MUST appear in the extern "C" block if called
50 // from a CPP file.
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 DLLEXPORT void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_use);
55 DLLEXPORT void DLLFUNCCALL DLLGameCall(int eventnum, dllinfo *data);
56 DLLEXPORT void DLLFUNCCALL DLLGameClose();
57 DLLEXPORT void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options);
58 DLLEXPORT int DLLFUNCCALL GetGOScriptID(const char *name, uint8_t isdoor);
59 DLLEXPORT void DLLFUNCCALLPTR CreateInstance(int id);
60 DLLEXPORT void DLLFUNCCALL DestroyInstance(int id, void *ptr);
61 DLLEXPORT int16_t DLLFUNCCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo *data);
62 DLLEXPORT int DLLFUNCCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
63 #ifdef __cplusplus
64 }
65 #endif
66
67
68 // The main entry point where the game calls the dll
69 void DLLFUNCCALL DLLGameCall(int eventnum, dllinfo *data) {
70 if ((eventnum < EVT_CLIENT_INTERVAL) && (DMFCBase->GetLocalRole() != LR_SERVER)) {
71 return;
72 }
73
74 DMFCBase->TranslateEvent(eventnum, data);
75 }
76
77 // GetGOScriptID
78 // Purpose:
79 // Given the name of the object (from it's pagename), this function will search through it's
80 // list of General Object Scripts for a script with a matching name (to see if there is a script
81 // for that type/id of object within this DLL). If a matching scriptname is found, a UNIQUE ID
82 // is to be returned back to Descent 3. This ID will be used from here on out for all future
83 // interaction with the DLL. Since doors are not part of the generic object's, it's possible
84 // for a door to have the same name as a generic object (OBJ_POWERUP, OBJ_BUILDING, OBJ_CLUTTER
85 // or OBJ_ROBOT), therefore, a 1 is passed in for isdoor if the given object name refers to a
86 // door, else it is a 0. The return value is the unique identifier, else -1 if the script
87 // does not exist in the DLL.
88 int DLLFUNCCALL GetGOScriptID(const char *name, uint8_t isdoor) { return -1; }
89
90 // CreateInstance
91 // Purpose:
92 // Given an ID from a call to GetGOScriptID(), this function will create a new instance for that
93 // particular script (by allocating and initializing memory, etc.). A pointer to this instance
94 // is to be returned back to Descent 3. This pointer will be passed around, along with the ID
95 // for CallInstanceEvent() and DestroyInstance(). Return NULL if there was an error.
96 void DLLFUNCCALLPTR CreateInstance(int id) { return NULL; }
97
98 // DestroyInstance
99 // Purpose:
100 // Given an ID, and a pointer to a particular instance of a script, this function will delete and
101 // destruct all information associated with that script, so it will no longer exist.
102 void DLLFUNCCALL DestroyInstance(int id, void *ptr) {}
103
104 // CallInstanceEvent
105 // Purpose:
106 // Given an ID, a pointer to a script instance, an event and a pointer to the struct of
107 // information about the event, this function will translate who this event belongs to and
108 // passes the event to that instance of the script to be handled. Return a combination of
109 // CONTINUE_CHAIN and CONTINUE_DEFAULT, to give instructions on what to do based on the
110 // event. CONTINUE_CHAIN means to continue through the chain of scripts (custom script, level
111 // script, mission script, and finally default script). If CONTINUE_CHAIN is not specified,
112 // than the chain is broken and those scripts of lower priority will never get the event. Return
113 // CONTINUE_DEFAULT in order to tell D3 if you want process the normal action that is built into
114 // the game for that event. This only pertains to certain events. If the chain continues
115 // after this script, than the CONTINUE_DEFAULT setting will be overridden by lower priority
116 // scripts return value.
117 int16_t DLLFUNCCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo *data) {
118 return CONTINUE_CHAIN | CONTINUE_DEFAULT;
119 }
120
121 // SaveRestoreState
122 // Purpose:
123 // This function is called when Descent 3 is saving or restoring the game state. In this function
124 // you should save/restore any global data that you want preserved through load/save (which includes
125 // demos). You must be very careful with this function, corrupting the file (reading or writing too
126 // much or too little) may be hazardous to the game (possibly making it impossible to restore the
127 // state). It would be best to use version information to keep older versions of saved states still
128 // able to be used. IT IS VERY IMPORTANT WHEN SAVING THE STATE TO RETURN THE NUMBER OF _BYTES_ WROTE
129 // TO THE FILE. When restoring the data, the return value is ignored. saving_state is 1 when you should
130 // write data to the file_ptr, 0 when you should read in the data.
131 int DLLFUNCCALL SaveRestoreState(void *file_ptr, uint8_t saving_state) { return 0; }
132
133
134 #endif