* Cancel the building of object for given structure. * * @param s The Structure. */
| 1410 | * @param s The Structure. |
| 1411 | */ |
| 1412 | static 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. |
no test coverage detected