/** * @brief Remove aliens that exceed containment capacity * @note called on destroying an Alien Containment (from building_ondestroy) * @param[in, out] base Pointer to the base to check */ void AL_RemoveAliensExceedingCapacity (base_t *base) { const int max = CAP_GetMax(base, CAP_ALIENS); int current = CAP_GetCurrent(base, CAP_ALIENS); int i; assert(base); assert(max >= 0); for (i = 0; i < ccs.numAliensTD; i++) { const int remove = min(base->alienscont[i].amountAlive, current - max); if (!base->alienscont[i].teamDef) continue; /* remove dead aliens if there is no alien containment */ if (max == 0) base->alienscont[i].amountDead = 0; if (remove > 0) { base->alienscont[i].amountAlive -= remove; CAP_SetCurrent(base, CAP_ALIENS, current - remove); current = CAP_GetCurrent(base, CAP_ALIENS); } } assert(max >= current); }
/** * @brief Update Storage Capacity. * @param[in] base Pointer to the base * @sa B_ResetAllStatusAndCapacities_f */ void CAP_UpdateStorageCap (base_t* base) { CAP_SetCurrent(base, CAP_ITEMS, 0); for (int i = 0; i < cgi->csi->numODs; i++) { const objDef_t* obj = INVSH_GetItemByIDX(i); if (!B_ItemIsStoredInBaseStorage(obj)) continue; CAP_AddCurrent(base, CAP_ITEMS, B_ItemInBase(obj, base) * obj->size); } /* UGV takes room in storage capacity */ CAP_AddCurrent(base, CAP_ITEMS, UGV_SIZE * E_CountHired(base, EMPL_ROBOT)); }