Debian Codegraph @

Descent3/DllWrappers.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 DLLWRAPPERS_H_
20 #define DLLWRAPPERS_H_
21
22 #include "pserror.h"
23 #include "cfile.h"
24 #include "gamefont.h"
25 #include "grdefs.h"
26 #include "descent.h"
27 #include "ddio.h"
28 #include "d3movie.h"
29 #include "program.h"
30 #include "object.h"
31 #include "hlsoundlib.h"
32 #include "Inventory.h"
33
34 // plays a 3dsound
35 int D3W_Play3dSound(int sound_index, object *cur_obj, float volume = MAX_GAME_VOLUME, int flags = 0);
36 int D3W_Play2dSound(int sound_index, float volume);
37 void D3W_TouchSound(int sound_index);
38
39 // for mprintfs
40 void MonoPrintf(int n, char *format, ...);
41 // checks a players inventory for an object type/id
42 bool InvCheckItem(int playernum, int type, int id);
43 // adds an object to a player inventory
44 bool InvAdd(int playernum, object *obj, bool remove = true);
45 // adds a type/id to a player inventory
46 bool InvAddTypeID(int playernum, int type, int id, int aux_type = -1, int aux_id = -1, int flags = 0, const char *description = NULL);
47 // removes a type/id from a players inventory
48 bool InvRemove(int playernum, int type, int id);
49 // returns how many of a type/id a player has in his inventory
50 int InvGetTypeIDCount(int playernum, int type, int id);
51 // Inventory Reset wrapper
52 void InvReset(int playernum, bool reset_all = true);
53 // wraps cfopen
54 void OpenCFILE(CFILE **handle, const std::filesystem::path &filename, const char *mode);
55 // wrapper for ObjGetUltimateParent
56 void GetUltimateParentForObject(object **parent, object *child);
57 // sets an object's flag dead
58 void SetObjectDeadFlagDLL(object *obj, bool tell_client_to_remove = false, bool tell_clients_to_play_sound = false);
59 // Assert for the DLLs
60 void assertdll(int x, const char *expression, const char *file, int line);
61 void RetrieveUICallback(void **fn);
62
63 // Registry database functions
64 bool dDatabaseRead1(const char *label, char *entry, int *entrylen);
65 bool dDatabaseRead2(const char *label, void *entry, int wordsize);
66 bool dDatabaseRead3(const char *label, bool *entry);
67 bool dDatabaseWrite1(const char *label, const char *entry, int entrylen);
68 bool dDatabaseWrite2(const char *label, int entry);
69 bool dObjGet(int handle, object **obj);
70
71 // Attaches 2 objects via attach points on each. The f_used_aligned allows for an aligned connection.
72 // NOTE: The child always moves to the parent
73 bool dAttachObject(object *parent, char parent_ap, object *child, char child_ap, bool f_use_aligned = false);
74 // Attaches a child object to a parent object by a percent of the radius of the child.
75 // NOTE: The child always moves to the parent and not the reverse
76 bool dAttachObjectRadius(object *parent, char parent_ap, object *child, float percent_rad);
77 // Unattaches all children from a parent object
78 bool dUnattachChildren(object *parent);
79 // Unattaches a child from an attach point
80 bool dUnattachChild(object *parent, char parent_ap);
81 // Unattaches an object from its parent
82 bool dUnattachFromParent(object *child);
83 // Set a vector to {0,0,0}
84 void dvm_MakeZeroVector(vector *v);
85 void dvm_MakeZeroAngle(angvec *v);
86 void dStartFrame(int x, int y, int x2, int y2, bool clear);
87
88 // ObjSetPos, that automatically sets the OF_MOVED_THIS_FRAME
89 void ObjSetPosAndMarkMoved(object *obj, vector *pos, int roomnum, matrix *orient, bool f_update_attached_children);
90 // SetObjectDeadFlag that automatically writes out demo data
91 void dSetObjectDeadFlagWDemo(object *obj, bool tell_clients_to_remove = false, bool tell_clients_to_play_sound = false);
92 void dSetAudioTaunts(bool enable);
93
94 // Changes the ship_index for a given player
95 void ChangePlayerShipIndex(int pnum, int ship_index);
96
97 // adds a type/id item to the inventory (returns true on success)
98 bool dInven_Add(Inventory *inven, int type, int id, object *parent = NULL, int aux_type = -1, int aux_id = -1,
99 int flags = 0, char *description = NULL);
100 // adds an object to the inventory (marked by it's objhandle)
101 bool dInven_AddObject(Inventory *inven, int object_handle, int flags = 0, char *description = NULL);
102 // adds a special cased CounterMeasure into the inventory
103 bool dInven_AddCounterMeasure(Inventory *inven, int id, int aux_type = -1, int aux_id = -1, int flags = 0,
104 char *description = NULL);
105 // removes an item from the inventory (reduces it's count by one...if there is no more, then it goes bye-bye)
106 // to remove an object that was added via objhandle, then pass the objhandle
107 // in the 'type' parameter, and don't pass in an id.
108 bool dInven_Remove(Inventory *inven, int type, int id = -1);
109 // uses an item in the inventory (also reduces its count by one...if there is no more, then it goes bye-bye)
110 bool dInven_Use(Inventory *inven, int type, int id, object *parent = NULL);
111 // uses an item in the inventory (given it's objhandle).
112 bool dInven_UseObjHandle(Inventory *inven, int objhandle, object *parent = NULL);
113 // returns how many unique type/ids are in the inventory
114 int dInven_Size(Inventory *inven);
115 // returns true if there is an item in the inventory with the given type/id (or objhandle if id is -1, pass the object
116 // handle as the type parameter)
117 bool dInven_CheckItem(Inventory *inven, int type, int id = -1);
118 // Resets the inventory, cleaning it out
119 // in_game: set to true if this is being called from during gameplay
120 // reset_stage:
121 // INVRESET_ALL: Reset _EVERYTHING_
122 // INVRESET_LEVELCHANGE: Remove everything except those that last across levels
123 // INVRESET_DEATHSPEW: Remove everything except those that do not spew (Default)
124 void dInven_Reset(Inventory *inven, bool in_game, int reset_stage = INVRESET_DEATHSPEW);
125 // resets the position pointer in the list to the beginning
126 void dInven_ResetPos(Inventory *inven);
127 // moves the position pointer to the next inventory item
128 // skip : if true then skip over non-selectable items
129 void dInven_NextPos(Inventory *inven, bool skip = false);
130 // moves the position pointer to the previous inventory item
131 // skip : if true then skip over non-selectable items
132 void dInven_PrevPos(Inventory *inven, bool skip = false);
133 // returns the type/id of the item at the current position
134 // return true if it is a real object (meaning it was placed in the inventory
135 // via an object handle...so id will be -1)
136 bool dInven_GetPosTypeID(Inventory *inven, int &type, int &id);
137 // returns the aux type/id of the item
138 // return true if it is a real object (meaning it was placed in the inventory
139 // via an object handle...so id will be -1)
140 bool dInven_GetAuxPosTypeID(Inventory *inven, int &type, int &id);
141 // returns the description of the item at the current position
142 char *dInven_GetPosDescription(Inventory *inven);
143 // returns the icon name of the item at the current position
144 char *dInven_GetPosIconName(Inventory *inven);
145 // returns the name of the item at the current position
146 char *dInven_GetPosName(Inventory *inven);
147 // return information about the current position item
148 // return true if it is a real object
149 bool dInven_GetPosInfo(Inventory *inven, uint16_t &iflags, int &flags);
150 // returns the count of the item at the current position
151 int dInven_GetPosCount(Inventory *inven);
152 // returns true if the position pointer is at the begining of the inventory list
153 bool dInven_AtBeginning(Inventory *inven);
154 // returns false if the position pointer is at the end of the inventory list
155 bool dInven_AtEnd(Inventory *inven);
156 // jump right to an item in the inventory
157 void dInven_GotoPos(Inventory *inven, int newpos);
158 // jump right to an item in the inventory give it's type and id
159 // to jump to an item that was added via object handle, pass the object
160 // handle in as the type, and make id -1.
161 void dInven_GotoPosTypeID(Inventory *inven, int type, int id);
162 // uses the currently selected item
163 bool dInven_UsePos(Inventory *inven, object *parent = NULL);
164 // returns the 'index' position of the current position
165 int dInven_GetPos(Inventory *inven);
166 // checks the pos, if its on a nonselectable item it will move to the next selectable (NULL if none)
167 void dInven_ValidatePos(Inventory *inven, bool forward = true);
168 // returns whether an item is selectable
169 bool dInven_IsSelectable(Inventory *inven);
170 bool dInven_IsUsable(Inventory *inven);
171 // returns how many of an type/id is in the inventory
172 // for object handle items, pass the object handle in as the type and leave
173 // id as -1
174 int dInven_GetTypeIDCount(Inventory *inven, int type, int id);
175 // searches the inventory for the specified type/id, sets the pos to it
176 // for object handle items, pass the object handle in as the type and leave
177 // id as -1
178 bool dInven_FindPos(Inventory *inven, int type, int id = -1);
179 // gets a detailed list of information about what is in the inventory
180 // returns the number of items filled in.
181 int dInven_GetInventoryItemList(Inventory *inven, tInvenList *list, int max_amount, int *cur_sel);
182
183 #endif