/** * @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); }
/** * @return The translated name of the item in production */ const char* PR_GetName (const productionData_t* data) { switch (data->type) { case PRODUCTION_TYPE_ITEM: return _(data->data.item->name); case PRODUCTION_TYPE_AIRCRAFT: return _(data->data.aircraft->tpl->name); case PRODUCTION_TYPE_DISASSEMBLY: return UFO_TypeToName(data->data.ufo->ufoTemplate->getUfoType()); default: cgi->Com_Error(ERR_DROP, "Invalid production type given: %i", data->type); } }
/** * @brief Function to start UFO selling process. * @note Command to call this: cp_uforecovery_sell_start. */ static void UR_DialogStartSell_f (void) { int price = -1; const nation_t *nation; int i; if (!ufoRecovery.nation) return; nation = ufoRecovery.nation; i = UR_DialogGetCurrentNationIndex(); price = ufoRecovery.ufoNations[i].price; assert(price >= 0); #if 0 if (ufoRecovery.selectedStorage) { Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("Sold previously recovered %s from %s to nation %s, gained %i credits."), UFO_TypeToName( ufoRecovery.selectedStorage->ufoTemplate->ufotype), ufoRecovery.selectedStorage->base->name, _(nation->name), price); } else #endif { Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("Recovered %s from the battlefield. UFO sold to nation %s, gained %i credits."), UFO_GetName(ufoRecovery.ufoTemplate), _(nation->name), price); } MS_AddNewMessage(_("UFO Recovery"), cp_messageBuffer); CP_UpdateCredits(ccs.credits + price); /* update nation happiness */ for (i = 0; i < ccs.numNations; i++) { nation_t *nat = NAT_GetNationByIDX(i); float ufoHappiness; assert(nat); if (nat == nation) /* nation is happy because it got the UFO */ ufoHappiness = HAPPINESS_UFO_SALE_GAIN; else /* nation is unhappy because it wanted the UFO */ ufoHappiness = HAPPINESS_UFO_SALE_LOSS; NAT_SetHappiness(ccs.curCampaign->minhappiness, nat, nat->stats[0].happiness + ufoHappiness); } /* UFO recovery process is done, disable buttons. */ UR_DialogRecoveryDone(); }