~ubuntu-branches/ubuntu/vivid/angband/vivid-proposed

« back to all changes in this revision

Viewing changes to src/init2.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Carr
  • Date: 2010-03-18 18:19:40 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100318181940-zd784dumo2hyzq1j
Tags: 1:3.1.2v2-1
* New upstream release. Angband 3.1.x is a development series which
  contains a number of major changes - see the changelog for details.
* Package now built --with-private-dirs, which enables Gtk support at the
  expense of a system-wide score file. Score, save and user pref files now
  in ~/.angband/Angband/ (any old save, pref and spoiler files are left in 
  /var/games/angband for manual cleanup). To avoid using Gtk, start the 
  game with the -mx11 or -msdl options (-mgcu for console mode).
* Added reference to recovering old files to README.debian
                                                Closes: #573117
* ".raw" files removed upstream.                      Closes: #542346
                                                Closes: #547259
* Minor changes to documentation pending full rewrite.
                                                Closes: #542348
* Corrected all uses of "lite" and "hilite" except the one on the 
  resistances display screen.                           Closes: #547260
* Added recommendation for xfonts-base.         Closes: #566268
* Updated Standards-Version. No changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 * at a time.
31
31
 *
32
32
 * Several of the arrays for Angband are built from "template" files in
33
 
 * the "lib/file" directory, from which quick-load binary "image" files
34
 
 * are constructed whenever they are not present in the "lib/data"
35
 
 * directory, or if those files become obsolete, if we are allowed.
 
33
 * the "lib/edit" directory.
36
34
 *
37
35
 * Warning -- the "ascii" file parsers use a minor hack to collect the
38
36
 * name and text information in a single pass.  Thus, the game will not
39
37
 * be able to load any template file with more than 20K of names or 60K
40
38
 * of text, even though technically, up to 64K should be legal.
41
 
 *
42
 
 * The "init1.c" file is used only to parse the ascii template files,
43
 
 * to create the binary image files.  If you include the binary image
44
 
 * files instead of the ascii template files, then you can undefine
45
 
 * "ALLOW_TEMPLATES", saving about 20K by removing "init1.c".  Note
46
 
 * that the binary image files are extremely system dependant.
47
39
 */
48
40
 
49
41
 
51
43
/*
52
44
 * Find the default paths to all of our important sub-directories.
53
45
 *
54
 
 * The purpose of each sub-directory is described in "variable.c".
55
 
 *
56
46
 * All of the sub-directories should, by default, be located inside
57
 
 * the main "lib" directory, whose location is very system dependant.
 
47
 * the main directory, whose location is very system dependant and is 
 
48
 * set by the ANGBAND_PATH environment variable, if it exists. (On multi-
 
49
 * user systems such as Linux this is not the default - see config.h for
 
50
 * more info.)
58
51
 *
59
 
 * This function takes a writable buffer, initially containing the
60
 
 * "path" to the "lib" directory, for example, "/pkg/lib/angband/",
 
52
 * This function takes a writable buffers, initially containing the
 
53
 * "path" to the "config", "lib" and "data" directories, for example, 
 
54
 * "/etc/angband/", "/usr/share/angband" and "/var/games/angband" -
61
55
 * or a system dependant string, for example, ":lib:".  The buffer
62
56
 * must be large enough to contain at least 32 more characters.
63
57
 *
64
58
 * Various command line options may allow some of the important
65
59
 * directories to be changed to user-specified directories, most
66
 
 * importantly, the "info" and "user" and "save" directories,
 
60
 * importantly, the "apex" and "user" and "save" directories,
67
61
 * but this is done after this function, see "main.c".
68
62
 *
69
63
 * In general, the initial path should end in the appropriate "PATH_SEP"
77
71
 * this function to be called multiple times, for example, to
78
72
 * try several base "path" values until a good one is found.
79
73
 */
80
 
void init_file_paths(const char *path)
 
