naev 0.11.5
ntime.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include <stdint.h>
10#define TIME_PRI PRIi64
11
12#define NT_CYCLE_PERIODS (5000)
13#define NT_PERIOD_SECONDS (10000)
15typedef int64_t ntime_t;
17/* Create. */
18ntime_t ntime_create( int scu, int stp, int stu );
19
20/* update */
21void ntime_update( double dt );
22
23/* get */
24ntime_t ntime_get (void);
25void ntime_getR( int *cycles, int *periods, int *seconds, double *rem );
26int ntime_getCycles( ntime_t t );
27int ntime_getPeriods( ntime_t t );
28int ntime_getSeconds( ntime_t t );
29double ntime_convertSeconds( ntime_t t );
30double ntime_getRemainder( ntime_t t );
31char* ntime_pretty( ntime_t t, int d );
32void ntime_prettyBuf( char *str, int max, ntime_t t, int d );
33
34/* set */
35void ntime_set( ntime_t t );
36void ntime_setR( int cycles, int periods, int seconds, double rem );
37void ntime_inc( ntime_t t );
38void ntime_incLagged( ntime_t t );
39
40/* misc */
41void ntime_refresh (void);
42void ntime_allowUpdate( int enable );
void ntime_set(ntime_t t)
Sets the time absolutely, does NOT generate an event, used at init.
Definition ntime.c:215
ntime_t ntime_create(int scu, int stp, int stu)
Creates a time structure.
Definition ntime.c:94
ntime_t ntime_get(void)
Gets the current time.
Definition ntime.c:108
char * ntime_pretty(ntime_t t, int d)
Gets the time in a pretty human readable format.
Definition ntime.c:173
int ntime_getSeconds(ntime_t t)
Gets the seconds of a time.
Definition ntime.c:143
void ntime_refresh(void)
Checks to see if ntime has any hooks pending to run.
Definition ntime.c:288
void ntime_inc(ntime_t t)
Sets the time relatively.
Definition ntime.c:236
void ntime_getR(int *cycles, int *periods, int *seconds, double *rem)
Gets the current time broken into individual components.
Definition ntime.c:116
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.
Definition ntime.c:188
void ntime_update(double dt)
Updatse the time based on realtime.
Definition ntime.c:69
void ntime_allowUpdate(int enable)
Allows the time to update when the game is updating.
Definition ntime.c:251
int ntime_getCycles(ntime_t t)
Gets the cycles of a time.
Definition ntime.c:127
void ntime_setR(int cycles, int periods, int seconds, double rem)
Loads time including remainder.
Definition ntime.c:224
int ntime_getPeriods(ntime_t t)
Gets the periods of a time.
Definition ntime.c:135
double ntime_getRemainder(ntime_t t)
Gets the remainder.
Definition ntime.c:161
double ntime_convertSeconds(ntime_t t)
Converts the time to seconds.
Definition ntime.c:153
void ntime_incLagged(ntime_t t)
Sets the time relatively.
Definition ntime.c:264
static const double d[]
Definition rng.c:273