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

Function ConvertObject

Descent3/LoadLevel.cpp:1505–1568  ·  view source on GitHub ↗

bash/converts generics, from those not allowed, to something that is allowed

Source from the content-addressed store, hash-verified

1503
1504// bash/converts generics, from those not allowed, to something that is allowed
1505void ConvertObject(int *type, int *id) {
1506 // NOTE: Only type/id are valid at this point
1507#if ((!defined(OEM)) && (!defined(DEMO)))
1508 // Non-OEM build
1509 return;
1510#else
1511#ifdef EDITOR
1512 // Editor OEM?
1513 return;
1514#else
1515 int new_type = *type, new_id = *id;
1516
1517 bool is_multi = (Game_mode & GM_MULTI) ? true : false;
1518 bool c_multi, c_single, convert;
1519
1520 // bash/convert
1521
1522 // look at even numbered items, they are the object to convert
1523 // odd number items are destination
1524 for (int i = 0; i < object_convert_size; i += 2) {
1525 if (*type == object_convert[i].type) {
1526 // type match, check id's
1527 if (object_convert[i].id == -2) {
1528 object_convert[i].id = FindObjectIDName(object_convert[i].name);
1529 }
1530
1531 ASSERT(object_convert[i].id >= 0);
1532
1533 if (*id == object_convert[i].id) {
1534 convert = false;
1535 c_multi = (object_convert[i].flag & CONV_MULTI) ? true : false;
1536 c_single = (object_convert[i].flag & CONV_SINGLE) ? true : false;
1537
1538 if (is_multi && c_multi)
1539 convert = true;
1540 if ((!is_multi) && c_single)
1541 convert = true;
1542
1543 // convert!
1544 if (convert) {
1545 int convert_to = i + 1;
1546
1547 if (object_convert[convert_to].id == -2) {
1548 object_convert[convert_to].id = FindObjectIDName(object_convert[convert_to].name);
1549 }
1550
1551 ASSERT(object_convert[convert_to].id >= 0);
1552
1553 if (object_convert[convert_to].id >= 0) {
1554 mprintf(0, "LEVELLOAD: Converting: '%s' -> '%s'\n", object_convert[i].name, object_convert[convert_to].name);
1555
1556 new_id = object_convert[convert_to].id;
1557 new_type = object_convert[convert_to].type;
1558 }
1559 }
1560 }
1561 }
1562 }

Callers 1

ReadObjectFunction · 0.85

Calls 1

FindObjectIDNameFunction · 0.85

Tested by

no test coverage detected