diff options
-rw-r--r-- | src/cmd1.cc | 2 | ||||
-rw-r--r-- | src/cmd2.cc | 8 | ||||
-rw-r--r-- | src/cmd4.cc | 2 | ||||
-rw-r--r-- | src/externs.h | 3 | ||||
-rw-r--r-- | src/init1.cc | 40 | ||||
-rw-r--r-- | src/init2.cc | 14 | ||||
-rw-r--r-- | src/object1.cc | 6 | ||||
-rw-r--r-- | src/spells1.cc | 2 | ||||
-rw-r--r-- | src/traps.cc | 9 | ||||
-rw-r--r-- | src/types.h | 28 | ||||
-rw-r--r-- | src/variable.cc | 3 | ||||
-rw-r--r-- | src/xtra2.cc | 2 |
12 files changed, 39 insertions, 80 deletions
diff --git a/src/cmd1.cc b/src/cmd1.cc index da3529ee..6affcad9 100644 --- a/src/cmd1.cc +++ b/src/cmd1.cc @@ -657,7 +657,7 @@ static void hit_trap(void) { t_info[c_ptr->t_idx].ident = TRUE; msg_format("You identified the trap as %s.", - t_name + t_info[c_ptr->t_idx].name); + t_info[c_ptr->t_idx].name); } } } diff --git a/src/cmd2.cc b/src/cmd2.cc index 0cbf73df..dd78064b 100644 --- a/src/cmd2.cc +++ b/src/cmd2.cc @@ -716,7 +716,7 @@ static void chest_trap(int y, int x, s16b o_idx) { t_info[o_ptr->pval].ident = TRUE; msg_format("You identified the trap as %s.", - t_name + t_info[trap].name); + t_info[trap].name); } } @@ -2017,9 +2017,13 @@ bool_ do_cmd_disarm_aux(int y, int x, int dir, int do_pickup) /* Access trap name */ if (t_info[c_ptr->t_idx].ident) - name = (t_name + t_info[c_ptr->t_idx].name); + { + name = t_info[c_ptr->t_idx].name; + } else + { name = "unknown trap"; + } /* Get the "disarm" factor */ i = p_ptr->skill_dis; diff --git a/src/cmd4.cc b/src/cmd4.cc index dc437272..046075f2 100644 --- a/src/cmd4.cc +++ b/src/cmd4.cc @@ -3363,7 +3363,7 @@ void do_cmd_knowledge_traps(void) if (!t_ptr->ident) continue; /* Hack -- Build the trap name */ - fprintf(fff, " %s\n", t_name + t_ptr->name); + fprintf(fff, " %s\n", t_ptr->name); } /* Close the file */ diff --git a/src/externs.h b/src/externs.h index 50fa4777..7b8540f8 100644 --- a/src/externs.h +++ b/src/externs.h @@ -335,10 +335,7 @@ extern player_class *class_info; extern meta_class_type *meta_class_info; extern player_race *race_info; extern player_race_mod *race_mod_info; -extern header *t_head; extern trap_type *t_info; -extern char *t_name; -extern char *t_text; extern header *wf_head; extern wilderness_type_info *wf_info; extern char *wf_name; diff --git a/src/init1.cc b/src/init1.cc index 1d8d30d7..76c33e9a 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -8415,18 +8415,12 @@ errr init_t_info_txt(FILE *fp, char *buf) /* Current entry */ trap_type *t_ptr = NULL; - /* Just before the first record */ error_idx = -1; /* Just before the first line */ error_line = -1; - - /* Prepare the "fake" stuff */ - t_head->name_size = 0; - t_head->text_size = 0; - /* Parse */ fp_stack_init(fp); while (0 == my_fgets_dostack(buf, 1024)) @@ -8488,7 +8482,7 @@ errr init_t_info_txt(FILE *fp, char *buf) if (i <= error_idx) return (4); /* Verify information */ - if (i >= t_head->info_num) return (2); + if (i >= max_t_idx) return (2); /* Save the index */ error_idx = i; @@ -8496,17 +8490,11 @@ errr init_t_info_txt(FILE *fp, char *buf) /* Point at the "info" */ t_ptr = &t_info[i]; - /* Hack -- Verify space */ - if (t_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7); - - /* Advance and Save the name index */ - if (!t_ptr->name) t_ptr->name = ++t_head->name_size; - - /* Append chars to the name */ - strcpy(t_name + t_head->name_size, s); + /* Copy name */ + t_ptr->name = my_strdup(s); - /* Advance the index */ - t_head->name_size += strlen(s); + /* Initialize */ + t_ptr->text = my_strdup(""); /* Next... */ continue; @@ -8550,17 +8538,8 @@ errr init_t_info_txt(FILE *fp, char *buf) /* Acquire the text */ s = buf + 2; - /* Hack -- Verify space */ - if (t_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7); - - /* Advance and Save the text index */ - if (!t_ptr->text) t_ptr->text = ++t_head->text_size; - /* Append chars to the name */ - strcpy(t_text + t_head->text_size, s); - - /* Advance the index */ - t_head->text_size += strlen(s); + strappend(&t_ptr->text, s); /* Next... */ continue; @@ -8602,16 +8581,9 @@ errr init_t_info_txt(FILE *fp, char *buf) return (6); } - - /* Complete the "name" and "text" sizes */ - ++t_head->name_size; - ++t_head->text_size; - - /* No version yet */ if (!okay) return (2); - /* Success */ return (0); } diff --git a/src/init2.cc b/src/init2.cc index afee0538..11505edb 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -1301,20 +1301,8 @@ static errr init_t_info(void) /* General buffer */ char buf[1024]; - - /*** Make the header ***/ - t_head = make_header(max_t_idx); - - - /*** Make the fake arrays ***/ - /* Allocate the "t_info" array */ - t_info = make_array<trap_type>(t_head->info_num); - - /* Hack -- make "fake" arrays */ - t_name = make_array<char>(FAKE_NAME_SIZE); - t_text = make_array<char>(FAKE_TEXT_SIZE); - + t_info = make_array<trap_type>(max_t_idx); /*** Load the ascii template file ***/ diff --git a/src/object1.cc b/src/object1.cc index cffd1f84..2dae8303 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -2002,9 +2002,13 @@ void object_desc(char *buf, object_type *o_ptr, int pref, int mode) /* Describe the traps */ t = object_desc_str(t, " ("); if (t_info[o_ptr->pval].ident) - t = object_desc_str(t, t_name + t_info[o_ptr->pval].name); + { + t = object_desc_str(t, t_info[o_ptr->pval].name); + } else + { t = object_desc_str(t, "trapped"); + } t = object_desc_str(t, ")"); } } diff --git a/src/spells1.cc b/src/spells1.cc index dd69dfc8..95b19ed4 100644 --- a/src/spells1.cc +++ b/src/spells1.cc @@ -7276,7 +7276,7 @@ static bool_ project_p(int who, int r, int y, int x, int dam, int typ, int a_rad if (who == -2) { sprintf(killer, "%s", - t_name + t_info[cave[p_ptr->py][p_ptr->px].t_idx].name); + t_info[cave[p_ptr->py][p_ptr->px].t_idx].name); } /* Analyze the damage */ diff --git a/src/traps.cc b/src/traps.cc index 6410e76c..6b56de16 100644 --- a/src/traps.cc +++ b/src/traps.cc @@ -439,12 +439,9 @@ static bool_ player_handle_breath_trap(s16b rad, s16b type, u16b trap) */ static void trap_hit(s16b trap) { - s16b dam; trap_type *t_ptr = &t_info[trap]; - - dam = damroll(t_ptr->dd, t_ptr->ds); - - take_hit(dam, t_name + t_ptr->name); + s16b dam = damroll(t_ptr->dd, t_ptr->ds); + take_hit(dam, t_ptr->name); } /* @@ -1988,7 +1985,7 @@ void player_activate_door_trap(s16b y, s16b x) { t_info[c_ptr->t_idx].ident = TRUE; msg_format("You identified that trap as %s.", - t_name + t_info[c_ptr->t_idx].name); + t_info[c_ptr->t_idx].name); } } diff --git a/src/types.h b/src/types.h index 88a19e1c..1e6103cf 100644 --- a/src/types.h +++ b/src/types.h @@ -620,20 +620,20 @@ typedef struct trap_type trap_type; struct trap_type { - s16b probability; /* probability of existence */ - s16b another; /* does this trap easily combine */ - s16b p1valinc; /* how much does this trap attribute to p1val */ - byte difficulty; /* how difficult to disarm */ - byte minlevel; /* what is the minimum level on which the traps should be */ - byte color; /* what is the color on screen */ - u32b flags; /* where can these traps go - and perhaps other flags */ - bool_ ident; /* do we know the name */ - s16b known; /* how well is this trap known */ - s16b name; /* normal name like weakness */ - s16b dd, ds; /* base damage */ - s16b text; /* longer description once you've met this trap */ - byte g_attr; /* Overlay graphic attribute */ - char g_char; /* Overlay graphic character */ + s16b probability; /* probability of existence */ + s16b another; /* does this trap easily combine */ + s16b p1valinc; /* how much does this trap attribute to p1val */ + byte difficulty; /* how difficult to disarm */ + byte minlevel; /* what is the minimum level on which the traps should be */ + byte color; /* what is the color on screen */ + u32b flags; /* where can these traps go - and perhaps other flags */ + bool_ ident; /* do we know the name */ + s16b known; /* how well is this trap known */ + const char *name; /* normal name like weakness */ + s16b dd, ds; /* base damage */ + char *text; /* longer description once you've met this trap */ + byte g_attr; /* Overlay graphic attribute */ + char g_char; /* Overlay graphic character */ }; diff --git a/src/variable.cc b/src/variable.cc index 36fd2246..2aa3c358 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -635,10 +635,7 @@ randart_gen_type ra_gen[30]; /* jk */ /* the trap-arrays */ -header *t_head; trap_type *t_info; -char *t_name; -char *t_text; /* * The monster race arrays diff --git a/src/xtra2.cc b/src/xtra2.cc index 5896e3bc..0876396b 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -4417,7 +4417,7 @@ static int target_set_aux(int y, int x, int mode, cptr info) /* Name trap */ if (t_info[c_ptr->t_idx].ident) { - s4 = format("(%s)", t_name + t_info[c_ptr->t_idx].name); + s4 = format("(%s)", t_info[c_ptr->t_idx].name); } else { |