summaryrefslogtreecommitdiff
path: root/src/init1.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:57 +0100
committerBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:57 +0100
commitcbc6fe196f7205f3e5de8c14cba957dbd2e72890 (patch)
tree2f34e451526ef6d9b0e23d3dbcab9ae4bd32d839 /src/init1.cc
parent7357dd5d299d7937ce62b486dda375b3b0eadb49 (diff)
Replace a_head, a_name, a_text with simple char *
Diffstat (limited to 'src/init1.cc')
-rw-r--r--src/init1.cc48
1 files changed, 11 insertions, 37 deletions
diff --git a/src/init1.cc b/src/init1.cc
index 402618e..a65863b 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);