MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / RemapStaticIDs

Function RemapStaticIDs

Descent3/objinfo.cpp:348–391  ·  view source on GitHub ↗

Remap all the static object ids (objects that must have a specific index) into their assigned slots.

Source from the content-addressed store, hash-verified

346
347// Remap all the static object ids (objects that must have a specific index) into their assigned slots.
348void RemapStaticIDs() {
349 bool f_anim = false;
350 bool f_weapons = false;
351 bool f_ai = false;
352
353 for (int i = 0; i < NUM_STATIC_OBJECTS; i++) {
354
355 int cur_index = FindObjectIDName(IGNORE_TABLE(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 Error("Cannot find object <%s>", 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_info[i].type != OBJ_NONE) {
368 // int new_index = AllocObjectID(Object_info[i].type, Object_info[i].flags);
369 if (Object_info[i].anim)
370 f_anim = true;
371 if (Object_info[i].static_wb)
372 f_weapons = true;
373 if (Object_info[i].ai_info)
374 f_ai = true;
375 int new_index = AllocObjectID(Object_info[i].type, f_anim, f_weapons, f_ai);
376 if (new_index >= 0) { // DAJ -1FIX
377 Object_info[new_index] = Object_info[i];
378 RemapObjects(i, new_index);
379 }
380 }
381
382 // Copy static ID into new slot
383 Object_info[i] = Object_info[cur_index];
384
385 // Free up the old slot
386 Object_info[cur_index].type = OBJ_NONE;
387
388 // Remap the objects that used this ID
389 RemapObjects(cur_index, i);
390 }
391}
392
393// Changes all existing objects model_nums to a new model num
394void ChangeOldModelsForObjects(int old_handle, int new_handle) {

Callers 6

OnGenericAddNewMethod · 0.85
OnGenericDeleteMethod · 0.85
OnGenericChangeNameMethod · 0.85
OnGenericPasteMethod · 0.85
RemapEverythingFunction · 0.85
RemapObjectsFunction · 0.85

Calls 4

FindObjectIDNameFunction · 0.85
ErrorFunction · 0.85
AllocObjectIDFunction · 0.85
RemapObjectsFunction · 0.85

Tested by

no test coverage detected