Debian Codegraph @

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