Пример #1
0
/**
 * @brief Alien containment menu init function.
 * @note Command to call this: ui_aliencont_init
 * @note Should be called whenever the alien containment menu gets active.
 */
static void AC_Init_f (void)
{
	base_t* base;
	if (cgi->Cmd_Argc() < 2)
		base = B_GetCurrentSelectedBase();
	else
		base = B_GetFoundedBaseByIDX(atoi(cgi->Cmd_Argv(1)));
	if (!base) {
		Com_Printf("No base selected\n");
		return;
	}

	cgi->UI_ExecuteConfunc("ui_aliencont_cap %d %d", CAP_GetCurrent(base, CAP_ALIENS), CAP_GetMax(base, CAP_ALIENS));
	cgi->UI_ExecuteConfunc("ui_aliencont_clear");
	if (!base->alienContainment)
		return;
	linkedList_t* list = base->alienContainment->list();
	LIST_Foreach(list, alienCargo_t, item) {
		const technology_t* tech = RS_GetTechForTeam(item->teamDef);
		cgi->UI_ExecuteConfunc("ui_aliencont_add \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" %f %d %d",
			item->teamDef->id, _(item->teamDef->name), tech->id, tech->image,
			(RS_IsResearched_ptr(tech)) ? _("Researched") : _("Awaiting autopsy"),
			(1.0f - tech->time / tech->overallTime) * 100, item->alive, item->dead);
	}
	cgi->LIST_Delete(&list);
}
Пример #2
0
/**
 * @brief Add aliens to the containment by teamDef
 * @param[in] team Pointer to the alien Team Definition
 * @param[in] alive Number of alive aliens
 * @param[in] dead Number of dead aliens
 */
bool AlienContainment::add(const teamDef_t* team, int alive, int dead)
{
	if (!team)
		return false;

	if (!isLifeSupported(team)) {
		dead += alive;
		alive = 0;
	}

	if (AlienCargo::add(team, alive, dead)) {
		if (this->aliveCapacity)
			this->aliveCapacity->cur += alive * getCapacityNeedForAlien(team, false);
		if (this->deadCapacity)
			this->deadCapacity->cur += dead * getCapacityNeedForAlien(team, true);
		if (this->getAlive(team) > 0 || this->getDead(team) > 0) {
			technology_t* tech = RS_GetTechForTeam(team);
			RS_MarkCollected(tech);
		}
		return true;
	}
	return false;
}