diff options
-rw-r--r-- | src/externs.h | 3 | ||||
-rw-r--r-- | src/files.cc | 20 | ||||
-rw-r--r-- | src/init1.cc | 43 | ||||
-rw-r--r-- | src/init2.cc | 16 | ||||
-rw-r--r-- | src/object1.cc | 4 | ||||
-rw-r--r-- | src/types.h | 5 | ||||
-rw-r--r-- | src/variable.cc | 3 | ||||
-rw-r--r-- | src/xtra1.cc | 8 | ||||
-rw-r--r-- | src/xtra2.cc | 4 |
9 files changed, 36 insertions, 70 deletions
diff --git a/src/externs.h b/src/externs.h index bea4a842..0c3735a4 100644 --- a/src/externs.h +++ b/src/externs.h @@ -332,10 +332,7 @@ extern meta_class_type *meta_class_info; extern player_race *race_info; extern player_race_mod *race_mod_info; extern trap_type *t_info; -extern header *wf_head; extern wilderness_type_info *wf_info; -extern char *wf_name; -extern char *wf_text; extern int wildc2i[256]; extern header *st_head; extern store_info_type *st_info; diff --git a/src/files.cc b/src/files.cc index 29b216e4..b5c4da8a 100644 --- a/src/files.cc +++ b/src/files.cc @@ -2293,11 +2293,11 @@ cptr describe_player_location() } else if (wf_info[feat].terrain_idx == TERRAIN_TOWN) { - sprintf(desc, "in the town of %s", wf_info[feat].name + wf_name); + sprintf(desc, "in the town of %s", wf_info[feat].name); } else if (wf_info[feat].entrance) { - sprintf(desc, "near %s", wf_info[feat].name + wf_name); + sprintf(desc, "near %s", wf_info[feat].name); } else { @@ -2335,10 +2335,14 @@ cptr describe_player_location() } if (!landmark) - sprintf(desc, "in %s", wf_info[feat].text + wf_text); + { + sprintf(desc, "in %s", wf_info[feat].text); + } else if (pwx == lwx && pwy == lwy) + { /* Paranoia; this should have been caught above */ - sprintf(desc, "near %s", wf_info[feat].name + wf_name); + sprintf(desc, "near %s", wf_info[feat].name); + } else { /* @@ -2360,8 +2364,10 @@ cptr describe_player_location() if (dx * 81 < dy * 31) ew = ""; sprintf(desc, "in %s %s%s of %s", - wf_info[feat].text + wf_text, ns, ew, - wf_info[landmark].name + wf_name); + wf_info[feat].text, + ns, + ew, + wf_info[landmark].name); } } @@ -2469,7 +2475,7 @@ void file_character_print_store(FILE *fff, wilderness_type_info *place, int stor if (st_ptr->stock_num) { /* Header with name of the town */ - fprintf(fff, " [%s Inventory - %s]\n\n", st_name + st_info[store].name, wf_name + place->name); + fprintf(fff, " [%s Inventory - %s]\n\n", st_name + st_info[store].name, place->name); /* Dump all available items */ for (i = 0; i < st_ptr->stock_num; i++) diff --git a/src/init1.cc b/src/init1.cc index b4180a88..40fa8605 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -10020,18 +10020,12 @@ errr init_wf_info_txt(FILE *fp, char *buf) /* Current entry */ wilderness_type_info *wf_ptr = NULL; - /* Just before the first record */ error_idx = -1; /* Just before the first line */ error_line = -1; - - /* Start the "fake" stuff */ - wf_head->name_size = 0; - wf_head->text_size = 0; - /* Parse */ fp_stack_init(fp); while (0 == my_fgets_dostack(buf, 1024)) @@ -10093,7 +10087,7 @@ errr init_wf_info_txt(FILE *fp, char *buf) if (i < error_idx) return (4); /* Verify information */ - if (i >= wf_head->info_num) return (2); + if (i >= max_wf_idx) return (2); /* Save the index */ error_idx = i; @@ -10101,17 +10095,9 @@ errr init_wf_info_txt(FILE *fp, char *buf) /* Point at the "info" */ wf_ptr = &wf_info[i]; - /* Hack -- Verify space */ - if (wf_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7); - - /* Advance and Save the name index */ - if (!wf_ptr->name) wf_ptr->name = ++wf_head->name_size; - - /* Append chars to the name */ - strcpy(wf_name + wf_head->name_size, s); - - /* Advance the index */ - wf_head->name_size += strlen(s); + /* Copy the name */ + assert(!wf_ptr->name); + wf_ptr->name = my_strdup(s); /* Next... */ continue; @@ -10120,23 +10106,15 @@ errr init_wf_info_txt(FILE *fp, char *buf) /* There better be a current wf_ptr */ if (!wf_ptr) return (3); - /* Process 'D' for "Description */ + /* Process 'D' for "Description (one line only) */ if (buf[0] == 'D') { /* Acquire the text */ s = buf + 2; - /* Hack -- Verify space */ - if (wf_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7); - - /* Advance and Save the text index */ - if (!wf_ptr->text) wf_ptr->text = ++wf_head->text_size; - - /* Append chars to the name */ - strcpy(wf_text + wf_head->text_size, s); - - /* Advance the index */ - wf_head->text_size += strlen(s); + /* Copy description */ + assert(!wf_ptr->text); + wf_ptr->text = my_strdup(s); /* Next... */ continue; @@ -10222,11 +10200,6 @@ errr init_wf_info_txt(FILE *fp, char *buf) return (6); } - - /* Complete the "name" and "text" sizes */ - ++wf_head->name_size; - ++wf_head->text_size; - /* No version yet */ if (!okay) return (2); diff --git a/src/init2.cc b/src/init2.cc index c50cd428..52120950 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -1220,20 +1220,8 @@ static errr init_wf_info(void) /* General buffer */ char buf[1024]; - - /*** Make the header ***/ - wf_head = make_header(max_wf_idx); - - - /*** Make the fake arrays ***/ - - /* Allocate the "r_info" array */ - wf_info = make_array<wilderness_type_info>(wf_head->info_num); - - /* Hack -- make "fake" arrays */ - wf_name = make_array<char>(FAKE_NAME_SIZE); - wf_text = make_array<char>(FAKE_TEXT_SIZE); - + /* Allocate the "wf_info" array */ + wf_info = make_array<wilderness_type_info>(max_wf_idx); /*** Load the ascii template file ***/ diff --git a/src/object1.cc b/src/object1.cc index 2dae8303..3bf48663 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -2777,11 +2777,11 @@ static cptr object_out_desc_where_found(s16b level, s16b dungeon) } else if (wf_info[level].terrain_idx == TERRAIN_TOWN) { - sprintf(str, "in the town of %s", wf_info[level].name + wf_name); + sprintf(str, "in the town of %s", wf_info[level].name); } else { - sprintf(str, "in %s", wf_info[level].text + wf_text); + sprintf(str, "in %s", wf_info[level].text); } } else diff --git a/src/types.h b/src/types.h index 2e9602dc..b5248c21 100644 --- a/src/types.h +++ b/src/types.h @@ -1805,8 +1805,9 @@ typedef struct wilderness_type_info wilderness_type_info; struct wilderness_type_info { - u32b name; /* Name (offset) */ - u32b text; /* Text (offset) */ + const char *name; /* Name */ + const char *text; /* Text */ + u16b entrance; /* Which town is there(<1000 i's a town, >=1000 it a dungeon) */ s32b wild_x; /* Map coordinates (backed out while parsing map) */ s32b wild_y; diff --git a/src/variable.cc b/src/variable.cc index 3689bc5c..b0ad10ea 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -679,10 +679,7 @@ meta_class_type *meta_class_info; /* * The wilderness features arrays */ -header *wf_head; wilderness_type_info *wf_info; -char *wf_name; -char *wf_text; int wildc2i[256]; /* diff --git a/src/xtra1.cc b/src/xtra1.cc index eb70787d..718d2569 100644 --- a/src/xtra1.cc +++ b/src/xtra1.cc @@ -515,10 +515,14 @@ static void prt_depth(int row, int col) } else if (!dun_level) { - if (wf_info[wild_map[p_ptr->wilderness_y][p_ptr->wilderness_x].feat].name + wf_name) - strcpy(depths, wf_info[wild_map[p_ptr->wilderness_y][p_ptr->wilderness_x].feat].name + wf_name); + if (wf_info[wild_map[p_ptr->wilderness_y][p_ptr->wilderness_x].feat].name) + { + strcpy(depths, wf_info[wild_map[p_ptr->wilderness_y][p_ptr->wilderness_x].feat].name); + } else + { strcpy(depths, "Town/Wild"); + } } else { diff --git a/src/xtra2.cc b/src/xtra2.cc index 0876396b..a26e29b6 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -4501,8 +4501,8 @@ static int target_set_aux(int y, int x, int mode, cptr info) { s3 = ""; name = format("%s(%s)", - wf_name + wf_info[wild_map[y][x].feat].name, - wf_text + wf_info[wild_map[y][x].feat].text); + wf_info[wild_map[y][x].feat].name, + wf_info[wild_map[y][x].feat].text); } if ((feat == FEAT_FOUNTAIN) && (c_ptr->info & CAVE_IDNT)) |