27 #include "../../cl_shared.h"
49 assert(ufo->ufoTemplate);
50 assert(ufo->ufoTemplate->tech);
58 switch (ufo->status) {
70 if (!ufo->ufoTemplate->tech->statusCollected)
102 cgi->Com_DPrintf(
DEBUG_CLIENT,
"US_StoreUFO: Invalid aircraft (UFO) Template.\n");
112 cgi->Com_DPrintf(
DEBUG_CLIENT,
"US_StoreUFO: Installation is full with UFOs.\n");
126 assert(ufoTemplate->
tech);
138 ufo.
condition = std::min(std::max(0.0
f, condition), 1.0
f);
184 if (ufo->ufoTemplate != ufoTemplate)
186 if (installation && ufo->installation != installation)
204 cgi->Com_Error(
ERR_DROP,
"US_RemoveUFOsExceedingCapacity: No installation given!\n");
209 if (ufoCap->
cur <= ufoCap->
max)
211 if (ufo->installation != installation) {
229 cgi->Com_Error(
ERR_DROP,
"No UFO cannot be transferred!");
231 cgi->Com_Error(
ERR_DROP,
"UFO cannot be transferred to void!");
267 float minDistance = -1;
273 if (ufoTemplate && ufo->ufoTemplate != ufoTemplate)
277 assert(ufo->installation);
281 if (minDistance < 0 || minDistance > distance) {
282 minDistance = distance;
317 if (ufo->installation)
346 cgi->Com_Printf(
"Invalid or no IDX defined for stored UFO.\n");
351 cgi->Com_Printf(
"Invalid storedUFOStatus '%s'\n",
id);
358 cgi->Com_Printf(
"UFO has no/invalid installation assigned\n");
371 cgi->Com_Printf(
"UFO has no/invalid aircraftTemplare assigned\n");
376 cgi->Com_Printf(
"UFO has no/invalid components set\n");
393 static void US_ListStoredUFOs_f (
void)
399 cgi->Com_Printf(
"IDX: %i\n", ufo->idx);
400 cgi->Com_Printf(
"id: %s\n", ufo->id);
401 cgi->Com_Printf(
"stored at %s\n", (ufo->installation) ? ufo->installation->name :
"NOWHERE");
404 cgi->Com_Printf(
"arrived at: %i %s %02i, %02i:%02i\n", date.
year,
407 if (ufo->ufoTemplate->tech->base)
408 cgi->Com_Printf(
"tech being researched at %s\n", ufo->ufoTemplate->tech->base->name);
410 cgi->Com_Printf(
"being disassembled at %s\n", prodBase->
name);
417 static void US_StoreUFO_f (
void)
421 if (
cgi->Cmd_Argc() <= 2) {
422 cgi->Com_Printf(
"Usage: %s <ufoType> <installationIdx>\n",
cgi->
Cmd_Argv(0));
430 if (installationIDX < 0) {
431 cgi->Com_Printf(
"US_StoreUFO_f: Invalid Installation index.\n");
436 cgi->Com_Printf(
"US_StoreUFO_f: There is no Installation: idx=%i.\n", installationIDX);
449 if (ufoType ==
nullptr) {
450 cgi->Com_Printf(
"US_StoreUFO_f: In valid UFO Id.\n");
460 static void US_RemoveStoredUFO_f (
void)
462 if (
cgi->Cmd_Argc() < 2) {
469 cgi->Com_Printf(
"US_RemoveStoredUFO_f: No such ufo index.\n");
479 {
"debug_liststoredufos", US_ListStoredUFOs_f,
"Debug function to list UFOs in Hangars."},
480 {
"debug_storeufo", US_StoreUFO_f,
"Debug function to Add UFO to Hangars."},
481 {
"debug_removestoredufo", US_RemoveStoredUFO_f,
"Debug function to Remove UFO from Hangars."},
483 {
nullptr,
nullptr,
nullptr}
492 cgi->Cmd_TableAddList(debugStoredUfosCmds);
503 cgi->Cmd_TableRemoveList(debugStoredUfosCmds);
void UR_ShutdownCallbacks(void)
Header file for Aircraft and item components.
uiMessageListNodeMessage_t * MSO_CheckAddNewMessage(const notify_t messagecategory, const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup)
Adds a new message to message stack. It uses message settings to verify whether sound should be playe...
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.
int US_StoredUFOCount(void)
Returns the number of storedUFOs.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
#define PR_GetProductionForBase(base)
#define SAVE_UFORECOVERY_UFOIDX
const aircraft_t * ufoTemplate
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
#define SAVE_UFORECOVERY_UFO
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
#define SAVE_UFORECOVERY_DATE
int US_UFOsInStorage(const aircraft_t *ufoTemplate, const installation_t *installation)
Returns the number of UFOs stored (on an installation or anywhere)
const char * UFO_GetName(const aircraft_t *ufocraft)
Returns name of the UFO if UFO has been researched.
void US_RemoveUFOsExceedingCapacity(installation_t *installation)
Removes ufos which are over the storing capacity.
#define SAVE_UFORECOVERY_UFOID
void PR_QueueNext(base_t *base)
Queues the next production in the queue.
bool Date_LaterThan(const date_t *now, const date_t *compare)
Check whether the given date and time is later than current date.
UFO recovery and storing callback header file.
A base with all it's data.
const char * Date_GetMonthName(int month)
Returns the short monthame to the given month index.
void UR_InitStartup(void)
Init actions for ufostoring-subsystem.
components_t * COMP_GetComponentsByID(const char *id)
Returns components definition by ID.
bool US_LoadXML(xmlNode_t *p)
Load callback for xml savegames.
struct technology_s * tech
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
xmlNode_t *IMPORT * XML_GetDate(xmlNode_t *parent, const char *name, int *day, int *sec)
#define SAVE_STOREDUFOSTATUS_NAMESPACE
void US_RemoveStoredUFO(storedUFO_t *ufo)
Removes an UFO from the storage.
XML tag constants for savegame.
void UR_InitCallbacks(void)
void UR_ProcessActive(void)
Function to process active recoveries.
void RS_MarkCollected(technology_t *tech)
Marks a give technology as collected.
base_t * PR_ProductionBase(const production_t *production)
Returns the base pointer the production belongs to.
installation_t * installation
const cgame_import_t * cgi
linkedList_t * storedUFOs
Structure for stored UFOs.
bool US_SaveXML(xmlNode_t *p)
Save callback for savegames in XML Format.
const char *IMPORT * Com_GetConstVariable(const char *space, int value)
UFO recovery and storing.
Engine-side time information in the game.
aircraft_t aircraftTemplates[MAX_AIRCRAFT]
Campaign geoscape time header.
production_t * disassembly
Header for Geoscape management.
static const constListEntry_t saveStoredUFOConstants[]
void PR_QueueDelete(base_t *base, production_queue_t *queue, int index)
Delete the selected entry from the queue.
char cp_messageBuffer[MAX_MESSAGE_TEXT]
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
storedUFO_t * US_GetStoredUFOByIDX(const int idx)
Returns a stored ufo.
void RS_CheckRequirements(void)
Checks if running researches still meet their requirements.
void UR_Shutdown(void)
Closing actions for ufostoring-subsystem.
Header file for aircraft stuff.
storedUFOStatus_t
different statuses for a stored UFO
Human readable time information in the game.
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
#define SAVE_UFORECOVERY_STOREDUFOS
#define SAVE_UFORECOVERY_INSTALLATIONIDX
bool US_TransferUFO(storedUFO_t *ufo, installation_t *ufoyard)
Start transferring of a stored UFO.
void CP_DateConvertLong(const date_t *date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
static const cmdList_t debugStoredUfosCmds[]
storedUFO_t * US_GetClosestStoredUFO(const aircraft_t *ufoTemplate, const base_t *base)
get the closest stored ufo (of a type) from a base
Header file for single player campaign control.
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
#define SAVE_UFORECOVERY_STATUS
Store capacities in base.
An aircraft with all it's data.
#define SAVE_UFORECOVERY_CONDITION
const char *IMPORT * Cmd_Argv(int n)
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
struct components_s * comp
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
installation_t * INS_GetByIDX(int idx)
Get installation by it's index.