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
commit4b6f8d810f5ad513bea8fada09be01dde0fd643c (patch)
tree380e3b41ad48424ecf48d1af7bbd11f17cbdd6db /src/init1.cc
parentc4746c0f6d328baa429c96e54d86d2d7f97ccbcc (diff)
Remove k_name, k_text, k_head in favor of simple strings
Diffstat (limited to 'src/init1.cc')
-rw-r--r--src/init1.cc46
1 files changed, 5 insertions, 41 deletions
diff --git a/src/init1.cc b/src/init1.cc
index 4fc3513d..f00e5a54 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -4155,10 +4155,6 @@ errr init_k_info_txt(FILE *fp, char *buf)
error_line = -1;
- /* Prepare the "fake" stuff */
- k_head->name_size = 0;
- k_head->text_size = 0;
-
/* Parse */
fp_stack_init(fp);
while (0 == my_fgets_dostack(buf, 1024))
@@ -4220,7 +4216,7 @@ errr init_k_info_txt(FILE *fp, char *buf)
if (i <= error_idx) return (4);
/* Verify information */
- if (i >= k_head->info_num) return (2);
+ if (i >= max_k_idx) return (2);
/* Save the index */
error_idx = i;
@@ -4228,17 +4224,9 @@ errr init_k_info_txt(FILE *fp, char *buf)
/* Point at the "info" */
k_ptr = &k_info[i];
- /* Hack -- Verify space */
- if (k_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7);
-
/* Advance and Save the name index */
- if (!k_ptr->name) k_ptr->name = ++k_head->name_size;
-
- /* Append chars to the name */
- strcpy(k_name + k_head->name_size, s);
-
- /* Advance the index */
- k_head->name_size += strlen(s);
+ assert(!k_ptr->name);
+ k_ptr->name = strdup(s);
/* Needed hack */
k_ptr->esp = 0;
@@ -4257,27 +4245,8 @@ errr init_k_info_txt(FILE *fp, char *buf)
/* Acquire the text */
s = buf + 2;
- /* Hack -- Verify space */
- if (k_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7);
-
- /* Advance and Save the text index */
- if (!k_ptr->text) k_ptr->text = ++k_head->text_size;
-
- /* Append a space if needed */
- else if (k_text[k_head->text_size - 1] != ' ')
- {
- /* Append chars to the name */
- strcpy(k_text + k_head->text_size, " ");
-
- /* Advance the index */
- k_head->text_size += 1;
- }
-
- /* Append chars to the name */
- strcpy(k_text + k_head->text_size, s);
-
- /* Advance the index */
- k_head->text_size += strlen(s);
+ /* Append description */
+ strappend(&k_ptr->text, s);
/* Next... */
continue;
@@ -4538,11 +4507,6 @@ errr init_k_info_txt(FILE *fp, char *buf)
}
- /* Complete the "name" and "text" sizes */
- ++k_head->name_size;
- ++k_head->text_size;
-
-
/* No version yet */
if (!okay) return (2);