naev 0.12.6
ntime.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include <stdint.h>
9
10#define TIME_PRI PRIi64
11
12#define NT_CYCLE_PERIODS ( 5000 )
13#define NT_PERIOD_SECONDS ( 10000 )
14
15typedef int64_t ntime_t;
16
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:222
ntime_t ntime_create(int scu, int stp, int stu)
Creates a time structure.
Definition ntime.c:99
ntime_t ntime_get(void)
Gets the current time.
Definition ntime.c:113
char * ntime_pretty(ntime_t t, int d)
Gets the time in a pretty human readable format.
Definition ntime.c:178
int ntime_getSeconds(ntime_t t)
Gets the seconds of a time.
Definition ntime.c:148
void ntime_refresh(void)
Checks to see if ntime has any hooks pending to run.
Definition ntime.c:296
void ntime_inc(ntime_t t)
Sets the time relatively.
Definition ntime.c:243
void ntime_getR(int *cycles, int *periods, int *seconds, double *rem)
Gets the current time broken into individual components.
Definition ntime.c:121
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:194
void ntime_update(double dt)
Updatse the time based on realtime.
Definition ntime.c:74
void ntime_allowUpdate(int enable)
Allows the time to update when the game is updating.
Definition ntime.c:258
int ntime_getCycles(ntime_t t)
Gets the cycles of a time.
Definition ntime.c:132
void ntime_setR(int cycles, int periods, int seconds, double rem)
Loads time including remainder.
Definition ntime.c:231
int ntime_getPeriods(ntime_t t)
Gets the periods of a time.
Definition ntime.c:140
double ntime_getRemainder(ntime_t t)
Gets the remainder.
Definition ntime.c:166
double ntime_convertSeconds(ntime_t t)
Converts the time to seconds.
Definition ntime.c:158
void ntime_incLagged(ntime_t t)
Sets the time relatively.
Definition ntime.c:271
static const double d[]
Definition rng.c:263