74
void init_file_paths(const char *configpath, const char *libpath, const char *datapath)
81
75
{
82
76
#ifdef PRIVATE_USER_PATH
83
77
        char buf[1024];
85
79
 
86
80
        /*** Free everything ***/
87
81
 
88
 
        /* Free the main path */
89
 
        string_free(ANGBAND_DIR);
90
 
 
91
82
        /* Free the sub-paths */
92
83
        string_free(ANGBAND_DIR_APEX);
93
 
        string_free(ANGBAND_DIR_BONE);
94
 
        string_free(ANGBAND_DIR_DATA);
95
84
        string_free(ANGBAND_DIR_EDIT);
96
85
        string_free(ANGBAND_DIR_FILE);
97
86
        string_free(ANGBAND_DIR_HELP);
109
98
 
110
99
        /*** Prepare the paths ***/
111
100
 
112
 
        /* Save the main directory */
113
 
        ANGBAND_DIR = string_make(path);
114
 
 
115
101
        /* Build path names */
116
 
        ANGBAND_DIR_EDIT = string_make(format("%sedit", path));
117
 
        ANGBAND_DIR_FILE = string_make(format("%sfile", path));
118
 
        ANGBAND_DIR_HELP = string_make(format("%shelp", path));
119
 
        ANGBAND_DIR_INFO = string_make(format("%sinfo", path));
120
 
        ANGBAND_DIR_PREF = string_make(format("%spref", path));
121
 
        ANGBAND_DIR_XTRA = string_make(format("%sxtra", path));
 
102
        ANGBAND_DIR_EDIT = string_make(format("%sedit", configpath));
 
103
        ANGBAND_DIR_FILE = string_make(format("%sfile", libpath));
 
104
        ANGBAND_DIR_HELP = string_make(format("%shelp", libpath));
 
105
        ANGBAND_DIR_INFO = string_make(format("%sinfo", libpath));
 
106
        ANGBAND_DIR_PREF = string_make(format("%spref", configpath));
 
107
        ANGBAND_DIR_XTRA = string_make(format("%sxtra", libpath));
122
108
 
123
109
        /* Build xtra/ paths */
124
110
        ANGBAND_DIR_XTRA_FONT = string_make(format("%s" PATH_SEP "font", ANGBAND_DIR_XTRA));
133
119
        path_build(buf, sizeof(buf), PRIVATE_USER_PATH, VERSION_NAME);
134
120
        ANGBAND_DIR_USER = string_make(buf);
135
121
 
136
 
#else /* PRIVATE_USER_PATH */
 
122
#else /* !PRIVATE_USER_PATH */
137
123
 
138
 
        ANGBAND_DIR_USER = string_make(format("%suser", path));
 
124
        ANGBAND_DIR_USER = string_make(format("%suser", datapath));
139
125
 
140
126
#endif /* PRIVATE_USER_PATH */
141
127
 
147
133
        ANGBAND_DIR_APEX = string_make(buf);
148
134
 
149
135
        /* Build the path to the user specific sub-directory */
150
 
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "bone");
151
 
        ANGBAND_DIR_BONE = string_make(buf);
152
 
 
153
 
        /* Build the path to the user specific sub-directory */
154
 
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "data");
155
 
        ANGBAND_DIR_DATA = string_make(buf);
156
 
 
157
 
        /* Build the path to the user specific sub-directory */
158
136
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "save");
159
137
        ANGBAND_DIR_SAVE = string_make(buf);
160
138
 
161
 
#else /* USE_PRIVATE_PATHS */
 
139
#else /* !USE_PRIVATE_PATHS */
162
140
 
163
141
        /* Build pathnames */
164
 
        ANGBAND_DIR_APEX = string_make(format("%sapex", path));
165
 
        ANGBAND_DIR_BONE = string_make(format("%sbone", path));
166
 
        ANGBAND_DIR_DATA = string_make(format("%sdata", path));
167
 
        ANGBAND_DIR_SAVE = string_make(format("%ssave", path));
 
142
        ANGBAND_DIR_APEX = string_make(format("%sapex", datapath));
 
143
        ANGBAND_DIR_SAVE = string_make(format("%ssave", datapath));
168
144
 
169
145
#endif /* USE_PRIVATE_PATHS */
170
146
}
171
147
 
172
148
 
173
 
#ifdef PRIVATE_USER_PATH
174
 
 
175
149
/*
176
 
 * Create an ".angband/" directory in the users home directory.
 
150
 * Create any missing directories. We create only those dirs which may be
 
151
 * empty (user/, save/, apex/, info/, help/). The others are assumed 
 
152
 * to contain required files and therefore must exist at startup 
 
153
 * (edit/, pref/, file/, xtra/).
177
154
 *
178
 
 * ToDo: Add error handling.
179
155
 * ToDo: Only create the directories when actually writing files.
180
156
 */
181
 
