From c54c7ab7a45e1729bcd3a238cd296850ba91c55f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:11:58 +0100 Subject: Remove st_head, st_name --- src/externs.h | 2 -- src/files.cc | 2 +- src/init1.cc | 26 ++++---------------------- src/init2.cc | 13 +------------ src/object1.cc | 4 ++-- src/store.cc | 15 +++++++-------- src/types.h | 2 +- src/variable.cc | 3 --- src/xtra2.cc | 2 +- 9 files changed, 17 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/externs.h b/src/externs.h index 0c3735a4..84005c4b 100644 --- a/src/externs.h +++ b/src/externs.h @@ -334,9 +334,7 @@ extern player_race_mod *race_mod_info; extern trap_type *t_info; extern wilderness_type_info *wf_info; extern int wildc2i[256]; -extern header *st_head; extern store_info_type *st_info; -extern char *st_name; extern header *ba_head; extern store_action_type *ba_info; extern char *ba_name; diff --git a/src/files.cc b/src/files.cc index b5c4da8a..8e7354f9 100644 --- a/src/files.cc +++ b/src/files.cc @@ -2475,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, place->name); + fprintf(fff, " [%s Inventory - %s]\n\n", 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 40fa8605..31d56fed 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -9324,11 +9324,6 @@ errr init_st_info_txt(FILE *fp, char *buf) /* Just before the first line */ error_line = -1; - - /* Start the "fake" stuff */ - st_head->name_size = 0; - st_head->text_size = 0; - /* Parse */ fp_stack_init(fp); while (0 == my_fgets_dostack(buf, 1024)) @@ -9390,7 +9385,7 @@ errr init_st_info_txt(FILE *fp, char *buf) if (i < error_idx) return (4); /* Verify information */ - if (i >= st_head->info_num) return (2); + if (i >= max_st_idx) return (2); /* Save the index */ error_idx = i; @@ -9398,17 +9393,9 @@ errr init_st_info_txt(FILE *fp, char *buf) /* Point at the "info" */ st_ptr = &st_info[i]; - /* Hack -- Verify space */ - if (st_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7); - - /* Advance and Save the name index */ - if (!st_ptr->name) st_ptr->name = ++st_head->name_size; - - /* Append chars to the name */ - strcpy(st_name + st_head->name_size, s); - - /* Advance the index */ - st_head->name_size += strlen(s); + /* Copy name */ + assert(!st_ptr->name); + st_ptr->name = my_strdup(s); /* We are ready for a new set of objects */ item_idx = 0; @@ -9579,11 +9566,6 @@ errr init_st_info_txt(FILE *fp, char *buf) return (6); } - - /* Complete the "name" and "text" sizes */ - ++st_head->name_size; - ++st_head->text_size; - /* No version yet */ if (!okay) return (2); diff --git a/src/init2.cc b/src/init2.cc index 52120950..fd529c07 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -1016,19 +1016,8 @@ static errr init_st_info(void) /* General buffer */ char buf[1024]; - - /*** Make the header ***/ - st_head = make_header(max_st_idx); - - - /*** Make the fake arrays ***/ - /* Allocate the "st_info" array */ - st_info = make_array(st_head->info_num); - - /* Hack -- make "fake" arrays */ - st_name = make_array(FAKE_NAME_SIZE); - + st_info = make_array(max_st_idx); /*** Load the ascii template file ***/ diff --git a/src/object1.cc b/src/object1.cc index 3bf48663..d704272c 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -3773,12 +3773,12 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait else if (o_ptr->found == OBJ_FOUND_STORE) { text_out(format("\nYou bought it from the %s.", - st_info[o_ptr->found_aux1].name + st_name)); + st_info[o_ptr->found_aux1].name)); } else if (o_ptr->found == OBJ_FOUND_STOLEN) { text_out(format("\nYou stole it from the %s.", - st_info[o_ptr->found_aux1].name + st_name)); + st_info[o_ptr->found_aux1].name)); } else if (o_ptr->found == OBJ_FOUND_SELFMADE) { diff --git a/src/store.cc b/src/store.cc index 15c97d1d..e948c094 100644 --- a/src/store.cc +++ b/src/store.cc @@ -613,7 +613,7 @@ bool_ is_blessed(object_type *o_ptr) */ static bool_ store_will_buy(object_type *o_ptr) { - cptr store_name = st_info[st_ptr->st_idx].name + st_name; + cptr store_name = st_info[st_ptr->st_idx].name; /* Hack -- The Home is simple */ if (cur_store_num == 7) return (TRUE); @@ -1217,7 +1217,7 @@ static void store_create(void) obj_all_done = FALSE; /* Magic Shop */ - if (streq(st_info[st_ptr->st_idx].name + st_name, STORE_MAGIC) && + if (streq(st_info[st_ptr->st_idx].name, STORE_MAGIC) && magik(20)) { s16b spell; @@ -1233,7 +1233,7 @@ static void store_create(void) } /* Temple */ - else if (streq(st_info[st_ptr->st_idx].name + st_name, STORE_TEMPLE) && + else if (streq(st_info[st_ptr->st_idx].name, STORE_TEMPLE) && magik(20)) { s16b spell; @@ -1584,10 +1584,8 @@ void display_store(void) else if (st_info[st_ptr->st_idx].flags1 & SF1_MUSEUM) { - cptr store_name = (st_name + st_info[cur_store_num].name); - /* Show the name of the store */ - strnfmt(buf, 80, "%s", store_name); + strnfmt(buf, 80, "%s", st_info[cur_store_num].name); prt(buf, 3, 30); /* Label the item descriptions */ @@ -1600,7 +1598,6 @@ void display_store(void) /* Normal stores */ else { - cptr store_name = (st_name + st_info[cur_store_num].name); cptr owner_name = (ow_name + ot_ptr->name); /* Put the owner name and race */ @@ -1608,7 +1605,9 @@ void display_store(void) put_str(buf, 3, 10); /* Show the max price in the store (above prices) */ - strnfmt(buf, 80, "%s (" FMTs16b ")", store_name, ot_ptr->max_cost); + strnfmt(buf, 80, "%s (" FMTs16b ")", + st_info[cur_store_num].name, + ot_ptr->max_cost); prt(buf, 3, 50); /* Label the item descriptions */ diff --git a/src/types.h b/src/types.h index b5248c21..6dd27a44 100644 --- a/src/types.h +++ b/src/types.h @@ -976,7 +976,7 @@ typedef struct store_info_type store_info_type; struct store_info_type { - u32b name; /* Name (offset) */ + const char *name; /* Name */ s16b table[STORE_CHOICES][2]; /* Table -- Legal item kinds */ byte table_num; /* Number of items */ diff --git a/src/variable.cc b/src/variable.cc index b0ad10ea..3fdb6f03 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -685,10 +685,7 @@ int wildc2i[256]; /* * The store/building types arrays */ -header *st_head; store_info_type *st_info; -char *st_name; -/* char *st_text; */ /* * The building actions types arrays diff --git a/src/xtra2.cc b/src/xtra2.cc index a26e29b6..f4016281 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -4462,7 +4462,7 @@ static int target_set_aux(int y, int x, int mode, cptr info) /* Hack -- special handling for building doors */ if (feat == FEAT_SHOP) { - name = st_name + st_info[c_ptr->special].name; + name = st_info[c_ptr->special].name; } else { -- cgit v1.2.3