version 1.105 | | version 1.106 |
---|
| | |
/* | | /* |
* static char *rcsid_main_c = | | * static char *rcsid_main_c = |
* "$Id: main.c,v 1.105 2005/12/05 23:34:04 akirschbaum Exp $"; | | * "$Id: main.c,v 1.106 2005/12/08 21:50:19 akirschbaum Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
#include <../random_maps/random_map.h> | | #include <../random_maps/random_map.h> |
#include <../random_maps/rproto.h> | | #include <../random_maps/rproto.h> |
| | #include "path.h" |
| | |
static char days[7][4] = { | | static char days[7][4] = { |
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; | | "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; |
| | |
free_object(tmp); | | free_object(tmp); |
} | | } |
| | |
| | |
static const char *normalize_path (const char *src, const char *dst) { | | |
char *p, *q; | | |
char buf[HUGE_BUF]; | | |
static char path[HUGE_BUF]; | | |
| | |
/* LOG(llevDebug,"path before normalization >%s<>%s<\n", src, dst); */ | | |
| | |
if (*dst == '/') { | | |
strcpy (buf, dst); | | |
| | |
} else { | | |
strcpy (buf, src); | | |
if ((p = strrchr (buf, '/'))) | | |
p[1] = '\0'; | | |
else | | |
strcpy (buf, "/"); | | |
strcat (buf, dst); | | |
} | | |
| | |
q = p = buf; | | |
while ((q = strstr (q, "//"))) | | |
p = ++q; | | |
| | |
*path = '\0'; | | |
q = path; | | |
p = strtok (p, "/"); | | |
while (p) { | | |
if (!strcmp (p, "..")) { | | |
q = strrchr (path, '/'); | | |
if (q) | | |
*q = '\0'; | | |
else { | | |
*path = '\0'; | | |
LOG (llevError, "Illegal path.\n"); | | |
} | | |
} else { | | |
strcat (path, "/"); | | |
strcat (path, p); | | |
} | | |
p = strtok (NULL, "/"); | | |
} | | |
/* LOG(llevDebug,"path after normalization >%s<\n", path); */ | | |
| | |
return (path); | | |
} | | |
| | |
/* All this really is is a glorified remove_object that also updates | | /* All this really is is a glorified remove_object that also updates |
* the counts on the map if needed. | | * the counts on the map if needed. |
*/ | | */ |
| | |
| | |
newmap = ready_map_name(apartment, MAP_PLAYER_UNIQUE); | | newmap = ready_map_name(apartment, MAP_PLAYER_UNIQUE); |
if (!newmap) { | | if (!newmap) { |
newmap = load_original_map(create_pathname(normalize_path(reldir, EXIT_PATH(exit_ob))), MAP_PLAYER_UNIQUE); | | newmap = load_original_map(create_pathname(path_combine_and_normalize(reldir, EXIT_PATH(exit_ob))), MAP_PLAYER_UNIQUE); |
if (newmap) fix_auto_apply(newmap); | | if (newmap) fix_auto_apply(newmap); |
} | | } |
} | | } |
| | |
*/ | | */ |
sprintf(apartment, "%s/%s/%s/%s", settings.localdir, | | sprintf(apartment, "%s/%s/%s/%s", settings.localdir, |
settings.playerdir, op->name, | | settings.playerdir, op->name, |
clean_path(normalize_path(exit_ob->map->path, EXIT_PATH(exit_ob)))); | | clean_path(path_combine_and_normalize(exit_ob->map->path, EXIT_PATH(exit_ob)))); |
newmap = ready_map_name(apartment, MAP_PLAYER_UNIQUE); | | newmap = ready_map_name(apartment, MAP_PLAYER_UNIQUE); |
if (!newmap) { | | if (!newmap) { |
newmap = ready_map_name(normalize_path(exit_ob->map->path, EXIT_PATH(exit_ob)), 0); | | newmap = ready_map_name(path_combine_and_normalize(exit_ob->map->path, EXIT_PATH(exit_ob)), 0); |
if (newmap) fix_auto_apply(newmap); | | if (newmap) fix_auto_apply(newmap); |
} | | } |
} | | } |
| | |
*/ | | */ |
mapstruct *newmap; | | mapstruct *newmap; |
if (exit_ob->map) { | | if (exit_ob->map) { |
newmap = ready_map_name(normalize_path(exit_ob->map->path, EXIT_PATH(exit_ob)), 0); | | newmap = ready_map_name(path_combine_and_normalize(exit_ob->map->path, EXIT_PATH(exit_ob)), 0); |
/* Random map was previously generated, but is no longer about. Lets generate a new | | /* Random map was previously generated, but is no longer about. Lets generate a new |
* map. | | * map. |
*/ | | */ |
| | |
free_object(tmp); | | free_object(tmp); |
} | | } |
| | |
strcpy(op->contr->savebed_map, normalize_path(exit_ob->map->path, EXIT_PATH(exit_ob))); | | strcpy(op->contr->savebed_map, path_combine_and_normalize(exit_ob->map->path, EXIT_PATH(exit_ob))); |
op->contr->bed_x = EXIT_X(exit_ob), op->contr->bed_y = EXIT_Y(exit_ob); | | op->contr->bed_x = EXIT_X(exit_ob), op->contr->bed_y = EXIT_Y(exit_ob); |
save_player(op, 1); | | save_player(op, 1); |
/* LOG(llevDebug,"enter_exit: Taking damned exit %s to (%d,%d) on map %s\n", | | /* LOG(llevDebug,"enter_exit: Taking damned exit %s to (%d,%d) on map %s\n", |
* exit_ob->name?exit_ob->name:"(none)", exit_ob->x, exit_ob->y, | | * exit_ob->name?exit_ob->name:"(none)", exit_ob->x, exit_ob->y, |
* normalize_path(exit_ob->map->path, EXIT_PATH(exit_ob))); */ | | * path_combine_and_normalize(exit_ob->map->path, EXIT_PATH(exit_ob))); */ |
} | | } |
| | |
enter_map(op, newmap, x, y); | | enter_map(op, newmap, x, y); |