diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-02-23 09:11:58 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-02-23 09:11:58 +0100 |
commit | 560ebe18ecf165dcfffa2d57870f01f1099be44c (patch) | |
tree | 551526f30dfee94d21034e027ef81b675159624e | |
parent | caa23251d8b279529330641032c62f8640ee13ff (diff) |
Remove set_head, set_name, set_text
-rw-r--r-- | src/externs.h | 4 | ||||
-rw-r--r-- | src/init1.cc | 38 | ||||
-rw-r--r-- | src/init2.cc | 14 | ||||
-rw-r--r-- | src/object1.cc | 25 | ||||
-rw-r--r-- | src/types.h | 4 | ||||
-rw-r--r-- | src/variable.cc | 3 |
6 files changed, 29 insertions, 59 deletions
diff --git a/src/externs.h b/src/externs.h index b9d64914..2fd649fe 100644 --- a/src/externs.h +++ b/src/externs.h @@ -354,10 +354,8 @@ extern char *ba_name; extern header *ow_head; extern owner_type *ow_info; extern char *ow_name; -extern header *set_head; extern set_type *set_info; -extern char *set_name; -extern char *set_text; + extern cptr ANGBAND_SYS; extern cptr ANGBAND_KEYBOARD; extern cptr ANGBAND_GRAF; diff --git a/src/init1.cc b/src/init1.cc index 28f8ba10..d8217499 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -5302,7 +5302,7 @@ errr init_set_info_txt(FILE *fp, char *buf) if (i < error_idx) return (4); /* Verify information */ - if (i >= set_head->info_num) return (2); + if (i >= max_set_idx) return (2); /* Save the index */ error_idx = i; @@ -5310,19 +5310,11 @@ errr init_set_info_txt(FILE *fp, char *buf) /* Point at the "info" */ set_ptr = &set_info[i]; - /* Hack -- Verify space */ - if (set_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7); - - /* Advance and Save the name index */ - if (!set_ptr->name) set_ptr->name = ++set_head->name_size; - - /* Append chars to the name */ - strcpy(set_name + set_head->name_size, s); - - /* Advance the index */ - set_head->name_size += strlen(s); + /* Copy name */ + assert(!set_ptr->name); + set_ptr->name = my_strdup(s); - /* Needed hack */ + /* Initialize */ set_ptr->num = 0; set_ptr->num_use = 0; for (z = 0; z < 6; z++) @@ -5354,17 +5346,8 @@ errr init_set_info_txt(FILE *fp, char *buf) /* Acquire the text */ s = buf + 2; - /* Hack -- Verify space */ - if (set_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7); - - /* Advance and Save the text index */ - if (!set_ptr->desc) set_ptr->desc = ++set_head->text_size; - - /* Append chars to the name */ - strcpy(set_text + set_head->text_size, s); - - /* Advance the index */ - set_head->text_size += strlen(s); + /* Append chars to the description */ + strappend(&set_ptr->desc, s); /* Next... */ continue; @@ -5438,16 +5421,9 @@ errr init_set_info_txt(FILE *fp, char *buf) return (6); } - - /* Complete the "name" and "text" sizes */ - ++set_head->name_size; - ++set_head->text_size; - - /* No version yet */ if (!okay) return (2); - /* Success */ return (0); } diff --git a/src/init2.cc b/src/init2.cc index 433a6337..20c9ee9a 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -414,20 +414,8 @@ static errr init_set_info(void) /* General buffer */ char buf[1024]; - - /*** Make the "header" ***/ - set_head = make_header(max_set_idx); - - - /*** Make the fake arrays ***/ - /* Allocate the "set_info" array */ - set_info = make_array<set_type>(set_head->info_num); - - /* Hack -- make "fake" arrays */ - set_name = make_array<char>(FAKE_NAME_SIZE); - set_text = make_array<char>(FAKE_TEXT_SIZE); - + set_info = make_array<set_type>(max_set_idx); /*** Load the ascii template file ***/ diff --git a/src/object1.cc b/src/object1.cc index dacf1b93..cffd1f84 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -17,6 +17,8 @@ #include "hooks.h" #include "spells5.hpp" +#include <cassert> + /* * Hack -- note that "TERM_MULTI" is now just "TERM_VIOLET". * We will have to find a cleaner method for "MULTI_HUED" later. @@ -2858,9 +2860,7 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait if (a_ptr->set != -1) { - set_type *set_ptr = &set_info[a_ptr->set]; - - text_out_c(TERM_GREEN, set_text + set_ptr->desc); + text_out_c(TERM_GREEN, set_info[a_ptr->set].desc); text_out("\n"); } } @@ -6514,8 +6514,14 @@ bool_ wield_set(s16b a_idx, s16b set_idx, bool_ silent) { s_ptr->num_use++; s_ptr->arts[i].present = TRUE; - if (s_ptr->num_use > s_ptr->num) msg_print("ERROR!! s_ptr->num_use > s_ptr->use"); - else if ((s_ptr->num_use == s_ptr->num) && (!silent)) cmsg_format(TERM_GREEN, "%s item set completed.", s_ptr->name + set_name); + if (s_ptr->num_use > s_ptr->num) + { + msg_print("ERROR!! s_ptr->num_use > s_ptr->use"); + } + else if ((s_ptr->num_use == s_ptr->num) && (!silent)) + { + cmsg_format(TERM_GREEN, "%s item set completed.", s_ptr->name); + } return (TRUE); } return (FALSE); @@ -6533,10 +6539,15 @@ bool_ takeoff_set(s16b a_idx, s16b set_idx) if (s_ptr->arts[i].present) { s_ptr->arts[i].present = FALSE; + + assert(s_ptr->num_use > 0); s_ptr->num_use--; - if (s_ptr->num_use == 255) msg_print("ERROR!! s_ptr->num_use < 0"); - if (s_ptr->num_use == s_ptr->num - 1) cmsg_format(TERM_GREEN, "%s item set not complete anymore.", s_ptr->name + set_name); + if (s_ptr->num_use == s_ptr->num - 1) + { + cmsg_format(TERM_GREEN, "%s item set not complete anymore.", s_ptr->name); + } + return (TRUE); } return (FALSE); diff --git a/src/types.h b/src/types.h index 6240e5f8..88a19e1c 100644 --- a/src/types.h +++ b/src/types.h @@ -2405,8 +2405,8 @@ struct hist_type typedef struct set_type set_type; struct set_type { - u32b name; /* Name */ - u32b desc; /* Desc */ + const char *name; /* Name */ + char *desc; /* Desc */ byte num; /* Number of artifacts used */ byte num_use; /* Number actually wore */ diff --git a/src/variable.cc b/src/variable.cc index 8781485b..17145a1a 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -620,10 +620,7 @@ artifact_type *a_info; /* * The item set arrays */ -header *set_head; set_type *set_info; -char *set_name; -char *set_text; /* * The ego-item arrays |