void create_user_dirs(void)
 
157
void create_needed_dirs(void)
182
158
{
183
 
        char dirpath[1024];
184
 
        char subdirpath[1024];
185
 
 
186
 
 
187
 
        /* Get an absolute path from the filename */
188
 
        path_build(dirpath, sizeof(dirpath), PRIVATE_USER_PATH, "");
189
 
 
190
 
        /* Create the ~/.angband/ directory */
191
 
        mkdir(dirpath, 0700);
192
 
 
193
 
        /* Build the path to the variant-specific sub-directory */
194
 
        path_build(subdirpath, sizeof(subdirpath), dirpath, VERSION_NAME);
195
 
 
196
 
        /* Create the directory */
197
 
        mkdir(subdirpath, 0700);
198
 
 
199
 
#ifdef USE_PRIVATE_PATHS
200
 
        /* Build the path to the scores sub-directory */
201
 
        path_build(dirpath, sizeof(dirpath), subdirpath, "scores");
202
 
 
203
 
        /* Create the directory */
204
 
        mkdir(dirpath, 0700);
205
 
 
206
 
        /* Build the path to the savefile sub-directory */
207
 
        path_build(dirpath, sizeof(dirpath), subdirpath, "bone");
208
 
 
209
 
        /* Create the directory */
210
 
        mkdir(dirpath, 0700);
211
 
 
212
 
        /* Build the path to the savefile sub-directory */
213
 
        path_build(dirpath, sizeof(dirpath), subdirpath, "data");
214
 
 
215
 
        /* Create the directory */
216
 
        mkdir(dirpath, 0700);
217
 
 
218
 
        /* Build the path to the savefile sub-directory */
219
 
        path_build(dirpath, sizeof(dirpath), subdirpath, "save");
220
 
 
221
 
        /* Create the directory */
222
 
        mkdir(dirpath, 0700);
223
 
#endif /* USE_PRIVATE_PATHS */
 
159
        char dirpath[512];
 
160
 
 
161
        path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_USER, "");
 
162
        if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
 
163
 
 
164
        path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_SAVE, "");
 
165
        if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
 
166
 
 
167
        path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_APEX, "");
 
168
        if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
 
169
 
 
170
        path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_INFO, "");
 
171
        if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
 
172
 
 
173
        path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_HELP, "");
 
174
        if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
224
175
}
225
176
 
226
 
#endif /* PRIVATE_USER_PATH */
227
 
 
228
 
 
229
 
 
230
177
 
231
178
/*
232
179
 * Hack -- help give useful error messages
245
192
        "invalid flag specification",
246
193
        "invalid number of items (0-99)",
247
194
        "invalid spell frequency",
 
195
        "invalid random value",
248
196
        "missing colon",
249
197
        "missing field",
250
198
        "missing record header",
282
230
header s_head;
283
231
 
284
232
 
285
 
 
286
 
/*** Initialize from binary image files ***/
287
 
 
288
 
 
289
 
/*
290
 
 * Initialize a "*_info" array, by parsing a binary "image" file
291
 
 */
292
 
static bool init_info_raw(const char *fname, header *head)
293
 
{
294
 
        header test;
295
 
        ang_file *fh = file_open(fname, MODE_READ, -1);
296
 
 
297
 
        if (!fh) return FALSE;
298
 
 
299
 
        /* Read and verify the header */
300
 
        if (!file_read(fh, (char *)(&test), sizeof(header)) ||
301
 
            (test.v_major != head->v_major) ||
302
 
            (test.v_minor != head->v_minor) ||
303
 
            (test.v_patch != head->v_patch) ||
304
 
            (test.v_extra != head->v_extra) ||
305
 
            (test.info_num != head->info_num) ||
306
 
            (test.info_len != head->info_len) ||
307
 
            (test.head_size != head->head_size) ||
308
 
            (test.info_size != head->info_size))
309
 
        {
310
 
                file_close(fh);
311
 
                return FALSE;
312
 
        }
313
 
 
314
 
 
315
 
        /* 
316
 
         * Accept the header - these are the only parts we need to copy
317
 
         * from the saved structure, as the rest is either identical (see
318
 
         * above test), or not restorable (function hooks, data pointers).
319
 
         */
320
 
        head->name_size = test.name_size;
321
 
        head->text_size = test.text_size;
322
 
 
323
 
        /* Allocate and read the "*_info" array */
324
 
        head->info_ptr = C_RNEW(head->info_size, char);
325
 
        file_read(fh, head->info_ptr, head->info_size);
326
 
 
327
 
        if (head->name_size)
328
 
        {
329
 
                /* Allocate and read the "*_name" array */
330
 
                head->name_ptr = C_RNEW(head->name_size, char);
331
 
                file_read(fh, head->name_ptr, head->name_size);
332
 
        }
333
 
 
334
 
        if (head->text_size)
335
 
        {
336
 
                /* Allocate and read the "*_text" array */
337
 
                head->text_ptr = C_RNEW(head->text_size, char);
338
 
                file_read(fh, head->text_ptr, head->text_size);
339
 
        }
340
 
 
341
 
        file_close(fh);
342
 
        return TRUE;
343
 
}
344
 
 
345
 
 
346
 
