diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-02 21:53:11 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-02 22:08:27 +0200 |
commit | 6eb6d9b8aa702f333d480158265cc0c3a469a0c9 (patch) | |
tree | a8d164a36e347a73413997600d2d3e866de5a3b8 | |
parent | 9bbfe24fccd16a17c89f9222ded38aa5a220c4f6 (diff) |
Refactor: Clean up process_dungeon_file()
-rw-r--r-- | lib/core/dungeon.lua | 16 | ||||
-rw-r--r-- | lib/mods/theme/core/dungeon.lua | 16 | ||||
-rw-r--r-- | src/externs.h | 8 | ||||
-rw-r--r-- | src/generate.c | 4 | ||||
-rw-r--r-- | src/init1.c | 49 | ||||
-rw-r--r-- | src/init2.c | 2 | ||||
-rw-r--r-- | src/loadsave.c | 8 | ||||
-rw-r--r-- | src/lua_bind.c | 19 | ||||
-rw-r--r-- | src/q_betwen.c | 4 | ||||
-rw-r--r-- | src/q_dragons.c | 2 | ||||
-rw-r--r-- | src/q_evil.c | 2 | ||||
-rw-r--r-- | src/q_haunted.c | 2 | ||||
-rw-r--r-- | src/q_invas.c | 4 | ||||
-rw-r--r-- | src/q_nirna.c | 4 | ||||
-rw-r--r-- | src/q_rand.c | 11 | ||||
-rw-r--r-- | src/q_spider.c | 4 | ||||
-rw-r--r-- | src/q_thief.c | 2 | ||||
-rw-r--r-- | src/q_thrain.c | 11 | ||||
-rw-r--r-- | src/q_troll.c | 8 | ||||
-rw-r--r-- | src/q_wight.c | 4 | ||||
-rw-r--r-- | src/q_wolves.c | 2 | ||||
-rw-r--r-- | src/util.c | 101 | ||||
-rw-r--r-- | src/util.pkg | 25 | ||||
-rw-r--r-- | src/wild.c | 6 |
24 files changed, 53 insertions, 261 deletions
diff --git a/lib/core/dungeon.lua b/lib/core/dungeon.lua index fc8364bd..d91d785b 100644 --- a/lib/core/dungeon.lua +++ b/lib/core/dungeon.lua @@ -46,22 +46,6 @@ function rotate_dir(dir, mov) return dir end --- Check if the map is a filename or directly a map -function load_map(map, y, x) - if strsub(map, 1, 5) == "#!map" then - %load_map(TRUE, map, y, x) - else - %load_map(FALSE, map, y, x) - end -end -function get_map_size(map) - if strsub(map, 1, 5) == "#!map" then - return %get_map_size(TRUE, map) - else - return %get_map_size(FALSE, map) - end -end - -- Place a trap for a specific level function place_trap(y, x, level) local old_dun = dun_level diff --git a/lib/mods/theme/core/dungeon.lua b/lib/mods/theme/core/dungeon.lua index fc8364bd..d91d785b 100644 --- a/lib/mods/theme/core/dungeon.lua +++ b/lib/mods/theme/core/dungeon.lua @@ -46,22 +46,6 @@ function rotate_dir(dir, mov) return dir end --- Check if the map is a filename or directly a map -function load_map(map, y, x) - if strsub(map, 1, 5) == "#!map" then - %load_map(TRUE, map, y, x) - else - %load_map(FALSE, map, y, x) - end -end -function get_map_size(map) - if strsub(map, 1, 5) == "#!map" then - return %get_map_size(TRUE, map) - else - return %get_map_size(FALSE, map) - end -end - -- Place a trap for a specific level function place_trap(y, x, level) local old_dun = dun_level diff --git a/src/externs.h b/src/externs.h index 49f848fd..f7f97b79 100644 --- a/src/externs.h +++ b/src/externs.h @@ -957,8 +957,7 @@ extern errr init_ba_info_txt(FILE *fp, char *buf); extern errr init_st_info_txt(FILE *fp, char *buf); extern errr init_ow_info_txt(FILE *fp, char *buf); extern errr init_wf_info_txt(FILE *fp, char *buf); -extern bool_ process_dungeon_file_full; -extern errr process_dungeon_file(cptr full_text, cptr name, int *yval, int *xval, int ymax, int xmax, bool_ init); +extern errr process_dungeon_file(cptr name, int *yval, int *xval, int ymax, int xmax, bool_ init, bool_ full); /* init2.c */ extern void init_corruptions(s16b new_size); @@ -1436,7 +1435,6 @@ extern errr path_parse(char *buf, int max, cptr file); extern errr path_temp(char *buf, int max); extern errr path_build(char *buf, int max, cptr path, cptr file); extern FILE *my_fopen(cptr file, cptr mode); -extern errr my_str_fgets(cptr full_text, char *buf, huge n); extern errr my_fgets(FILE *fff, char *buf, huge n); extern errr my_fputs(FILE *fff, cptr buf, huge n); extern errr my_fclose(FILE *fff); @@ -1808,8 +1806,8 @@ extern cave_type *lua_get_cave(int y, int x); extern void set_target(int y, int x); extern void get_target(int dir, int *y, int *x); -extern void get_map_size(bool_ full_text, char *name, int *ysize, int *xsize); -extern void load_map(bool_ full_text, char *name, int *y, int *x); +extern void get_map_size(char *name, int *ysize, int *xsize); +extern void load_map(char *name, int *y, int *x); extern bool_ alloc_room(int by0, int bx0, int ysize, int xsize, int *y1, int *x1, int *y2, int *x2); extern void lua_print_hook(cptr str); diff --git a/src/generate.c b/src/generate.c index ab74dffe..6d83c321 100644 --- a/src/generate.c +++ b/src/generate.c @@ -8291,9 +8291,7 @@ bool_ build_special_level(void) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON | INIT_POSITION; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, buf, &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file(buf, &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); special_lvl[level][dungeon_type] = REGEN_HACK; generate_special_feeling = TRUE; diff --git a/src/init1.c b/src/init1.c index 7446b189..9715831d 100644 --- a/src/init1.c +++ b/src/init1.c @@ -10626,8 +10626,7 @@ static dungeon_grid letter[255]; /* * Parse a sub-file of the "extra info" */ -bool_ process_dungeon_file_full = FALSE; -static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalstart, int ymax, int xmax) +static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalstart, int ymax, int xmax, bool_ full) { int i; @@ -10651,7 +10650,7 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst if (buf[0] == '%') { /* Attempt to Process the given file */ - return (process_dungeon_file(NULL, buf + 2, yval, xval, ymax, xmax, FALSE)); + return (process_dungeon_file(buf + 2, yval, xval, ymax, xmax, FALSE, full)); } /* Process "N:<sleep>" */ @@ -11089,7 +11088,7 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst c_ptr->special = letter[idx].special; } } - if ((process_dungeon_file_full) && (*xval < x)) *xval = x; + if (full && (*xval < x)) *xval = x; (*yval)++; return (0); @@ -11703,7 +11702,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp) } -errr process_dungeon_file(cptr full_text, cptr name, int *yval, int *xval, int ymax, int xmax, bool_ init) +errr process_dungeon_file(cptr name, int *yval, int *xval, int ymax, int xmax, bool_ init, bool_ full) { FILE *fp = 0; @@ -11731,30 +11730,21 @@ errr process_dungeon_file(cptr full_text, cptr name, int *yval, int *xval, int y } } - /* We dont need any files for full_text */ - if (full_text) - { - /* Init */ - my_str_fgets(full_text, NULL, 0); - } - else - { - /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_EDIT, name); + /* Build the filename */ + path_build(buf, 1024, ANGBAND_DIR_EDIT, name); - /* Open the file */ - fp = my_fopen(buf, "r"); + /* Open the file */ + fp = my_fopen(buf, "r"); - /* No such file */ - if (!fp) - { - msg_format("Cannot find file %s at %s", name, buf); - return ( -1); - } + /* No such file */ + if (!fp) + { + msg_format("Cannot find file %s at %s", name, buf); + return ( -1); } /* Process the file */ - while (0 == ((full_text) ? my_str_fgets(full_text, buf, 1024) : my_fgets(fp, buf, 1024))) + while (0 == my_fgets(fp, buf, 1024)) { /* Count lines */ num++; @@ -11798,7 +11788,7 @@ errr process_dungeon_file(cptr full_text, cptr name, int *yval, int *xval, int y if (buf[0] == '%') { /* Process that file if allowed */ - (void)process_dungeon_file(NULL, buf + 2, yval, xval, ymax, xmax, FALSE); + (void)process_dungeon_file(buf + 2, yval, xval, ymax, xmax, FALSE, full); /* Continue */ continue; @@ -11806,7 +11796,7 @@ errr process_dungeon_file(cptr full_text, cptr name, int *yval, int *xval, int y /* Process the line */ - err = process_dungeon_file_aux(buf, yval, xval, xmin, ymax, xmax); + err = process_dungeon_file_aux(buf, yval, xval, xmin, ymax, xmax, full); /* Oops */ if (err) break; @@ -11821,11 +11811,8 @@ errr process_dungeon_file(cptr full_text, cptr name, int *yval, int *xval, int y msg_format("Parsing '%s'", buf); } - if (!full_text) - { - /* Close the file */ - my_fclose(fp); - } + /* Close the file */ + my_fclose(fp); /* Result */ return (err); diff --git a/src/init2.c b/src/init2.c index b6156727..5239426c 100644 --- a/src/init2.c +++ b/src/init2.c @@ -2013,7 +2013,7 @@ static errr init_misc(void) process_hooks(HOOK_INIT_GAME, "(s)", "begin"); /* Initialise the values */ - process_dungeon_file(NULL, "misc.txt", &ystart, &xstart, 0, 0, TRUE); + process_dungeon_file("misc.txt", &ystart, &xstart, 0, 0, TRUE, FALSE); /* Init the spell effects */ for (i = 0; i < MAX_EFFECTS; i++) diff --git a/src/loadsave.c b/src/loadsave.c index 75252e1a..6799a502 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -2190,15 +2190,15 @@ static bool_ do_dungeon(int flag, bool_ no_companions) int xstart = 0; int ystart = 0; /* Init the wilderness */ - process_dungeon_file(NULL, "w_info.txt", &ystart, &xstart, cur_hgt, cur_wid, - TRUE); + process_dungeon_file("w_info.txt", &ystart, &xstart, cur_hgt, cur_wid, + TRUE, FALSE); /* Init the town */ xstart = 0; ystart = 0; init_flags = 0; - process_dungeon_file(NULL, "t_info.txt", &ystart, &xstart, cur_hgt, cur_wid, - TRUE); + process_dungeon_file("t_info.txt", &ystart, &xstart, cur_hgt, cur_wid, + TRUE, FALSE); } do_grid(flag); diff --git a/src/lua_bind.c b/src/lua_bind.c index c8e861a9..67b75ee6 100644 --- a/src/lua_bind.c +++ b/src/lua_bind.c @@ -343,21 +343,15 @@ void get_target(int dir, int *y, int *x) } /* Level gen */ -void get_map_size(bool_ full_text, char *name, int *ysize, int *xsize) +void get_map_size(char *name, int *ysize, int *xsize) { *xsize = 0; *ysize = 0; init_flags = INIT_GET_SIZE; - process_dungeon_file_full = TRUE; - if (full_text) - process_dungeon_file(name, "embeded map script", ysize, xsize, cur_hgt, cur_wid, TRUE); - else - process_dungeon_file(NULL, name, ysize, xsize, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; - + process_dungeon_file(name, ysize, xsize, cur_hgt, cur_wid, TRUE, TRUE); } -void load_map(bool_ full_text, char *name, int *y, int *x) +void load_map(char *name, int *y, int *x) { /* Set the correct monster hook */ set_mon_num_hook(); @@ -366,12 +360,7 @@ void load_map(bool_ full_text, char *name, int *y, int *x) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - if (full_text) - process_dungeon_file(name, "embeded map script", y, x, cur_hgt, cur_wid, TRUE); - else - process_dungeon_file(NULL, name, y, x, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file(name, y, x, cur_hgt, cur_wid, TRUE, TRUE); } bool_ alloc_room(int by0, int bx0, int ysize, int xsize, int *y1, int *x1, int *y2, int *x2) diff --git a/src/q_betwen.c b/src/q_betwen.c index da9b0db4..e6452dd9 100644 --- a/src/q_betwen.c +++ b/src/q_betwen.c @@ -74,9 +74,7 @@ bool_ quest_between_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "between.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("between.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); /* Otherwise instadeath */ energy_use = 0; diff --git a/src/q_dragons.c b/src/q_dragons.c index 222e4742..025e8ecd 100644 --- a/src/q_dragons.c +++ b/src/q_dragons.c @@ -31,7 +31,7 @@ bool_ quest_dragons_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file(NULL, "dragons.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("dragons.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); dungeon_flags2 |= DF2_NO_GENO; /* Place some columns */ diff --git a/src/q_evil.c b/src/q_evil.c index 33a01d29..a143f65c 100644 --- a/src/q_evil.c +++ b/src/q_evil.c @@ -31,7 +31,7 @@ bool_ quest_evil_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file(NULL, "evil.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("evil.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); dungeon_flags2 |= DF2_NO_GENO; /* Place some random balrogs */ diff --git a/src/q_haunted.c b/src/q_haunted.c index d89698fe..db8992bc 100644 --- a/src/q_haunted.c +++ b/src/q_haunted.c @@ -31,7 +31,7 @@ bool_ quest_haunted_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file(NULL, "haunted.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("haunted.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); dungeon_flags2 |= DF2_NO_GENO; /* Place some ghosts */ diff --git a/src/q_invas.c b/src/q_invas.c index 634bfe97..59c71d62 100644 --- a/src/q_invas.c +++ b/src/q_invas.c @@ -26,9 +26,7 @@ bool_ quest_invasion_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "maeglin.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("maeglin.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = 3; x < xstart; x++) for (y = 3; y < ystart; y++) diff --git a/src/q_nirna.c b/src/q_nirna.c index 1fbd05db..be856d31 100644 --- a/src/q_nirna.c +++ b/src/q_nirna.c @@ -26,9 +26,7 @@ bool_ quest_nirnaeth_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "nirnaeth.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("nirnaeth.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); /* Count the number of monsters */ cquest.data[0] = 0; diff --git a/src/q_rand.c b/src/q_rand.c index 50617bb8..5a3b3ab2 100644 --- a/src/q_rand.c +++ b/src/q_rand.c @@ -316,12 +316,7 @@ bool_ quest_random_gen_hook(char *fmt) bx0 = get_next_arg(fmt); /* Pick a room size */ - xsize = 0; - ysize = 0; - init_flags = INIT_GET_SIZE; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, format("qrand%d.map", random_quests[dun_level].type), &ysize, &xsize, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + get_map_size(format("qrand%d.map", random_quests[dun_level].type), &ysize, &xsize); /* Try to allocate space for room. If fails, exit */ if (!room_alloc(xsize + 2, ysize + 2, FALSE, by0, bx0, &xval, &yval)) return FALSE; @@ -353,9 +348,7 @@ bool_ quest_random_gen_hook(char *fmt) xstart = x1; ystart = y1; init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, format("qrand%d.map", random_quests[dun_level].type), &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file(format("qrand%d.map", random_quests[dun_level].type), &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = x1; x < xstart; x++) for (y = y1; y < ystart; y++) diff --git a/src/q_spider.c b/src/q_spider.c index da8b7af6..a739535b 100644 --- a/src/q_spider.c +++ b/src/q_spider.c @@ -26,9 +26,7 @@ bool_ quest_spider_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "spiders.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("spiders.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); return TRUE; } diff --git a/src/q_thief.c b/src/q_thief.c index f91b4ec5..6b033f8c 100644 --- a/src/q_thief.c +++ b/src/q_thief.c @@ -32,7 +32,7 @@ bool_ quest_thieves_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file(NULL, "thieves.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("thieves.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); dungeon_flags2 |= DF2_NO_GENO; /* Rip the inventory from the player */ diff --git a/src/q_thrain.c b/src/q_thrain.c index 8b2df5a4..b2b1be9f 100644 --- a/src/q_thrain.c +++ b/src/q_thrain.c @@ -104,12 +104,7 @@ bool_ quest_thrain_gen_hook(char *fmt) bx0 = get_next_arg(fmt); /* Pick a room size */ - xsize = 0; - ysize = 0; - init_flags = INIT_GET_SIZE; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "thrain.map", &ysize, &xsize, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + get_map_size("thrain.map", &ysize, &xsize); /* Try to allocate space for room. If fails, exit */ if (!room_alloc(xsize + 2, ysize + 2, FALSE, by0, bx0, &xval, &yval)) return FALSE; @@ -141,9 +136,7 @@ bool_ quest_thrain_gen_hook(char *fmt) xstart = x1; ystart = y1; init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "thrain.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("thrain.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = x1; x < xstart; x++) for (y = y1; y < ystart; y++) diff --git a/src/q_troll.c b/src/q_troll.c index 4a193079..c314d2a7 100644 --- a/src/q_troll.c +++ b/src/q_troll.c @@ -26,9 +26,7 @@ bool_ quest_troll_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "trolls.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("trolls.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = 3; x < xstart; x++) for (y = 3; y < ystart; y++) @@ -140,9 +138,7 @@ bool_ quest_troll_death_hook(char *fmt) } init_flags = INIT_GET_SIZE; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "trolls.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("trolls.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); if (cquest.data[0]) return FALSE; diff --git a/src/q_wight.c b/src/q_wight.c index c7e3d667..3f6b2c34 100644 --- a/src/q_wight.c +++ b/src/q_wight.c @@ -26,9 +26,7 @@ bool_ quest_wight_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file_full = TRUE; - process_dungeon_file(NULL, "wights.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); - process_dungeon_file_full = FALSE; + process_dungeon_file("wights.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = 3; x < xstart; x++) for (y = 3; y < ystart; y++) diff --git a/src/q_wolves.c b/src/q_wolves.c index a4537f0e..2ec14cc2 100644 --- a/src/q_wolves.c +++ b/src/q_wolves.c @@ -31,7 +31,7 @@ bool_ quest_wolves_gen_hook(char *fmt) get_mon_num_prep(); init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file(NULL, "wolves.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("wolves.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); dungeon_flags2 |= DF2_NO_GENO; /* Place some random wolves */ @@ -383,107 +383,6 @@ errr my_fclose(FILE *fff) /* -* Like "fgets()" but for strings -* -* Process tabs, strip internal non-printables -*/ -errr my_str_fgets(cptr full_text, char *buf, huge n) -{ - static huge last_read = 0; - static huge full_size; - huge i = 0; - - char *s; - - char tmp[1024]; - - /* Initialize */ - if (!buf) - { - last_read = 0; - full_size = strlen(full_text); - return 0; - } - - /* The end! */ - if (last_read >= full_size) - { - return 1; - } - - while (last_read < full_size) - { - char c = full_text[last_read++]; - - tmp[i++] = c; - - /* Dont overflow */ - if (i >= 1024) - { - /* Nothing */ - buf[0] = '\0'; - - /* Failure */ - return (1); - } - - if ((c == '\n') || (c == '\r')) - { - break; - } - } - - tmp[i++] = '\n'; - tmp[i++] = '\0'; - - /* We need it again */ - i = 0; - - /* Convert weirdness */ - for (s = tmp; *s; s++) - { - /* Handle newline */ - if (*s == '\n') - { - /* Terminate */ - buf[i] = '\0'; - - /* Success */ - return (0); - } - - /* Handle tabs */ - else if (*s == '\t') - { - /* Hack -- require room */ - if (i + 8 >= n) break; - - /* Append a space */ - buf[i++] = ' '; - - /* Append some more spaces */ - while (!(i % 8)) buf[i++] = ' '; - } - - /* Handle printables */ - else if (isprint(*s)) - { - /* Copy */ - buf[i++] = *s; - - /* Check length */ - if (i >= n) break; - } - } - - /* Nothing */ - buf[0] = '\0'; - - /* Failure */ - return (1); -} - -/* * Hack -- replacement for "fgets()" * * Read a string, without a newline, to a file diff --git a/src/util.pkg b/src/util.pkg index b2981681..39f70b40 100644 --- a/src/util.pkg +++ b/src/util.pkg @@ -2345,29 +2345,10 @@ extern s16b ddy_ddd[9]; /* Gen stuff */ -/** @fn get_map_size(bool full_text, char *name, int *ysize = 0, int *xsize = 0) - * @brief Return the size of the map in file "name".\n - * @param full_text Boolean \n if TRUE, "name" contains the map itself, - * otherwise "name" is the name of the map file. - * @brief Name is a map? - * @param *name String \n the map itself, or the name of the map file. - * @brief Map - * @param *ysize Number - * @brief Maximum y-coordinate - * @param *xsize Number - * @brief Maximum x-coordinate - * @return *ysize Number \n The maximum y-coordinate of the map. - * @return *xsize Number \n The maximum x-coordinate of the map. - * @note (see file lua_bind.c, init1.c) - */ -extern void get_map_size(bool full_text, char *name, int *ysize = 0, int *xsize = 0); -/** @fn load_map(bool full_text, char *name, int *y = 2, int *x = 2) +/** @fn load_map(char *name, int *y = 2, int *x = 2) * @brief Load the map in file "name".\n - * @param full_text Boolean \n if TRUE, "name" contains the map itself, - * otherwise "name" is the name of the map file. - * @brief Name is a map? - * @param *name String \n the map itself, or the name of the map file. + * @param *name String \n the name of the map file. * @brief Map * @param *y Number * @brief Maximum y-coordinate @@ -2379,7 +2360,7 @@ extern void get_map_size(bool full_text, char *name, int *ysize = 0, int *xsize * The map is loaded and the player is placed at the starting position. * @note (see file lua_bind.c) */ -extern void load_map(bool full_text, char *name, int *y = 2, int *x = 2); +extern void load_map(char *name, int *y = 2, int *x = 2); /** @fn alloc_room(int by0, int bx0, int ysize, int xsize, int *y1 = 0, int *x1 = 0, int *y2 = 0, int *x2 = 0) * @brief Allocate the space needed by a room in the room_map array.\n @@ -224,7 +224,7 @@ int generate_area(int y, int x, bool_ border, bool_ corner, bool_ refresh) /* Initialize the town */ init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file(NULL, "t_info.txt", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("t_info.txt", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); } else { @@ -350,7 +350,7 @@ void wilderness_gen(int refresh) cave_type *c_ptr; /* Init the wilderness */ - process_dungeon_file(NULL, "w_info.txt", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("w_info.txt", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); x = p_ptr->wilderness_x; y = p_ptr->wilderness_y; @@ -554,7 +554,7 @@ void wilderness_gen_small() } /* Init the wilderness */ - process_dungeon_file(NULL, "w_info.txt", &ystart, &xstart, cur_hgt, cur_wid, TRUE); + process_dungeon_file("w_info.txt", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); /* Fill the map */ for (i = 0; i < max_wild_x; i++) |