Crossfire Server, Branch 1.12
R12190
|
Ingame time functions. More...
#include <global.h>
#include <tod.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
Go to the source code of this file.
Defines | |
#define | PBUFLEN 100 |
Size of history buffer. | |
Functions | |
int | enough_elapsed_time (void) |
Checks elapsed time since last tick. | |
const char * | get_month_name (const int index) |
give access to month names | |
const char * | get_periodofday (const int index) |
give access to weekday names | |
const char * | get_season_name (const int index) |
give access to season names | |
void | get_tod (timeofday_t *tod) |
Computes the ingame time of the day. | |
const char * | get_weekday (const int index) |
give access to weekday names | |
static void | log_time (uint32 process_utime) |
Adds time to our history list. | |
static void | print_tod (object *op) |
Prints the time. | |
void | reset_sleep (void) |
Initialise all variables used in the timing routines. | |
long | seconds (void) |
Gets the seconds. | |
void | set_max_time (long t) |
Sets the max speed. | |
void | sleep_delta (void) |
sleep_delta checks how much time has elapsed since last tick. | |
void | time_info (object *op) |
Players wants to know the time. | |
Variables | |
struct timeval | last_time |
uint32 | max_time = MAX_TIME |
Gloabal variables: | |
static const char *const | month_name [MONTHS_PER_YEAR] |
Months. | |
static const char *const | periodsofday [PERIODS_PER_DAY] |
static uint32 | process_max_utime = 0 |
Longest cycle time. | |
static uint32 | process_min_utime = 999999999 |
Shortest cycle time. | |
static uint32 | process_tot_mtime |
? | |
static uint32 | process_utime_long_count |
? | |
static uint32 | process_utime_save [PBUFLEN] |
Historic data. | |
static uint32 | psaveind |
Index in process_utime_save. | |
uint32 | pticks |
? | |
static const char *const | season_name [SEASONS_PER_YEAR+1] |
Ingame seasons. | |
unsigned long | todtick |
Ingame time. | |
static const char *const | weekdays [DAYS_PER_WEEK] |
Days of the week. |
Ingame time functions.
Definition in file time.c.
#define PBUFLEN 100 |
Size of history buffer.
Definition at line 50 of file time.c.
Referenced by log_time(), reset_sleep(), and time_info().
int enough_elapsed_time | ( | void | ) |
Checks elapsed time since last tick.
Definition at line 175 of file time.c.
References GETTIMEOFDAY, last_time, log_time(), and max_time.
const char* get_month_name | ( | const int | index | ) |
give access to month names
Definition at line 120 of file time.c.
References month_name, and MONTHS_PER_YEAR.
Referenced by cfapi_get_month_name(), and START_TEST().
const char* get_periodofday | ( | const int | index | ) |
give access to weekday names
Definition at line 113 of file time.c.
References PERIODS_PER_DAY, and periodsofday.
Referenced by cfapi_get_periodofday_name().
const char* get_season_name | ( | const int | index | ) |
give access to season names
Definition at line 134 of file time.c.
References season_name, and SEASONS_PER_YEAR.
Referenced by cfapi_get_season_name(), and START_TEST().
void get_tod | ( | timeofday_t * | tod | ) |
Computes the ingame time of the day.
[out] | tod | where to store information. Must not be NULL. |
Definition at line 268 of file time.c.
References _timeofday::day, _timeofday::dayofweek, DAYS_PER_MONTH, DAYS_PER_WEEK, _timeofday::hour, HOURS_PER_DAY, HOURS_PER_MONTH, HOURS_PER_YEAR, _timeofday::minute, _timeofday::month, MONTHS_PER_YEAR, _timeofday::periodofday, pticks, PTICKS_PER_CLOCK, _timeofday::season, todtick, _timeofday::weekofmonth, WEEKS_PER_MONTH, and _timeofday::year.
Referenced by cfapi_get_time(), clock_type_apply(), print_tod(), set_darkness_map(), and tick_the_clock().
const char* get_weekday | ( | const int | index | ) |
give access to weekday names
Definition at line 127 of file time.c.
References DAYS_PER_WEEK, and weekdays.
Referenced by cfapi_get_weekday_name(), and START_TEST().
Adds time to our history list.
Definition at line 158 of file time.c.
References PBUFLEN, process_max_utime, process_min_utime, process_tot_mtime, process_utime_save, psaveind, and pticks.
Referenced by enough_elapsed_time(), and sleep_delta().
static void print_tod | ( | object * | op | ) | [static] |
Prints the time.
op | player who requested time. |
Definition at line 311 of file time.c.
References _timeofday::day, _timeofday::dayofweek, draw_ext_info_format(), get_tod(), _timeofday::hour, _timeofday::minute, _timeofday::month, month_name, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_INFO, NDI_UNIQUE, _timeofday::season, season_name, weekdays, and _timeofday::year.
Referenced by time_info().
void reset_sleep | ( | void | ) |
Initialise all variables used in the timing routines.
Definition at line 141 of file time.c.
References GETTIMEOFDAY, last_time, PBUFLEN, process_max_utime, process_min_utime, process_tot_mtime, process_utime_save, psaveind, and pticks.
Referenced by block_until_new_connection(), command_speed(), init(), and setup().
long seconds | ( | void | ) |
Gets the seconds.
Definition at line 417 of file time.c.
References GETTIMEOFDAY.
Referenced by cftimer_create(), cftimer_process_timers(), flush_old_maps(), map_info(), read_map_log(), set_map_reset_time(), and swap_map().
void set_max_time | ( | long | t | ) |
Sets the max speed.
Can be called by a DM through the speed command.
t | new speed. |
Definition at line 256 of file time.c.
References max_time.
Referenced by command_speed().
void sleep_delta | ( | void | ) |
sleep_delta checks how much time has elapsed since last tick.
If it is less than max_time, the remaining time is slept with select().
Definition at line 195 of file time.c.
References GETTIMEOFDAY, last_time, log_time(), max_time, and process_utime_long_count.
Referenced by server_main().
void time_info | ( | object * | op | ) |
Players wants to know the time.
Called through the 'time' command.
op | player who requested time. |
Definition at line 353 of file time.c.
References draw_ext_info(), draw_ext_info_format(), FLAG_WIZ, max_time, MIN, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, NDI_UNIQUE, PBUFLEN, print_tod(), process_max_utime, process_min_utime, process_tot_mtime, process_utime_long_count, process_utime_save, pticks, and QUERY_FLAG.
Referenced by command_time().
struct timeval last_time |
Definition at line 47 of file time.c.
Referenced by enough_elapsed_time(), reset_sleep(), and sleep_delta().
Gloabal variables:
Definition at line 46 of file time.c.
Referenced by command_speed(), enough_elapsed_time(), set_max_time(), sleep_delta(), and time_info().
const char* const month_name[MONTHS_PER_YEAR] [static] |
{ "Month of Winter", "Month of the Ice Dragon", "Month of the Frost Giant", "Month of Valriel", "Month of Lythander", "Month of the Harvest", "Month of Gaea", "Month of Futility", "Month of the Dragon", "Month of the Sun", "Month of the Great Infernus", "Month of Ruggilli", "Month of the Dark Shades", "Month of the Devourers", "Month of Sorig", "Month of the Ancient Darkness", "Month of Gorokh" }
Months.
Definition at line 81 of file time.c.
Referenced by get_month_name(), and print_tod().
const char* const periodsofday[PERIODS_PER_DAY] [static] |
{ "Night", "Dawn", "Morning", "Noon", "Evening", "Dusk" }
Definition at line 101 of file time.c.
Referenced by get_periodofday().
uint32 process_max_utime = 0 [static] |
Longest cycle time.
Definition at line 53 of file time.c.
Referenced by log_time(), reset_sleep(), and time_info().
uint32 process_min_utime = 999999999 [static] |
Shortest cycle time.
Definition at line 54 of file time.c.
Referenced by log_time(), reset_sleep(), and time_info().
uint32 process_tot_mtime [static] |
uint32 process_utime_long_count [static] |
uint32 process_utime_save[PBUFLEN] [static] |
Historic data.
Definition at line 51 of file time.c.
Referenced by log_time(), reset_sleep(), and time_info().
Index in process_utime_save.
Definition at line 52 of file time.c.
Referenced by log_time(), and reset_sleep().
?
Used by various function to determine how often to save the character.
Definition at line 56 of file time.c.
Referenced by check_login(), check_output_buffers(), do_some_living(), do_specials(), get_tod(), handle_newcs_player(), key_change_class(), log_time(), process_players1(), reset_sleep(), send_tick(), and time_info().
const char* const season_name[SEASONS_PER_YEAR+1] [static] |
{ "The Season of New Year", "The Season of Growth", "The Season of Harvest", "The Season of Decay", "The Season of the Blizzard", "\n" }
Ingame seasons.
Definition at line 60 of file time.c.
Referenced by get_season_name(), and print_tod().
const char* const weekdays[DAYS_PER_WEEK] [static] |
{ "the Day of the Moon", "the Day of the Bull", "the Day of the Deception", "the Day of Thunder", "the Day of Freedom", "the Day of the Great Gods", "the Day of the Sun" }
Days of the week.
Definition at line 70 of file time.c.
Referenced by get_weekday(), and print_tod().