| 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/objinfo.cpp $ |
| 21 | * $Revision: 64 $ |
| 22 | * $Date: 4/19/00 5:07p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Code to handle objects in the big list of robots,powerups,etc. |
| 26 | * |
| 27 | * $NoKeywords: $ |
| 28 | */ |
| 29 | |
| 30 | #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/ |
| 31 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 32 | #include "object.h"cxx . . $ `<file>/Descent3/object.h`/ |
| 33 | #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/ |
| 34 | #include "3d.h"cxx . . $ `<file>/lib/3d.h`/ |
| 35 | #include <stdlib.h> |
| 36 | #include <stdio.h> |
| 37 | #include <stdarg.h> |
| 38 | #include <string.h> |
| 39 | #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/ |
| 40 | #include "robotfire.h"cxx . . $ `<file>/Descent3/robotfire.h`/ |
| 41 | #include "AIMain.h"cxx . . $ `<file>/Descent3/AIMain.h`/ |
| 42 | #include "sounds.h"cxx . . $ `<file>/Descent3/sounds.h`/ |
| 43 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 44 | #include "mem.h"cxx . . $ `<file>/mem/mem.h`/ |
| 45 | |
| 46 | // The array with information for robots, powerups, buildings, etc. |
| 47 | object_infocxx . . $ object_info# Object_infocxx . . $ Object_info.[MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!]; |
| 48 | |
| 49 | // The number of ids of each type in the list |
| 50 | int Num_object_idscxx . . $ Num_object_ids.[MAX_OBJECT_TYPEScxx . . $ `Descent3/object_external.h:186:9`!]; |
| 51 | |
| 52 | // Objects that must be remapped so we can reference by index |
| 53 | // If you change this array then you must change the defines in the header file |
| 54 | // #ifdef _WIN32 |
| 55 | // char *Static_object_names[]={TBL_GENERIC("GuideBot"),TBL_GENERIC("ChaffChunk"),TBL_GENERIC("GuideBotRed")}; |
| 56 | // #else |
| 57 | const char *Static_object_namescxx . . $ Static_object_names.[] = {TBL_GENERICcxx . . $ `lib/manage_external.h:59:9`!("GuideBot"), TBL_GENERICcxx . . $ `lib/manage_external.h:59:9`!("ChaffChunk"),TBL_GENERICcxx . . $ `lib/manage_external.h:59:9`!("GuideBotRed")}; |
| 58 | // #endif |
| 59 | |
| 60 | #define NUM_STATIC_OBJECTScxx . . $ `Descent3/objinfo.cpp:60:9`! (sizeof(Static_object_names) / sizeof(*Static_object_names)) |
| 61 | |
| 62 | #ifdef EDITOR |
| 63 | const char * const Movement_class_names[] = {"Standing", "Flying", "Rolling", "Walking", "Jumping"}; |
| 64 | const char * const Anim_state_names[] = {"Alert", |
| 65 | "Death", |
| 66 | "Fire Missile 1", |
| 67 | "Missile Recoil 1", |
| 68 | "Fire Missile 2", |
| 69 | "Missile Recoil 2", |
| 70 | "Melee 1", |
| 71 | "Melee Recoil 1", |
| 72 | "Melee 2", |
| 73 | "Melee Recoil 2", |
| 74 | "Idle", |
| 75 | "Quirk", |
| 76 | "Flinch", |
| 77 | "Taunt", |
| 78 | "To Standing Idle", |
| 79 | "To Flying Idle", |
| 80 | "To Rolling Idle", |
| 81 | ";To Walking Idle", |
| 82 | "To Jumping Idle", |
| 83 | "Goto standing", |
| 84 | "Goto flying", |
| 85 | "Goto rolling", |
| 86 | "Goto walking", |
| 87 | "Goto jumping"}; |
| 88 | #endif |
| 89 | |
| 90 | // Sets all objects to unused |
| 91 | void InitObjectInfocxx . . $ InitObjectInfo(49f6e7a06ebc5aa8).() { |
| 92 | int i; |
| 93 | |
| 94 | for (i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) { |
| 95 | Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. = OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!; |
| 96 | Object_infocxx . . $ Object_info.[i].namecxx . . $ object_info#name.[0] = 0; |
| 97 | // Object_info[i].script_name[0] = 0; |
| 98 | Object_infocxx . . $ Object_info.[i].script_name_overridecxx . . $ object_info#script_name_override.[0] = 0; |
| 99 | Object_infocxx . . $ Object_info.[i].multi_allowedcxx . . $ object_info#multi_allowed. = 1; |
| 100 | Object_infocxx . . $ Object_info.[i].module_namecxx . . $ object_info#module_name.[0] = 0; |
| 101 | } |
| 102 | |
| 103 | for (i = 0; i < MAX_OBJECT_TYPEScxx . . $ `Descent3/object_external.h:186:9`!; i++) |
| 104 | Num_object_idscxx . . $ Num_object_ids.[i] = 0; |
| 105 | |
| 106 | atexit(FreeObjectInfocxx . . $ FreeObjectInfo(49f6e7a06ebc5aa8).); |
| 107 | } |
| 108 | |
| 109 | #define DEFAULT_OBJECT_SIZEcxx . . $ `Descent3/objinfo.cpp:109:9`! 4.0f |
| 110 | #define DEFAULT_OBJECT_MASScxx . . $ `Descent3/objinfo.cpp:110:9`! 1.0f |
| 111 | #define DEFAULT_OBJECT_DRAGcxx . . $ `Descent3/objinfo.cpp:111:9`! 0.1f |
| 112 | #define DEFAULT_OBJECT_ROTDRAGcxx . . $ `Descent3/objinfo.cpp:112:9`! 0.01f |
| 113 | |
| 114 | // Allocs a object for use, returns -1 if error, else index on success |
| 115 | int AllocObjectIDcxx . . $ AllocObjectID(851aef5fe1595069).(int type, bool f_anim, bool f_weapons, bool f_ai) { |
| 116 | int j, k; |
| 117 | |
| 118 | for (int i = NUM_STATIC_OBJECTScxx . . $ `Descent3/objinfo.cpp:60:9`!; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) { |
| 119 | if (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. == OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) { |
| 120 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "%d ", type); |
| 121 | memset(&Object_infocxx . . $ Object_info.[i], 0, sizeof(*Object_infocxx . . $ Object_info.)); |
| 122 | |
| 123 | extern void AISetDefaultcxx . . $ AISetDefault(452b88ebebccf6b5).(t_ai_infocxx . . $ t_ai_info# * ai_info_ptr); |
| 124 | if (f_ai) { |
| 125 | Object_infocxx . . $ Object_info.[i].ai_infocxx . . $ object_info#ai_info. = (t_ai_infocxx . . $ t_ai_info# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(t_ai_info)); |
| 126 | memset(Object_infocxx . . $ Object_info.[i].ai_infocxx . . $ object_info#ai_info., 0, sizeof(t_ai_infocxx . . $ t_ai_info#)); |
| 127 | AISetDefaultcxx . . $ AISetDefault(452b88ebebccf6b5).(Object_infocxx . . $ Object_info.[i].ai_infocxx . . $ object_info#ai_info.); |
| 128 | } |
| 129 | // Make sure the weapon battery info is cleared for a new object |
| 130 | if (f_weapons) { |
| 131 | Object_infocxx . . $ Object_info.[i].static_wbcxx . . $ object_info#static_wb. = (otype_wb_infocxx . . $ otype_wb_info# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(otype_wb_info) * MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!); |
| 132 | memset(Object_infocxx . . $ Object_info.[i].static_wbcxx . . $ object_info#static_wb., 0, sizeof(otype_wb_infocxx . . $ otype_wb_info#) * MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!); |
| 133 | WBClearInfocxx . . $ WBClearInfo(35337aada7327cb).(Object_infocxx . . $ Object_info.[i].static_wbcxx . . $ object_info#static_wb.); |
| 134 | } |
| 135 | |
| 136 | if (f_anim) { |
| 137 | Object_infocxx . . $ Object_info.[i].animcxx . . $ object_info#anim. = (anim_elemcxx . . $ anim_elem# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(anim_elem) * NUM_MOVEMENT_CLASSEScxx . . $ `Descent3/objinfo.h:368:9`!); |
| 138 | memset(Object_infocxx . . $ Object_info.[i].animcxx . . $ object_info#anim., 0, sizeof(anim_elemcxx . . $ anim_elem#) * NUM_MOVEMENT_CLASSEScxx . . $ `Descent3/objinfo.h:368:9`!); |
| 139 | for (j = 0; j < NUM_MOVEMENT_CLASSEScxx . . $ `Descent3/objinfo.h:368:9`!; j++) |
| 140 | for (k = 0; k < NUM_ANIMS_PER_CLASScxx . . $ `Descent3/objinfo.h:369:9`!; k++) { |
| 141 | Object_infocxx . . $ Object_info.[i].animcxx . . $ object_info#anim.[j].elemcxx . . $ anim_elem#elem.[k].spccxx . . $ anim_entry#spc. = 1.0f; |
| 142 | Object_infocxx . . $ Object_info.[i].animcxx . . $ object_info#anim.[j].elemcxx . . $ anim_elem#elem.[k].anim_sound_indexcxx . . $ anim_entry#anim_sound_index. = SOUND_NONE_INDEXcxx . . $ `Descent3/sounds.h:105:9`!; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. = type; |
| 147 | Object_infocxx . . $ Object_info.[i].sizecxx . . $ object_info#size. = DEFAULT_OBJECT_SIZEcxx . . $ `Descent3/objinfo.cpp:109:9`!; |
| 148 | Object_infocxx . . $ Object_info.[i].phys_infocxx . . $ object_info#phys_info..masscxx . . $ physics_info#mass. = DEFAULT_OBJECT_MASScxx . . $ `Descent3/objinfo.cpp:110:9`!; |
| 149 | Object_infocxx . . $ Object_info.[i].phys_infocxx . . $ object_info#phys_info..dragcxx . . $ physics_info#drag. = DEFAULT_OBJECT_DRAGcxx . . $ `Descent3/objinfo.cpp:111:9`!; |
| 150 | Object_infocxx . . $ Object_info.[i].phys_infocxx . . $ object_info#phys_info..rotdragcxx . . $ physics_info#rotdrag. = DEFAULT_OBJECT_ROTDRAGcxx . . $ `Descent3/objinfo.cpp:112:9`!; |
| 151 | |
| 152 | Object_infocxx . . $ Object_info.[i].phys_infocxx . . $ object_info#phys_info..flagscxx . . $ physics_info#flags. = PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!; |
| 153 | Object_infocxx . . $ Object_info.[i].phys_infocxx . . $ object_info#phys_info..num_bouncescxx . . $ physics_info#num_bounces. = -1; |
| 154 | Object_infocxx . . $ Object_info.[i].phys_infocxx . . $ object_info#phys_info..coeff_restitutioncxx . . $ physics_info#coeff_restitution. = 1.0; |
| 155 | Object_infocxx . . $ Object_info.[i].phys_infocxx . . $ object_info#phys_info..hit_die_dotcxx . . $ physics_info#$anonymous_type_5#hit_die_dot. = -1; //-1 mean doesn't apply |
| 156 | |
| 157 | Object_infocxx . . $ Object_info.[i].med_render_handlecxx . . $ object_info#med_render_handle. = -1; |
| 158 | Object_infocxx . . $ Object_info.[i].lo_render_handlecxx . . $ object_info#lo_render_handle. = -1; |
| 159 | Object_infocxx . . $ Object_info.[i].med_lod_distancecxx . . $ object_info#med_lod_distance. = DEFAULT_MED_LOD_DISTANCEcxx . . $ `Descent3/objinfo.h:349:9`!; |
| 160 | Object_infocxx . . $ Object_info.[i].lo_lod_distancecxx . . $ object_info#lo_lod_distance. = DEFAULT_LO_LOD_DISTANCEcxx . . $ `Descent3/objinfo.h:350:9`!; |
| 161 | Object_infocxx . . $ Object_info.[i].respawn_scalarcxx . . $ object_info#respawn_scalar. = 1.0; |
| 162 | |
| 163 | if (type == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`! || type == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`!) { |
| 164 | Object_infocxx . . $ Object_info.[i].med_lod_distancecxx . . $ object_info#med_lod_distance. *= 10; |
| 165 | Object_infocxx . . $ Object_info.[i].lo_lod_distancecxx . . $ object_info#lo_lod_distance. *= 10; |
| 166 | } |
| 167 | |
| 168 | // Object_info[i].script_name[0] = 0; |
| 169 | Object_infocxx . . $ Object_info.[i].icon_namecxx . . $ object_info#icon_name.[0] = 0; |
| 170 | Object_infocxx . . $ Object_info.[i].descriptioncxx . . $ object_info#description. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 171 | Object_infocxx . . $ Object_info.[i].flagscxx . . $ object_info#flags. |= OIF_INVEN_SELECTABLEcxx . . $ `Descent3/objinfo.h:336:9`!; |
| 172 | |
| 173 | // init spew types |
| 174 | for (j = 0; j < MAX_DSPEW_TYPEScxx . . $ `Descent3/objinfo.h:383:9`!; j++) { |
| 175 | Object_infocxx . . $ Object_info.[i].dspewcxx . . $ object_info#dspew.[j] = -1; |
| 176 | Object_infocxx . . $ Object_info.[i].dspew_numbercxx . . $ object_info#dspew_number.[j] = 0; |
| 177 | } |
| 178 | |
| 179 | // init ammo count |
| 180 | Object_infocxx . . $ Object_info.[i].ammo_countcxx . . $ object_info#ammo_count. = 0; |
| 181 | Object_infocxx . . $ Object_info.[i].multi_allowedcxx . . $ object_info#multi_allowed. = 1; |
| 182 | Num_object_idscxx . . $ Num_object_ids.[type]++; |
| 183 | return i; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // No slots free! |
| 188 | return -1; |
| 189 | } |
| 190 | |
| 191 | // Frees object index n |
| 192 | void FreeObjectIDcxx . . $ FreeObjectID(d4f767463ce0a6b3).(int n) { |
| 193 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Object_info[n].type != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!); |
| 194 | |
| 195 | Num_object_idscxx . . $ Num_object_ids.[Object_infocxx . . $ Object_info.[n].typecxx . . $ object_info#type.]--; |
| 196 | Object_infocxx . . $ Object_info.[n].typecxx . . $ object_info#type. = OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!; |
| 197 | Object_infocxx . . $ Object_info.[n].namecxx . . $ object_info#name.[0] = 0; |
| 198 | Object_infocxx . . $ Object_info.[n].icon_namecxx . . $ object_info#icon_name.[0] = 0; |
| 199 | Object_infocxx . . $ Object_info.[n].script_name_overridecxx . . $ object_info#script_name_override.[0] = 0; |
| 200 | Object_infocxx . . $ Object_info.[n].module_namecxx . . $ object_info#module_name.[0] = 0; |
| 201 | if (Object_infocxx . . $ Object_info.[n].descriptioncxx . . $ object_info#description.) { |
| 202 | mem_freecxx . . $ `mem/mem.h:80:9`!(Object_info[n].description); |
| 203 | Object_infocxx . . $ Object_info.[n].descriptioncxx . . $ object_info#description. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 204 | } |
| 205 | if (Object_infocxx . . $ Object_info.[n].animcxx . . $ object_info#anim.) // DAJ LEAK FIX |
| 206 | { |
| 207 | mem_freecxx . . $ `mem/mem.h:80:9`!(Object_info[n].anim); |
| 208 | Object_infocxx . . $ Object_info.[n].animcxx . . $ object_info#anim. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 209 | } |
| 210 | if (Object_infocxx . . $ Object_info.[n].ai_infocxx . . $ object_info#ai_info.) // DAJ LEAK FIX |
| 211 | { |
| 212 | mem_freecxx . . $ `mem/mem.h:80:9`!(Object_info[n].ai_info); |
| 213 | Object_infocxx . . $ Object_info.[n].ai_infocxx . . $ object_info#ai_info. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 214 | } |
| 215 | if (Object_infocxx . . $ Object_info.[n].descriptioncxx . . $ object_info#description.) // DAJ LEAK FIX |
| 216 | { |
| 217 | mem_freecxx . . $ `mem/mem.h:80:9`!(Object_info[n].description); |
| 218 | Object_infocxx . . $ Object_info.[n].descriptioncxx . . $ object_info#description. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 219 | } |
| 220 | if (Object_infocxx . . $ Object_info.[n].static_wbcxx . . $ object_info#static_wb.) // DAJ LEAK FIX |
| 221 | { |
| 222 | mem_freecxx . . $ `mem/mem.h:80:9`!(Object_info[n].static_wb); |
| 223 | Object_infocxx . . $ Object_info.[n].static_wbcxx . . $ object_info#static_wb. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Frees up all the Objects and any memory allocated |
| 228 | void FreeObjectInfocxx . . $ FreeObjectInfo(49f6e7a06ebc5aa8).(void) { |
| 229 | for (int i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) { |
| 230 | if (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) |
| 231 | FreeObjectIDcxx . . $ FreeObjectID(d4f767463ce0a6b3).(i); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | // Find an object with the given type. Returns -1 if none found. |
| 236 | int GetObjectIDcxx . . $ GetObjectID(7864480464b09eea).(int type) { |
| 237 | int i; |
| 238 | |
| 239 | for (i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) |
| 240 | if (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. == type) |
| 241 | return i; |
| 242 | |
| 243 | return -1; |
| 244 | } |
| 245 | |
| 246 | #ifdef EDITOR |
| 247 | |
| 248 | // Gets next object from n of the same type as n |
| 249 | int GetNextObjectID(int n) { |
| 250 | int i; |
| 251 | int type = Object_info[n].type; |
| 252 | |
| 253 | ASSERT(n >= 0 && n < MAX_OBJECT_IDS); |
| 254 | |
| 255 | if (Num_object_ids[type] == 0) |
| 256 | return -1; |
| 257 | |
| 258 | for (i = n + 1; i < MAX_OBJECT_IDS; i++) |
| 259 | if (Object_info[i].type == Object_info[n].type) |
| 260 | return i; |
| 261 | |
| 262 | for (i = 0; i <= n; i++) |
| 263 | if (Object_info[i].type == Object_info[n].type) |
| 264 | return i; |
| 265 | |
| 266 | Int3(); // shouldn't be here |
| 267 | return n; |
| 268 | } |
| 269 | |
| 270 | // Gets previous object from n that has the same type |
| 271 | int GetPrevObjectID(int n) { |
| 272 | int i; |
| 273 | int type = Object_info[n].type; |
| 274 | |
| 275 | ASSERT(n >= 0 && n < MAX_OBJECT_IDS); |
| 276 | |
| 277 | if (Num_object_ids[type] == 0) |
| 278 | return -1; |
| 279 | |
| 280 | for (i = n - 1; i >= 0; i--) { |
| 281 | if (Object_info[i].type == Object_info[n].type) |
| 282 | return i; |
| 283 | } |
| 284 | |
| 285 | for (i = MAX_OBJECT_IDS - 1; i >= n; i--) { |
| 286 | if (Object_info[i].type == Object_info[n].type) |
| 287 | return i; |
| 288 | } |
| 289 | |
| 290 | Int3(); // shouldn't get here |
| 291 | return n; |
| 292 | } |
| 293 | #endif |
| 294 | |
| 295 | // Searches thru all object ids for a specific name |
| 296 | // Returns the found id, or -1 if not found |
| 297 | int FindObjectIDNamecxx . . $ FindObjectIDName(5c4306d8553b3696).(const char *name) { |
| 298 | int i; |
| 299 | |
| 300 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 301 | |
| 302 | for (i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) |
| 303 | if ((Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) && !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(name, Object_info[i].name)) |
| 304 | return i; |
| 305 | |
| 306 | return -1; |
| 307 | } |
| 308 | |
| 309 | // Given an object handle, returns an index to that object's model |
| 310 | int GetObjectImagecxx . . $ GetObjectImage(7864480464b09eea).(int handle) { |
| 311 | if (Object_infocxx . . $ Object_info.[handle].typecxx . . $ object_info#type. == OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) |
| 312 | return -1; |
| 313 | else |
| 314 | return (Object_infocxx . . $ Object_info.[handle].render_handlecxx . . $ object_info#render_handle.); |
| 315 | } |
| 316 | |
| 317 | // Given an object, renders the representation of this object |
| 318 | void DrawObjectcxx . . $ DrawObject(419c470199a90a97).(objectcxx . . $ object# *obj) { |
| 319 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Object_info[obj->id].type != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!); |
| 320 | |
| 321 | if (obj->render_typecxx . . $ object#render_type. == RT_POLYOBJcxx . . $ `Descent3/object_external.h:258:9`!) |
| 322 | DrawPolygonModelcxx . . $ DrawPolygonModel(505ac7ffa3f87ac5).(&obj->poscxx . . $ object#pos., &obj->orientcxx . . $ object#orient., Object_infocxx . . $ Object_info.[obj->idcxx . . $ object#id.].render_handlecxx . . $ object_info#render_handle., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, 1.0, 1.0, 1.0, |
| 323 | obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..subobj_flagscxx . . $ polyobj_info#subobj_flags.); |
| 324 | else |
| 325 | Int3cxx . . $ `misc/pserror.h:247:9`!(); |
| 326 | } |
| 327 | |
| 328 | // Go through the object list and update an ID which has changed |
| 329 | void RemapObjectscxx . . $ RemapObjects(3e454b8ccf442868).(int old_id, int new_id) { |
| 330 | int i; |
| 331 | |
| 332 | for (i = 0; i < MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`!; i++) |
| 333 | if ((Objectscxx . . $ Objects.[i].typecxx . . $ object#type. == Object_infocxx . . $ Object_info.[new_id].typecxx . . $ object_info#type.) && (Objectscxx . . $ Objects.[i].idcxx . . $ object#id. == old_id)) |
| 334 | Objectscxx . . $ Objects.[i].idcxx . . $ object#id. = new_id; |
| 335 | |
| 336 | for (i = 0; i < MAX_OBJECT_IDScxx . . $ `Descent3/objinfo.h:327:9`!; i++) { |
| 337 | if (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) { |
| 338 | int j; |
| 339 | |
| 340 | for (j = 0; j < MAX_DSPEW_TYPEScxx . . $ `Descent3/objinfo.h:383:9`!; j++) |
| 341 | if (Object_infocxx . . $ Object_info.[i].dspewcxx . . $ object_info#dspew.[j] == old_id) |
| 342 | Object_infocxx . . $ Object_info.[i].dspewcxx . . $ object_info#dspew.[j] = new_id; |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | // Remap all the static object ids (objects that must have a specific index) into their assigned slots. |
| 348 | void RemapStaticIDscxx . . $ RemapStaticIDs(49f6e7a06ebc5aa8).() { |
| 349 | bool f_anim = false; |
| 350 | bool f_weapons = false; |
| 351 | bool f_ai = false; |
| 352 | |
| 353 | for (int i = 0; i < NUM_STATIC_OBJECTScxx . . $ `Descent3/objinfo.cpp:60:9`!; i++) { |
| 354 | |
| 355 | int cur_index = FindObjectIDNamecxx . . $ FindObjectIDName(5c4306d8553b3696).(IGNORE_TABLEcxx . . $ `lib/manage_external.h:54:9`!(Static_object_names[i])); |
| 356 | |
| 357 | if (cur_index == -1) { |
| 358 | // The object we are trying to find is not loaded or doesn't exist |
| 359 | Errorcxx . . $ Error(326aeb464d16410c).("Cannot find object <%s>", Static_object_namescxx . . $ Static_object_names.[i]); |
| 360 | continue; |
| 361 | } |
| 362 | |
| 363 | if (cur_index == i) |
| 364 | continue; // hurray, we're already matched up! |
| 365 | |
| 366 | // If our slot is already used, move the ID somewhere else |
| 367 | if (Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type. != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) { |
| 368 | // int new_index = AllocObjectID(Object_info[i].type, Object_info[i].flags); |
| 369 | if (Object_infocxx . . $ Object_info.[i].animcxx . . $ object_info#anim.) |
| 370 | f_anim = true; |
| 371 | if (Object_infocxx . . $ Object_info.[i].static_wbcxx . . $ object_info#static_wb.) |
| 372 | f_weapons = true; |
| 373 | if (Object_infocxx . . $ Object_info.[i].ai_infocxx . . $ object_info#ai_info.) |
| 374 | f_ai = true; |
| 375 | int new_index = AllocObjectIDcxx . . $ AllocObjectID(851aef5fe1595069).(Object_infocxx . . $ Object_info.[i].typecxx . . $ object_info#type., f_anim, f_weapons, f_ai); |
| 376 | if (new_index >= 0) { // DAJ -1FIX |
| 377 | Object_infocxx . . $ Object_info.[new_index] =cxx . . $ object_info#`operator=`(b225cf8c4507450d). Object_infocxx . . $ Object_info.[i]; |
| 378 | RemapObjectscxx . . $ RemapObjects(3e454b8ccf442868).(i, new_index); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | // Copy static ID into new slot |
| 383 | Object_infocxx . . $ Object_info.[i] =cxx . . $ object_info#`operator=`(b225cf8c4507450d). Object_infocxx . . $ Object_info.[cur_index]; |
| 384 | |
| 385 | // Free up the old slot |
| 386 | Object_infocxx . . $ Object_info.[cur_index].typecxx . . $ object_info#type. = OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!; |
| 387 | |
| 388 | // Remap the objects that used this ID |
| 389 | RemapObjectscxx . . $ RemapObjects(3e454b8ccf442868).(cur_index, i); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | // Changes all existing objects model_nums to a new model num |
| 394 | void ChangeOldModelsForObjectscxx . . $ ChangeOldModelsForObjects(3e454b8ccf442868).(int old_handle, int new_handle) { |
| 395 | int i; |
| 396 | |
| 397 | for (i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++) { |
| 398 | if (Objectscxx . . $ Objects.[i].render_typecxx . . $ object#render_type. == RT_POLYOBJcxx . . $ `Descent3/object_external.h:258:9`! && Objectscxx . . $ Objects.[i].rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num. == old_handle) { |
| 399 | Objectscxx . . $ Objects.[i].rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num. = new_handle; |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | void RemapObjectscxx . . $ RemapObjects(49f6e7a06ebc5aa8).() { RemapStaticIDscxx . . $ RemapStaticIDs(49f6e7a06ebc5aa8).(); }; |