Debian Codegraph @

netgames/coop/coop.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/coop/coop.h $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003/08/26 03:56:42 $
23 * $Author: kevinb $
24 *
25 * Co-Op play
26 *
27 * $Log: coop.h,v $
28 * Revision 1.1.1.1 2003/08/26 03:56:42 kevinb
29 * initial 1.5 import
30 *
31 *
32 * 8 10/21/99 9:28p Jeff
33 * B.A. Macintosh code merge
34 *
35 * 7 3/22/99 5:51p Matt
36 * Removed some includes from one file and added some to other files, to
37 * reduce the amount of rebuilding when headers change.
38 *
39 * 6 3/19/99 12:54p Jeff
40 * base support for requesting the number of teams for a multiplayer game
41 *
42 * 5 3/17/99 12:23p Jeff
43 * converted DMFC to be COM interface
44 *
45 * 4 2/08/99 12:46a Jeff
46 * updated
47 *
48 * 3 2/07/99 2:06a Jeff
49 * updated coop...fixed bug when getting countermeasure owner, if owner is
50 * observer
51 *
52 * 2 2/03/99 8:48p Josh
53 * Luke: Checked in for Josh (copied from Jeff) so he could work
54 *
55 * 1 2/03/99 8:47p Josh
56 *
57 * $NoKeywords: $
58 */
59
60 #ifndef __DMFC_APP_H_
61 #define __DMFC_APP_H_
62
63 #include "osiris_share.h"
64 #include "d3events.h"
65
66 void OnHUDInterval(void);
67 void OnInterval(void);
68 void OnKeypress(int key);
69 void OnClientPlayerEntersGame(int player_num);
70 void OnServerObjectKilled(object *obj, object *killer);
71 void OnClientObjectKilled(object *obj, object *killer);
72 void OnPlayerConnect(int player_num);
73 void OnServerGameCreated(void);
74 void OnClientLevelStart(void);
75 void OnGameStateRequest(int player_num);
76 void SaveStatsToFile(char *filename);
77 void OnSaveStatsToFile(void);
78 void OnLevelEndSaveStatsToFile(void);
79 void OnDisconnectSaveStatsToFile(void);
80 void OnPrintScores(int level);
81 extern IDMFC *DMFCBase;
82
83 // These next two function prototypes MUST appear in the extern "C" block if called
84 // from a CPP file.
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 DLLEXPORT void DLLFUNCCALL DLLGameInit(int *api_func, uint8_t *all_ok, int num_teams_to_use);
89 DLLEXPORT void DLLFUNCCALL DLLGameCall(int eventnum, dllinfo *data);
90 DLLEXPORT void DLLFUNCCALL DLLGameClose();
91 DLLEXPORT void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options);
92 DLLEXPORT int DLLFUNCCALL GetGOScriptID(const char *name, uint8_t isdoor);
93 DLLEXPORT void DLLFUNCCALLPTR CreateInstance(int id);
94 DLLEXPORT void DLLFUNCCALL DestroyInstance(int id, void *ptr);
95 DLLEXPORT int16_t DLLFUNCCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo *data);
96 DLLEXPORT int DLLFUNCCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
97 #ifdef __cplusplus
98 }
99 #endif
100
101
102 // The main entry point where the game calls the dll
103 void DLLFUNCCALL DLLGameCall(int eventnum, dllinfo *data) {
104 if ((eventnum < EVT_CLIENT_INTERVAL) && (DMFCBase->GetLocalRole() != LR_SERVER)) {
105 return;
106 }
107
108 DMFCBase->TranslateEvent(eventnum, data);
109 }
110
111 // GetGOScriptID
112 // Purpose:
113 // Given the name of the object (from it's pagename), this function will search through it's
114 // list of General Object Scripts for a script with a matching name (to see if there is a script
115 // for that type/id of object within this DLL). If a matching scriptname is found, a UNIQUE ID
116 // is to be returned back to Descent 3. This ID will be used from here on out for all future
117 // interaction with the DLL. Since doors are not part of the generic object's, it's possible
118 // for a door to have the same name as a generic object (OBJ_POWERUP, OBJ_BUILDING, OBJ_CLUTTER
119 // or OBJ_ROBOT), therefore, a 1 is passed in for isdoor if the given object name refers to a
120 // door, else it is a 0. The return value is the unique identifier, else -1 if the script
121 // does not exist in the DLL.
122 int DLLFUNCCALL GetGOScriptID(const char *name, uint8_t isdoor) { return -1; }
123
124 // CreateInstance
125 // Purpose:
126 // Given an ID from a call to GetGOScriptID(), this function will create a new instance for that
127 // particular script (by allocating and initializing memory, etc.). A pointer to this instance
128 // is to be returned back to Descent 3. This pointer will be passed around, along with the ID
129 // for CallInstanceEvent() and DestroyInstance(). Return NULL if there was an error.
130 void DLLFUNCCALLPTR CreateInstance(int id) { return NULL; }
131
132 // DestroyInstance
133 // Purpose:
134 // Given an ID, and a pointer to a particular instance of a script, this function will delete and
135 // destruct all information associated with that script, so it will no longer exist.
136 void DLLFUNCCALL DestroyInstance(int id, void *ptr) {}
137
138 // CallInstanceEvent
139 // Purpose:
140 // Given an ID, a pointer to a script instance, an event and a pointer to the struct of
141 // information about the event, this function will translate who this event belongs to and
142 // passes the event to that instance of the script to be handled. Return a combination of
143 // CONTINUE_CHAIN and CONTINUE_DEFAULT, to give instructions on what to do based on the
144 // event. CONTINUE_CHAIN means to continue through the chain of scripts (custom script, level
145 // script, mission script, and finally default script). If CONTINUE_CHAIN is not specified,
146 // than the chain is broken and those scripts of lower priority will never get the event. Return
147 // CONTINUE_DEFAULT in order to tell D3 if you want process the normal action that is built into
148 // the game for that event. This only pertains to certain events. If the chain continues
149 // after this script, than the CONTINUE_DEFAULT setting will be overridden by lower priority
150 // scripts return value.
151 int16_t DLLFUNCCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo *data) {
152 return CONTINUE_CHAIN | CONTINUE_DEFAULT;
153 }
154
155 // SaveRestoreState
156 // Purpose:
157 // This function is called when Descent 3 is saving or restoring the game state. In this function
158 // you should save/restore any global data that you want preserved through load/save (which includes
159 // demos). You must be very careful with this function, corrupting the file (reading or writing too
160 // much or too little) may be hazardous to the game (possibly making it impossible to restore the
161 // state). It would be best to use version information to keep older versions of saved states still
162 // able to be used. IT IS VERY IMPORTANT WHEN SAVING THE STATE TO RETURN THE NUMBER OF _BYTES_ WROTE
163 // TO THE FILE. When restoring the data, the return value is ignored. saving_state is 1 when you should
164 // write data to the file_ptr, 0 when you should read in the data.
165 int DLLFUNCCALL SaveRestoreState(void *file_ptr, uint8_t saving_state) { return 0; }
166
167
168 #endif