/** * @brief Run actions on finishing disassembling of a ufo * @param base The base to produce in * @param prod The production that is running */ static void PR_FinishDisassembly (base_t* base, production_t* prod) { storedUFO_t* ufo = prod->data.data.ufo; assert(ufo); for (int i = 0; i < ufo->comp->numItemtypes; i++) { const objDef_t* compOd = ufo->comp->items[i]; const int amount = (ufo->condition < 1 && ufo->comp->itemAmount2[i] != COMP_ITEMCOUNT_SCALED) ? ufo->comp->itemAmount2[i] : round(ufo->comp->itemAmount[i] * ufo->condition); assert(compOd); if (amount <= 0) continue; if (Q_streq(compOd->id, ANTIMATTER_ITEM_ID)) { B_AddAntimatter(base, amount); } else { technology_t* tech = RS_GetTechForItem(compOd); B_AddToStorage(base, compOd, amount); RS_MarkCollected(tech); } } Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("The disassembling of %s at %s has finished."), UFO_TypeToName(ufo->ufoTemplate->getUfoType()), base->name); MSO_CheckAddNewMessage(NT_PRODUCTION_FINISHED, _("Production finished"), cp_messageBuffer, MSG_PRODUCTION, ufo->ufoTemplate->tech); /* Removing UFO will remove the production too */ US_RemoveStoredUFO(ufo); }
/** * @brief Destroys a stored UFO * @note it's called by 'ui_destroystoredufo' command with a parameter of the stored UFO IDX and a confirmation value */ static void US_DestroySoredUFO_f (void) { if (cgi->Cmd_Argc() < 2) { Com_DPrintf(DEBUG_CLIENT, "Usage: %s <idx> [0|1]\nWhere the second, optional parameter is the confirmation.\n", cgi->Cmd_Argv(0)); return; } storedUFO_t *ufo = US_GetStoredUFOByIDX(atoi(cgi->Cmd_Argv(1))); if (!ufo) { Com_DPrintf(DEBUG_CLIENT, "Stored UFO with idx: %i does not exist\n", atoi(cgi->Cmd_Argv(1))); return; } /* Ask 'Are you sure?' by default */ if (cgi->Cmd_Argc() < 3 || !atoi(cgi->Cmd_Argv(2))) { char command[128]; Com_sprintf(command, sizeof(command), "ui_pop; ui_destroystoredufo %d 1; mn_installation_select %d;", ufo->idx, ufo->installation->idx); cgi->UI_PopupButton(_("Destroy stored UFO"), _("Do you really want to destroy this stored UFO?"), command, _("Destroy"), _("Destroy stored UFO"), "ui_pop;", _("Cancel"), _("Forget it"), nullptr, nullptr, nullptr); return; } US_RemoveStoredUFO(ufo); cgi->Cmd_ExecuteString(va("mn_installation_select %d", ufo->installation->idx)); }