/*
347
 
 * Initialize the header of an *_info.raw file.
 
233
/*
 
234
 * Initialize the header of an *_info array.
348
235
 */
349
236
static void init_header(header *head, int num, int len)
350
237
{
351
 
        /* Save the "version" */
352
 
        head->v_major = VERSION_MAJOR;
353
 
        head->v_minor = VERSION_MINOR;
354
 
        head->v_patch = VERSION_PATCH;
355
 
        head->v_extra = VERSION_EXTRA;
356
 
 
357
 
        /* Save the "record" information */
358
 
        head->info_num = num;
359
 
        head->info_len = len;
360
 
 
361
 
        /* Save the size of "*_head" and "*_info" */
362
 
        head->head_size = sizeof(header);
363
 
        head->info_size = head->info_num * head->info_len;
364
 
 
365
 
        /* Clear post-parsing evaluation function */
366
 
        head->eval_info_post = NULL;
367
 
        
368
 
        /* Clear the template emission functions */
369
 
        head->emit_info_txt_index = NULL;
370
 
        head->emit_info_txt_always = NULL;
 
238
       /* Save the "version" */
 
239
       head->v_major = VERSION_MAJOR;
 
240
       head->v_minor = VERSION_MINOR;
 
241
       head->v_patch = VERSION_PATCH;
 
242
       head->v_extra = VERSION_EXTRA;
 
243
 
 
244
       /* Save the "record" information */
 
245
       head->info_num = num;
 
246
       head->info_len = len;
 
247
 
 
248
       /* Save the size of "*_head" and "*_info" */
 
249
       head->head_size = sizeof(header);
 
250
       head->info_size = head->info_num * head->info_len;
 
251
 
 
252
       /* Clear post-parsing evaluation function */
 
253
       head->eval_info_post = NULL;
 
254
 
 
255
       /* Clear the template emission functions */
 
256
       head->emit_info_txt_index = NULL;
 
257
       head->emit_info_txt_always = NULL;
371
258
}
372
259
 
373
260
 
404
291
 
405
292
        errr err = 1;
406
293
 
407
 
        char raw_file[1024];
408
294
        char txt_file[1024];
409
295
 
410
296
        char buf[1024];
411
297
 
 
298
        void *fake_name;
 
299
        void *fake_text;
412
300
 
413
 
        /* Build the filenames */
414
 
        path_build(raw_file, sizeof(raw_file), ANGBAND_DIR_DATA, format("%s.raw", filename));
 
301
        /* Build the filename */
415
302
        path_build(txt_file, sizeof(txt_file), ANGBAND_DIR_EDIT, format("%s.txt", filename));
416
303
 
417
 
 
418
 
#ifdef ALLOW_TEMPLATES
419
 
 
420
 
        /* If the raw file's more recent than the text file, load it */
421
 
        if (file_newer(raw_file, txt_file) &&
422
 
            init_info_raw(raw_file, head))
423
 
        {
424
 
                /* Post processing the data */
425
 
                if (head->eval_info_post) eval_info(head->eval_info_post, head);
426
 
                return 0;
427
 
        }
428
 
 
429
 
 
430
 
        /*** Make the fake arrays ***/
431
 
 
432
304
        /* Allocate the "*_info" array */
433
305
        head->info_ptr = C_ZNEW(head->info_size, char);
434
306
 
457
329
        /* Post processing the data */
458
330
        if (head->eval_info_post) eval_info(head->eval_info_post, head);
459
331
 
460
 
#ifdef ALLOW_TEMPLATES_OUTPUT
461
332
 
