UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_time.h File Reference

Campaign geoscape time header. More...

#include "../../DateTime.h"
#include "../../cl_shared.h"
Include dependency graph for cp_time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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

Functions

void CP_DateConvertLong (const DateTime &date, dateLong_t *dateLong)
 Converts a date from the engine in a (longer) human-readable format.
const char * CP_SecondConvert (int second)
 Converts a number of second into a char to display.
void CP_UpdateTime (void)
 Updates date/time and timescale (=timelapse) on the geoscape menu.
void CP_GameTimeStop (void)
 Stop game time speed.
bool CP_IsTimeStopped (void)
 Check if time is stopped.
void CP_GameTimeFast (void)
 Increase game time speed.
void CP_GameTimeSlow (void)
 Decrease game time speed.
void CP_SetGameTime_f (void)
 Set a new time game from id.
int Date_DateToSeconds (const DateTime &date)
 Convert a date to seconds.
DateTime Date_Random (const DateTime &minFrame, const DateTime &maxFrame)
 Return a random relative date which lies between a lower and upper limit.
const char * Date_GetMonthName (int month)
 Returns the short monthame to the given month index.

Detailed Description

Campaign geoscape time header.

Definition in file cp_time.h.

Function Documentation

◆ CP_DateConvertLong()

void CP_DateConvertLong ( const DateTime & 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 73 of file cp_time.cpp.

References dateLong_t::day, DAYS_PER_MONTH, DateTime::DAYS_PER_YEAR, DateTime::getDateAsDays(), DateTime::getTimeAsSeconds(), dateLong_t::hour, i, dateLong_t::min, dateLong_t::month, DateTime::MONTHS_PER_YEAR, dateLong_t::sec, DateTime::SECONDS_PER_HOUR, and dateLong_t::year.

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

◆ CP_GameTimeFast()

void CP_GameTimeFast ( void )

Increase game time speed.

Definition at line 174 of file cp_time.cpp.

References ccs, CP_AllowTimeScale(), CP_UpdateTime(), and NUM_TIMELAPSE.

◆ CP_GameTimeSlow()

void CP_GameTimeSlow ( void )

Decrease game time speed.

Definition at line 160 of file cp_time.cpp.

References ccs, CP_AllowTimeScale(), and CP_UpdateTime().

◆ CP_GameTimeStop()

◆ CP_IsTimeStopped()

bool CP_IsTimeStopped ( void )

Check if time is stopped.

Definition at line 139 of file cp_time.cpp.

References ccs.

Referenced by CP_CampaignRun(), and TEST_F().

◆ CP_SecondConvert()

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 57 of file cp_time.cpp.

References Com_sprintf(), and DateTime::SECONDS_PER_HOUR.

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

◆ CP_SetGameTime_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, and CP_SetGameTime().

◆ CP_UpdateTime()

◆ Date_DateToSeconds()

int Date_DateToSeconds ( const DateTime & date)

Convert a date to seconds.

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

Definition at line 228 of file cp_time.cpp.

References DateTime::getDateAsDays(), DateTime::getTimeAsSeconds(), and DateTime::SECONDS_PER_DAY.

Referenced by TR_List_f(), and US_SelectStoredUfo_f().

◆ Date_GetMonthName()

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 250 of file cp_time.cpp.

References _.

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

◆ Date_Random()

DateTime Date_Random ( const DateTime & minFrame,
const DateTime & 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 239 of file cp_time.cpp.

References frand(), DateTime::getDateAsDays(), DateTime::getTimeAsSeconds(), and DateTime::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().