46#define NT_SECONDS_DIV (1000)
47#define NT_SECONDS_DT (30)
48#define NT_CYCLE_SECONDS ((ntime_t)NT_CYCLE_PERIODS*(ntime_t)NT_PERIOD_SECONDS)
49#define NT_PERIODS_DIV ((ntime_t)NT_PERIOD_SECONDS*(ntime_t)NT_SECONDS_DIV)
50#define NT_CYCLES_DIV ((ntime_t)NT_CYCLE_SECONDS*(ntime_t)NT_SECONDS_DIV)
56typedef struct NTimeUpdate_s {
57 struct NTimeUpdate_s *
next;
64static int ntime_enable = 1;
96 ntime_t tscu, tstp, tstu;
100 return tscu*NT_CYCLES_DIV + tstp*NT_PERIODS_DIV + tstu*NT_SECONDS_DIV;
116void ntime_getR(
int *cycles,
int *periods,
int *seconds,
double *rem )
129 return (t / NT_CYCLES_DIV);
137 return (t / NT_PERIODS_DIV) % NT_CYCLE_PERIODS;
145 return (t / NT_SECONDS_DIV) % NT_PERIOD_SECONDS;
155 return ((
double)t / (
double)NT_SECONDS_DIV);
163 return (
double)(t % NT_SECONDS_DIV);
191 int cycles, periods, seconds;
202 if ((cycles == 0) && (periods == 0))
203 snprintf( str, max, _(
"%04d s"), seconds );
204 else if ((cycles == 0) || (
d==0))
205 snprintf( str, max, _(
"%.*f p"),
d, periods + 0.0001 * seconds );
207 snprintf( str, max, _(
"UST %d:%.*f"), cycles,
d, periods + 0.0001 * seconds );
224void ntime_setR(
int cycles,
int periods,
int seconds,
double rem )
253 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.
Header file with generic functions and naev-specifics.
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