Go to the documentation of this file.
48 static const int shutdown_warn_times[] = {120, 90, 60, 45, 30, 15, 10, 5, 4, 3, 2, 1};
51 static const char *
days[] = {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"};
75 #if (defined(__FreeBSD__))
87 static const char *
const c =
88 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
101 char const*
newhash(
char const password[
static 1]) {
116 if (strlen(crypted) == 0) {
117 return strlen(typed) == 0 ? true :
false;
120 const char *typed_hashed =
crypt_string(typed, crypted);
121 if (typed_hashed != NULL) {
122 return strcmp(typed_hashed, crypted) == 0;
124 LOG(
llevError,
"Could not check password with stored hash %s\n", crypted);
153 if (oldmap ==
op->map && strcmp(
op->contr->savebed_map, oldmap->
path)) {
154 LOG(
llevDebug,
"Player %s savebed location %s is invalid - going to emergency location (%s)\n",
185 if (x < 0 && y >= 0)
x=0;
186 if (y < 0 && x >= 0)
y=0;
189 LOG(
llevError,
"enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", newmap->
path,
x,
y);
200 "The exit is closed");
224 LOG(
llevInfo,
"enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", newmap->
path,
x,
y);
240 sizeof(
op->contr->maplevel));
241 op->contr->count = 0;
252 op->contr->golem_count = 0;
269 if (oldmap != newmap) {
278 if (oldmap != NULL) {
335 for (cp = newpath; *cp !=
'\0'; cp++) {
362 cp = strrchr(src,
'/');
368 for (cp = newpath; *cp !=
'\0'; cp++) {
387 static int reference_number = 0;
390 memset(&rp, 0,
sizeof(
RMParms));
415 while (isdigit(
buf[strlen(
buf)-1]))
420 snprintf(newmap_name,
sizeof(newmap_name),
"/random/%s%04d", cp+1, reference_number++);
468 sourcemap = strchr(exitpath,
'!');
474 LOG(
llevError,
"enter_fixed_template_map: Exit %s (%d,%d) on map %s has no source template.\n", exit_ob->
name, exit_ob->
x, exit_ob->
y, exit_ob->
map->
path);
485 sourcemap = sourcemap_buf;
491 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
x);
492 replace(exitpath,
"%x", tmpnum, resultname,
sizeof(resultname));
494 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
y);
495 strlcpy(tmpstring, resultname,
sizeof(tmpstring));
496 replace(tmpstring,
"%y", tmpnum, resultname,
sizeof(resultname));
498 strlcpy(tmpstring, resultname,
sizeof(tmpstring));
499 replace(tmpstring,
"%n", exit_ob->
map->
name, resultname,
sizeof(resultname));
523 "Template exit in '%s' (%d, %d) does not reference a valid "
524 "template. Make sure a template exists at '%s'.\n",
557 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
x);
558 replace(
EXIT_PATH(exit_ob)+3,
"%x", tmpnum, resultname,
sizeof(resultname));
560 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
y);
561 strlcpy(tmpstring, resultname,
sizeof(tmpstring));
562 replace(tmpstring,
"%y", tmpnum, resultname,
sizeof(resultname));
564 strlcpy(tmpstring, resultname,
sizeof(tmpstring));
565 replace(tmpstring,
"%n", exit_ob->
map->
name, resultname,
sizeof(resultname));
578 memset(&rp, 0,
sizeof(
RMParms));
631 char* src = strdup(
op->map->path);
632 char* slash = strrchr(src,
'/');
643 if ((cp = strrchr(tmpc,
'_')) != NULL)
657 snprintf(apartment,
sizeof(apartment),
"~%s/%s",
op->name,
clean_path(reldir,
path,
sizeof(
path)));
683 LOG(
llevDebug,
"enter_unique_map: Exit %s (%d,%d) on map %s is leads no where.\n", exit_ob->
name, exit_ob->
x, exit_ob->
y, exit_ob->
map->
path);
701 LOG(
llevError,
"Fatal: Could not load emergency map!\n");
706 "You find yourself somewhere unexpected...");
711 if (
x == -1 &&
y == -1) {
733 #define PORTAL_DESTINATION_NAME "Town portal destination"
741 assert(exit_ob != NULL);
754 "You feel a force fizzling away. You feel a vibration from: %s",
buf);
761 if (
op->contr->transport)
799 if (!newmap && !strncmp(
EXIT_PATH(exit_ob),
"/random/", 8)) {
843 if (
x == -1 &&
y == -1) {
876 exit_copy->
speed = 0;
878 exit_copy->
map = exit_ob->
map;
879 if (
op->contr->last_exit) {
882 op->contr->last_exit = exit_copy;
907 int sx, sy, sx2, sy2;
909 return (
ob->x >=
x+sx2) && (
ob->x <=
x+sx) && (
ob->y >=
y+sy2) && (
ob->y <=
y+sy);
918 if (followed && followed->
ob && followed->
ob->
map) {
966 for (flag = 1; flag != 0; ) {
1008 pl->last_save_tick += 100;
1077 return op->env != NULL && strcmp(
op->env->arch->name,
"icecube") == 0;
1090 memset(&marker, 0,
sizeof(
object));
1106 if (
op->active_prev)
1107 op->active_prev->active_next =
op;
1116 op->active_next = ▮
1120 LOG(
llevError,
"BUG: process_events(): Free object on list\n");
1143 LOG(
llevError,
"BUG: process_events(): Removed object on list\n");
1154 LOG(
llevError,
"BUG: process_events(): Object %s has no speed, but is on active list\n",
op->arch->name);
1162 &&
op->type !=
MAP) {
1163 LOG(
llevError,
"BUG: process_events(): Object without map or inventory is on active list: %s (%d)\n",
op->name,
op->count);
1177 LOG(
llevError,
"BUG: process_events(): Processing object on swapped out map: %s (%d), map=%s\n",
op->name,
op->count,
op->map->path);
1183 if ((
op->anim_speed &&
op->last_anim >=
op->anim_speed)
1184 || (
op->temp_animation &&
op->last_anim >=
op->temp_anim_speed)) {
1195 if (
op->speed_left > 0) {
1202 op->speed_left -= 10;
1204 op->speed_left -= 1;
1333 "%s has left. You are now the captain of %s",
1352 "%s left the game.",
1364 #if !defined(_IBMR2) && !defined(___IBMR2) && defined(PERM_FILE)
1369 int i, start,
stop, forbit = 0;
1372 tm = (
struct tm *)localtime(&clock);
1375 if ((fp = fopen(
buf,
"r")) == NULL)
1378 while (fgets(
buf,
sizeof(
buf), fp)) {
1381 if (!strncmp(
buf,
"msg", 3)) {
1383 while (fgets(
buf,
sizeof(
buf), fp))
1386 }
else if (sscanf(
buf,
"%s %d%*c%d\n", day, &start, &
stop) != 3) {
1387 LOG(
llevDebug,
"Warning: Incomplete line in permission file ignored.\n");
1391 for (i = 0; i < 7; i++) {
1393 && (tm->tm_wday == i)
1394 && (tm->tm_hour >= start)
1395 && (tm->tm_hour <
stop))
1421 LOG(
llevInfo,
"Received SIGINT; shutting down...\n");
1438 LOG(
llevInfo,
"No active players in the last %ld seconds, shutting down...\n", diff);
1466 if (time_left <= 0) {
1484 "This server will shut down when all players leave.");
1494 "This server will shut down in %d minutes.", time_left / 60);
1575 if (getuid() == 0 || geteuid() == 0) {
1577 "Running crossfire-server as root is a bad idea; aborting!\n"
1578 "Please run it again as a normal, unprivileged user.\n");
1583 #ifdef DEBUG_MALLOC_LEVEL
1584 malloc_debug(DEBUG_MALLOC_LEVEL);
1590 PROFILE_END(diff,
LOG(
llevInfo,
"Initialization complete (%ld ms). Waiting for connections.\n", diff/1000));
#define object_was_destroyed(op, old_tag)
mapstruct * ready_map_name(const char *name, int flags)
int handle_newcs_player(object *op)
#define FREE_OBJ_NO_DESTROY_CALLBACK
void object_free(object *ob, int flags)
sstring add_string(const char *str)
void tick_the_clock(void)
void object_remove(object *op)
StringBuffer * stringbuffer_new(void)
void remove_friendly_object(object *op)
void pets_terminate_all(object *owner)
void object_set_enemy(object *op, object *enemy)
void login_check_shutdown(object *const op)
#define MSG_TYPE_ADMIN_PLAYER
#define PORTAL_DESTINATION_NAME
static const char * days[]
void clean_tmp_map(mapstruct *m)
#define QUERY_FLAG(xyz, p)
void server_main(int argc, char *argv[])
void flush_old_maps(void)
void process_events(void)
int out_of_map(mapstruct *m, int x, int y)
object * object_new(void)
static event_registration c
int set_random_map_variable(RMParms *rp, const char *buf)
static char * unclean_path(const char *src, char *newpath, int size)
void leave(player *pl, int draw_exit)
static void do_follow(player *pl)
int move_player(object *op, int dir)
char * create_pathname(const char *name, char *buf, size_t size)
void free_all_newserver(void)
#define MAP_PLAYER_UNIQUE
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
static void enter_map(object *op, mapstruct *newmap, int x, int y)
int ob_blocked(const object *ob, mapstruct *m, int16_t x, int16_t y)
void enter_player_savebed(object *op)
#define PROFILE_BEGIN(expr)
void free_all_recipes(void)
void free_knowledge(void)
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout, sstring reset_group)
static const flag_definition flags[]
void cleanupPlugins(void)
static void do_shutdown(void)
int get_rangevector(object *op1, const object *op2, rv_vector *retval, int flags)
void object_free_all_data(void)
EXTERN mapstruct * first_map
void party_obsolete_parties(void)
void hiscore_check(object *op, int quiet)
static int query_flag(const object *op, int flag)
short freearr_x[SIZEOFFREE]
short freearr_y[SIZEOFFREE]
method_ret ob_apply(object *op, object *applier, int aflags)
static bool check_shutdown(void)
void animate_object(object *op, int dir)
#define MSG_TYPE_ADMIN_DM
void free_string(sstring str)
#define PROFILE_END(var, expr)
static event_registration m
void clean_tmp_files(void)
void apply_auto_fix(mapstruct *m)
object * object_find_by_type_and_slaying(const object *who, int type, const char *slaying)
void set_map_timeout(mapstruct *oldmap)
static bool object_on_exit(object *ob, object *exit)
void object_copy(const object *src_ob, object *dest_ob)
void query_name(const object *op, char *buf, size_t size)
void object_dump(const object *op, StringBuffer *sb)
void clean_friendly_list(void)
void party_leave(object *op)
#define FOR_OB_AND_BELOW_FINISH()
static bool object_in_icecube(object *op)
static char const * crypt_string(char const str[static 1], char const *salt)
EXTERN player * first_player
static int move_towards(object *ob, object *towards, unsigned int mindist)
char * stringbuffer_finish(StringBuffer *sb)
void player_map_change_common(object *op, mapstruct *const oldmap, mapstruct *const newmap)
struct regiondef * region
#define FOR_OB_AND_BELOW_PREPARE(op_)
static void do_specials(void)
void cftimer_process_timers(void)
char const * newhash(char const password[static 1])
static char * clean_path(const char *file, char *newpath, int size)
size_t strlcpy(char *dst, const char *src, size_t size)
void object_get_multi_size(const object *ob, int *sx, int *sy, int *hx, int *hy)
bool check_password(const char *typed, const char *crypted)
#define FREE_AND_CLEAR_STR(xyz)
void free_quest_definitions(void)
void enter_player_maplevel(object *op)
int save_map(mapstruct *m, int flag)
#define MSG_TYPE_COMMAND_FAILURE
bool can_follow(object *, player *)
char * ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
void pets_attempt_follow(object *for_owner, int force)
int swap_map(mapstruct *map)
void write_book_archive(void)
static void enter_unique_map(object *op, object *exit_ob)
#define MSG_TYPE_SPELL_FAILURE
void free_style_maps(void)
#define ST_CONFIRM_PASSWORD
void metaserver_update(void)
void LOG(LogLevel logLevel, const char *format,...)
void write_cs_stats(void)
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
void update_players(void)
void enter_exit(object *op, object *exit_ob)
static void process_players2(void)
void init(int argc, char **argv)
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
player * find_player_partial_name(const char *plname)
void object_update_speed(object *op)
void map_newmap_cmd(socket_struct *ns)
static void process_players1(void)
static void enter_fixed_template_map(object *pl, object *exit_ob)
int find_dir_2(int x, int y)
void replace(const char *src, const char *key, const char *replacement, char *result, size_t resultsize)
region * get_region_by_map(mapstruct *m)
int save_player(object *op, int flag)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
void object_free_drop_inventory(object *ob)
void free_all_artifacts(void)
struct shutdown_s shutdown_state
static const int shutdown_warn_times[]
void do_some_living(object *op)
void check_active_maps(void)
volatile sig_atomic_t shutdown_flag
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
static void enter_random_map(object *pl, object *exit_ob)
void write_todclock(void)
void free_all_readable(void)
int process_object(object *op)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
void knowledge_process_incremental(void)
void events_execute_global_event(int eventcode,...)
#define SP_WORD_OF_RECALL
mapstruct * mapfile_load(const char *map, int flags)
void player_update_bg_music(object *player)
void create_template_pathname(const char *name, char *buf, size_t size)
static void enter_random_template_map(object *pl, object *exit_ob)