/**
 * @brief Send Stored UFO data to the UI
 * @note it's called by 'ui_selectstoredufo' command with a parameter of the stored UFO IDX
 */
static void US_SelectStoredUfo_f (void)
{
	const storedUFO_t *ufo;

	if (cgi->Cmd_Argc() < 2 || (ufo = US_GetStoredUFOByIDX(atoi(cgi->Cmd_Argv(1)))) == nullptr) {
		cgi->UI_ExecuteConfunc("show_storedufo -");
		return;
	}

	const char *ufoName = UFO_GetName(ufo->ufoTemplate);
	const char *status = US_StoredUFOStatus(ufo);
	const char *eta;

	if (Q_streq(status, "transfering")) {
		date_t time = Date_Substract(ufo->arrive, ccs.date);
		eta = CP_SecondConvert(Date_DateToSeconds(&time));
	} else {
		eta = "-";
	}

	cgi->UI_ExecuteConfunc("show_storedufo %d \"%s\" %3.0f \"%s\" \"%s\" \"%s\" \"%s\"", ufo->idx, ufoName, ufo->condition * 100, ufo->ufoTemplate->model, status, eta, ufo->installation->name);
}
예제 #2
0
/**
 * @brief Returns the time remaining time of a building construction
 * @param[in] building Pointer to the building to check
 */
float B_GetConstructionTimeRemain (const building_t * building)
{
	date_t diff = Date_Substract(building->timeStart, ccs.date);
	diff.day += building->buildTime;
	return diff.day + (float)diff.sec / SECONDS_PER_DAY;
}