diff options
-rw-r--r-- | src/externs.h | 3 | ||||
-rw-r--r-- | src/init1.cc | 48 | ||||
-rw-r--r-- | src/init2.cc | 14 | ||||
-rw-r--r-- | src/object1.cc | 4 | ||||
-rw-r--r-- | src/types.h | 4 | ||||
-rw-r--r-- | src/variable.cc | 3 |
6 files changed, 16 insertions, 60 deletions
diff --git a/src/externs.h b/src/externs.h index 318ae205..88ca9d8e 100644 --- a/src/externs.h +++ b/src/externs.h @@ -330,10 +330,7 @@ extern feature_type *f_info; extern char *f_name; extern char *f_text; extern object_kind *k_info; -extern header *a_head; extern artifact_type *a_info; -extern char *a_name; -extern char *a_text; extern header *e_head; extern ego_item_type *e_info; extern char *e_name; diff --git a/src/init1.cc b/src/init1.cc index 402618ea..a65863b5 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -7,6 +7,7 @@ #include <boost/algorithm/string/predicate.hpp> using boost::algorithm::iequals; +using boost::algorithm::ends_with; /* @@ -5111,26 +5112,18 @@ errr init_a_info_txt(FILE *fp, char *buf) /* Verify information */ if (i < error_idx) return (4); - /* Verify information */ - if (i >= a_head->info_num) return (2); - /* Save the index */ error_idx = i; /* Point at the "info" */ a_ptr = &a_info[i]; - /* Hack -- Verify space */ - if (a_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7); - - /* Advance and Save the name index */ - if (!a_ptr->name) a_ptr->name = ++a_head->name_size; - - /* Append chars to the name */ - strcpy(a_name + a_head->name_size, s); + /* Copy name */ + assert(!a_ptr->name); + a_ptr->name = my_strdup(s); - /* Advance the index */ - a_head->name_size += strlen(s); + /* Ensure empty description */ + a_ptr->text = my_strdup(""); /* Ignore everything */ a_ptr->flags3 |= (TR3_IGNORE_ACID); @@ -5162,27 +5155,13 @@ errr init_a_info_txt(FILE *fp, char *buf) /* Acquire the text */ s = buf + 2; - /* Hack -- Verify space */ - if (a_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7); - - /* Advance and Save the text index */ - if (!a_ptr->text) a_ptr->text = ++a_head->text_size; - - /* Append a space at the end of the line, if needed */ - else if (a_text[a_head->text_size - 1] != ' ') - { - /* Append the space */ - strcpy(a_text + a_head->text_size, " "); - - /* Advance the index */ - a_head->text_size += 1; + /* Add separator if necessary */ + if (*a_ptr->text != '\0' && !ends_with(a_ptr->text, " ")) { + strappend(&a_ptr->text, " "); } - /* Append chars to the name */ - strcpy(a_text + a_head->text_size, s); - - /* Advance the index */ - a_head->text_size += strlen(s); + /* Append to description */ + strappend(&a_ptr->text, s); /* Next... */ continue; @@ -5347,11 +5326,6 @@ errr init_a_info_txt(FILE *fp, char *buf) } - /* Complete the "name" and "text" sizes */ - ++a_head->name_size; - ++a_head->text_size; - - /* No version yet */ if (!okay) return (2); diff --git a/src/init2.cc b/src/init2.cc index 446c6412..caf1bf27 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -484,20 +484,8 @@ static errr init_a_info(void) /* General buffer */ char buf[1024]; - - /*** Make the "header" ***/ - a_head = make_header(max_a_idx); - - - /*** Make the fake arrays ***/ - /* Allocate the "a_info" array */ - a_info = make_array<artifact_type>(a_head->info_num); - - /* Hack -- make "fake" arrays */ - a_name = make_array<char>(FAKE_NAME_SIZE); - a_text = make_array<char>(FAKE_TEXT_SIZE); - + a_info = make_array<artifact_type>(max_a_idx); /*** Load the ascii template file ***/ diff --git a/src/object1.cc b/src/object1.cc index 34eb8ade..1abdf36b 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -1909,7 +1909,7 @@ void object_desc(char *buf, object_type *o_ptr, int pref, int mode) if (o_ptr->tval != TV_CORPSE) { t = object_desc_chr(t, ' '); - t = object_desc_str(t, (a_name + a_ptr->name)); + t = object_desc_str(t, a_ptr->name); } } @@ -2844,7 +2844,7 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait { artifact_type *a_ptr = &a_info[o_ptr->name1]; - text_out_c(TERM_YELLOW, a_text + a_ptr->text); + text_out_c(TERM_YELLOW, a_ptr->text); text_out("\n"); if (a_ptr->set != -1) diff --git a/src/types.h b/src/types.h index a9dc4de0..48c07671 100644 --- a/src/types.h +++ b/src/types.h @@ -213,8 +213,8 @@ typedef struct artifact_type artifact_type; struct artifact_type { - u32b name; /* Name (offset) */ - u32b text; /* Text (offset) */ + char const *name; /* Artifact name */ + char *text; /* Artifact description */ byte tval; /* Artifact type */ byte sval; /* Artifact sub type */ diff --git a/src/variable.cc b/src/variable.cc index efb2dbaf..7eb13f9c 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -621,10 +621,7 @@ char *k_text; /* * The artifact arrays */ -header *a_head; artifact_type *a_info; -char *a_name; -char *a_text; /* * The item set arrays |