43#define NT_SECONDS_DIV ( 1000 )
44#define NT_SECONDS_DT \
46#define NT_CYCLE_SECONDS \
47 ( (ntime_t)NT_CYCLE_PERIODS * \
48 (ntime_t)NT_PERIOD_SECONDS )
49#define NT_PERIODS_DIV \
50 ( (ntime_t)NT_PERIOD_SECONDS * \
51 (ntime_t)NT_SECONDS_DIV )
52#define NT_CYCLES_DIV \
53 ( (ntime_t)NT_CYCLE_SECONDS * \
54 (ntime_t)NT_SECONDS_DIV )
60typedef struct NTimeUpdate_s {
61 struct NTimeUpdate_s *
next;
69static int ntime_enable = 1;
101 ntime_t tscu, tstp, tstu;
105 return tscu * NT_CYCLES_DIV + tstp * NT_PERIODS_DIV + tstu * NT_SECONDS_DIV;
121void ntime_getR(
int *cycles,
int *periods,
int *seconds,
double *rem )
134 return ( t / NT_CYCLES_DIV );
142 return ( t / NT_PERIODS_DIV ) % NT_CYCLE_PERIODS;
150 return ( t / NT_SECONDS_DIV ) % NT_PERIOD_SECONDS;
160 return ( (
double)t / (
double)NT_SECONDS_DIV );
168 return (
double)( t % NT_SECONDS_DIV );
182 return strdup( str );
197 int cycles, periods, seconds;
208 if ( ( cycles == 0 ) && ( periods == 0 ) )
209 snprintf( str, max, _(
"%04d s" ), seconds );
210 else if ( ( cycles == 0 ) || (
d == 0 ) )
211 snprintf( str, max, _(
"%.*f p" ),
d, periods + 0.0001 * seconds );
213 snprintf( str, max, _(
"UST %d:%.*f" ), cycles,
d,
214 periods + 0.0001 * seconds );
231void ntime_setR(
int cycles,
int periods,
int seconds,
double rem )
260 ntime_enable = enable;
int economy_update(unsigned int dt)
Updates the economy.
void hooks_updateDate(ntime_t change)
Updates the time to see if it should be updated.
void ntime_set(ntime_t t)
Sets the time absolutely, does NOT generate an event, used at init.
ntime_t ntime_create(int scu, int stp, int stu)
Creates a time structure.
static NTimeUpdate_t * ntime_inclist
ntime_t ntime_get(void)
Gets the current time.
char * ntime_pretty(ntime_t t, int d)
Gets the time in a pretty human readable format.
static double naev_remainder
int ntime_getSeconds(ntime_t t)
Gets the seconds of a time.
void ntime_refresh(void)
Checks to see if ntime has any hooks pending to run.
void ntime_inc(ntime_t t)
Sets the time relatively.
void ntime_getR(int *cycles, int *periods, int *seconds, double *rem)
Gets the current time broken into individual components.
void ntime_prettyBuf(char *str, int max, ntime_t t, int d)
Gets the time in a pretty human readable format filling a preset buffer.
void ntime_update(double dt)
Updatse the time based on realtime.
void ntime_allowUpdate(int enable)
Allows the time to update when the game is updating.
int ntime_getCycles(ntime_t t)
Gets the cycles of a time.
void ntime_setR(int cycles, int periods, int seconds, double rem)
Loads time including remainder.
int ntime_getPeriods(ntime_t t)
Gets the periods of a time.
double ntime_getRemainder(ntime_t t)
Gets the remainder.
double ntime_convertSeconds(ntime_t t)
Converts the time to seconds.
void ntime_incLagged(ntime_t t)
Sets the time relatively.
Used for storing time increments to not trigger hooks during Lua calls and such.
struct NTimeUpdate_s * next