Debian Codegraph @

lib/game2dll.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 GAME2DLL_H
20 #define GAME2DLL_H
21
22 #include "pstypes.h"
23 #include "multi.h"
24
25 #include "d3events.h"
26 #include "vecmat.h"
27
28 struct tPreJoinData {
29 bool is_banned;
30 int team;
31 };
32
33 struct game_collide_info {
34 vector point, normal;
35 float hitspeed, hit_dot;
36 int hitseg, hitwall;
37 };
38
39 struct dllinfo {
40 int me_handle;
41 int it_handle;
42 uint8_t *special_data;
43 char *input_string;
44 int input_key;
45 union {
46 int iRet;
47 float fRet;
48 };
49 float fParam;
50 ptrdiff_t iParam;
51 game_collide_info collide_info;
52 int newseg, oldseg;
53 };
54
55 #define MAX_GAMENAME_LEN 32
56 #define MAX_REQUIREMENT_LEN 384
57 #define DOF_MAXTEAMS 0x0001 // max_teams member is valid
58 #define DOF_MINTEAMS 0x0002
59 // this struct is used to return game specific information to Descent 3
60 struct tDLLOptions {
61 // general flags, also specifies what members of the structure are valid
62 int flags;
63
64 // 0 or 1 for non-team games...maximum value is 4. If not specified, than it is assumed 0
65 int max_teams;
66 // must be less then or equal to max_teams. If not specified, then it is assumed 0 for
67 // non-team games, 2 for team games. (max_teams will always tell you if it's a team game)
68 int min_teams;
69
70 // gives the full name of the game (must be set)
71 char game_name[MAX_GAMENAME_LEN];
72
73 // this is an array of semicolor seperated 'string identifiers' that serve as requirements
74 // the mission needs to support in order for it to be playable with the game.
75 // this parameter must be set (even it is just a '\0' for the first character..aka no requirements)
76 char requirements[MAX_REQUIREMENT_LEN];
77
78 };
79
80 extern dllinfo DLLInfo;
81
82 // The chokepoint function to call the dll function
83 void CallGameDLL(int eventnum, dllinfo *data);
84
85 // Frees the dll if its in memory
86 void FreeGameDLL();
87
88 // Loads the game dll. Returns 1 on success, else 0 on failure
89 int LoadGameDLL(const char *name, int num_teams_to_use = -1);
90
91 // If this function is called than the DLL is to be closed, because there was an error running it
92 // if reason is not NULL than that is the reason why
93 void DLLFatalError(const char *reason = NULL);
94
95 // Call this function right after a player connects to the game to see if a player is banned
96 bool GameDLLIsAddressBanned(network_address *addr, const char *tracker_id);
97
98 // Call this function to get information/options from a unloaded mod
99 bool GetDLLGameInfo(const char *name, tDLLOptions *options);
100
101 // Call this function to get information about the number of teams for the game
102 // Returns true if it's a team game...false if it's a non-team game.
103 // If it returns true, then min is filled in with the minumum number of teams needed for the game
104 // and max is filled in with the maximum number of teams for the game...if they are the same
105 // value, then it is the only number of teams supported.
106 bool GetDLLNumTeamInfo(const char *name, int *mint, int *maxt);
107
108 // Call this function to get the list of requirements that the given module needs in order
109 // to be playable. Returns the number of requirements it needs...-1 on error.
110 int GetDLLRequirements(const char *name, char *requirements, int buflen);
111
112 #endif