UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_time.h File Reference

Campaign geoscape time header. More...

Go to the source code of this file.

Data Structures

struct  dateLong_s
 Human readable time information in the game. More...
 

Typedefs

typedef struct dateLong_s dateLong_t
 Human readable time information in the game. More...
 

Functions

void CP_DateConvertLong (const date_t *date, dateLong_t *dateLong)
 Converts a date from the engine in a (longer) human-readable format. More...
 
const char * CP_SecondConvert (int second)
 Converts a number of second into a char to display. More...
 
void CP_UpdateTime (void)
 Updates date/time and timescale (=timelapse) on the geoscape menu. More...
 
void CP_GameTimeStop (void)
 Stop game time speed. More...
 
bool CP_IsTimeStopped (void)
 Check if time is stopped. More...
 
void CP_GameTimeFast (void)
 Increase game time speed. More...
 
void CP_GameTimeSlow (void)
 Decrease game time speed. More...
 
void CP_SetGameTime_f (void)
 Set a new time game from id. More...
 
int Date_DateToSeconds (const date_t *date)
 Convert a date_t date to seconds. More...
 
bool Date_LaterThan (const date_t *now, const date_t *compare)
 Check whether the given date and time is later than current date. More...
 
bool Date_IsDue (const date_t *date)
 Checks whether a given date is equal or earlier than the current campaign date. More...
 
date_t Date_Add (date_t a, const date_t &b)
 Add two dates and return the result. More...
 
date_t Date_Substract (date_t a, const date_t &b)
 Substract the second date from the first and return the result. More...
 
date_t Date_Random (date_t minFrame, date_t maxFrame)
 Return a random relative date which lies between a lower and upper limit. More...
 
const char * Date_GetMonthName (int month)
 Returns the short monthame to the given month index. More...
 

Detailed Description

Campaign geoscape time header.

Definition in file cp_time.h.

Typedef Documentation

typedef struct dateLong_s dateLong_t

Human readable time information in the game.

Note
Use this on runtime - please avoid for structs that get saved.
See also
date_t For storage & network transmitting (engine only).
CP_DateConvertLong

Function Documentation

void CP_DateConvertLong ( const date_t date,
dateLong_t dateLong 
)

Converts a date from the engine in a (longer) human-readable format.

Note
The seconds from "date" are ignored here.
The function always starts calculation from Jan. and also catches new years.
Parameters
[in]dateContains the date to be converted.
[out]dateLongThe converted date.

Definition at line 72 of file cp_time.cpp.

References dateLong_s::day, date_s::day, DAYS_PER_YEAR, dateLong_s::hour, i, length, lengthof, dateLong_s::min, dateLong_s::month, monthLength, MONTHS_PER_YEAR, dateLong_s::sec, date_s::sec, SECONDS_PER_HOUR, and dateLong_s::year.

Referenced by CL_EventAddMail(), CP_CampaignRun(), CP_UpdateTime(), MS_LoadXML(), MS_TimestampedText(), SAV_GameSave(), UP_OpenMail_f(), and UP_SetMailHeader().

void CP_GameTimeFast ( void  )

Increase game time speed.

Definition at line 174 of file cp_time.cpp.

References ccs, CP_AllowTimeScale(), CP_UpdateTime(), ccs_s::gameLapse, and NUM_TIMELAPSE.

void CP_GameTimeSlow ( void  )

Decrease game time speed.

Definition at line 160 of file cp_time.cpp.

References ccs, CP_AllowTimeScale(), CP_UpdateTime(), and ccs_s::gameLapse.

bool CP_IsTimeStopped ( void  )

Check if time is stopped.

Definition at line 139 of file cp_time.cpp.

References ccs, and ccs_s::gameLapse.

Referenced by CP_CampaignRun(), and TEST_F().

const char* CP_SecondConvert ( int  second)

Converts a number of second into a char to display.

Parameters
[in]secondNumber of second.
Todo:
Abstract the code into an extra function (DateConvertSeconds?) see also CP_DateConvertLong

Definition at line 56 of file cp_time.cpp.

References Com_sprintf(), and SECONDS_PER_HOUR.

Referenced by CL_DisplayPopupInterceptMission(), GEO_GetAircraftText(), TR_List_f(), and US_SelectStoredUfo_f().

void CP_SetGameTime_f ( void  )

Set a new time game from id.

See also
CL_SetGameTime
lapse

Definition at line 214 of file cp_time.cpp.

References cgi, cgame_import_s::Cmd_Argv(), and CP_SetGameTime().

int Date_DateToSeconds ( const date_t date)

Convert a date_t date to seconds.

Parameters
[in]dateThe date in date_t format
Returns
the date in seconds

Definition at line 228 of file cp_time.cpp.

References date_s::day, and date_s::sec.

Referenced by TR_List_f(), and US_SelectStoredUfo_f().

const char* Date_GetMonthName ( int  month)

Returns the short monthame to the given month index.

Parameters
[in]monthThe month index - [0-11]
Returns
month name as char*

Definition at line 317 of file cp_time.cpp.

References _.

Referenced by CL_EventAddMail(), CP_UpdateTime(), MS_LoadXML(), MS_TimestampedText(), SAV_GameSave(), UP_OpenMail_f(), and UP_SetMailHeader().

bool Date_IsDue ( const date_t date)

Checks whether a given date is equal or earlier than the current campaign date.

Parameters
dateThe date to check
Returns
true if the given date is equal or earlier than the current campaign date, false otherwise

Definition at line 255 of file cp_time.cpp.

References ccs, ccs_s::date, date_s::day, and date_s::sec.

Referenced by B_IsBuildingBuiltUp(), CP_CheckTriggerEvent(), TEST_F(), and TR_TransferRun().

bool Date_LaterThan ( const date_t now,
const date_t compare 
)

Check whether the given date and time is later than current date.

Parameters
[in]nowCurrent date.
[in]compareDate to compare.
Returns
True if current date is later than given one.

Definition at line 239 of file cp_time.cpp.

References date_s::day, and date_s::sec.

Referenced by CP_CheckMissionEnd(), CP_EndRescueMission(), TEST_F(), UR_ProcessActive(), and US_StoreUFO().

date_t Date_Random ( date_t  minFrame,
date_t  maxFrame 
)

Return a random relative date which lies between a lower and upper limit.

Parameters
[in]minFrameMinimal date.
[in]maxFrameMaximal date.
Returns
A date value between minFrame and maxFrame.

Definition at line 302 of file cp_time.cpp.

References date_s::day, frand(), date_s::sec, and SECONDS_PER_DAY.

Referenced by CP_BeginRescueMission(), CP_BuildBaseSetUpBase(), CP_BuildBaseSubvertGovernment(), CP_CreateNewMission(), CP_HarvestMissionStart(), CP_InterceptAircraftMissionSet(), CP_InterceptAttackInstallation(), CP_ReconMissionAerial(), CP_ReconMissionGround(), CP_SpawnCrashSiteMission(), CP_SupplySetStayAtBase(), CP_TerrorMissionStart(), and CP_XVIMissionStart().

date_t Date_Substract ( date_t  a,
const date_t b 
)

Substract the second date from the first and return the result.

Parameters
[in]aFirst date.
[in]bSecond date.

Definition at line 285 of file cp_time.cpp.

References date_s::day, date_s::sec, and SECONDS_PER_DAY.

Referenced by B_GetConstructionTimeRemain(), TR_List_f(), and US_SelectStoredUfo_f().