27 #include "../../cl_shared.h"
28 #include "../../ui/ui_dataids.h"
36 #define HAPPINESS_UFO_SALE_GAIN 0.02
37 #define HAPPINESS_UFO_SALE_LOSS 0.005
48 const capacities_t* capacity = &installation->ufoCapacity;
49 if (capacity->
max > 0 && capacity->
max > capacity->
cur) {
50 cgi->UI_ExecuteConfunc(
"ui_uforecovery_ufoyards %d \"%s\" %d %d",
53 std::max(capacity->
max - capacity->
cur, 0),
67 if (
cgi->Cmd_Argc() < 4) {
68 cgi->Com_Printf(
"Usage: %s <ufoType> <damage> <installationIDX>\n",
cgi->
Cmd_Argv(0));
79 if (condition < 0.0f || condition > 100.0
f) {
80 cgi->Com_Printf(
"%s Invalid UFO damage value\n",
cgi->
Cmd_Argv(0));
85 if (installation ==
nullptr || installation->
ufoCapacity.
max <= 0) {
86 cgi->Com_Printf(
"%s Invalid Installation IDX\n",
cgi->
Cmd_Argv(0));
91 cgi->Com_Printf(
"%s The selected installation has no spare capacity\n",
cgi->
Cmd_Argv(0));
110 if (
cgi->Cmd_Argc() < 2) {
116 if (ufo ==
nullptr) {
129 cgi->UI_ExecuteConfunc(
"ui_uforecovery_nations %s \"%s\" %d %s %.2f",
145 if (
cgi->Cmd_Argc() < 4) {
146 cgi->Com_Printf(
"Usage: %s <ufoID> <nationId> <price>\n",
cgi->
Cmd_Argv(0));
151 if (nation ==
nullptr) {
196 return "disassembling";
203 return "transferring";
218 cgi->UI_ExecuteConfunc(
"show_storedufo -");
226 if (
Q_streq(status,
"transferring")) {
243 if (
cgi->Cmd_Argc() < 2) {
244 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Usage: %s <idx> [0|1]\nWhere the second, optional parameter is the confirmation.\n",
cgi->
Cmd_Argv(0));
258 cgi->UI_PopupButton(
_(
"Destroy stored UFO"),
_(
"Do you really want to destroy this stored UFO?"),
259 command,
_(
"Destroy"),
_(
"Destroy stored UFO"),
260 "ui_pop;",
_(
"Cancel"),
_(
"Forget it"),
261 nullptr,
nullptr,
nullptr);
273 if (
cgi->Cmd_Argc() < 2) {
284 cgi->UI_ExecuteConfunc(
"ufotransferlist_clear");
289 const char* nationName = nat ?
_(nat->
name) :
"";
290 const int freeSpace = std::max(0, ins->ufoCapacity.max - ins->ufoCapacity.cur);
291 cgi->UI_ExecuteConfunc(
"ufotransferlist_addyard %d \"%s\" \"%s\" %d %d", ins->idx, ins->name, nationName, freeSpace, ins->ufoCapacity.max);
300 if (
cgi->Cmd_Argc() < 2) {
311 cgi->UI_ExecuteConfunc(
"ufotransferlist_clearufos %d", ins->
idx);
313 if (ufo->installation != ins)
315 cgi->UI_ExecuteConfunc(
"ufotransferlist_addufos %d %d \"%s\"", ins->
idx, ufo->idx, ufo->ufoTemplate->model);
327 if (
cgi->Cmd_Argc() < 3) {
328 cgi->Com_Printf(
"Usage: %s <stored-ufo-idx> <ufoyard-idx>\n",
cgi->
Cmd_Argv(0));
332 if (ufo ==
nullptr) {
333 cgi->Com_Printf(
"Stored ufo with idx %i not found.\n", atoi(
cgi->
Cmd_Argv(1)));
338 cgi->Com_Printf(
"Installation with idx: %i does not exist\n", atoi(
cgi->
Cmd_Argv(2)));
345 {
"cp_uforecovery_sell_init",
UR_DialogInitSell_f,
"Function to initialize sell recovered UFO to desired nation."},
346 {
"cp_uforecovery_store_init",
UR_DialogInitStore_f,
"Function to initialize store recovered UFO in desired base."},
348 {
"cp_uforecovery_sell_start",
UR_DialogStartSell_f,
"Function to start UFO selling processing."},
353 {
"ui_transferufo",
US_TransferUFO_f,
"Transfer stored UFO to another UFO Yard"},
354 {
nullptr,
nullptr,
nullptr}
359 cgi->Cmd_TableAddList(ufoRecoveryCallbacks);
364 cgi->Cmd_TableRemoveList(ufoRecoveryCallbacks);
void UR_ShutdownCallbacks(void)
static void US_DestroyStoredUFO_f(void)
Destroys a stored UFO.
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
nation_t * NAT_GetNationByID(const char *nationID)
Return a nation-pointer by the nations id.
storedUFO_t * US_StoreUFO(const aircraft_t *ufoTemplate, installation_t *installation, date_t date, float condition)
Adds an UFO to the storage.
A installation with all it's data.
const char * NAT_GetHappinessString(const float happiness)
Translates the nation happiness float value to a string.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
static void UR_DialogStartStore_f(void)
Function to start UFO recovery process.
const aircraft_t * AIR_GetAircraftSilent(const char *name)
Searches the global array of aircraft types for a given aircraft.
const aircraft_t * ufoTemplate
int Date_DateToSeconds(const date_t *date)
Convert a date_t date to seconds.
#define INS_ForeachOfType(var, installationType)
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const char * UFO_GetName(const aircraft_t *ufocraft)
Returns name of the UFO if UFO has been researched.
uiMessageListNodeMessage_t * MS_AddNewMessage(const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup, bool playSound)
Adds a new message to message stack.
UFO recovery and storing callback header file.
static void UR_DialogInitSell_f(void)
Function to initialize list to sell recovered UFO to desired nation.
void US_RemoveStoredUFO(storedUFO_t *ufo)
Removes an UFO from the storage.
#define NAT_Foreach(var)
iterates trough nations
void UR_InitCallbacks(void)
void NAT_SetHappiness(const float minhappiness, nation_t *nation, const float happiness)
Updates the nation happiness.
installation_t * installation
const cgame_import_t * cgi
Structure for stored UFOs.
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
UFO recovery and storing.
Engine-side time information in the game.
date_t Date_Substract(date_t a, const date_t &b)
Substract the second date from the first and return the result.
Campaign geoscape time header.
production_t * disassembly
Header for Geoscape management.
#define HAPPINESS_UFO_SALE_GAIN
char cp_messageBuffer[MAX_MESSAGE_TEXT]
#define HAPPINESS_UFO_SALE_LOSS
storedUFO_t * US_GetStoredUFOByIDX(const int idx)
Returns a stored ufo.
static void US_FillUFOTransferUFOs_f(void)
Send Stored UFOs of the destination UFO Yard.
static const cmdList_t ufoRecoveryCallbacks[]
float frand(void)
Return random values between 0 and 1.
#define AIR_IsUFO(aircraft)
bool US_TransferUFO(storedUFO_t *ufo, installation_t *ufoyard)
Start transferring of a stored UFO.
static void US_FillUFOTransfer_f(void)
Fills UFO Yard UI with transfer destinations.
static void US_SelectStoredUfo_f(void)
Send Stored UFO data to the UI.
Header file for single player campaign control.
static void US_TransferUFO_f(void)
Callback to start the transfer of a stored UFO.
static void UR_DialogStartSell_f(void)
Function to start UFO selling process.
Store capacities in base.
An aircraft with all it's data.
static void UR_DialogInitStore_f(void)
Function to initialize list of storage locations for recovered UFO.
nation_t * GEO_GetNation(const vec2_t pos)
Translate nation map color to nation.
const char *IMPORT * Cmd_Argv(int n)
const char * CP_SecondConvert(int second)
Converts a number of second into a char to display.
const char * US_StoredUFOStatus(const storedUFO_t *ufo)
Returns string representation of the stored UFO's status.
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...
installation_t * INS_GetByIDX(int idx)
Get installation by it's index.