57 # include <sys/types.h>
60 #include <../random_maps/random_map.h>
61 #include <../random_maps/rproto.h>
65 static const char days[7][4] = {
83 "This is Crossfire v%s",
84 "This is Crossfire v%s",
87 "The authors can be reached at crossfire@metalforge.org", NULL);
99 "Welcome to Crossfire, v%s!\nPress `?' for help\n",
100 "Welcome to Crossfire, v%s!\nPress `?' for help\n",
105 "%s entered the game.",
106 "%s entered the game.",
111 "Note that you must set your name with the name command to enter the highscore list.", NULL);
131 #if defined(WIN32) || (defined(__FreeBSD__) && !defined(HAVE_LIBDES))
134 static const char *
const c =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
138 s[0] = c[RANDOM()%(int)strlen(c)],
139 s[1] = c[RANDOM()%(int)strlen(c)];
145 return (
char *)des_crypt(str, s);
148 return (
char *)crypt(str, s);
219 LOG(
llevError,
"enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", newmap->
path, x, y);
225 "The exit is closed", NULL);
249 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);
258 if (op->
map != NULL) {
315 if (oldmap != newmap) {
366 static char *
clean_path(
const char *file,
char *newpath,
int size) {
369 snprintf(newpath, size,
"%s", file);
370 for (cp = newpath; *cp !=
'\0'; cp++) {
397 cp = strrchr(src,
'/');
399 snprintf(newpath, size,
"%s", cp+1);
403 for (cp = newpath; *cp !=
'\0'; cp++) {
423 static int reference_number = 0;
426 memset(&rp, 0,
sizeof(
RMParms));
452 snprintf(buf,
sizeof(buf),
"%s", cp);
453 while (isdigit(buf[strlen(buf)-1]))
454 buf[strlen(buf)-1] = 0;
458 snprintf(newmap_name,
sizeof(newmap_name),
"/random/%s%04d", cp+1, reference_number++);
499 sourcemap = strchr(exitpath,
'!');
508 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);
519 snprintf(exitpath,
sizeof(exitpath),
"%s", tmpstring);
520 sourcemap = exitpath;
526 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
x);
527 replace(exitpath,
"%x", tmpnum, resultname,
sizeof(resultname));
529 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
y);
530 snprintf(tmpstring,
sizeof(tmpstring),
"%s", resultname);
531 replace(tmpstring,
"%y", tmpnum, resultname,
sizeof(resultname));
533 snprintf(tmpstring,
sizeof(tmpstring),
"%s", resultname);
534 replace(tmpstring,
"%n", exit_ob->
map->
name, resultname,
sizeof(resultname));
573 LOG(
llevDebug,
"enter_fixed_template_map: Exit %s (%d,%d) on map %s leads no where.\n", exit_ob->
name, exit_ob->
x, exit_ob->
y, exit_ob->
map->
path);
595 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
x);
596 replace(
EXIT_PATH(exit_ob)+3,
"%x", tmpnum, resultname,
sizeof(resultname));
598 snprintf(tmpnum,
sizeof(tmpnum),
"%d", exit_ob->
y);
599 snprintf(tmpstring,
sizeof(tmpstring),
"%s", resultname);
600 replace(tmpstring,
"%y", tmpnum, resultname,
sizeof(resultname));
602 snprintf(tmpstring,
sizeof(tmpstring),
"%s", resultname);
603 replace(tmpstring,
"%n", exit_ob->
map->
name, resultname,
sizeof(resultname));
616 memset(&rp, 0,
sizeof(
RMParms));
677 if ((cp = strrchr(tmpc,
'_')) != NULL)
721 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);
741 #define PORTAL_DESTINATION_NAME "Town portal destination"
785 if (!newmap && !strncmp(
EXIT_PATH(exit_ob),
"/random/", 8)) {
837 if (x == 0 && y == 0) {
840 LOG(
llevDebug,
"enter_exit: Exit %s (%d,%d) on map %s is 0 destination coordinates\n",
841 exit_ob->
name ? exit_ob->
name :
"(none)", exit_ob->
x, exit_ob->
y,
842 exit_ob->
map ? exit_ob->
map->
path :
"(none)");
848 for (tmp = op->
inv; tmp != NULL; tmp = tmp->
below) {
895 LOG(
llevError,
"enter_exit: could not load emergency map? Fatal error\n");
913 for (flag = 1; flag != 0; ) {
924 if (followed && followed->
ob && followed->
ob->
map) {
967 pl->last_save_tick += 100;
970 pl->last_save_tick =
pticks;
1033 memset(&marker, 0,
sizeof(
object));
1063 LOG(
llevError,
"BUG: process_events(): Free object on list\n");
1086 LOG(
llevError,
"BUG: process_events(): Removed object on list\n");
1097 LOG(
llevError,
"BUG: process_events(): Object %s has no speed, but is on active list\n", op->
arch->
name);
1106 LOG(
llevError,
"BUG: process_events(): Object without map or inventory is on active list: %s (%d)\n", op->
name, op->
count);
1173 for (m =
first_map; m != NULL; m = next) {
1261 "%s has left. You are now the captain of %s",
1262 "%s has left. You are now the captain of %s",
1284 "%s left the game.",
1285 "%s left the game.",
1297 #if !defined(_IBMR2) && !defined(___IBMR2) && defined(PERM_FILE)
1302 int i, start, stop, forbit = 0, comp;
1305 tm = (
struct tm *)localtime(&clock);
1311 while (fgets(buf,
sizeof(buf), fp)) {
1314 if (!strncmp(buf,
"msg", 3)) {
1316 while (fgets(buf,
sizeof(buf), fp))
1319 }
else if (sscanf(buf,
"%s %d%*c%d\n", day, &start, &stop) != 3) {
1320 LOG(
llevDebug,
"Warning: Incomplete line in permission file ignored.\n");
1324 for (i = 0; i < 7; i++) {
1325 if (!strncmp(buf,
days[i], 3)
1326 && (tm->tm_wday == i)
1327 && (tm->tm_hour >= start)
1328 && (tm->tm_hour < stop))
1407 if (getuid() == 0 || geteuid() == 0) {
1408 fputs(
"Don't run crossfire as root, it is unsupported.\n", stderr);
1409 fputs(
"Instead run it as a normal unprivileged user.\n", stderr);
1410 fputs(
"Aborting...\n", stderr);
1415 #ifdef DEBUG_MALLOC_LEVEL
1416 malloc_debug(DEBUG_MALLOC_LEVEL);
void enter_exit(object *op, object *exit_ob)
int find_dir_2(int x, int y)
void leave(player *pl, int draw_exit)
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny)
void enter_player_savebed(object *op)
static void enter_random_map(object *pl, object *exit_ob)
static void do_specials(void)
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout)
void do_some_living(object *op)
void metaserver_update(void)
object * insert_ob_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
char * create_pathname(const char *name, char *buf, size_t size)
int save_player(object *op, int flag)
StringBuffer * stringbuffer_new(void)
mapstruct * ready_map_name(const char *name, int flags)
void free_string(sstring str)
short freearr_x[SIZEOFFREE]
#define ST_CONFIRM_PASSWORD
#define MSG_TYPE_ADMIN_PLAYER
void draw_ext_info(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *message, const char *oldmessage)
region * get_region_by_map(mapstruct *m)
object * ranges[range_size]
void swap_below_max(const char *except_level)
void close_and_delete(FILE *fp, int compressed)
mapstruct * load_original_map(const char *filename, int flags)
void remove_friendly_object(object *op)
method_ret ob_apply(object *op, object *applier, int aflags)
void clean_friendly_list(void)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
static void enter_unique_map(object *op, object *exit_ob)
int swap_map(mapstruct *map)
char savebed_map[MAX_BUF]
static const char days[7][4]
#define MSG_TYPE_COMMAND_FAILURE
void check_active_maps(void)
short freearr_y[SIZEOFFREE]
void free_all_newserver(void)
void map_newmap_cmd(socket_struct *ns)
void remove_ob(object *op)
void flush_old_maps(void)
void write_todclock(void)
void fix_auto_apply(mapstruct *m)
static char * clean_path(const char *file, char *newpath, int size)
static void enter_fixed_template_map(object *pl, object *exit_ob)
void send_background_music(player *pl, const char *music)
void free_all_treasures(void)
static void enter_random_template_map(object *pl, object *exit_ob)
void get_rangevector(object *op1, const object *op2, rv_vector *retval, int flags)
void dump_object(object *op, StringBuffer *sb)
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
int execute_global_event(int eventcode,...)
static void process_players1(void)
static char * unclean_path(const char *src, char *newpath, int size)
void check_score(object *op, int quiet)
void obsolete_parties(void)
#define MSG_TYPE_ADMIN_VERSION
#define FREE_AND_CLEAR_STR(xyz)
void remove_all_pets(void)
void process_events(void)
void tick_the_clock(void)
int process_object(object *op)
void init(int argc, char **argv)
#define QUERY_FLAG(xyz, p)
void cleanupPlugins(void)
int server_main(int argc, char **argv)
void emergency_save(int flag)
void clean_tmp_files(void)
object * get_object(void)
void free_all_images(void)
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
void free_all_archs(void)
int handle_newcs_player(object *op)
#define MSG_TYPE_ADMIN_DM
static const flag_definition flags[]
char * crypt_string(char *str, char *salt)
void animate_object(object *op, int dir)
int save_map(mapstruct *m, int flag)
void free_all_recipes(void)
int snprintf(char *dest, int max, const char *format,...)
void replace(const char *src, const char *key, const char *replacement, char *result, size_t resultsize)
int set_random_map_variable(RMParms *rp, const char *buf)
int check_password(char *typed, char *crypted)
#define PORTAL_DESTINATION_NAME
#define MAP_PLAYER_UNIQUE
static void enter_map(object *op, mapstruct *newmap, int x, int y)
struct regiondef * region
int out_of_map(mapstruct *m, int x, int y)
void free_all_readable(void)
void cftimer_process_timers(void)
void write_book_archive(void)
void update_ob_speed(object *op)
sstring add_string(const char *str)
EXTERN player * first_player
int find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
void free_style_maps(void)
void LOG(LogLevel logLevel, const char *format,...)
#define was_destroyed(op, old_tag)
void query_name(const object *op, char *buf, size_t size)
void free_object(object *ob)
void set_map_timeout(mapstruct *oldmap)
#define MSG_TYPE_ADMIN_LOGIN
void create_template_pathname(const char *name, char *buf, size_t size)
void free_all_object_data(void)
void clean_tmp_map(mapstruct *m)
player * find_player_partial_name(const char *plname)
EXTERN mapstruct * first_map
FILE * open_and_uncompress(const char *name, int flag, int *compressed)
void start_info(object *op)
int hit_player(object *op, int dam, object *hitter, uint32 type, int full_hit)
char * stringbuffer_finish(StringBuffer *sb)
int ob_blocked(const object *ob, mapstruct *m, sint16 x, sint16 y)
static void process_players2(void)