462
333
        /*** Output a 'parsable' ascii template file ***/
463
334
        if ((head->emit_info_txt_index) || (head->emit_info_txt_always))
482
353
                file_close(fout);
483
354
        }
484
355
 
485
 
#endif
486
 
 
487
 
 
488
 
        /*** Dump the binary image file ***/
489
 
 
490
 
        safe_setuid_grab();
491
 
        fh = file_open(raw_file, MODE_WRITE, FTYPE_RAW);
492
 
        safe_setuid_drop();
493
 
 
494
 
        /* Failure */
495
 
        if (!fh)
496
 
        {
497
 
                plog_fmt("Cannot write the '%s' file!", raw_file);
498
 
                return (0);
499
 
        }
500
 
 
501
 
        /* Dump it */
502
 
        file_write(fh, (const char *) head, head->head_size);
503
 
 
504
 
        /* Dump the "*_info" array */
505
 
        if (head->info_size > 0)
506
 
                file_write(fh, head->info_ptr, head->info_size);
507
 
 
508
 
        /* Dump the "*_name" array */
509
 
        if (head->name_size > 0)
510
 
                file_write(fh, head->name_ptr, head->name_size);
511
 
 
512
 
        /* Dump the "*_text" array */
513
 
        if (head->text_size > 0)
514
 
                file_write(fh, head->text_ptr, head->text_size);
515
 
 
516
 
        /* Close */
517
 
        file_close(fh);
518
 
 
519
 
 
520
 
        /*** Kill the fake arrays ***/
521
 
 
522
 
        /* Free the "*_info" array */
523
 
        FREE(head->info_ptr);
524
 
 
525
 
        /* MegaHack -- Free the "fake" arrays */
 
356
        /* Copy the parsed data into the real array from the fakes */
 
357
        fake_name = head->name_ptr;
 
358
        head->name_ptr = C_ZNEW(head->name_size, char);
 
359
        memcpy(head->name_ptr, fake_name, head->name_size);
 
360
 
 
361
        fake_text = head->text_ptr;
 
362
        head->text_ptr = C_ZNEW(head->text_size, char);
 
363
        memcpy(head->text_ptr, fake_text, head->text_size);
 
364
 
 
365
        /* Free the fake arrays */
526
366
        if (z_info)
527
367
        {
528
 
                FREE(head->name_ptr);
529
 
                FREE(head->text_ptr);
 
368
                FREE(fake_name);
 
369
                FREE(fake_text);
530
370
        }
531
371
 
532
 
 
533
 
#endif /* ALLOW_TEMPLATES */
534
 
 
535
 
 
536
 
        /*** Load the binary image file ***/
537
 
 
538
 
        if (!init_info_raw(raw_file, head))
539
 
                quit(format("Cannot load '%s.raw' file.", filename));
540
 
 
541
 
 
542
372
        /* Success */
543
373
        return (0);
544
374
}
573
403
        /* Init the header */
574
404
        init_header(&z_head, 1, sizeof(maxima));
575
405
 
576
 
#ifdef ALLOW_TEMPLATES
577
 
 
578
406
        /* Save a pointer to the parsing function */
579
407
        z_head.parse_info_txt = parse_z_info;
580
408
 
581
 
#endif /* ALLOW_TEMPLATES */
582
 
 
583
409
        err = init_info("limits", &z_head);
584
410
 
585
411
        /* Set the global variables */
599
425
        /* Init the header */
600
426
        init_header(&f_head, z_info->f_max, sizeof(feature_type));
601
427
 
602
 
#ifdef ALLOW_TEMPLATES
603
 
 
604
428
        /* Save a pointer to the parsing function */
605
429
        f_head.parse_info_txt = parse_f_info;
606
430
 
607
 
#endif /* ALLOW_TEMPLATES */
608
 
 
609
431
        err = init_info("terrain", &f_head);
610
432
 
611
433
        /* Set the global variables */
628
450
        /* Init the header */
629
451
        init_header(&k_head, z_info->k_max, sizeof(object_kind));
630
452
 
631
 
#ifdef ALLOW_TEMPLATES
632
 
 
633
453
        /* Save a pointer to the parsing function */
634
454
        k_head.parse_info_txt = parse_k_info;
635
455
 
636
 
#endif /* ALLOW_TEMPLATES */
637
 
 
638
456
        err = init_info("object", &k_head);
