 |
Crossfire Server, Trunk
1.75.0
|
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)
Prints the time.
static uint32_t process_utime_save[PBUFLEN]
Historic data.
static void log_time(uint32_t process_utime)
Adds time to our history list.
#define PTICKS_PER_CLOCK
Number of ticks per in-game hour.
static struct timespec game_time
void time_info(object *op)
Players wants to know the time.
#define QUERY_FLAG(xyz, p)
unsigned long todtick
Game world time, in in-game hours.
#define MAX_TIME
If you feel the game is too fast or too slow, change MAX_TIME.
static const char *const periodsofday[PERIODS_PER_DAY]
Represents the ingame time.
non standard information is not specified or uptime this means how long since the executable has been started A particular host may have been running a server for quite a long time
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)
Computes the ingame time of the day.
static uint32_t psaveind
Index in process_utime_save.
uint32_t pticks
Number of ticks since time reset.
void set_tick_duration(long t)
Sets the tick duration.
const char * time_format_time(const timeofday_t *tod, char *buf, size_t bufsize)
Formats a timestamp in Crossfire time.
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
float ticks_to_seconds(int ticks)
const char * get_season_name(const int index)
give access to season names
#define MSG_TYPE_COMMAND_DEBUG
Various debug type commands.
const char * get_weekday(const int index)
give access to weekday names
#define MSG_TYPE_COMMAND_INFO
Generic info: resistances, etc.
static uint32_t process_min_utime
Shortest cycle time.
const char * get_periodofday(const int index)
give access to weekday names
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn t
static const char *const season_name[SEASONS_PER_YEAR+1]
Ingame seasons.
static const char *const weekdays[DAYS_PER_WEEK]
Days of the week.
static uint32_t process_utime_long_count
Number of times server couldn't keep up with game time (tried to sleep for a negative time)
long get_sleep_remaining()
long seconds(void)
Return wall clock time in seconds.
unsigned int tick_length(float seconds)
Calculate the number of ticks that correspond to real time.
static uint32_t process_tot_mtime
?
long timespec_diff(struct timespec *end, struct timespec *start)
Return the difference between two timespec's in microseconds.
#define FLAG_WIZ
Object has special privilegies.
#define NDI_UNIQUE
Print immediately, don't buffer.
static uint32_t process_max_utime
Longest cycle time.
void reset_sleep(void)
Initialise all variables used in the timing routines.
uint32_t tick_duration
Gloabal variables:
static void timespec_add(struct timespec *time, long usec)
Add 'usec' microseconds to the given timespec.
const char * get_month_name(const int index)
give access to month names
static const char *const month_name[MONTHS_PER_YEAR]
Months.
#define PBUFLEN
Size of history buffer.