summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd1.cc10
-rw-r--r--src/cmd2.cc18
-rw-r--r--src/cmd4.cc4
-rw-r--r--src/defines.h7
-rw-r--r--src/externs.h7
-rw-r--r--src/init1.cc74
-rw-r--r--src/init2.cc27
-rw-r--r--src/spells1.cc3
-rw-r--r--src/types.h33
-rw-r--r--src/types_fwd.h1
-rw-r--r--src/variable.cc10
-rw-r--r--src/xtra2.cc2
12 files changed, 53 insertions, 143 deletions
diff --git a/src/cmd1.cc b/src/cmd1.cc
index 6affcad9..2548aa72 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -3244,7 +3244,7 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
else
feat = f_info[c_ptr->feat].mimic;
- msg_format("You feel %s.", f_text + f_info[feat].block);
+ msg_format("You feel %s.", f_info[feat].block);
c_ptr->info |= (CAVE_MARK);
lite_spot(y, x);
}
@@ -3301,7 +3301,7 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
else
feat = f_info[c_ptr->feat].mimic;
- msg_format("There is %s.", f_text + f_info[feat].block);
+ msg_format("There is %s.", f_info[feat].block);
if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
energy_use = 0;
@@ -3420,7 +3420,7 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
if (!run) p_ptr->window |= (PW_OVERHEAD);
/* Some feature descs */
- if (f_info[cave[p_ptr->py][p_ptr->px].feat].text > 1)
+ if (f_info[cave[p_ptr->py][p_ptr->px].feat].text != DEFAULT_FEAT_TEXT)
{
/* Mega-hack for dungeon branches */
if ((feat == FEAT_MORE) && c_ptr->special)
@@ -3429,7 +3429,7 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
}
else
{
- msg_print(f_text + f_info[feat].text);
+ msg_print(f_info[feat].text);
}
/* Flush message while running */
@@ -3464,7 +3464,7 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
else if (cave[y][x].feat >= FEAT_ALTAR_HEAD &&
cave[y][x].feat <= FEAT_ALTAR_TAIL)
{
- cptr name = f_name + f_info[cave[y][x].feat].name;
+ cptr name = f_info[cave[y][x].feat].name;
cptr pref = (is_a_vowel(name[0])) ? "an" : "a";
msg_format("You see %s %s.", pref, name);
diff --git a/src/cmd2.cc b/src/cmd2.cc
index dd78064b..aa4371ac 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -1382,7 +1382,7 @@ static bool_ do_cmd_tunnel_test(int y, int x)
if (!(f_info[cave[y][x].feat].flags1 & FF1_TUNNELABLE))
{
/* Message */
- msg_print(f_text + f_info[cave[y][x].feat].tunnel);
+ msg_print(f_info[cave[y][x].feat].tunnel);
/* Nope */
return (FALSE);
@@ -1473,7 +1473,7 @@ bool_ do_cmd_tunnel_aux(int y, int x, int dir)
/* Titanium */
if (f_ptr->flags1 & FF1_PERMANENT)
{
- msg_print(f_text + f_ptr->tunnel);
+ msg_print(f_ptr->tunnel);
}
else if ((c_ptr->feat == FEAT_TREES) || (c_ptr->feat == FEAT_DEAD_TREE))
@@ -1490,7 +1490,7 @@ bool_ do_cmd_tunnel_aux(int y, int x, int dir)
else
{
/* We may continue chopping */
- msg_print(f_text + f_ptr->tunnel);
+ msg_print(f_ptr->tunnel);
more = TRUE;
/* Occasional Search XXX XXX */
@@ -1515,7 +1515,7 @@ bool_ do_cmd_tunnel_aux(int y, int x, int dir)
else
{
/* We may continue tunelling */
- msg_print(f_text + f_ptr->tunnel);
+ msg_print(f_ptr->tunnel);
more = TRUE;
}
}
@@ -1595,7 +1595,7 @@ bool_ do_cmd_tunnel_aux(int y, int x, int dir)
else
{
/* Message, continue digging */
- msg_print(f_text + f_ptr->tunnel);
+ msg_print(f_ptr->tunnel);
more = TRUE;
}
}
@@ -1629,7 +1629,7 @@ bool_ do_cmd_tunnel_aux(int y, int x, int dir)
else
{
/* Message, keep digging */
- msg_print(f_text + f_ptr->tunnel);
+ msg_print(f_ptr->tunnel);
more = TRUE;
}
}
@@ -1660,7 +1660,7 @@ bool_ do_cmd_tunnel_aux(int y, int x, int dir)
feat = c_ptr->feat;
/* We may continue tunelling */
- msg_print(f_text + f_info[feat].tunnel);
+ msg_print(f_info[feat].tunnel);
more = TRUE;
/* Occasional Search XXX XXX */
@@ -1683,7 +1683,7 @@ bool_ do_cmd_tunnel_aux(int y, int x, int dir)
else
{
/* We may continue tunelling */
- msg_print(f_text + f_ptr->tunnel);
+ msg_print(f_ptr->tunnel);
more = TRUE;
}
}
@@ -2803,7 +2803,7 @@ void do_cmd_rest(void)
/* Tell the player why */
msg_print(format("Resting on a %s is too dangerous!",
- f_name + f_info[cave[p_ptr->py][p_ptr->px].feat].name));
+ f_info[cave[p_ptr->py][p_ptr->px].feat].name));
/* Done */
return;
diff --git a/src/cmd4.cc b/src/cmd4.cc
index 046075f2..2eb40fae 100644
--- a/src/cmd4.cc
+++ b/src/cmd4.cc
@@ -2288,7 +2288,7 @@ void do_cmd_visuals(void)
if (!f_ptr->name) continue;
/* Dump a comment */
- fprintf(fff, "# %s\n", (f_name + f_ptr->name));
+ fprintf(fff, "# %s\n", f_ptr->name);
/* Dump the feature attr/char info */
fprintf(fff, "F:%d:0x%02X:0x%02X\n\n", i,
@@ -2436,7 +2436,7 @@ void do_cmd_visuals(void)
/* Label the object */
Term_putstr(5, 17, -1, TERM_WHITE,
format("Terrain = %d, Name = %-40.40s",
- f, (f_name + f_ptr->name)));
+ f, f_ptr->name));
/* Label the Default values */
Term_putstr(10, 19, -1, TERM_WHITE,
diff --git a/src/defines.h b/src/defines.h
index e29f47e1..67ed3b6b 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -172,13 +172,6 @@
/*
- * Size of memory reserved for initialization of some arrays
- */
-#define FAKE_NAME_SIZE 40 * 1024L
-#define FAKE_TEXT_SIZE 120 * 1024L
-
-
-/*
* Maximum number of high scores in the high score file
*/
#define MAX_HISCORES 100
diff --git a/src/externs.h b/src/externs.h
index e40470cf..3313c081 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -315,10 +315,7 @@ extern ability_type *ab_info;
extern skill_type *s_info;
extern vault_type *v_info;
-extern header *f_head;
extern feature_type *f_info;
-extern char *f_name;
-extern char *f_text;
extern object_kind *k_info;
extern artifact_type *a_info;
extern ego_item_type *e_info;
@@ -339,6 +336,10 @@ extern store_action_type *ba_info;
extern owner_type *ow_info;
extern set_type *set_info;
+extern cptr DEFAULT_FEAT_TEXT;
+extern cptr DEFAULT_FEAT_TUNNEL;
+extern cptr DEFAULT_FEAT_BLOCK;
+
extern cptr ANGBAND_SYS;
extern cptr ANGBAND_KEYBOARD;
extern cptr ANGBAND_GRAF;
diff --git a/src/init1.cc b/src/init1.cc
index 79ae95f8..be294cce 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -3590,36 +3590,16 @@ errr init_f_info_txt(FILE *fp, char *buf)
/* Not ready yet */
bool_ okay = FALSE;
- u32b default_desc = 0, default_tunnel = 0, default_block = 0;
/* Current entry */
feature_type *f_ptr = NULL;
-
/* Just before the first record */
error_idx = -1;
/* Just before the first line */
error_line = -1;
-
- /* Prepare the "fake" stuff */
- f_head->name_size = 0;
- f_head->text_size = 0;
-
- /* Add some fake descs */
- default_desc = ++f_head->text_size;
- strcpy(f_text + f_head->text_size, "a wall blocking your way");
- f_head->text_size += strlen("a wall blocking your way");
-
- default_tunnel = ++f_head->text_size;
- strcpy(f_text + f_head->text_size, "You cannot tunnel through that.");
- f_head->text_size += strlen("You cannot tunnel through that.");
-
- default_block = ++f_head->text_size;
- strcpy(f_text + f_head->text_size, "a wall blocking your way");
- f_head->text_size += strlen("a wall blocking your way");
-
/* Parse */
fp_stack_init(fp);
while (0 == my_fgets_dostack(buf, 1024))
@@ -3681,7 +3661,7 @@ errr init_f_info_txt(FILE *fp, char *buf)
if (i <= error_idx) return (4);
/* Verify information */
- if (i >= f_head->info_num) return (2);
+ if (i >= max_f_idx) return (2);
/* Save the index */
error_idx = i;
@@ -3689,24 +3669,15 @@ errr init_f_info_txt(FILE *fp, char *buf)
/* Point at the "info" */
f_ptr = &f_info[i];
- /* Hack -- Verify space */
- if (f_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7);
-
- /* Advance and Save the name index */
- if (!f_ptr->name) f_ptr->name = ++f_head->name_size;
-
- /* Append chars to the name */
- strcpy(f_name + f_head->name_size, s);
-
- /* Advance the index */
- f_head->name_size += strlen(s);
+ /* Copy name */
+ assert(!f_ptr->name);
+ f_ptr->name = my_strdup(s);
- /* Default "mimic" */
+ /* Initialize */
f_ptr->mimic = i;
- f_ptr->text = default_desc;
- f_ptr->block = default_desc;
- f_ptr->tunnel = default_tunnel;
- f_ptr->block = default_block;
+ f_ptr->text = DEFAULT_FEAT_TEXT;
+ f_ptr->tunnel = DEFAULT_FEAT_TUNNEL;
+ f_ptr->block = DEFAULT_FEAT_BLOCK;
/* Next... */
continue;
@@ -3722,34 +3693,24 @@ errr init_f_info_txt(FILE *fp, char *buf)
/* Acquire the text */
s = buf + 4;
- /* Hack -- Verify space */
- if (f_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7);
-
switch (buf[2])
{
case '0':
- /* Advance and Save the text index */
- f_ptr->text = ++f_head->text_size;
+ assert(f_ptr->text == DEFAULT_FEAT_TEXT);
+ f_ptr->text = my_strdup(s);
break;
case '1':
- /* Advance and Save the text index */
- f_ptr->tunnel = ++f_head->text_size;
+ assert(f_ptr->tunnel == DEFAULT_FEAT_TUNNEL);
+ f_ptr->tunnel = my_strdup(s);
break;
case '2':
- /* Advance and Save the text index */
- f_ptr->block = ++f_head->text_size;
+ assert(f_ptr->block == DEFAULT_FEAT_BLOCK);
+ f_ptr->block = my_strdup(s);
break;
default:
return (6);
- break;
}
- /* Append chars to the name */
- strcpy(f_text + f_head->text_size, s);
-
- /* Advance the index */
- f_head->text_size += strlen(s);
-
/* Next... */
continue;
}
@@ -3906,16 +3867,9 @@ errr init_f_info_txt(FILE *fp, char *buf)
return (6);
}
-
- /* Complete the "name" and "text" sizes */
- ++f_head->name_size;
- ++f_head->text_size;
-
-
/* No version yet */
if (!okay) return (2);
-
/* Success */
return (0);
}
diff --git a/src/init2.cc b/src/init2.cc
index e6033907..a1e9831f 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -257,19 +257,6 @@ static void note(cptr str)
/*
- * Make a new header
- */
-static header *make_header(u16b info_num)
-{
- header *h = new header;
- h->info_num = info_num;
- h->name_size = 0;
- h->text_size = 0;
- return h;
-}
-
-
-/*
* Initialise the "f_info" array
*
* Note that we let each entry have a unique "name" and "text" string,
@@ -284,20 +271,8 @@ static errr init_f_info(void)
/* General buffer */
char buf[1024];
-
- /*** Make the header ***/
- f_head = make_header(max_f_idx);
-
-
- /*** Make the fake arrays ***/
-
/* Allocate the "f_info" array */
- f_info = make_array<feature_type>(f_head->info_num);
-
- /* Hack -- make "fake" arrays */
- f_name = make_array<char>(FAKE_NAME_SIZE);
- f_text = make_array<char>(FAKE_TEXT_SIZE);
-
+ f_info = make_array<feature_type>(max_f_idx);
/*** Load the ascii template file ***/
diff --git a/src/spells1.cc b/src/spells1.cc
index 95b19ed4..c2f5394b 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -7257,8 +7257,7 @@ static bool_ project_p(int who, int r, int y, int x, int dam, int typ, int a_rad
}
if (who == -101)
{
- sprintf(killer, "%s",
- f_name + f_info[cave[p_ptr->py][p_ptr->px].feat].name);
+ sprintf(killer, "%s", f_info[cave[p_ptr->py][p_ptr->px].feat].name);
}
if (who >= -1)
diff --git a/src/types.h b/src/types.h
index 326cebf6..16bd5b04 100644
--- a/src/types.h
+++ b/src/types.h
@@ -42,31 +42,15 @@
* clearing of many variables at once.
*
* Certain data is saved in multiple places for efficient access, currently,
- * this includes the tval/sval/weight fields in "object_type", various fields
- * in "header_type", and the "m_idx" and "o_idx" fields in "cave_type". All
- * of these could be removed, but this would, in general, slow down the game
- * and increase the complexity of the code.
+ * this includes the tval/sval/weight fields in "object_type" and the "m_idx"
+ * and "o_idx" fields in "cave_type". All of these could be removed, but
+ * this would, in general, slow down the game and increase the complexity of
+ * the code.
*/
/*
- * Template file header information (see "init.c"). 16 bytes.
- */
-
-typedef struct header header;
-
-struct header
-{
- u16b info_num; /* Number of "info" records */
-
- u32b name_size; /* Size of the "name" array in bytes */
-
- u32b text_size; /* Size of the "text" array in bytes */
-};
-
-
-/*
* "Themed" objects.
* Probability in percent for each class of objects to be dropped.
* This could perhaps be an array - but that wouldn't be as clear.
@@ -89,10 +73,11 @@ typedef struct feature_type feature_type;
struct feature_type
{
- u32b name; /* Name (offset) */
- u32b text; /* Text (offset) */
- u32b tunnel; /* Text for tunneling */
- u32b block; /* Text for blocking */
+ char *name; /* Name */
+
+ const char *text; /* Text. May point to shared read-only memory, DO NOT FREE! */
+ const char *tunnel; /* Text for tunneling. May point to shared read-only memory, DO NOT FREE! */
+ const char *block; /* Text for blocking. May point to shared read-only memory, DO NOT FREE! */
byte mimic; /* Feature to mimic */
diff --git a/src/types_fwd.h b/src/types_fwd.h
index b644a73b..a959073c 100644
--- a/src/types_fwd.h
+++ b/src/types_fwd.h
@@ -4,7 +4,6 @@
extern "C" {
#endif
-struct header;
struct obj_theme;
struct feature_type;
struct object_kind;
diff --git a/src/variable.cc b/src/variable.cc
index 988aa2e9..bc4a5570 100644
--- a/src/variable.cc
+++ b/src/variable.cc
@@ -600,10 +600,7 @@ vault_type *v_info;
/*
* The terrain feature arrays
*/
-header *f_head;
feature_type *f_info;
-char *f_name;
-char *f_text;
/*
* The object kind arrays
@@ -698,6 +695,13 @@ store_action_type *ba_info;
owner_type *ow_info;
/*
+ * Default texts for feature information.
+ */
+cptr DEFAULT_FEAT_TEXT = "a wall blocking your way";
+cptr DEFAULT_FEAT_TUNNEL = "You cannot tunnel through that.";
+cptr DEFAULT_FEAT_BLOCK = DEFAULT_FEAT_TEXT;
+
+/*
* Hack -- The special Angband "System Suffix"
* This variable is used to choose an appropriate "pref-xxx" file
*/
diff --git a/src/xtra2.cc b/src/xtra2.cc
index f4016281..4d0750c5 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -4466,7 +4466,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
}
else
{
- name = f_name + f_info[feat].name;
+ name = f_info[feat].name;
}
/* Hack -- handle unknown grids */