639
457
 
640
458
        /* Set the global variables */
657
475
        /* Init the header */
658
476
        init_header(&a_head, z_info->a_max, sizeof(artifact_type));
659
477
 
660
 
#ifdef ALLOW_TEMPLATES
661
 
 
662
478
        /* Save a pointer to the parsing function */
663
479
        a_head.parse_info_txt = parse_a_info;
664
480
 
665
 
#endif /* ALLOW_TEMPLATES */
666
 
 
667
481
        err = init_info("artifact", &a_head);
668
482
 
669
483
        /* Set the global variables */
686
500
        /* Init the header */
687
501
        init_header(&e_head, z_info->e_max, sizeof(ego_item_type));
688
502
 
689
 
#ifdef ALLOW_TEMPLATES
690
 
 
691
503
        /* Save a pointer to the parsing function */
692
504
        e_head.parse_info_txt = parse_e_info;
693
505
 
694
506
        /* Save a pointer to the slay cache function */
695
507
        e_head.eval_info_post = eval_e_slays;
696
508
 
697
 
#endif /* ALLOW_TEMPLATES */
698
 
 
699
509
        err = init_info("ego_item", &e_head);
700
510
 
701
511
        /* Set the global variables */
702
512
        e_info = e_head.info_ptr;
703
513
        e_name = e_head.name_ptr;
704
514
        e_text = e_head.text_ptr;
705
 
 
706
515
        return (err);
707
516
}
708
517
 
719
528
        /* Init the header */
720
529
        init_header(&r_head, z_info->r_max, sizeof(monster_race));
721
530
 
722
 
#ifdef ALLOW_TEMPLATES
723
 
 
724
531
        /* Save a pointer to the parsing function */
725
532
        r_head.parse_info_txt = parse_r_info;
726
533
 
727
534
        /* Save a pointer to the evaluate power function*/
728
535
        r_head.eval_info_post = eval_r_power;
729
536
 
730
 
#ifdef ALLOW_TEMPLATES_OUTPUT
731
 
 
732
 
        /* Save a pointer to the evaluate power function*/
733
 
        r_head.emit_info_txt_index = emit_r_info_index;
734
 
#endif /* ALLOW_TEMPLATES_OUTPUT */
735
 
 
736
 
#endif /* ALLOW_TEMPLATES */
 
537
        /* Save a pointer to the text file output function*/
 
538
        if (arg_rebalance) r_head.emit_info_txt_index = emit_r_info_index;
737
539
 
738
540
        err = init_info("monster", &r_head);
739
541
 
762
564
        /* Init the header */
763
565
        init_header(&v_head, z_info->v_max, sizeof(vault_type));
764
566
 
765
 
#ifdef ALLOW_TEMPLATES
766
 
 
767
567
        /* Save a pointer to the parsing function */
768
568
        v_head.parse_info_txt = parse_v_info;
769
569
 
770
 
#endif /* ALLOW_TEMPLATES */
771
 
 
772
570
        err = init_info("vault", &v_head);
773
571
 
774
572
        /* Set the global variables */
790
588
        /* Init the header */
791
589
        init_header(&p_head, z_info->p_max, sizeof(player_race));
792
590
 
793
 
#ifdef ALLOW_TEMPLATES
794
 
 
795
591
        /* Save a pointer to the parsing function */
796
592
        p_head.parse_info_txt = parse_p_info;
797
593
 
798
 
#endif /* ALLOW_TEMPLATES */
799
 
 
800
594
        err = init_info("p_race", &p_head);
801
595
 
802
596
        /* Set the global variables */
818
612
        /* Init the header */
819
613
        init_header(&c_head, z_info->c_max, sizeof(player_class));
820
614
 
821
 
#ifdef ALLOW_TEMPLATES
822
 
 
823
615
        /* Save a pointer to the parsing function */
824
616
        c_head.parse_info_txt = parse_c_info;
825
617
 
826
 
#endif /* ALLOW_TEMPLATES */
827
 
 
828
618
        err = init_info("p_class", &c_head);
829
619
 
830
620
        /* Set the global variables */
847
637
        /* Init the header */
848
638
        init_header(&h_head, z_info->h_max, sizeof(hist_type));
849
639
 
850
 
#ifdef ALLOW_TEMPLATES
851
 
 
852
640
        /* Save a pointer to the parsing function */
853
641
        h_head.parse_info_txt = parse_h_info;
