MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Structure_CancelBuild

Function Structure_CancelBuild

src/structure.c:1412–1433  ·  view source on GitHub ↗

* Cancel the building of object for given structure. * * @param s The Structure. */

Source from the content-addressed store, hash-verified

1410 * @param s The Structure.
1411 */
1412static void Structure_CancelBuild(Structure *s)
1413{
1414 ObjectInfo *oi;
1415
1416 if (s == NULL || s->o.linkedID == 0xFF) return;
1417
1418 if (s->o.type == STRUCTURE_CONSTRUCTION_YARD) {
1419 Structure *s2 = Structure_Get_ByIndex(s->o.linkedID);
1420 oi = &g_table_structureInfo[s2->o.type].o;
1421 Structure_Free(s2);
1422 } else {
1423 Unit *u = Unit_Get_ByIndex(s->o.linkedID);
1424 oi = &g_table_unitInfo[u->o.type].o;
1425 Unit_Free(u);
1426 }
1427
1428 House_Get_ByIndex(s->o.houseID)->credits += ((oi->buildTime - (s->countDown >> 8)) * 256 / oi->buildTime) * oi->buildCredits / 256;
1429
1430 s->o.flags.s.onHold = false;
1431 s->countDown = 0;
1432 s->o.linkedID = 0xFF;
1433}
1434
1435/**
1436 * Make the given Structure build an object.

Callers 1

Structure_BuildObjectFunction · 0.85

Calls 5

Structure_Get_ByIndexFunction · 0.85
Structure_FreeFunction · 0.85
Unit_Get_ByIndexFunction · 0.85
Unit_FreeFunction · 0.85
House_Get_ByIndexFunction · 0.85

Tested by

no test coverage detected