Go to the documentation of this file.
28 #include <sys/types.h>
54 "The Season of New Year",
55 "The Season of Growth",
56 "The Season of Harvest",
57 "The Season of Decay",
58 "The Season of the Blizzard",
64 "the Day of the Moon",
65 "the Day of the Bull",
66 "the Day of the Deception",
69 "the Day of the Great Gods",
76 "Month of the Ice Dragon",
77 "Month of the Frost Giant",
80 "Month of the Harvest",
83 "Month of the Dragon",
85 "Month of the Great Infernus",
87 "Month of the Dark Shades",
88 "Month of the Devourers",
90 "Month of the Ancient Darkness",
145 clock_gettime(CLOCK_MONOTONIC, &
game_time);
167 double sec = difftime(end->tv_sec, start->tv_sec);
168 long nsec = end->tv_nsec - start->tv_nsec;
169 return (
long)(sec * 1e6 + nsec / 1e3);
176 long nsec_sum = time->tv_nsec + usec * 1e3;
177 time->tv_sec += nsec_sum / 1e9;
178 time->tv_nsec = nsec_sum % (long)1e9;
191 clock_gettime(CLOCK_MONOTONIC, &now);
193 if (time_since_last_sleep >= 0)
200 clock_gettime(CLOCK_MONOTONIC, &
game_time);
231 else if (tod->
month < 6)
233 else if (tod->
month < 9)
235 else if (tod->
month < 12)
242 else if (tod->
hour < 8)
244 else if (tod->
hour < 13)
246 else if (tod->
hour < 15)
248 else if (tod->
hour < 20)
250 else if (tod->
hour < 23)
274 if (day == 1 || ((day%10) == 1 && day > 20))
276 else if (day == 2 || ((day%10) == 2 && day > 20))
278 else if (day == 3 || ((day%10) == 3 && day > 20))
284 "The %d%s Day of the %s, Year %d",
299 int tot = 0, long_count = 0;
300 uint32_t maxt = 0, mint = 99999999, i;
309 "Statistics for last %d ticks:\n\tmin/avg/max = %d/%d/%d ms per tick",
315 "\tticks longer than %d ms = %d (%d%%)",
tick_duration / 1000,
319 "Time last %d ticks:",
335 "avg time=%dms max time=%dms min time=%dms",
340 "ticks longer than max time (%dms) = %d (%d%%)",
350 clock_gettime(CLOCK_REALTIME, &now);
371 snprintf(
buf, bufsize,
"%d minute%s past %d o'clock %s",
373 tod->
minute+1 < 2 ?
"" :
"s",
374 tod->
hour%14 == 0 ? 14 : tod->
hour%14,
375 tod->
hour >= 14 ?
"pm" :
"am");
static void print_tod(object *op)
static uint32_t process_utime_save[PBUFLEN]
static void log_time(uint32_t process_utime)
static struct timespec game_time
void time_info(object *op)
#define QUERY_FLAG(xyz, p)
static const char *const periodsofday[PERIODS_PER_DAY]
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
void get_tod(timeofday_t *tod)
void set_tick_duration(long t)
const char * time_format_time(const timeofday_t *tod, char *buf, size_t bufsize)
const char * get_season_name(const int index)
#define MSG_TYPE_COMMAND_DEBUG
const char * get_weekday(const int index)
#define MSG_TYPE_COMMAND_INFO
static uint32_t process_min_utime
const char * get_periodofday(const int index)
static const char *const season_name[SEASONS_PER_YEAR+1]
static const char *const weekdays[DAYS_PER_WEEK]
static uint32_t process_utime_long_count
long get_sleep_remaining()
unsigned int tick_length(float seconds)
static uint32_t process_tot_mtime
long timespec_diff(struct timespec *end, struct timespec *start)
static uint32_t process_max_utime
static void timespec_add(struct timespec *time, long usec)
const char * get_month_name(const int index)
static const char *const month_name[MONTHS_PER_YEAR]