| 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.cpp $ |
| 21 | * $Revision: 80 $ |
| 22 | * $Date: 5/19/99 4:23p $ |
| 23 | * $Author: Chris $ |
| 24 | * |
| 25 | * Inventory control source file |
| 26 | * |
| 27 | * $Log: /DescentIII/main/Inventory.cpp $ |
| 28 | * |
| 29 | * 80 5/19/99 4:23p Chris |
| 30 | * Fixed level goal problems with keys and persistant inventory items |
| 31 | * |
| 32 | * 79 5/19/99 3:24p Jason |
| 33 | * fixed wrong ordering of InitObjectScripts and MultiSendObject |
| 34 | * |
| 35 | * 78 5/12/99 6:01p Jeff |
| 36 | * sanity check. fixed reset |
| 37 | * |
| 38 | * 76 5/08/99 4:12p Chris |
| 39 | * Added AI hearing noises... version 1 |
| 40 | * |
| 41 | * 75 4/29/99 1:28p Jeff |
| 42 | * play sound when switching inven/countermeasres |
| 43 | * |
| 44 | * 74 4/28/99 8:32p Jeff |
| 45 | * fixed bug adding an object to the inventory, was forgetting to set |
| 46 | * count |
| 47 | * |
| 48 | * 73 4/28/99 5:20p Jeff |
| 49 | * fixed missing return |
| 50 | * |
| 51 | * 72 4/28/99 5:22a Jeff |
| 52 | * added function to get list of inventory items, without having to go |
| 53 | * through inventory one by one |
| 54 | * |
| 55 | * 71 4/25/99 5:20p Chris |
| 56 | * Made the GB work with the inventory system... CT_AI not remapped for |
| 57 | * non-vis USED inventory items. |
| 58 | * |
| 59 | * 70 4/20/99 3:06p Jeff |
| 60 | * fixed inventory displaying of non-usable items |
| 61 | * |
| 62 | * 69 4/20/99 1:14p Samir |
| 63 | * added function to determine if inventory item is usable. |
| 64 | * |
| 65 | * 68 4/14/99 2:50a Jeff |
| 66 | * fixed some case mismatched #includes |
| 67 | * |
| 68 | * 67 3/02/99 4:41p Jeff |
| 69 | * Fixed inventory save/load |
| 70 | * |
| 71 | * 66 2/25/99 8:54p Jeff |
| 72 | * Inventory supports level change persistant items. Inventory supports |
| 73 | * time-out objects. Inventory Reset changed (takes a level of reset |
| 74 | * now). Quad lasers stay across level change (single player). Guidebot |
| 75 | * bug fixed (now back in ship on level start). Quads time out when |
| 76 | * spewed. Invulnerability and cloak powerups no longer use game |
| 77 | * event/callbacks, so they can be saved in game saves (moved to |
| 78 | * MakePlayerInvulnerable and MakeObjectInvisible) |
| 79 | * |
| 80 | * 65 2/23/99 7:37p Jeff |
| 81 | * fixed reset so it doesn't remove non-spewable items...made multiplayer |
| 82 | * friendly |
| 83 | * |
| 84 | * 64 2/22/99 1:20a Jeff |
| 85 | * added support for inventory (simple) in dallas. Moved end-level |
| 86 | * sequence to use IGC. Add position clipboard stuff for dallas. Fixed |
| 87 | * some inventory bug with storing object handles |
| 88 | * |
| 89 | * 63 2/14/99 4:29a Jeff |
| 90 | * able to set custom descriptions for an item when adding it |
| 91 | * |
| 92 | * 62 2/13/99 12:37a Jeff |
| 93 | * new inventory system. Supports objects that don't die when put in (by |
| 94 | * objhandles). Also changed Inventory::Reset() |
| 95 | * |
| 96 | * 61 2/08/99 5:24p Jeff |
| 97 | * removed all calls to MultiSendRemoveObject, incorportated into |
| 98 | * SetObjectDeadFlag. Fixes sequencing issues in multiplayer |
| 99 | * |
| 100 | * 60 1/21/99 11:15p Jeff |
| 101 | * pulled out some structs and defines from header files and moved them |
| 102 | * into seperate header files so that multiplayer dlls don't require major |
| 103 | * game headers, just those new headers. Side effect is a shorter build |
| 104 | * time. Also cleaned up some header file #includes that weren't needed. |
| 105 | * This affected polymodel.h, object.h, player.h, vecmat.h, room.h, |
| 106 | * manage.h and multi.h |
| 107 | * |
| 108 | * 59 1/13/99 2:28a Chris |
| 109 | * Massive AI, OSIRIS update |
| 110 | * |
| 111 | * 58 1/08/99 2:55p Samir |
| 112 | * Ripped out OSIRIS1. |
| 113 | * |
| 114 | * 57 1/04/99 12:23p Jeff |
| 115 | * added to evt_use and support for mission module scripts |
| 116 | * |
| 117 | * 56 12/17/98 12:08p Jeff |
| 118 | * first checkin of new implementation of OSIRIS (old OSIRIS no longer |
| 119 | * works) |
| 120 | * |
| 121 | * 55 10/08/98 4:23p Kevin |
| 122 | * Changed code to comply with memory library usage. Always use mem_malloc |
| 123 | * , mem_free and mem_strdup |
| 124 | * |
| 125 | * 54 10/06/98 2:37p Jeff |
| 126 | * fixed next,prev pos bugs |
| 127 | * |
| 128 | * 53 10/03/98 8:05p Matt |
| 129 | * Added asserts |
| 130 | * |
| 131 | * 52 8/31/98 6:50p Jeff |
| 132 | * made inventory and countermeasure keys customizable |
| 133 | * |
| 134 | * 51 8/25/98 1:35p Jeff |
| 135 | * fixed 0 byte malloc and removed mprintfs |
| 136 | * |
| 137 | * 50 8/19/98 2:17p Jeff |
| 138 | * added a function to get the aux type/id |
| 139 | * |
| 140 | * 49 8/19/98 12:38p Jason |
| 141 | * made countermeasure spewing work correctly |
| 142 | * |
| 143 | * 48 8/16/98 2:00a Jeff |
| 144 | * fixed ugly mprintf |
| 145 | * |
| 146 | * 47 8/13/98 11:56a Jeff |
| 147 | * handle new flags for inventory use |
| 148 | * |
| 149 | * 46 8/12/98 10:38a Jeff |
| 150 | * fixed some major bugs with reset |
| 151 | * |
| 152 | * 45 8/10/98 11:18a Jeff |
| 153 | * reset takes a bool now whether to reset everything |
| 154 | * |
| 155 | * 44 7/23/98 6:26p Jeff |
| 156 | * added checks to make sure scripts match |
| 157 | * |
| 158 | * 43 7/11/98 9:14p Jeff |
| 159 | * fixed an mprintf |
| 160 | * |
| 161 | * 42 7/10/98 7:49p Jeff |
| 162 | * fixed way of getting icon info for countermeasure |
| 163 | * |
| 164 | * 41 7/09/98 7:51p Jeff |
| 165 | * forgot to tell the clients to remove countermeasures on use |
| 166 | * |
| 167 | * 40 7/09/98 5:44p Jeff |
| 168 | * fixed bug with unique count for countermeasures |
| 169 | * |
| 170 | * 39 7/08/98 6:01p Jeff |
| 171 | * first chance at making multiplayer friendly |
| 172 | * |
| 173 | * 38 7/06/98 7:17p Jeff |
| 174 | * countermeasure support added |
| 175 | * |
| 176 | * 37 7/03/98 3:10p Jeff |
| 177 | * some error handling and added functions to get inventory information |
| 178 | * |
| 179 | * 36 5/25/98 6:38p Matt |
| 180 | * Added needed include. |
| 181 | * |
| 182 | * 35 5/11/98 4:40p Chris |
| 183 | * AI info is now a malloc'ed pointer |
| 184 | * |
| 185 | * 34 5/08/98 1:38p Jeff |
| 186 | * D3XExecScript returns true by default, not false (made change in |
| 187 | * EVT_USE) |
| 188 | * |
| 189 | * 33 5/08/98 1:31p Jeff |
| 190 | * if EVT_USE returns true, it won't remove item from inventory on use |
| 191 | * |
| 192 | * 32 4/24/98 7:09p Jeff |
| 193 | * added a flag for non-useable inventory items |
| 194 | * |
| 195 | * 31 4/23/98 12:02p Jeff |
| 196 | * added a limit to how many items you can put in your inventory |
| 197 | * |
| 198 | * 30 4/19/98 7:32p Jeff |
| 199 | * Moved inventory wrappers to DLLWrappers |
| 200 | * |
| 201 | * 29 4/09/98 6:43p Craig |
| 202 | * |
| 203 | * 28 4/09/98 6:09p Craig |
| 204 | * |
| 205 | * 27 4/09/98 6:02p Craig |
| 206 | * Fixed the non-linked player getting an inventory add crash. |
| 207 | * |
| 208 | * 26 4/03/98 11:49a Jeff |
| 209 | * Added another function wrapper, renamed others to fit naming convention |
| 210 | * |
| 211 | * 25 3/31/98 3:55p Jeff |
| 212 | * Added some inventory wrappers |
| 213 | * |
| 214 | * 24 3/26/98 2:58p Jeff |
| 215 | * Added a GetTypeIDCount function |
| 216 | * |
| 217 | * 23 3/23/98 5:36p Jeff |
| 218 | * added a parameter to Add to specify if you want it destroyed when it's |
| 219 | * added |
| 220 | * |
| 221 | * 22 3/20/98 9:34p Jason |
| 222 | * added SetObjectDeadFlag inlined function |
| 223 | * |
| 224 | * 21 3/20/98 2:58p Jason |
| 225 | * fixed Jeff's dumb error :P |
| 226 | * |
| 227 | * 20 3/20/98 2:44p Jeff |
| 228 | * removed ValidatePos() from ResetPos()....ValidatePos() should be called |
| 229 | * after a ResetPos() if you want to make sure you are on a selectable |
| 230 | * item |
| 231 | * |
| 232 | * 19 2/20/98 5:50p Jeff |
| 233 | * Changed it so that whether an inventory item was selected was placed in |
| 234 | * the objinfo flags |
| 235 | * |
| 236 | * 18 2/20/98 5:02p Jeff |
| 237 | * fixed bug so you can switch to a nonselectable item while playing the |
| 238 | * game |
| 239 | * |
| 240 | * 17 2/20/98 4:56p Jeff |
| 241 | * Changed inventory so it now supports non selectable items, plus made |
| 242 | * the list into a circular list |
| 243 | * |
| 244 | * 16 2/15/98 4:49p Jeff |
| 245 | * Added a reset function to clear the inventory |
| 246 | * |
| 247 | * 15 2/12/98 1:41p Jeff |
| 248 | * commented out constructor/destructor mprintfs |
| 249 | * |
| 250 | * 14 2/11/98 4:54p Jeff |
| 251 | * Moved the inventory into the Player struct |
| 252 | * |
| 253 | * 13 2/09/98 4:58p Jeff |
| 254 | * Connected inventory to hud |
| 255 | * |
| 256 | * 12 2/07/98 6:34p Jeff |
| 257 | * |
| 258 | * 11 2/06/98 2:04p Jeff |
| 259 | * inventory system much more stable now, and works with telcom |
| 260 | * |
| 261 | * 10 2/05/98 7:38p Jeff |
| 262 | * changed inventory system completly...now is classes...works in telcom |
| 263 | * to, added use feature |
| 264 | * |
| 265 | * 9 2/04/98 7:42p Jeff |
| 266 | * began connecting telcom to inventory |
| 267 | * |
| 268 | * 8 2/04/98 6:09p Matt |
| 269 | * Changed object room number to indicate a terrain cell via a flag. Got |
| 270 | * rid of the object flag which used to indicate terrain. |
| 271 | * |
| 272 | * 7 2/04/98 12:18p Jeff |
| 273 | * |
| 274 | * 6 2/03/98 6:15p Jeff |
| 275 | * |
| 276 | * 5 1/31/98 8:49p Jeff |
| 277 | * Added a function to count the number of items in the inventory |
| 278 | * |
| 279 | * 4 1/31/98 8:12p Jeff |
| 280 | * Added more inventory functions |
| 281 | * |
| 282 | * 3 1/30/98 7:02p Jeff |
| 283 | * wrote basic internals inven system |
| 284 | * |
| 285 | * 2 1/29/98 3:52p Jeff |
| 286 | * initial creation |
| 287 | * |
| 288 | * $NoKeywords: $ |
| 289 | */ |
| 290 | |
| 291 | #include "Inventory.h"cxx . . $ `<file>/Descent3/Inventory.h`/ |
| 292 | |
| 293 | #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/ |
| 294 | #include "player.h"cxx . . $ `<file>/Descent3/player.h`/ |
| 295 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 296 | #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/ |
| 297 | #include "room.h"cxx . . $ `<file>/Descent3/room.h`/ |
| 298 | #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/ |
| 299 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 300 | #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/ |
| 301 | #include "osiris_dll.h"cxx . . $ `<file>/Descent3/osiris_dll.h`/ |
| 302 | #include "mem.h"cxx . . $ `<file>/mem/mem.h`/ |
| 303 | #include "ObjScript.h"cxx . . $ `<file>/Descent3/ObjScript.h`/ |
| 304 | #include "osiris_share.h"cxx . . $ `<file>/Descent3/osiris_share.h`/ |
| 305 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 306 | #include "hud.h"cxx . . $ `<file>/Descent3/hud.h`/ |
| 307 | #include "hlsoundlib.h"cxx . . $ `<file>/sndlib/hlsoundlib.h`/ |
| 308 | #include "sounds.h"cxx . . $ `<file>/Descent3/sounds.h`/ |
| 309 | #include "AIMain.h"cxx . . $ `<file>/Descent3/AIMain.h`/ |
| 310 | #include "levelgoal.h"cxx . . $ `<file>/Descent3/levelgoal.h`/ |
| 311 | |
| 312 | // constructor |
| 313 | Inventorycxx . . $ Inventory#::Inventorycxx . . $ Inventory#Inventory(49f6e7a06ebc5aa8).(void) { |
| 314 | // mprintf(0,"Inventory System: Initialize\n"); |
| 315 | rootcxx . . $ Inventory#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 316 | countcxx . . $ Inventory#count. = 0; |
| 317 | poscxx . . $ Inventory#pos. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 318 | } |
| 319 | |
| 320 | // destructor |
| 321 | Inventorycxx . . $ Inventory#::~cxx . . $ Inventory#`~Inventory`(ced63f7c635d850d).Inventorycxx . . $ Inventory#(void) { Resetcxx . . $ Inventory#Reset(b994e01f1c45a386).(false); } |
| 322 | |
| 323 | // Resets the inventory, cleaning it out |
| 324 | // in_game: set to true if this is being called from during gameplay |
| 325 | // reset_stage: |
| 326 | // INVRESET_ALL: Reset _EVERYTHING_ |
| 327 | // INVRESET_LEVELCHANGE: Remove everything except those that last across levels |
| 328 | // INVRESET_DEATHSPEW: Remove everything except those that do not spew (Default) |
| 329 | void Inventorycxx . . $ Inventory#::Resetcxx . . $ Inventory#Reset(b994e01f1c45a386).(bool in_game, int reset_stage) { |
| 330 | if (reset_stage < 0 || reset_stage > 2) |
| 331 | reset_stage = 2; |
| 332 | |
| 333 | inven_itemcxx . . $ inven_item# *current = rootcxx . . $ Inventory#root., *next, *new_root; |
| 334 | |
| 335 | int item_count = countcxx . . $ Inventory#count.; |
| 336 | new_root = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 337 | objectcxx . . $ object# *obj; |
| 338 | |
| 339 | bool remove_nonspewers = false; |
| 340 | bool remove_levelchangers = false; |
| 341 | |
| 342 | switch (reset_stage) { |
| 343 | case INVRESET_ALLcxx . . $ `Descent3/Inventory.h:201:9`!: // everything (mission over) |
| 344 | remove_nonspewers = true; |
| 345 | remove_levelchangers = true; |
| 346 | break; |
| 347 | case INVRESET_LEVELCHANGEcxx . . $ `Descent3/Inventory.h:202:9`!: // leave level static (level change) |
| 348 | remove_nonspewers = true; |
| 349 | remove_levelchangers = false; |
| 350 | break; |
| 351 | case INVRESET_DEATHSPEWcxx . . $ `Descent3/Inventory.h:203:9`!: // leave non spewers (player death spew reset) |
| 352 | remove_nonspewers = false; |
| 353 | remove_levelchangers = true; |
| 354 | break; |
| 355 | } |
| 356 | |
| 357 | bool no_spew, leave_across_level, should_spew; |
| 358 | |
| 359 | while (item_count) { |
| 360 | no_spew = false; |
| 361 | leave_across_level = false; |
| 362 | should_spew = true; |
| 363 | |
| 364 | next = current->nextcxx . . $ inven_item#next.; |
| 365 | |
| 366 | if (current->iflagscxx . . $ inven_item#iflags. & INVF_NOTSPEWABLEcxx . . $ `Descent3/Inventory.h:197:9`!) |
| 367 | no_spew = true; |
| 368 | if (current->iflagscxx . . $ inven_item#iflags. & INVF_MISSIONITEMcxx . . $ `Descent3/Inventory.h:193:9`!) |
| 369 | leave_across_level = true; |
| 370 | |
| 371 | // determine if we should spew |
| 372 | if (leave_across_level && !remove_levelchangers && (!(current->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!))) |
| 373 | should_spew = false; |
| 374 | if (no_spew && !remove_nonspewers) |
| 375 | should_spew = false; |
| 376 | |
| 377 | if (in_game && current->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`! && should_spew) { |
| 378 | // unmark this object as being in an inventory |
| 379 | obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(current->typecxx . . $ inven_item#type.); |
| 380 | if (obj) { |
| 381 | obj->flagscxx . . $ object#flags. &= ~OF_INPLAYERINVENTORYcxx . . $ `Descent3/object_external.h:299:9`!; |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | if (should_spew) |
| 386 | RemoveNodecxx . . $ Inventory#RemoveNode(95bff11ddb5ad274).(current); |
| 387 | |
| 388 | item_count--; |
| 389 | current = next; |
| 390 | } |
| 391 | ValidatePoscxx . . $ Inventory#ValidatePos(b45ddcbc8423892c).(true); |
| 392 | } |
| 393 | |
| 394 | // adds an object to the inventory (marked by it's objhandle) |
| 395 | bool Inventorycxx . . $ Inventory#::AddObjectcxx . . $ Inventory#AddObject(bc9c4eeb54e60257).(int object_handle, int flags, const char *description) { |
| 396 | // make sure we can fit another object |
| 397 | if (countcxx . . $ Inventory#count. >= MAX_UNIQUE_INVEN_ITEMScxx . . $ `Descent3/Inventory.h:189:9`!) { |
| 398 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Max unique count hit on add to inventory\n"); |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(object_handle); |
| 403 | if (!obj) { |
| 404 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "INVEN: Invalid object trying to be added\n"); |
| 405 | return false; |
| 406 | } |
| 407 | |
| 408 | if (obj->flagscxx . . $ object#flags. & OF_INFORM_DESTROY_TO_LGcxx . . $ `Descent3/object_external.h:302:9`!) { |
| 409 | Level_goalscxx . . $ Level_goals..Informcxx . . $ levelgoals#Inform(8589f1c7c2d24df6).(LIT_OBJECTcxx . . $ `Descent3/levelgoal_external.h:28:9`!, LGF_COMP_DESTROYcxx . . $ `Descent3/levelgoal_external.h:48:9`!, obj->handlecxx . . $ object#handle.); |
| 410 | } |
| 411 | |
| 412 | bool in_as_dummy = false; |
| 413 | if (obj->typecxx . . $ object#type. == OBJ_DUMMYcxx . . $ `Descent3/object_external.h:181:9`!) { |
| 414 | // type coming in is already dummy, un-dummy before adding it |
| 415 | ObjUnGhostObjectcxx . . $ ObjUnGhostObject(d4f767463ce0a6b3).(OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj)); |
| 416 | in_as_dummy = true; |
| 417 | } |
| 418 | |
| 419 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->type == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! || obj->type == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || obj->type == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! || obj->type == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!); |
| 420 | |
| 421 | inven_itemcxx . . $ inven_item# *current = rootcxx . . $ Inventory#root., *prev = rootcxx . . $ Inventory#root., *newnode; |
| 422 | |
| 423 | if (countcxx . . $ Inventory#count. == 0) { |
| 424 | // there are no items in the list...time to add |
| 425 | rootcxx . . $ Inventory#root. = new inven_itemcxx . . $ inven_item#; |
| 426 | newnode = rootcxx . . $ Inventory#root.; |
| 427 | rootcxx . . $ Inventory#root.->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 428 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = rootcxx . . $ Inventory#root.; |
| 429 | newnode->iflagscxx . . $ inven_item#iflags. = INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!; |
| 430 | newnode->countcxx . . $ inven_item#count. = 1; |
| 431 | } else { |
| 432 | newnode = new inven_itemcxx . . $ inven_item#; |
| 433 | |
| 434 | prev = rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev.; |
| 435 | |
| 436 | newnode->prevcxx . . $ inven_item#prev. = prev; |
| 437 | prev->nextcxx . . $ inven_item#next. = newnode; |
| 438 | newnode->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 439 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = newnode; |
| 440 | |
| 441 | newnode->iflagscxx . . $ inven_item#iflags. = INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!; |
| 442 | newnode->countcxx . . $ inven_item#count. = 1; |
| 443 | } |
| 444 | |
| 445 | newnode->typecxx . . $ inven_item#type. = object_handle; |
| 446 | newnode->idcxx . . $ inven_item#id. = -1; |
| 447 | newnode->flagscxx . . $ inven_item#flags. = 0; |
| 448 | newnode->otypecxx . . $ inven_item#otype. = obj->typecxx . . $ object#type.; |
| 449 | newnode->oidcxx . . $ inven_item#oid. = obj->idcxx . . $ object#id.; |
| 450 | |
| 451 | if (Object_infocxx . . $ Object_info.[newnode->oidcxx . . $ inven_item#oid.].descriptioncxx . . $ object_info#description.) { |
| 452 | newnode->descriptioncxx . . $ inven_item#description. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(Object_info[newnode->oid].description); |
| 453 | } else { |
| 454 | newnode->descriptioncxx . . $ inven_item#description. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(char)); |
| 455 | newnode->descriptioncxx . . $ inven_item#description.[0] = 0; |
| 456 | } |
| 457 | |
| 458 | if (Object_infocxx . . $ Object_info.[newnode->oidcxx . . $ inven_item#oid.].flagscxx . . $ object_info#flags. & OIF_INVEN_SELECTABLEcxx . . $ `Descent3/objinfo.h:336:9`!) |
| 459 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!; |
| 460 | // if(!(Object_info[newnode->oid].flags & OIF_INVEN_NONUSEABLE)) |
| 461 | // newnode->iflags |= INVF_USEABLE; |
| 462 | if (Object_infocxx . . $ Object_info.[newnode->oidcxx . . $ inven_item#oid.].flagscxx . . $ object_info#flags. & OIF_INVEN_TYPE_MISSIONcxx . . $ `Descent3/objinfo.h:338:9`!) |
| 463 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_MISSIONITEMcxx . . $ `Descent3/Inventory.h:193:9`!; |
| 464 | if (Object_infocxx . . $ Object_info.[newnode->oidcxx . . $ inven_item#oid.].flagscxx . . $ object_info#flags. & OIF_INVEN_NOREMOVEcxx . . $ `Descent3/objinfo.h:339:9`!) |
| 465 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_NOREMOVEONUSEcxx . . $ `Descent3/Inventory.h:194:9`!; |
| 466 | if (Object_infocxx . . $ Object_info.[newnode->oidcxx . . $ inven_item#oid.].flagscxx . . $ object_info#flags. & OIF_INVEN_VISWHENUSEDcxx . . $ `Descent3/objinfo.h:340:9`!) |
| 467 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_VISWHENUSEDcxx . . $ `Descent3/Inventory.h:195:9`!; |
| 468 | |
| 469 | if (flags & INVAF_NOTSPEWABLEcxx . . $ `scripts/osiris_common.h:765:9`!) |
| 470 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_NOTSPEWABLEcxx . . $ `Descent3/Inventory.h:197:9`!; |
| 471 | if (flags & INVAF_TIMEOUTONSPEWcxx . . $ `scripts/osiris_common.h:766:9`!) |
| 472 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_TIMEOUTONSPEWcxx . . $ `Descent3/Inventory.h:198:9`!; |
| 473 | if (flags & INVAF_LEVELLASTcxx . . $ `scripts/osiris_common.h:767:9`!) |
| 474 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_MISSIONITEMcxx . . $ `Descent3/Inventory.h:193:9`!; |
| 475 | |
| 476 | obj->flagscxx . . $ object#flags. |= OF_INPLAYERINVENTORYcxx . . $ `Descent3/object_external.h:299:9`!; |
| 477 | |
| 478 | if (in_as_dummy || (!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!)) || Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 479 | ObjGhostObjectcxx . . $ ObjGhostObject(d4f767463ce0a6b3).(OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj)); |
| 480 | |
| 481 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 482 | MultiSendGhostObjectcxx . . $ MultiSendGhostObject(674fac047436fc5b).(obj, true); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | newnode->icon_namecxx . . $ inven_item#icon_name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(Object_info[newnode->oid].icon_name); |
| 487 | |
| 488 | if (description) { |
| 489 | newnode->namecxx . . $ inven_item#name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(description); |
| 490 | } else { |
| 491 | newnode->namecxx . . $ inven_item#name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(Object_info[newnode->oid].name); |
| 492 | } |
| 493 | |
| 494 | countcxx . . $ Inventory#count.++; |
| 495 | |
| 496 | if (newnode->iflagscxx . . $ inven_item#iflags. & INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!) |
| 497 | poscxx . . $ Inventory#pos. = newnode; |
| 498 | |
| 499 | return true; |
| 500 | } |
| 501 | |
| 502 | // adds a new type/id item to the inventory |
| 503 | bool Inventorycxx . . $ Inventory#::Addcxx . . $ Inventory#Add(122d808d8b1091da).(int type, int id, objectcxx . . $ object# *parent, int aux_type, int aux_id, int flags, const char *description) { |
| 504 | // make sure we can fit another object |
| 505 | if (countcxx . . $ Inventory#count. >= MAX_UNIQUE_INVEN_ITEMScxx . . $ `Descent3/Inventory.h:189:9`!) { |
| 506 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Max unique count hit on add to inventory\n"); |
| 507 | return false; |
| 508 | } |
| 509 | |
| 510 | if ((type < 0) || (type == OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!)) { |
| 511 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Invalid type on add to inventory\n"); |
| 512 | return false; |
| 513 | } |
| 514 | |
| 515 | if (type != OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) { |
| 516 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(type == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! || type == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || type == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! || type == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!); |
| 517 | return AddObjectItemcxx . . $ Inventory#AddObjectItem(260f7ee685ef8f73).(type, id, (aux_type != -1) ? aux_type : type, (aux_id != -1) ? aux_id : id, flags, |
| 518 | description); |
| 519 | } else { |
| 520 | // special case for countermeasures |
| 521 | return AddCounterMeasurecxx . . $ Inventory#AddCounterMeasure(1165f2dcd82ced24).(id, aux_type, aux_id, flags, description); |
| 522 | } |
| 523 | |
| 524 | return false; |
| 525 | } |
| 526 | |
| 527 | // adds a special cased CounterMeasure into the inventory |
| 528 | bool Inventorycxx . . $ Inventory#::AddCounterMeasurecxx . . $ Inventory#AddCounterMeasure(1165f2dcd82ced24).(int id, int aux_type, int aux_id, int flags, const char *description) { |
| 529 | // make sure we can fit another object |
| 530 | if (countcxx . . $ Inventory#count. >= MAX_UNIQUE_INVEN_ITEMScxx . . $ `Descent3/Inventory.h:189:9`!) { |
| 531 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Hit max unique in counter measure add\n"); |
| 532 | return false; |
| 533 | } |
| 534 | |
| 535 | inven_itemcxx . . $ inven_item# *current = rootcxx . . $ Inventory#root., *prev = rootcxx . . $ Inventory#root., *newnode; |
| 536 | |
| 537 | if (countcxx . . $ Inventory#count. == 0) { |
| 538 | // there are no items in the list...time to add |
| 539 | rootcxx . . $ Inventory#root. = new inven_itemcxx . . $ inven_item#; |
| 540 | newnode = rootcxx . . $ Inventory#root.; |
| 541 | rootcxx . . $ Inventory#root.->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 542 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = rootcxx . . $ Inventory#root.; |
| 543 | newnode->countcxx . . $ inven_item#count. = 1; |
| 544 | } else { |
| 545 | newnode = FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!, id); |
| 546 | |
| 547 | if (!newnode) { |
| 548 | // NEEDTODO: adjust so it adds in order |
| 549 | |
| 550 | newnode = new inven_itemcxx . . $ inven_item#; |
| 551 | |
| 552 | prev = rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev.; |
| 553 | |
| 554 | newnode->prevcxx . . $ inven_item#prev. = prev; |
| 555 | prev->nextcxx . . $ inven_item#next. = newnode; |
| 556 | newnode->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 557 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = newnode; |
| 558 | |
| 559 | newnode->countcxx . . $ inven_item#count. = 1; |
| 560 | } else { |
| 561 | // there is an item of that type/id already, just increase it's count |
| 562 | newnode->countcxx . . $ inven_item#count.++; |
| 563 | // mprintf(0,"Inventory: Item #%d (%s) Count increased to %d\n",count,newnode->name,newnode->count); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | // its a new item type/id, so fill in its info |
| 568 | if (newnode->countcxx . . $ inven_item#count. == 1) { |
| 569 | newnode->typecxx . . $ inven_item#type. = OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!; |
| 570 | newnode->idcxx . . $ inven_item#id. = id; |
| 571 | newnode->flagscxx . . $ inven_item#flags. = 0; |
| 572 | newnode->iflagscxx . . $ inven_item#iflags. = 0; |
| 573 | newnode->otypecxx . . $ inven_item#otype. = aux_type; |
| 574 | newnode->oidcxx . . $ inven_item#oid. = aux_id; |
| 575 | |
| 576 | if ((aux_type != -1) && (aux_id != -1) && (Object_infocxx . . $ Object_info.[aux_id].descriptioncxx . . $ object_info#description.)) { |
| 577 | newnode->descriptioncxx . . $ inven_item#description. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(Object_info[aux_id].description); |
| 578 | } else { |
| 579 | newnode->descriptioncxx . . $ inven_item#description. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(Weapons[id].name); |
| 580 | } |
| 581 | |
| 582 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`! | INVF_USEABLEcxx . . $ `Descent3/Inventory.h:192:9`! | INVF_MISSIONITEMcxx . . $ `Descent3/Inventory.h:193:9`! | INVF_TIMEOUTONSPEWcxx . . $ `Descent3/Inventory.h:198:9`!; |
| 583 | |
| 584 | newnode->icon_namecxx . . $ inven_item#icon_name. = |
| 585 | (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(GameBitmaps[GameTextures[Weapons[id].icon_handle].bm_handle].name) + 1); |
| 586 | strcpy(newnode->icon_namecxx . . $ inven_item#icon_name., GameBitmapscxx . . $ GameBitmaps.[GameTexturescxx . . $ GameTextures.[Weaponscxx . . $ Weapons.[id].icon_handlecxx . . $ weapon#icon_handle.].bm_handlecxx . . $ texture#bm_handle.].namecxx . . $ bms_bitmap#name.); |
| 587 | |
| 588 | if (description) { |
| 589 | newnode->namecxx . . $ inven_item#name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(description); |
| 590 | } else { |
| 591 | newnode->namecxx . . $ inven_item#name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(Weapons[id].name); |
| 592 | } |
| 593 | |
| 594 | countcxx . . $ Inventory#count.++; |
| 595 | // mprintf(0,"Inventory: Item #%d Added Countermeasure (%s) ID=%d\n",count,newnode->name,newnode->id); |
| 596 | } |
| 597 | |
| 598 | poscxx . . $ Inventory#pos. = newnode; |
| 599 | return true; |
| 600 | } |
| 601 | |
| 602 | // adds an object to the inventory |
| 603 | bool Inventorycxx . . $ Inventory#::AddObjectItemcxx . . $ Inventory#AddObjectItem(260f7ee685ef8f73).(int otype, int oid, int oauxt, int oauxi, int flags, const char *description) { |
| 604 | // make sure we can fit another object |
| 605 | if (countcxx . . $ Inventory#count. >= MAX_UNIQUE_INVEN_ITEMScxx . . $ `Descent3/Inventory.h:189:9`!) |
| 606 | return false; |
| 607 | |
| 608 | inven_itemcxx . . $ inven_item# *current = rootcxx . . $ Inventory#root., *prev = rootcxx . . $ Inventory#root., *newnode; |
| 609 | |
| 610 | if (countcxx . . $ Inventory#count. == 0) { |
| 611 | // there are no items in the list...time to add |
| 612 | rootcxx . . $ Inventory#root. = new inven_itemcxx . . $ inven_item#; |
| 613 | newnode = rootcxx . . $ Inventory#root.; |
| 614 | rootcxx . . $ Inventory#root.->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 615 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = rootcxx . . $ Inventory#root.; |
| 616 | newnode->countcxx . . $ inven_item#count. = 1; |
| 617 | } else { |
| 618 | newnode = FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(otype, oid); |
| 619 | |
| 620 | if (!newnode) { |
| 621 | // NEEDTODO: adjust so it adds in order |
| 622 | |
| 623 | newnode = new inven_itemcxx . . $ inven_item#; |
| 624 | |
| 625 | prev = rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev.; |
| 626 | |
| 627 | newnode->prevcxx . . $ inven_item#prev. = prev; |
| 628 | prev->nextcxx . . $ inven_item#next. = newnode; |
| 629 | newnode->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 630 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = newnode; |
| 631 | |
| 632 | newnode->countcxx . . $ inven_item#count. = 1; |
| 633 | } else { |
| 634 | // there is an item of that type/id already, just increase it's count |
| 635 | newnode->countcxx . . $ inven_item#count.++; |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | // its a new item type/id, so fill in its info |
| 640 | if (newnode->countcxx . . $ inven_item#count. == 1) { |
| 641 | newnode->typecxx . . $ inven_item#type. = otype; |
| 642 | newnode->idcxx . . $ inven_item#id. = oid; |
| 643 | newnode->flagscxx . . $ inven_item#flags. = 0; |
| 644 | newnode->iflagscxx . . $ inven_item#iflags. = 0; |
| 645 | newnode->otypecxx . . $ inven_item#otype. = oauxt; |
| 646 | newnode->oidcxx . . $ inven_item#oid. = oauxi; |
| 647 | |
| 648 | if (Object_infocxx . . $ Object_info.[oid].descriptioncxx . . $ object_info#description.) { |
| 649 | newnode->descriptioncxx . . $ inven_item#description. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(Object_info[oid].description) + 1); |
| 650 | strcpy(newnode->descriptioncxx . . $ inven_item#description., Object_infocxx . . $ Object_info.[oid].descriptioncxx . . $ object_info#description.); |
| 651 | } else { |
| 652 | newnode->descriptioncxx . . $ inven_item#description. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(char)); |
| 653 | newnode->descriptioncxx . . $ inven_item#description.[0] = 0; |
| 654 | } |
| 655 | |
| 656 | if (Object_infocxx . . $ Object_info.[oid].flagscxx . . $ object_info#flags. & OIF_INVEN_SELECTABLEcxx . . $ `Descent3/objinfo.h:336:9`!) |
| 657 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!; |
| 658 | // if(!(Object_info[oid].flags & OIF_INVEN_NONUSEABLE)) |
| 659 | // newnode->iflags |= INVF_USEABLE; |
| 660 | if (Object_infocxx . . $ Object_info.[oid].flagscxx . . $ object_info#flags. & OIF_INVEN_TYPE_MISSIONcxx . . $ `Descent3/objinfo.h:338:9`!) |
| 661 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_MISSIONITEMcxx . . $ `Descent3/Inventory.h:193:9`!; |
| 662 | if (Object_infocxx . . $ Object_info.[oid].flagscxx . . $ object_info#flags. & OIF_INVEN_NOREMOVEcxx . . $ `Descent3/objinfo.h:339:9`!) |
| 663 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_NOREMOVEONUSEcxx . . $ `Descent3/Inventory.h:194:9`!; |
| 664 | if (Object_infocxx . . $ Object_info.[oid].flagscxx . . $ object_info#flags. & OIF_INVEN_VISWHENUSEDcxx . . $ `Descent3/objinfo.h:340:9`!) |
| 665 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_VISWHENUSEDcxx . . $ `Descent3/Inventory.h:195:9`!; |
| 666 | |
| 667 | if (flags & INVAF_NOTSPEWABLEcxx . . $ `scripts/osiris_common.h:765:9`!) |
| 668 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_NOTSPEWABLEcxx . . $ `Descent3/Inventory.h:197:9`!; |
| 669 | if (flags & INVAF_TIMEOUTONSPEWcxx . . $ `scripts/osiris_common.h:766:9`!) |
| 670 | newnode->iflagscxx . . $ inven_item#iflags. |= INVF_TIMEOUTONSPEWcxx . . $ `Descent3/Inventory.h:198:9`!; |
| 671 | if (flags & INVAF_LEVELLASTcxx . . $ `scripts/osiris_common.h:767:9`!) |
| 672 | newnode->iflagscxx . . $ inven_item#iflags. |= INVAF_LEVELLASTcxx . . $ `scripts/osiris_common.h:767:9`!; |
| 673 | |
| 674 | newnode->icon_namecxx . . $ inven_item#icon_name. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(Object_info[oid].icon_name) + 1); |
| 675 | strcpy(newnode->icon_namecxx . . $ inven_item#icon_name., Object_infocxx . . $ Object_info.[oid].icon_namecxx . . $ object_info#icon_name.); |
| 676 | |
| 677 | if (description) { |
| 678 | newnode->namecxx . . $ inven_item#name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(description); |
| 679 | } else { |
| 680 | newnode->namecxx . . $ inven_item#name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(Object_info[oid].name); |
| 681 | } |
| 682 | |
| 683 | countcxx . . $ Inventory#count.++; |
| 684 | } |
| 685 | |
| 686 | if (newnode->iflagscxx . . $ inven_item#iflags. & INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!) |
| 687 | poscxx . . $ Inventory#pos. = newnode; |
| 688 | |
| 689 | return true; |
| 690 | } |
| 691 | |
| 692 | // uses an item in the inventory (returns false if the item doesn't exist) |
| 693 | bool Inventorycxx . . $ Inventory#::Usecxx . . $ Inventory#Use(cc3bfdd2c949b92e).(int type, int id, objectcxx . . $ object# *parent) { |
| 694 | inven_itemcxx . . $ inven_item# *node; |
| 695 | |
| 696 | node = FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(type, id); |
| 697 | |
| 698 | if (!node) |
| 699 | return false; |
| 700 | |
| 701 | if (!(node->iflagscxx . . $ inven_item#iflags. & INVF_USEABLEcxx . . $ `Descent3/Inventory.h:192:9`!)) |
| 702 | return false; |
| 703 | |
| 704 | bool multiplayer = (bool)((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) != 0); |
| 705 | bool client; |
| 706 | bool server; |
| 707 | bool ret = false; |
| 708 | |
| 709 | if (multiplayer) { |
| 710 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. & LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 711 | client = false; |
| 712 | server = true; |
| 713 | } else { |
| 714 | client = true; |
| 715 | server = false; |
| 716 | } |
| 717 | } else { |
| 718 | client = false; |
| 719 | server = false; |
| 720 | } |
| 721 | |
| 722 | if (client) { |
| 723 | // OK, we're a client in a multiplayer game, so send a request to the server to use this Item |
| 724 | SendRequestToServerToUsecxx . . $ Inventory#SendRequestToServerToUse(3e454b8ccf442868).(node->typecxx . . $ inven_item#type., node->idcxx . . $ inven_item#id.); |
| 725 | |
| 726 | return false; |
| 727 | } |
| 728 | |
| 729 | // If we got here, then we are either the server in a multiplayer game, or in a single player game |
| 730 | |
| 731 | // get player object (needed when we recreate the object) |
| 732 | objectcxx . . $ object# *player; |
| 733 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(parent); |
| 734 | player = parent; |
| 735 | |
| 736 | if (player == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 737 | Int3cxx . . $ `misc/pserror.h:247:9`!(); |
| 738 | return false; |
| 739 | } |
| 740 | |
| 741 | // if type is OBJ_WEAPON then it's a countermeasure |
| 742 | if (type == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) { |
| 743 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "CounterMeasures: Use\n"); |
| 744 | // countermeasure |
| 745 | CreateCountermeasureFromObjectcxx . . $ CreateCountermeasureFromObject(766a1b7183ffa4b4).(player, id); |
| 746 | Removecxx . . $ Inventory#Remove(cf9ef193275fa6d8).(node->typecxx . . $ inven_item#type., node->idcxx . . $ inven_item#id.); |
| 747 | ret = true; |
| 748 | } else { |
| 749 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Inventory: Use\n"); |
| 750 | // regular |
| 751 | // recreate the object |
| 752 | int objnum; |
| 753 | int roomnum; |
| 754 | bool remove_on_use; |
| 755 | bool vis_when_created = false; |
| 756 | |
| 757 | if (node->iflagscxx . . $ inven_item#iflags. & INVF_NOREMOVEONUSEcxx . . $ `Descent3/Inventory.h:194:9`!) |
| 758 | remove_on_use = false; |
| 759 | else |
| 760 | remove_on_use = true; |
| 761 | |
| 762 | if (node->iflagscxx . . $ inven_item#iflags. & INVF_VISWHENUSEDcxx . . $ `Descent3/Inventory.h:195:9`!) |
| 763 | vis_when_created = true; |
| 764 | else |
| 765 | vis_when_created = false; |
| 766 | |
| 767 | roomnum = player->roomnumcxx . . $ object#roomnum.; |
| 768 | |
| 769 | if (node->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) { |
| 770 | // don't recreate the object..it already exists |
| 771 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(node->typecxx . . $ inven_item#type.); |
| 772 | if (!obj) { |
| 773 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // object no longer exists |
| 774 | return false; |
| 775 | } |
| 776 | objnum = OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj); |
| 777 | |
| 778 | obj->flagscxx . . $ object#flags. &= ~OF_INPLAYERINVENTORYcxx . . $ `Descent3/object_external.h:299:9`!; |
| 779 | |
| 780 | if (vis_when_created) { |
| 781 | ObjUnGhostObjectcxx . . $ ObjUnGhostObject(d4f767463ce0a6b3).(objnum); |
| 782 | MultiSendGhostObjectcxx . . $ MultiSendGhostObject(674fac047436fc5b).(obj, false); |
| 783 | } |
| 784 | |
| 785 | } else { |
| 786 | |
| 787 | objnum = ObjCreatecxx . . $ ObjCreate(849c3da80a4f387f).(node->typecxx . . $ inven_item#type., node->idcxx . . $ inven_item#id., roomnum, &player->poscxx . . $ object#pos., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, player->handlecxx . . $ object#handle.); |
| 788 | if (objnum == -1) { |
| 789 | Int3cxx . . $ `misc/pserror.h:247:9`!(); |
| 790 | return false; |
| 791 | } |
| 792 | |
| 793 | if (!vis_when_created) { |
| 794 | if (Objectscxx . . $ Objects.[objnum].control_typecxx . . $ object#control_type. != CT_AIcxx . . $ `Descent3/object_external.h:217:9`!) { |
| 795 | SetObjectControlTypecxx . . $ SetObjectControlType(766a1b7183ffa4b4).(&Objectscxx . . $ Objects.[objnum], CT_NONEcxx . . $ `Descent3/object_external.h:216:9`!); |
| 796 | } |
| 797 | Objectscxx . . $ Objects.[objnum].movement_typecxx . . $ object#movement_type. = MT_NONEcxx . . $ `Descent3/object_external.h:233:9`!; |
| 798 | Objectscxx . . $ Objects.[objnum].render_typecxx . . $ object#render_type. = RT_NONEcxx . . $ `Descent3/object_external.h:257:9`!; |
| 799 | } |
| 800 | |
| 801 | Objectscxx . . $ Objects.[objnum].flagscxx . . $ object#flags. = node->flagscxx . . $ inven_item#flags.; |
| 802 | |
| 803 | if (server) // if we're the server, then we need to send this object to the clients |
| 804 | MultiSendObjectcxx . . $ MultiSendObject(d7354c60e612ede5).(&Objectscxx . . $ Objects.[objnum], 0); |
| 805 | |
| 806 | InitObjectScriptscxx . . $ InitObjectScripts(674fac047436fc5b).(&Objectscxx . . $ Objects.[objnum]); |
| 807 | } |
| 808 | |
| 809 | tOSIRISEventInfocxx . . $ tOSIRISEventInfo# ei; |
| 810 | ei.evt_usecxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_use..it_handlecxx . . $ tOSIRISEVTUSE#it_handle. = player->handlecxx . . $ object#handle.; |
| 811 | if (Osiris_CallEventcxx . . $ Osiris_CallEvent(91e8d3045aa5549c).(&Objectscxx . . $ Objects.[objnum], EVT_USEcxx . . $ `scripts/osiris_common.h:370:9`!, &ei)) { |
| 812 | // if we're the server tell the clients to remove this item from their inventory |
| 813 | Removecxx . . $ Inventory#Remove(cf9ef193275fa6d8).(node->typecxx . . $ inven_item#type., node->idcxx . . $ inven_item#id.); |
| 814 | ret = true; |
| 815 | } else { |
| 816 | if (node->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) |
| 817 | Objectscxx . . $ Objects.[objnum].flagscxx . . $ object#flags. |= OF_INPLAYERINVENTORYcxx . . $ `Descent3/object_external.h:299:9`!; // mark as being in inventory |
| 818 | } |
| 819 | |
| 820 | if (remove_on_use) { |
| 821 | // now we need to kill the object |
| 822 | SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(&Objectscxx . . $ Objects.[objnum], true); |
| 823 | } |
| 824 | } |
| 825 | return ret; |
| 826 | } |
| 827 | |
| 828 | // sends a request to the server to use a particular item in the inventory |
| 829 | void Inventorycxx . . $ Inventory#::SendRequestToServerToUsecxx . . $ Inventory#SendRequestToServerToUse(3e454b8ccf442868).(int type, int id) { |
| 830 | // mprintf(0,"Sending request to server for T=%d ID=%d\n",type,id); |
| 831 | inven_itemcxx . . $ inven_item# *node = FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(type, id); |
| 832 | if (node) { |
| 833 | MultiSendClientInventoryUseItemcxx . . $ MultiSendClientInventoryUseItem(3e454b8ccf442868).(type, id); |
| 834 | } else { |
| 835 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sorry couldn't find it in your inventory\n"); |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | // searches the inventory for the specified type/id, sets the pos to it |
| 840 | bool Inventorycxx . . $ Inventory#::FindPoscxx . . $ Inventory#FindPos(cf9ef193275fa6d8).(int type, int id) { |
| 841 | int oldt, oldi; |
| 842 | int ttype, tid; |
| 843 | |
| 844 | // save current pos |
| 845 | GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(oldt, oldi); |
| 846 | |
| 847 | // try to move to the specified pos |
| 848 | GotoPoscxx . . $ Inventory#GotoPos(3e454b8ccf442868).(type, id); |
| 849 | |
| 850 | // see if we got there |
| 851 | GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(ttype, tid); |
| 852 | if ((ttype == type) && (tid == id)) |
| 853 | return true; |
| 854 | else { |
| 855 | // nope, so restore the old pos |
| 856 | GotoPoscxx . . $ Inventory#GotoPos(3e454b8ccf442868).(oldt, oldi); |
| 857 | return false; |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | // uses an item in the inventory (currently selected one) (returns false if the item doesn't exist) |
| 862 | bool Inventorycxx . . $ Inventory#::UsePoscxx . . $ Inventory#UsePos(39516aeee13ca5ab).(objectcxx . . $ object# *parent) { |
| 863 | if (poscxx . . $ Inventory#pos.) { |
| 864 | return Usecxx . . $ Inventory#Use(cc3bfdd2c949b92e).(poscxx . . $ Inventory#pos.->typecxx . . $ inven_item#type., poscxx . . $ Inventory#pos.->idcxx . . $ inven_item#id., parent); |
| 865 | } else |
| 866 | return false; |
| 867 | } |
| 868 | |
| 869 | bool Inventorycxx . . $ Inventory#::Usecxx . . $ Inventory#Use(bf595291c30e3265).(int objhandle, objectcxx . . $ object# *parent) { return Usecxx . . $ Inventory#Use(cc3bfdd2c949b92e).(objhandle, -1, parent); } |
| 870 | |
| 871 | // removes an item from inventory, without using it (returns true on success, false if object didn't exist) |
| 872 | bool Inventorycxx . . $ Inventory#::Removecxx . . $ Inventory#Remove(cf9ef193275fa6d8).(int type, int id) { |
| 873 | inven_itemcxx . . $ inven_item# *node; |
| 874 | |
| 875 | node = FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(type, id); |
| 876 | |
| 877 | if (!node) |
| 878 | return false; |
| 879 | |
| 880 | if (node->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) { |
| 881 | // always remove |
| 882 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(type); |
| 883 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj); |
| 884 | if (obj) { |
| 885 | obj->flagscxx . . $ object#flags. &= ~OF_INPLAYERINVENTORYcxx . . $ `Descent3/object_external.h:299:9`!; |
| 886 | } |
| 887 | |
| 888 | RemoveNodecxx . . $ Inventory#RemoveNode(95bff11ddb5ad274).(node); |
| 889 | } else { |
| 890 | node->countcxx . . $ inven_item#count.--; |
| 891 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Inventory System: Remove\n"); |
| 892 | |
| 893 | if (node->countcxx . . $ inven_item#count. <= 0) |
| 894 | RemoveNodecxx . . $ Inventory#RemoveNode(95bff11ddb5ad274).(node); |
| 895 | } |
| 896 | |
| 897 | return true; |
| 898 | } |
| 899 | |
| 900 | // removes a node from the list, decrementing the count |
| 901 | void Inventorycxx . . $ Inventory#::RemoveNodecxx . . $ Inventory#RemoveNode(95bff11ddb5ad274).(inven_itemcxx . . $ inven_item# *node) { |
| 902 | if (!node) |
| 903 | return; |
| 904 | |
| 905 | bool movepos = false; |
| 906 | countcxx . . $ Inventory#count.--; |
| 907 | inven_itemcxx . . $ inven_item# *prev, *next; |
| 908 | |
| 909 | prev = node->prevcxx . . $ inven_item#prev.; |
| 910 | next = node->nextcxx . . $ inven_item#next.; |
| 911 | |
| 912 | if (node->descriptioncxx . . $ inven_item#description.) |
| 913 | mem_freecxx . . $ `mem/mem.h:80:9`!(node->description); |
| 914 | if (node->icon_namecxx . . $ inven_item#icon_name.) |
| 915 | mem_freecxx . . $ `mem/mem.h:80:9`!(node->icon_name); |
| 916 | if (node->namecxx . . $ inven_item#name.) |
| 917 | mem_freecxx . . $ `mem/mem.h:80:9`!(node->name); |
| 918 | |
| 919 | if (poscxx . . $ Inventory#pos. == node) { |
| 920 | if (poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next. != node) { |
| 921 | movepos = true; |
| 922 | poscxx . . $ Inventory#pos. = poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next.; |
| 923 | } else |
| 924 | poscxx . . $ Inventory#pos. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 925 | } |
| 926 | |
| 927 | if (node == rootcxx . . $ Inventory#root.) { |
| 928 | if (rootcxx . . $ Inventory#root.->nextcxx . . $ inven_item#next. != rootcxx . . $ Inventory#root.) { |
| 929 | inven_itemcxx . . $ inven_item# *n = rootcxx . . $ Inventory#root.->nextcxx . . $ inven_item#next.; |
| 930 | inven_itemcxx . . $ inven_item# *p = rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev.; |
| 931 | delete node; |
| 932 | rootcxx . . $ Inventory#root. = n; |
| 933 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = p; |
| 934 | p->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 935 | } else { |
| 936 | delete node; |
| 937 | rootcxx . . $ Inventory#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 938 | } |
| 939 | } else { |
| 940 | delete node; |
| 941 | prev->nextcxx . . $ inven_item#next. = next; |
| 942 | next->prevcxx . . $ inven_item#prev. = prev; |
| 943 | } |
| 944 | |
| 945 | if (movepos) |
| 946 | ValidatePoscxx . . $ Inventory#ValidatePos(b45ddcbc8423892c).(); |
| 947 | } |
| 948 | |
| 949 | // given a type and id, it returns the first matching inventory item |
| 950 | inven_itemcxx . . $ inven_item# *Inventorycxx . . $ Inventory#::FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(int type, int id) { |
| 951 | inven_itemcxx . . $ inven_item# *current = rootcxx . . $ Inventory#root.; |
| 952 | |
| 953 | if (countcxx . . $ Inventory#count. == 0) |
| 954 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; // there are no items, don't even bother |
| 955 | |
| 956 | int counter = countcxx . . $ Inventory#count.; |
| 957 | |
| 958 | while (counter) { |
| 959 | if ((current->typecxx . . $ inven_item#type. == type) && (current->idcxx . . $ inven_item#id. == id)) // we got a match |
| 960 | { |
| 961 | // mprintf(0,"Inventory: FindItem found Type(%d) ID(%d)\n",type,id); |
| 962 | return current; |
| 963 | } |
| 964 | |
| 965 | current = current->nextcxx . . $ inven_item#next.; |
| 966 | counter--; |
| 967 | } |
| 968 | |
| 969 | // mprintf(0,"Inventory: FindItem couldn't find Type(%d) ID(%d)\n",type,id); |
| 970 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 971 | } |
| 972 | |
| 973 | // returns how many items are in the inventory |
| 974 | int Inventorycxx . . $ Inventory#::Sizecxx . . $ Inventory#Size(b126dc7c1de90089).(void) { |
| 975 | // mprintf(0,"Inventory System: Size\n"); |
| 976 | return countcxx . . $ Inventory#count.; |
| 977 | } |
| 978 | |
| 979 | // returns true if there is an item in the inventory with the given type/id |
| 980 | bool Inventorycxx . . $ Inventory#::CheckItemcxx . . $ Inventory#CheckItem(cf9ef193275fa6d8).(int type, int id) { |
| 981 | // mprintf(0,"Inventory System: CheckItem\n"); |
| 982 | if (FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(type, id)) |
| 983 | return true; |
| 984 | else |
| 985 | return false; |
| 986 | } |
| 987 | |
| 988 | // saves the inventory to the file (returns number of bytes written) |
| 989 | int Inventorycxx . . $ Inventory#::SaveInventorycxx . . $ Inventory#SaveInventory(413716a422df0036).(CFILEcxx . . $ CFILE# *file) { |
| 990 | int num_items = Sizecxx . . $ Inventory#Size(b126dc7c1de90089).(); |
| 991 | |
| 992 | int start_pos = cftellcxx . . $ cftell(65b457210a6528a1).(file); |
| 993 | |
| 994 | int pos_pos = 0; |
| 995 | int pos_count = 0; |
| 996 | |
| 997 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, num_items); |
| 998 | if (num_items > 0) { |
| 999 | inven_itemcxx . . $ inven_item# *curr; |
| 1000 | curr = rootcxx . . $ Inventory#root.; |
| 1001 | |
| 1002 | while (num_items > 0) { |
| 1003 | if (poscxx . . $ Inventory#pos. == curr) { |
| 1004 | pos_pos = pos_count; |
| 1005 | } |
| 1006 | |
| 1007 | if (curr->idcxx . . $ inven_item#id. == -1) { |
| 1008 | // make sure it is a valid object |
| 1009 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(curr->typecxx . . $ inven_item#type.); |
| 1010 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj); |
| 1011 | if (!obj) { |
| 1012 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Invalid object saving inventory\n"); |
| 1013 | curr = curr->nextcxx . . $ inven_item#next.; |
| 1014 | num_items--; |
| 1015 | pos_count++; |
| 1016 | continue; |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, curr->typecxx . . $ inven_item#type.); |
| 1021 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, curr->otypecxx . . $ inven_item#otype.); |
| 1022 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, curr->idcxx . . $ inven_item#id.); |
| 1023 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, curr->oidcxx . . $ inven_item#oid.); |
| 1024 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, curr->flagscxx . . $ inven_item#flags.); |
| 1025 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, curr->countcxx . . $ inven_item#count.); |
| 1026 | |
| 1027 | if (curr->descriptioncxx . . $ inven_item#description.) |
| 1028 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(file, curr->descriptioncxx . . $ inven_item#description.); |
| 1029 | else |
| 1030 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, 0); |
| 1031 | |
| 1032 | if (curr->icon_namecxx . . $ inven_item#icon_name.) |
| 1033 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(file, curr->icon_namecxx . . $ inven_item#icon_name.); |
| 1034 | else |
| 1035 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, 0); |
| 1036 | |
| 1037 | if (curr->namecxx . . $ inven_item#name.) |
| 1038 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(file, curr->namecxx . . $ inven_item#name.); |
| 1039 | else |
| 1040 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(file, 0); |
| 1041 | |
| 1042 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, curr->iflagscxx . . $ inven_item#iflags.); |
| 1043 | |
| 1044 | curr = curr->nextcxx . . $ inven_item#next.; |
| 1045 | num_items--; |
| 1046 | pos_count++; |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(file, pos_pos); |
| 1051 | |
| 1052 | int end_pos = cftellcxx . . $ cftell(65b457210a6528a1).(file); |
| 1053 | |
| 1054 | return (end_pos - start_pos); |
| 1055 | } |
| 1056 | |
| 1057 | // restores the inventory from file (returns number of bytes read) |
| 1058 | int Inventorycxx . . $ Inventory#::ReadInventorycxx . . $ Inventory#ReadInventory(413716a422df0036).(CFILEcxx . . $ CFILE# *file) { |
| 1059 | int start_pos = cftellcxx . . $ cftell(65b457210a6528a1).(file); |
| 1060 | |
| 1061 | int num_items = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1062 | countcxx . . $ Inventory#count. = num_items; |
| 1063 | rootcxx . . $ Inventory#root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1064 | char temp[512]; |
| 1065 | |
| 1066 | int t, i, otype; |
| 1067 | |
| 1068 | if (num_items > 0) { |
| 1069 | inven_itemcxx . . $ inven_item# *item, *prev; |
| 1070 | |
| 1071 | while (num_items > 0) { |
| 1072 | t = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1073 | otype = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1074 | i = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1075 | |
| 1076 | // make sure the object is valid |
| 1077 | if (i == -1) { |
| 1078 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(t); |
| 1079 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj); |
| 1080 | if (!obj) { |
| 1081 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Invalid object restoring inventory\n"); |
| 1082 | // skip this object |
| 1083 | cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1084 | cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1085 | cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1086 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(temp, 512, file); |
| 1087 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(temp, 512, file); |
| 1088 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(temp, 512, file); |
| 1089 | cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1090 | num_items--; |
| 1091 | countcxx . . $ Inventory#count.--; |
| 1092 | continue; |
| 1093 | } |
| 1094 | } |
| 1095 | |
| 1096 | if (rootcxx . . $ Inventory#root. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1097 | // there are no items in the list...time to add |
| 1098 | rootcxx . . $ Inventory#root. = new inven_itemcxx . . $ inven_item#; |
| 1099 | item = rootcxx . . $ Inventory#root.; |
| 1100 | rootcxx . . $ Inventory#root.->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 1101 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = rootcxx . . $ Inventory#root.; |
| 1102 | } else { |
| 1103 | item = new inven_itemcxx . . $ inven_item#; |
| 1104 | |
| 1105 | prev = rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev.; |
| 1106 | |
| 1107 | item->prevcxx . . $ inven_item#prev. = prev; |
| 1108 | prev->nextcxx . . $ inven_item#next. = item; |
| 1109 | item->nextcxx . . $ inven_item#next. = rootcxx . . $ Inventory#root.; |
| 1110 | rootcxx . . $ Inventory#root.->prevcxx . . $ inven_item#prev. = item; |
| 1111 | } |
| 1112 | |
| 1113 | item->typecxx . . $ inven_item#type. = t; |
| 1114 | item->idcxx . . $ inven_item#id. = i; |
| 1115 | item->otypecxx . . $ inven_item#otype. = otype; |
| 1116 | item->oidcxx . . $ inven_item#oid. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1117 | item->flagscxx . . $ inven_item#flags. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1118 | item->countcxx . . $ inven_item#count. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1119 | |
| 1120 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(temp, 512, file); |
| 1121 | item->descriptioncxx . . $ inven_item#description. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(temp); |
| 1122 | |
| 1123 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(temp, 512, file); |
| 1124 | item->icon_namecxx . . $ inven_item#icon_name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(temp); |
| 1125 | |
| 1126 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(temp, 512, file); |
| 1127 | item->namecxx . . $ inven_item#name. = mem_strdupcxx . . $ `mem/mem.h:81:9`!(temp); |
| 1128 | |
| 1129 | item->iflagscxx . . $ inven_item#iflags. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1130 | |
| 1131 | num_items--; |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | int pos_index = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(file); |
| 1136 | GotoPoscxx . . $ Inventory#GotoPos(d4f767463ce0a6b3).(pos_index); |
| 1137 | ValidatePoscxx . . $ Inventory#ValidatePos(b45ddcbc8423892c).(); |
| 1138 | |
| 1139 | int end_pos = cftellcxx . . $ cftell(65b457210a6528a1).(file); |
| 1140 | |
| 1141 | return (end_pos - start_pos); |
| 1142 | } |
| 1143 | |
| 1144 | // resets the position pointer in the list to the beginning |
| 1145 | void Inventorycxx . . $ Inventory#::ResetPoscxx . . $ Inventory#ResetPos(49f6e7a06ebc5aa8).(void) { poscxx . . $ Inventory#pos. = rootcxx . . $ Inventory#root.; } |
| 1146 | |
| 1147 | // moves the position pointer to the next inventory item |
| 1148 | void Inventorycxx . . $ Inventory#::NextPoscxx . . $ Inventory#NextPos(b45ddcbc8423892c).(bool skip) { |
| 1149 | if ((poscxx . . $ Inventory#pos.) && (poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next.)) { |
| 1150 | poscxx . . $ Inventory#pos. = poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next.; |
| 1151 | } else if (!poscxx . . $ Inventory#pos.) { |
| 1152 | poscxx . . $ Inventory#pos. = rootcxx . . $ Inventory#root.; |
| 1153 | } else |
| 1154 | return; |
| 1155 | |
| 1156 | if (!skip) |
| 1157 | ValidatePoscxx . . $ Inventory#ValidatePos(b45ddcbc8423892c).(); |
| 1158 | } |
| 1159 | |
| 1160 | // moves the position pointer to the previous inventory item |
| 1161 | void Inventorycxx . . $ Inventory#::PrevPoscxx . . $ Inventory#PrevPos(b45ddcbc8423892c).(bool skip) { |
| 1162 | if ((poscxx . . $ Inventory#pos.) && (poscxx . . $ Inventory#pos.->prevcxx . . $ inven_item#prev.)) { |
| 1163 | poscxx . . $ Inventory#pos. = poscxx . . $ Inventory#pos.->prevcxx . . $ inven_item#prev.; |
| 1164 | } else if (!poscxx . . $ Inventory#pos.) { |
| 1165 | poscxx . . $ Inventory#pos. = rootcxx . . $ Inventory#root.; |
| 1166 | } else |
| 1167 | return; |
| 1168 | |
| 1169 | if (!skip) |
| 1170 | ValidatePoscxx . . $ Inventory#ValidatePos(b45ddcbc8423892c).(false); |
| 1171 | } |
| 1172 | |
| 1173 | // returns true if the position pointer is at the begining of the inventory list |
| 1174 | bool Inventorycxx . . $ Inventory#::AtBeginningcxx . . $ Inventory#AtBeginning(c9857a73d68e59ba).(void) { |
| 1175 | if (!poscxx . . $ Inventory#pos.) |
| 1176 | return true; |
| 1177 | if (poscxx . . $ Inventory#pos. == rootcxx . . $ Inventory#root.) |
| 1178 | return true; |
| 1179 | else |
| 1180 | return false; |
| 1181 | } |
| 1182 | |
| 1183 | // returns false if the position pointer is at the end of the inventory list |
| 1184 | bool Inventorycxx . . $ Inventory#::AtEndcxx . . $ Inventory#AtEnd(c9857a73d68e59ba).(void) { |
| 1185 | if (!poscxx . . $ Inventory#pos.) |
| 1186 | return true; |
| 1187 | if (poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next. == rootcxx . . $ Inventory#root.) |
| 1188 | return true; |
| 1189 | else |
| 1190 | return false; |
| 1191 | } |
| 1192 | |
| 1193 | // returns the type/id of the item at the current position |
| 1194 | // returns true if the pos is a real object in the game |
| 1195 | // returns false if the pos is just a type/id inventory item |
| 1196 | bool Inventorycxx . . $ Inventory#::GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(int &type, int &id) { |
| 1197 | if (!poscxx . . $ Inventory#pos.) { |
| 1198 | type = id = 0; |
| 1199 | return false; |
| 1200 | } |
| 1201 | |
| 1202 | type = poscxx . . $ Inventory#pos.->typecxx . . $ inven_item#type.; |
| 1203 | id = poscxx . . $ Inventory#pos.->idcxx . . $ inven_item#id.; |
| 1204 | |
| 1205 | if (poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) |
| 1206 | return true; |
| 1207 | else |
| 1208 | return false; |
| 1209 | } |
| 1210 | |
| 1211 | // returns the aux type/id of the item |
| 1212 | // returns true if the pos is a real object in the game |
| 1213 | // returns false if the pos is just a type/id inventory item |
| 1214 | bool Inventorycxx . . $ Inventory#::GetAuxPosTypeIDcxx . . $ Inventory#GetAuxPosTypeID(8a990ad1ed500b42).(int &type, int &id) { |
| 1215 | if (!poscxx . . $ Inventory#pos.) { |
| 1216 | type = id = 0; |
| 1217 | return false; |
| 1218 | } |
| 1219 | type = poscxx . . $ Inventory#pos.->otypecxx . . $ inven_item#otype.; |
| 1220 | id = poscxx . . $ Inventory#pos.->oidcxx . . $ inven_item#oid.; |
| 1221 | |
| 1222 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(type != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!); |
| 1223 | |
| 1224 | if (poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) |
| 1225 | return true; |
| 1226 | else |
| 1227 | return false; |
| 1228 | } |
| 1229 | |
| 1230 | // returns the description of the item at the current position |
| 1231 | char *Inventorycxx . . $ Inventory#::GetPosDescriptioncxx . . $ Inventory#GetPosDescription(41208ce6ca65dd58).(void) { |
| 1232 | // mprintf(0,"Getting Pos Description (%s)\n",pos->description); |
| 1233 | if (!poscxx . . $ Inventory#pos.) |
| 1234 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1235 | return poscxx . . $ Inventory#pos.->descriptioncxx . . $ inven_item#description.; |
| 1236 | } |
| 1237 | |
| 1238 | // returns the name of the item at the current position |
| 1239 | char *Inventorycxx . . $ Inventory#::GetPosNamecxx . . $ Inventory#GetPosName(41208ce6ca65dd58).(void) { |
| 1240 | if (!poscxx . . $ Inventory#pos.) |
| 1241 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1242 | return poscxx . . $ Inventory#pos.->namecxx . . $ inven_item#name.; |
| 1243 | } |
| 1244 | |
| 1245 | // returns the icon name of the item at the current position |
| 1246 | char *Inventorycxx . . $ Inventory#::GetPosIconNamecxx . . $ Inventory#GetPosIconName(41208ce6ca65dd58).(void) { |
| 1247 | if (!poscxx . . $ Inventory#pos.) |
| 1248 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1249 | return poscxx . . $ Inventory#pos.->icon_namecxx . . $ inven_item#icon_name.; |
| 1250 | } |
| 1251 | |
| 1252 | // returns the count of the item at the current position |
| 1253 | int Inventorycxx . . $ Inventory#::GetPosCountcxx . . $ Inventory#GetPosCount(b126dc7c1de90089).(void) { |
| 1254 | // mprintf(0,"Getting Pos Count (%d)\n",pos->count); |
| 1255 | if (!poscxx . . $ Inventory#pos.) |
| 1256 | return 0; |
| 1257 | |
| 1258 | if (poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) |
| 1259 | return 1; |
| 1260 | |
| 1261 | return poscxx . . $ Inventory#pos.->countcxx . . $ inven_item#count.; |
| 1262 | } |
| 1263 | |
| 1264 | // return information about the current position item |
| 1265 | // returns true if the pos is a real object in the game |
| 1266 | // returns false if the pos is just a type/id inventory item |
| 1267 | bool Inventorycxx . . $ Inventory#::GetPosInfocxx . . $ Inventory#GetPosInfo(a9f116dbdd7af36d).(uint16_tcxx . . $ uint16_t# &iflags, int &flags) { |
| 1268 | if (!poscxx . . $ Inventory#pos.) { |
| 1269 | iflags = 0; |
| 1270 | flags = 0; |
| 1271 | return false; |
| 1272 | } |
| 1273 | |
| 1274 | iflags = poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags.; |
| 1275 | flags = poscxx . . $ Inventory#pos.->flagscxx . . $ inven_item#flags.; |
| 1276 | |
| 1277 | if (poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) |
| 1278 | return true; |
| 1279 | else |
| 1280 | return false; |
| 1281 | } |
| 1282 | |
| 1283 | // goes to a position in the list |
| 1284 | void Inventorycxx . . $ Inventory#::GotoPoscxx . . $ Inventory#GotoPos(d4f767463ce0a6b3).(int newpos) { |
| 1285 | // mprintf(0,"Going to Pos (%d)\n",newpos); |
| 1286 | ResetPoscxx . . $ Inventory#ResetPos(49f6e7a06ebc5aa8).(); |
| 1287 | int i; |
| 1288 | for (i = 0; i < newpos; i++) { |
| 1289 | if ((poscxx . . $ Inventory#pos.) && (poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 1290 | poscxx . . $ Inventory#pos. = poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next.; |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | // moves the current item pointer to the specified type/id |
| 1295 | void Inventorycxx . . $ Inventory#::GotoPoscxx . . $ Inventory#GotoPos(3e454b8ccf442868).(int type, int id) { |
| 1296 | inven_itemcxx . . $ inven_item# *node = FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(type, id); |
| 1297 | |
| 1298 | if (node) |
| 1299 | poscxx . . $ Inventory#pos. = node; |
| 1300 | } |
| 1301 | |
| 1302 | // returns the "index" position of the current item |
| 1303 | int Inventorycxx . . $ Inventory#::GetPoscxx . . $ Inventory#GetPos(b126dc7c1de90089).(void) { |
| 1304 | int type, id; |
| 1305 | int ctype, cid; |
| 1306 | int count = 0; |
| 1307 | bool done = false; |
| 1308 | |
| 1309 | if (!Sizecxx . . $ Inventory#Size(b126dc7c1de90089).()) |
| 1310 | return -1; |
| 1311 | |
| 1312 | bool is_object, cis_object; |
| 1313 | |
| 1314 | is_object = GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(type, id); |
| 1315 | ResetPoscxx . . $ Inventory#ResetPos(49f6e7a06ebc5aa8).(); |
| 1316 | |
| 1317 | done = AtEndcxx . . $ Inventory#AtEnd(c9857a73d68e59ba).(); |
| 1318 | |
| 1319 | while (!done) { |
| 1320 | cis_object = GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(ctype, cid); |
| 1321 | if ((ctype == type) && (cid == id) && (cis_object == is_object)) |
| 1322 | return count; |
| 1323 | |
| 1324 | count++; |
| 1325 | done = AtEndcxx . . $ Inventory#AtEnd(c9857a73d68e59ba).(); |
| 1326 | NextPoscxx . . $ Inventory#NextPos(b45ddcbc8423892c).(false); |
| 1327 | } |
| 1328 | return 0; |
| 1329 | } |
| 1330 | |
| 1331 | // moves to the next/prev item in the inventory list (forward==TRUE means forward, forward==FALSE means go backwards) |
| 1332 | void InventorySwitchcxx . . $ InventorySwitch(b45ddcbc8423892c).(bool forward) { |
| 1333 | int ctype, cid; |
| 1334 | |
| 1335 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].inventorycxx . . $ player#inventory..GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(ctype, cid); |
| 1336 | |
| 1337 | if (ctype != 0) { |
| 1338 | if (forward) { |
| 1339 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].inventorycxx . . $ player#inventory..NextPoscxx . . $ Inventory#NextPos(b45ddcbc8423892c).(); |
| 1340 | } else { |
| 1341 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].inventorycxx . . $ player#inventory..PrevPoscxx . . $ Inventory#PrevPos(b45ddcbc8423892c).(); |
| 1342 | } |
| 1343 | |
| 1344 | int ntype, nid; |
| 1345 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].inventorycxx . . $ player#inventory..GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(ntype, nid); |
| 1346 | |
| 1347 | if (ntype != ctype || nid != cid) { |
| 1348 | // AddHUDMessage(TXT_WPNSELECT, Players[Player_num].inventory.GetPosName()); |
| 1349 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_CHANGE_INVENTORYcxx . . $ `Descent3/sounds.h:150:9`!); |
| 1350 | |
| 1351 | ain_hearcxx . . $ ain_hear# hear; |
| 1352 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 1353 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.0f; |
| 1354 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.3f; |
| 1355 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 1356 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 1357 | } |
| 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | // moves to the next/prev item in the counter measures list (forward==TRUE means forward, forward==FALSE means go |
| 1362 | // backwards) |
| 1363 | void CounterMeasuresSwitchcxx . . $ CounterMeasuresSwitch(b45ddcbc8423892c).(bool forward) { |
| 1364 | int ctype, cid; |
| 1365 | |
| 1366 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].counter_measurescxx . . $ player#counter_measures..GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(ctype, cid); |
| 1367 | |
| 1368 | if (ctype != 0) { |
| 1369 | if (forward) { |
| 1370 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].counter_measurescxx . . $ player#counter_measures..NextPoscxx . . $ Inventory#NextPos(b45ddcbc8423892c).(); |
| 1371 | } else { |
| 1372 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].counter_measurescxx . . $ player#counter_measures..PrevPoscxx . . $ Inventory#PrevPos(b45ddcbc8423892c).(); |
| 1373 | } |
| 1374 | |
| 1375 | int ntype, nid; |
| 1376 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].counter_measurescxx . . $ player#counter_measures..GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(ntype, nid); |
| 1377 | |
| 1378 | if (ntype != ctype || nid != cid) { |
| 1379 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).(TXT_WPNSELECTcxx . . $ `Descent3/stringtable.h:273:9`!, Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].counter_measurescxx . . $ player#counter_measures..GetPosNamecxx . . $ Inventory#GetPosName(41208ce6ca65dd58).()); |
| 1380 | Sound_systemcxx . . $ Sound_system..Play2dSoundcxx . . $ hlsSystem#Play2dSound(d251026853493025).(SOUND_CHANGE_COUNTERMEASUREcxx . . $ `Descent3/sounds.h:149:9`!); |
| 1381 | |
| 1382 | ain_hearcxx . . $ ain_hear# hear; |
| 1383 | hear.f_directly_playercxx . . $ ain_hear#f_directly_player. = true; |
| 1384 | hear.hostile_levelcxx . . $ ain_hear#hostile_level. = 0.0f; |
| 1385 | hear.curiosity_levelcxx . . $ ain_hear#curiosity_level. = 0.3f; |
| 1386 | hear.max_distcxx . . $ ain_hear#max_dist. = AI_SOUND_SHORT_DISTcxx . . $ `Descent3/AIMain.h:157:9`!; |
| 1387 | AINotifycxx . . $ AINotify(f32b5964aaa42c22).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], AIN_HEAR_NOISEcxx . . $ `Descent3/aistruct_external.h:297:9`!, (void *)&hear); |
| 1388 | } |
| 1389 | } |
| 1390 | } |
| 1391 | |
| 1392 | // repositions the pos so its in the correct spot |
| 1393 | void Inventorycxx . . $ Inventory#::ValidatePoscxx . . $ Inventory#ValidatePos(b45ddcbc8423892c).(bool forward) { |
| 1394 | if (!poscxx . . $ Inventory#pos.) |
| 1395 | return; |
| 1396 | if (poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags. & INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!) |
| 1397 | return; |
| 1398 | |
| 1399 | inven_itemcxx . . $ inven_item# *node; |
| 1400 | if (forward) |
| 1401 | node = poscxx . . $ Inventory#pos.->nextcxx . . $ inven_item#next.; |
| 1402 | else |
| 1403 | node = poscxx . . $ Inventory#pos.->prevcxx . . $ inven_item#prev.; |
| 1404 | |
| 1405 | while (node != poscxx . . $ Inventory#pos.) { |
| 1406 | if (node->iflagscxx . . $ inven_item#iflags. & INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!) { |
| 1407 | poscxx . . $ Inventory#pos. = node; |
| 1408 | return; |
| 1409 | } |
| 1410 | |
| 1411 | if (forward) |
| 1412 | node = node->nextcxx . . $ inven_item#next.; |
| 1413 | else |
| 1414 | node = node->prevcxx . . $ inven_item#prev.; |
| 1415 | } |
| 1416 | poscxx . . $ Inventory#pos. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1417 | } |
| 1418 | |
| 1419 | // returns how many of a type/id exists in the inventory |
| 1420 | int Inventorycxx . . $ Inventory#::GetTypeIDCountcxx . . $ Inventory#GetTypeIDCount(9b79fb6aee4c0440).(int type, int id) { |
| 1421 | inven_itemcxx . . $ inven_item# *node = FindItemcxx . . $ Inventory#FindItem(586a8ad64a9b86d4).(type, id); |
| 1422 | |
| 1423 | if (!node) |
| 1424 | return 0; |
| 1425 | if (node->flagscxx . . $ inven_item#flags. & INVF_OBJECTcxx . . $ `Descent3/Inventory.h:196:9`!) { |
| 1426 | return 1; |
| 1427 | } |
| 1428 | |
| 1429 | return node->countcxx . . $ inven_item#count.; |
| 1430 | } |
| 1431 | |
| 1432 | // determines whether the position is selectable |
| 1433 | bool Inventorycxx . . $ Inventory#::IsSelectablecxx . . $ Inventory#IsSelectable(c9857a73d68e59ba).(void) { |
| 1434 | if (!poscxx . . $ Inventory#pos.) |
| 1435 | return false; |
| 1436 | |
| 1437 | return ((poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags. & INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!) != 0); |
| 1438 | } |
| 1439 | |
| 1440 | // determines whether the position is selectable |
| 1441 | bool Inventorycxx . . $ Inventory#::IsUsablecxx . . $ Inventory#IsUsable(c9857a73d68e59ba).(void) { |
| 1442 | if (!poscxx . . $ Inventory#pos.) |
| 1443 | return false; |
| 1444 | |
| 1445 | return ((poscxx . . $ Inventory#pos.->iflagscxx . . $ inven_item#iflags. & INVF_USEABLEcxx . . $ `Descent3/Inventory.h:192:9`!) != 0); |
| 1446 | } |
| 1447 | |
| 1448 | // gets a detailed list of information about what is in the inventory |
| 1449 | // returns the number of items filled in. |
| 1450 | int Inventorycxx . . $ Inventory#::GetInventoryItemListcxx . . $ Inventory#GetInventoryItemList(e2f4838e36fa1452).(tInvenListcxx . . $ tInvenList# *list, int max_amount, int *cur_sel) { |
| 1451 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(cur_sel); |
| 1452 | *cur_sel = -1; |
| 1453 | |
| 1454 | if (max_amount <= 0) |
| 1455 | return 0; |
| 1456 | |
| 1457 | inven_itemcxx . . $ inven_item# *current = rootcxx . . $ Inventory#root.; |
| 1458 | if (countcxx . . $ Inventory#count. == 0) |
| 1459 | return 0; // there are no items, don't even bother |
| 1460 | |
| 1461 | int counter = countcxx . . $ Inventory#count.; |
| 1462 | int cur_count = 0; |
| 1463 | |
| 1464 | while (counter) { |
| 1465 | if (cur_count < max_amount) { |
| 1466 | if (current == poscxx . . $ Inventory#pos.) { |
| 1467 | // current selected |
| 1468 | *cur_sel = cur_count; |
| 1469 | } |
| 1470 | |
| 1471 | list[cur_count].amountcxx . . $ tInvenList#amount. = current->countcxx . . $ inven_item#count.; |
| 1472 | list[cur_count].hud_namecxx . . $ tInvenList#hud_name. = current->namecxx . . $ inven_item#name.; |
| 1473 | list[cur_count].selectablecxx . . $ tInvenList#selectable. = (current->iflagscxx . . $ inven_item#iflags. & INVF_SELECTABLEcxx . . $ `Descent3/Inventory.h:191:9`!) ? true : false; |
| 1474 | cur_count++; |
| 1475 | } |
| 1476 | |
| 1477 | current = current->nextcxx . . $ inven_item#next.; |
| 1478 | counter--; |
| 1479 | } |
| 1480 | |
| 1481 | return countcxx . . $ Inventory#count.; |
| 1482 | } |
| 1483 | |
| 1484 | // use the currently selected inventory item |
| 1485 | bool UseInventoryItemcxx . . $ UseInventoryItem(c9857a73d68e59ba).() { |
| 1486 | int type, id; |
| 1487 | |
| 1488 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].inventorycxx . . $ player#inventory..GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(type, id); |
| 1489 | if (!type && !id) |
| 1490 | return false; |
| 1491 | |
| 1492 | if (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].inventorycxx . . $ player#inventory..UsePoscxx . . $ Inventory#UsePos(39516aeee13ca5ab).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.])) { |
| 1493 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!)) { |
| 1494 | MultiSendInventoryRemoveItemcxx . . $ MultiSendInventoryRemoveItem(b1146eedae1e1d0b).(Player_numcxx . . $ Player_num., type, id); |
| 1495 | } |
| 1496 | } |
| 1497 | return true; |
| 1498 | } |
| 1499 | |
| 1500 | // use the currently selected countermeasure |
| 1501 | bool UseCountermeasurecxx . . $ UseCountermeasure(c9857a73d68e59ba).() { |
| 1502 | int type, id; |
| 1503 | |
| 1504 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].counter_measurescxx . . $ player#counter_measures..GetPosTypeIDcxx . . $ Inventory#GetPosTypeID(8a990ad1ed500b42).(type, id); |
| 1505 | if (!type && !id) |
| 1506 | return false; |
| 1507 | |
| 1508 | if (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].counter_measurescxx . . $ player#counter_measures..UsePoscxx . . $ Inventory#UsePos(39516aeee13ca5ab).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.])) { |
| 1509 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!)) { |
| 1510 | MultiSendInventoryRemoveItemcxx . . $ MultiSendInventoryRemoveItem(b1146eedae1e1d0b).(Player_numcxx . . $ Player_num., type, id); |
| 1511 | } |
| 1512 | } |
| 1513 | return true; |
| 1514 | } |
| 1515 | |
| 1516 | // Checks for an object in any of the players inventorys and removes it |
| 1517 | void InventoryRemoveObjectcxx . . $ InventoryRemoveObject(d4f767463ce0a6b3).(int objhandle) { |
| 1518 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(objhandle); |
| 1519 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj); |
| 1520 | if (!obj) |
| 1521 | return; |
| 1522 | |
| 1523 | if (!(obj->flagscxx . . $ object#flags. & OF_INPLAYERINVENTORYcxx . . $ `Descent3/object_external.h:299:9`!)) // not in the player's inventory |
| 1524 | return; |
| 1525 | |
| 1526 | // go through all the players and look for the object |
| 1527 | for (int i = 0; i < MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`!; i++) { |
| 1528 | if (Playerscxx . . $ Players.[i].inventorycxx . . $ player#inventory..CheckItemcxx . . $ Inventory#CheckItem(cf9ef193275fa6d8).(objhandle, -1)) { |
| 1529 | // this player has it!! |
| 1530 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "INVEN: Removing dead object from %d\n", i); |
| 1531 | Playerscxx . . $ Players.[i].inventorycxx . . $ player#inventory..Removecxx . . $ Inventory#Remove(cf9ef193275fa6d8).(objhandle, -1); |
| 1532 | return; |
| 1533 | } |
| 1534 | } |
| 1535 | } |