854
642
 
855
 
#endif /* ALLOW_TEMPLATES */
856
 
 
857
643
        err = init_info("p_hist", &h_head);
858
644
 
859
645
        /* Set the global variables */
875
661
        /* Init the header */
876
662
        init_header(&b_head, (u16b)(MAX_STORES * z_info->b_max), sizeof(owner_type));
877
663
 
878
 
#ifdef ALLOW_TEMPLATES
879
 
 
880
664
        /* Save a pointer to the parsing function */
881
665
        b_head.parse_info_txt = parse_b_info;
882
666
 
883
 
#endif /* ALLOW_TEMPLATES */
884
 
 
885
667
        err = init_info("shop_own", &b_head);
886
668
 
887
669
        /* Set the global variables */
904
686
        /* Init the header */
905
687
        init_header(&flavor_head, z_info->flavor_max, sizeof(flavor_type));
906
688
 
907
 
#ifdef ALLOW_TEMPLATES
908
 
 
909
689
        /* Save a pointer to the parsing function */
910
690
        flavor_head.parse_info_txt = parse_flavor_info;
911
691
 
912
 
#endif /* ALLOW_TEMPLATES */
913
 
 
914
692
        err = init_info("flavor", &flavor_head);
915
693
 
916
694
        /* Set the global variables */
933
711
        /* Init the header */
934
712
        init_header(&s_head, z_info->s_max, sizeof(spell_type));
935
713
 
936
 
#ifdef ALLOW_TEMPLATES
937
 
 
938
714
        /* Save a pointer to the parsing function */
939
715
        s_head.parse_info_txt = parse_s_info;
940
716
 
941
 
#endif /* ALLOW_TEMPLATES */
942
 
 
943
717
        err = init_info("spell", &s_head);
944
718
 
945
719
        /* Set the global variables */
1009
783
}
1010
784
 
1011
785
 
 
786
/*
 
787
 * Initialise random name fragments, from the edit file.
 
788
 */
 
789
static void init_names(void)
 
790
{
 
791
        errr err;
 
792
        char filename[1024];
 
793
        char buf[1024];
 
794
        ang_file *fh;
 
795
 
 
796
        path_build(filename, sizeof(filename), ANGBAND_DIR_EDIT, "names.txt");
 
797
 
 
798
        /* Open the file */
 
799
        fh = file_open(filename, MODE_READ, -1);
 
800
        if (!fh) quit("Cannot open 'names.txt' file.");
 
801
 
 
802
        /* Parse the file */
 
803
        err = init_names_txt(fh, buf);
 
804
        file_close(fh);
 
805
 
 
806
        /* Errors */
 
807
        if (err) display_parse_error("names", err, buf);
 
808
 
 
809
        return;
 
810
}
 
811
 
 
812
 
1012
813
/*** Initialize others ***/
1013
814
 
1014
815
static void autoinscribe_init(void)
1113
914
        /*** Prepare the inventory ***/
1114
915
 
1115
916
        /* Allocate it */
1116
 
        inventory = C_ZNEW(INVEN_TOTAL, object_type);
 
917
        inventory = C_ZNEW(ALL_INVEN_TOTAL, object_type);
1117
918
 
1118
919
 
1119
920
 
1446
1247
        event_signal_string(EVENT_INITSTATUS, "Initializing arrays... (store stocks)");
1447
1248
        init_stores();
1448
1249
 
 
1250
        /* Initialise random name data */
 
1251
        event_signal_string(EVENT_INITSTATUS, "Initializing arrays... (random names)");
 
1252
        init_names();
 
1253
 
1449
1254
        /* Initialize some other arrays */
1450
1255
        event_signal_string(EVENT_INITSTATUS, "Initializing arrays... (other)");
1451
1256
        if (init_other()) quit("Cannot initialize other stuff");
1583
1388
        vformat_kill();
1584
1389
 
1585
1390
        /* Free the directories */
1586
 
        string_free(ANGBAND_DIR);
1587
1391
        string_free(ANGBAND_DIR_APEX);
1588
 
        string_free(ANGBAND_DIR_BONE);
1589
 
        string_free(ANGBAND_DIR_DATA);
1590
1392
        string_free(ANGBAND_DIR_EDIT);
1591
1393
        string_free(ANGBAND_DIR_FILE);
1592
1394
        string_free(ANGBAND_DIR_HELP);