28 #include <sys/types.h> 50 "The Season of New Year",
51 "The Season of Growth",
52 "The Season of Harvest",
53 "The Season of Decay",
54 "The Season of the Blizzard",
60 "the Day of the Moon",
61 "the Day of the Bull",
62 "the Day of the Deception",
65 "the Day of the Great Gods",
72 "Month of the Ice Dragon",
73 "Month of the Frost Giant",
76 "Month of the Harvest",
79 "Month of the Dragon",
81 "Month of the Great Infernus",
83 "Month of the Dark Shades",
84 "Month of the Devourers",
86 "Month of the Ancient Darkness",
141 clock_gettime(CLOCK_MONOTONIC, &
game_time);
163 long long sec = (
long long)end->tv_sec - (
long long)start->tv_sec;
164 long nsec = end->tv_nsec - start->tv_nsec;
165 return sec * 1e6 + nsec / 1e3;
172 long nsec_sum = time->tv_nsec + usec * 1e3;
173 time->tv_sec += nsec_sum / 1e9;
174 time->tv_nsec = nsec_sum % (long)1e9;
186 clock_gettime(CLOCK_MONOTONIC, &now);
189 return max_time - time_since_last_sleep;
194 clock_gettime(CLOCK_MONOTONIC, &
game_time);
227 else if (tod->
month < 6)
229 else if (tod->
month < 9)
231 else if (tod->
month < 12)
238 else if (tod->
hour < 8)
240 else if (tod->
hour < 13)
242 else if (tod->
hour < 15)
244 else if (tod->
hour < 20)
246 else if (tod->
hour < 23)
270 if (day == 1 || ((day%10) == 1 && day > 20))
272 else if (day == 2 || ((day%10) == 2 && day > 20))
274 else if (day == 3 || ((day%10) == 3 && day > 20))
280 "The %d%s Day of the %s, Year %d",
295 int tot = 0, long_count = 0;
296 uint32_t maxt = 0, mint = 99999999, i;
305 "Statistics for last %d ticks:\n\tmin/avg/max = %d/%d/%d ms per tick",
311 "\tticks longer than %d ms = %d (%d%%)",
max_time / 1000,
315 "Time last %d ticks:",
331 "avg time=%dms max time=%dms min time=%dms",
336 "ticks longer than max time (%dms) = %d (%d%%)",
346 clock_gettime(CLOCK_REALTIME, &now);
367 snprintf(buf, bufsize,
"%d minute%s past %d o'clock %s",
369 tod->
minute+1 < 2 ?
"" :
"s",
370 tod->
hour%14 == 0 ? 14 : tod->
hour%14,
371 tod->
hour >= 14 ?
"pm" :
"am");
379 return (
int)ceil(seconds * 1000000 /
max_time);
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
static void log_time(uint32_t process_utime)
long timespec_diff(struct timespec *end, struct timespec *start)
const char * get_season_name(const int index)
const char * get_weekday(const int index)
static uint32_t process_tot_mtime
static uint32_t process_utime_save[PBUFLEN]
static uint32_t process_utime_long_count
static uint32_t process_min_utime
static void timespec_add(struct timespec *time, long usec)
const char * get_month_name(const int index)
const char * time_format_time(const timeofday_t *tod, char *buf, size_t bufsize)
long get_sleep_remaining()
void set_max_time(long t)
static const char *const month_name[MONTHS_PER_YEAR]
void time_info(object *op)
#define QUERY_FLAG(xyz, p)
#define MSG_TYPE_COMMAND_DEBUG
static void print_tod(object *op)
static const char *const periodsofday[PERIODS_PER_DAY]
static const char *const weekdays[DAYS_PER_WEEK]
static const char *const season_name[SEASONS_PER_YEAR+1]
void get_tod(timeofday_t *tod)
static struct timespec game_time
#define MSG_TYPE_COMMAND_INFO
const char * get_periodofday(const int index)
static uint32_t process_max_utime
unsigned int tick_length(float seconds)