Debian Codegraph @

Descent3/Inventory.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/Inventory.h $
21 * $Revision: 46 $
22 * $Date: 4/28/99 5:22a $
23 * $Author: Jeff $
24 *
25 * Inventory control header
26 *
27 * $Log: /DescentIII/main/Inventory.h $
28 *
29 * 46 4/28/99 5:22a Jeff
30 * added function to get list of inventory items, without having to go
31 * through inventory one by one
32 *
33 * 45 4/20/99 3:06p Jeff
34 * fixed inventory displaying of non-usable items
35 *
36 * 44 4/20/99 1:14p Samir
37 * added function to determine if inventory item is usable.
38 *
39 * 43 4/14/99 3:56a Jeff
40 * fixed case mismatch in #includes
41 *
42 * 42 3/02/99 4:41p Jeff
43 * Fixed inventory save/load
44 *
45 * 41 2/25/99 8:54p Jeff
46 * Inventory supports level change persistant items. Inventory supports
47 * time-out objects. Inventory Reset changed (takes a level of reset
48 * now). Quad lasers stay across level change (single player). Guidebot
49 * bug fixed (now back in ship on level start). Quads time out when
50 * spewed. Invulnerability and cloak powerups no longer use game
51 * event/callbacks, so they can be saved in game saves (moved to
52 * MakePlayerInvulnerable and MakeObjectInvisible)
53 *
54 * 40 2/23/99 7:37p Jeff
55 * fixed reset so it doesn't remove non-spewable items...made multiplayer
56 * friendly
57 *
58 * 39 2/14/99 4:29a Jeff
59 * able to set custom descriptions for an item when adding it
60 *
61 * 38 2/13/99 12:37a Jeff
62 * new inventory system. Supports objects that don't die when put in (by
63 * objhandles). Also changed Inventory::Reset()
64 *
65 * 37 2/08/99 5:25p Jeff
66 * removed all calls to MultiSendRemoveObject, incorportated into
67 * SetObjectDeadFlag. Fixes sequencing issues in multiplayer
68 *
69 * 36 1/18/99 2:46p Matt
70 * Combined flags & flags2 fields in object struct
71 *
72 * 35 1/13/99 2:28a Chris
73 * Massive AI, OSIRIS update
74 *
75 * 34 1/08/99 2:55p Samir
76 * Ripped out OSIRIS1.
77 *
78 * 33 11/11/98 12:05p Jeff
79 * made inventory.add(object *) a private function...dangerous for
80 * multiplayer if called
81 *
82 * 32 8/19/98 2:17p Jeff
83 * added a function to get the aux type/id
84 *
85 * 31 8/19/98 12:38p Jason
86 * made countermeasure spewing work correctly
87 *
88 * 30 8/13/98 11:56a Jeff
89 * handle new flags for inventory use
90 *
91 * 29 8/10/98 2:20p Jeff
92 * reset takes a bool now whether to reset everything
93 *
94 * 28 7/10/98 7:49p Jeff
95 * fixed way of getting icon info for countermeasure
96 *
97 * 27 7/08/98 6:01p Jeff
98 * first chance at making multiplayer friendly
99 *
100 * 26 7/06/98 7:17p Jeff
101 * countermeasure support added
102 *
103 * 25 7/03/98 3:10p Jeff
104 * some error handling and added functions to get inventory information
105 *
106 * 24 4/24/98 7:09p Jeff
107 * added a flag for non-useable inventory items
108 *
109 * 23 4/23/98 12:02p Jeff
110 * added a limit to how many items you can put in your inventory
111 *
112 * 22 4/19/98 7:32p Jeff
113 * Moved inventory wrappers to DLLWrappers
114 *
115 * 21 4/03/98 11:49a Jeff
116 * Added another function wrapper, renamed others to fit naming convention
117 *
118 * 20 3/31/98 3:55p Jeff
119 * Added some inventory wrappers
120 *
121 * 19 3/26/98 2:58p Jeff
122 * Added a GetTypeIDCount function
123 *
124 * 18 3/23/98 5:36p Jeff
125 * added a parameter to Add to specify if you want it destroyed when it's
126 * added
127 *
128 * 17 3/20/98 2:44p Jeff
129 * removed ValidatePos() from ResetPos()....ValidatePos() should be called
130 * after a ResetPos() if you want to make sure you are on a selectable
131 * item
132 *
133 * 16 2/20/98 5:02p Jeff
134 * fixed bug so you can switch to a nonselectable item while playing the
135 * game
136 *
137 * 15 2/20/98 4:56p Jeff
138 * Changed inventory so it now supports non selectable items, plus made
139 * the list into a circular list
140 *
141 * 14 2/15/98 4:49p Jeff
142 * Added a reset function to clear the inventory
143 *
144 * 13 2/11/98 4:54p Jeff
145 * Moved the inventory into the Player struct
146 *
147 * 12 2/09/98 4:58p Jeff
148 * Connected inventory to hud
149 *
150 * 11 2/07/98 6:34p Jeff
151 *
152 * 10 2/06/98 2:04p Jeff
153 * inventory system much more stable now, and works with telcom
154 *
155 * 9 2/05/98 7:38p Jeff
156 * changed inventory system completly...now is classes...works in telcom
157 * to, added use feature
158 *
159 * 8 2/04/98 7:42p Jeff
160 * began connecting telcom to inventory
161 *
162 * 7 2/04/98 12:18p Jeff
163 *
164 * 6 2/03/98 6:15p Jeff
165 *
166 * 5 1/31/98 8:49p Jeff
167 * Added a function to count the number of items in the inventory
168 *
169 * 4 1/31/98 8:12p Jeff
170 * Added more inventory functions
171 *
172 * 3 1/30/98 7:02p Jeff
173 * wrote basic internals inven system
174 *
175 * 2 1/29/98 3:52p Jeff
176 * initial creation
177 *
178 * $NoKeywords: $
179 */
180
181 #ifndef __INVENTORY_H__
182 #define __INVENTORY_H__cxx . . $ `Descent3/Inventory.h:182:9`!
183
184 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
185 #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/
186
187 struct objectcxx . . $ object#;
188
189 #define MAX_UNIQUE_INVEN_ITEMScxx . . $ `Descent3/Inventory.h:189:9`! 10
190
191 #define INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`! 0x0003 // old 1
192 #define INVF_USEABLEcxx . . $ `Descent3/Inventory.h:192:9`! 0x0003 // old 2
193 #define INVF_MISSIONITEMcxx . . $ `Descent3/Inventory.h:193:9`! 0x0004 // this item lasts across levels
194 #define INVF_NOREMOVEONUSEcxx . . $ `Descent3/Inventory.h:194:9`! 0x0008
195 #define INVF_VISWHENUSEDcxx . . $ `Descent3/Inventory.h:195:9`! 0x0010
196 #define INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`! 0x0020 // this item isn't a type/id...but an objhandle
197 #define INVF_NOTSPEWABLEcxx . . $ `Descent3/Inventory.h:197:9`! 0x0040 // this object should not spew...stay in inventory after death
198 #define INVF_TIMEOUTONSPEWcxx . . $ `Descent3/Inventory.h:198:9`! 0x0080 // this object/item times out when it's spewed
199
200 // Inventory reset stage settings
201 #define INVRESET_ALLcxx . . $ `Descent3/Inventory.h:201:9`! 0
202 #define INVRESET_LEVELCHANGEcxx . . $ `Descent3/Inventory.h:202:9`! 1
203 #define INVRESET_DEATHSPEWcxx . . $ `Descent3/Inventory.h:203:9`! 2
204
205 struct tInvenListcxx . . $ tInvenList# {
206 bool selectablecxx . . $ tInvenList#selectable.;
207 char *hud_namecxx . . $ tInvenList#hud_name.;
208 int amountcxx . . $ tInvenList#amount.;
209 };
210
211 struct tInvenInfocxx . . $ tInvenInfo# {
212 int countcxx . . $ tInvenInfo#count.;
213 char *descriptioncxx . . $ tInvenInfo#description.;
214 char *icon_namecxx . . $ tInvenInfo#icon_name.;
215 char *namecxx . . $ tInvenInfo#name.;
216 int flagscxx . . $ tInvenInfo#flags.;
217 uint16_tcxx . . $ uint16_t# iflagscxx . . $ tInvenInfo#iflags.; // Inventory item flags
218 int typecxx . . $ tInvenInfo#type.;
219 int idcxx . . $ tInvenInfo#id.;
220 };
221
222 struct inven_itemcxx . . $ inven_item# {
223
224 int typecxx . . $ inven_item#type.; // what type of object this is... robot, weapon, hostage, powerup, fireball
225 // if INVF_OBJECT, this is the object handle
226 int otypecxx . . $ inven_item#otype.; // countermeasure powerup type
227 int idcxx . . $ inven_item#id.; // which form of object...which powerup, robot, etc.
228 // if INVF_OBJECT, this is -1
229 int oidcxx . . $ inven_item#oid.; // countermeasure powerup id
230 int flagscxx . . $ inven_item#flags.; // misc flags
231 uint16_tcxx . . $ uint16_t# pad2cxx . . $ inven_item#pad2.; // keep alignment
232
233 int countcxx . . $ inven_item#count.; // how many of this type/id (not INVF_OBJECT)
234
235 char *descriptioncxx . . $ inven_item#description.;
236 char *icon_namecxx . . $ inven_item#icon_name.;
237 char *namecxx . . $ inven_item#name.;
238
239 uint16_tcxx . . $ uint16_t# iflagscxx . . $ inven_item#iflags.; // Inventory item flags
240
241 inven_itemcxx . . $ inven_item# *nextcxx . . $ inven_item#next., *prevcxx . . $ inven_item#prev.; // pointer to next inventory item
242 };
243
244 class Inventorycxx . . $ Inventory# {
245 public:
246 Inventorycxx . . $ Inventory#Inventory(49f6e7a06ebc5aa8).();
247 ~cxx . . $ Inventory#`~Inventory`(49f6e7a06ebc5aa8).Inventorycxx . . $ Inventory#();
248 // adds a type/id item to the inventory (returns true on success)
249 bool Addcxx . . $ Inventory#Add(122d808d8b1091da).(int type, int id, objectcxx . . $ object# *parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, int aux_type = -1, int aux_id = -1, int flags = 0,
250 const char *description = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
251 // adds an object to the inventory (marked by it's objhandle)
252 bool AddObjectcxx . . $ Inventory#AddObject(bc9c4eeb54e60257).(int object_handle, int flags = 0, const char *description = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
253 // adds a special cased CounterMeasure into the inventory
254 bool AddCounterMeasurecxx . . $ Inventory#AddCounterMeasure(1165f2dcd82ced24).(int id, int aux_type = -1, int aux_id = -1, int flags = 0, const char *description = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
255 // removes an item from the inventory (reduces it's count by one...if there is no more, then it goes bye-bye)
256 bool Removecxx . . $ Inventory#Remove(cf9ef193275fa6d8).(int type, int id = -1);
257 // uses an item in the inventory (also reduces its count by one...if there is no more, then it goes bye-bye)
258 bool Usecxx . . $ Inventory#Use(cc3bfdd2c949b92e).(int type, int id, objectcxx . . $ object# *parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
259 bool Usecxx . . $ Inventory#Use(bf595291c30e3265).(int objhandle, objectcxx . . $ object# *parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
260 // returns how many unique type/ids are in the inventory
261 int Sizecxx . . $ Inventory#Size(b126dc7c1de90089).(void);
262 // returns true if there is an item in the inventory with the given type/id (or objhandle if id is -1)
263 bool CheckItemcxx . . $ Inventory#CheckItem(cf9ef193275fa6d8).(int type, int id = -1);
264 // Resets the inventory, cleaning it out
265 // in_game: set to true if this is being called from during gameplay
266 // reset_stage:
267 // INVRESET_ALL: Reset _EVERYTHING_
268 // INVRESET_LEVELCHANGE: Remove everything except those that last across levels
269 // INVRESET_DEATHSPEW: Remove everything except those that do not spew (Default)
270 void Resetcxx . . $ Inventory#Reset(b994e01f1c45a386).(bool in_game, int reset_stage = INVRESET_DEATHSPEWcxx . . $ `Descent3/Inventory.h:203:9`!);
271 // resets the position pointer in the list to the beginning
272 void ResetPoscxx . . $ Inventory#ResetPos(49f6e7a06ebc5aa8).(void);
273 // moves the position pointer to the next inventory item
274 void NextPoscxx . . $ Inventory#NextPos(b45ddcbc8423892c).(bool skip = false);
275 // moves the position pointer to the previous inventory item
276 void PrevPoscxx . . $ Inventory#PrevPos(b45ddcbc8423892c).(bool skip = false);
277 // returns the type/id of the item at the current position
278 // return true if it is a real object
279 bool GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(int &type, int &id);
280 // returns the aux type/id of the item
281 // return true if it is a real object
282 bool GetAuxPosTypeIDcxx . . $ Inventory#GetAuxPosTypeID(8a990ad1ed500b42).(int &type, int &id);
283 // returns the description of the item at the current position
284 char *GetPosDescriptioncxx . . $ Inventory#GetPosDescription(41208ce6ca65dd58).(void);
285 // returns the icon name of the item at the current position
286 char *GetPosIconNamecxx . . $ Inventory#GetPosIconName(41208ce6ca65dd58).(void);
287 // returns the name of the item at the current position
288 char *GetPosNamecxx . . $ Inventory#GetPosName(41208ce6ca65dd58).(void);
289 // return information about the current position item
290 // return true if it is a real object
291 bool GetPosInfocxx . . $ Inventory#GetPosInfo(a9f116dbdd7af36d).(uint16_tcxx . . $ uint16_t# &iflags, int &flags);
292 // returns the count of the item at the current position
293 int GetPosCountcxx . . $ Inventory#GetPosCount(b126dc7c1de90089).(void);
294 // returns true if the position pointer is at the begining of the inventory list
295 bool AtBeginningcxx . . $ Inventory#AtBeginning(c9857a73d68e59ba).(void);
296 // returns false if the position pointer is at the end of the inventory list
297 bool AtEndcxx . . $ Inventory#AtEnd(c9857a73d68e59ba).(void);
298 // jump right to an item in the inventory
299 void GotoPoscxx . . $ Inventory#GotoPos(d4f767463ce0a6b3).(int newpos);
300 void GotoPoscxx . . $ Inventory#GotoPos(3e454b8ccf442868).(int type, int id);
301 // uses the currently selected item
302 bool UsePoscxx . . $ Inventory#UsePos(39516aeee13ca5ab).(objectcxx . . $ object# *parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
303 // returns the 'index' position of the current position
304 int GetPoscxx . . $ Inventory#GetPos(b126dc7c1de90089).(void);
305 // checks the pos, if its on a nonselectable item it will move to the next selectable (NULL if none)
306 void ValidatePoscxx . . $ Inventory#ValidatePos(b45ddcbc8423892c).(bool forward = true);
307 // returns whether an item is selectable
308 bool IsSelectablecxx . . $ Inventory#IsSelectable(c9857a73d68e59ba).(void);
309 bool IsUsablecxx . . $ Inventory#IsUsable(c9857a73d68e59ba).(void);
310 // returns how many of an type/id is in the inventory
311 int GetTypeIDCountcxx . . $ Inventory#GetTypeIDCount(9b79fb6aee4c0440).(int type, int id);
312 // searches the inventory for the specified type/id, sets the pos to it
313 bool FindPoscxx . . $ Inventory#FindPos(cf9ef193275fa6d8).(int type, int id = -1);
314 // saves the inventory to the file (returns number of bytes written)
315 int SaveInventorycxx . . $ Inventory#SaveInventory(413716a422df0036).(CFILEcxx . . $ CFILE# *file);
316 // restores the inventory from file (returns number of bytes read)
317 int ReadInventorycxx . . $ Inventory#ReadInventory(413716a422df0036).(CFILEcxx . . $ CFILE# *file);
318 // gets a detailed list of information about what is in the inventory
319 // returns the number of items filled in.
320 int GetInventoryItemListcxx . . $ Inventory#GetInventoryItemList(e2f4838e36fa1452).(tInvenListcxx . . $ tInvenList# *list, int max_amount, int *cur_sel);
321
322 private:
323 // adds an item to the inventory (returns true on success)
324 bool AddObjectItemcxx . . $ Inventory#AddObjectItem(260f7ee685ef8f73).(int otype, int oid, int oauxt, int oauxi, int flags, const char *description = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
325 void RemoveNodecxx . . $ Inventory#RemoveNode(95bff11ddb5ad274).(inven_itemcxx . . $ inven_item# *node);
326 // sends a request to the server to use a particular item in the inventory
327 void SendRequestToServerToUsecxx . . $ Inventory#SendRequestToServerToUse(3e454b8ccf442868).(int type, int id = -1);
328 inven_itemcxx . . $ inven_item# *FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(int type, int id = -1);
329 inven_itemcxx . . $ inven_item# *rootcxx . . $ Inventory#root.;
330 int countcxx . . $ Inventory#count.;
331 inven_itemcxx . . $ inven_item# *poscxx . . $ Inventory#pos.; // used when looking through inventory
332 };
333
334 void InventorySwitchcxx . . $ InventorySwitch(b45ddcbc8423892c).(bool forward);
335 // moves to the next/prev item in the counter measures list (forward==TRUE means forward, forward==FALSE means go
336 // backwards)
337 void CounterMeasuresSwitchcxx . . $ CounterMeasuresSwitch(b45ddcbc8423892c).(bool forward);
338 // Checks for an object in any of the players inventorys and removes it
339 void InventoryRemoveObjectcxx . . $ InventoryRemoveObject(d4f767463ce0a6b3).(int objhandle);
340
341 #endif