OSDN Git Service

[Refactor] #40014 Separated place-monster-types.h from monster.h
[hengband/hengband.git] / src / info-reader / vault-reader.c
1 #include "info-reader/vault-reader.h"
2 #include "room/rooms-vault.h"
3
4 /*!
5  * @brief Vault情報(v_info)のパース関数 /
6  * Initialize the "v_info" array, by parsing an ascii "template" file
7  * @param buf テキスト列
8  * @param head ヘッダ構造体
9  * @return エラーコード
10  */
11 errr parse_v_info(char *buf, angband_header *head)
12 {
13     char *s;
14     static vault_type *v_ptr = NULL;
15
16     if (buf[0] == 'N') {
17         s = my_strchr(buf + 2, ':');
18         if (!s)
19             return 1;
20
21         *s++ = '\0';
22         if (!*s)
23             return 1;
24
25         int i = atoi(buf + 2);
26         if (i <= error_idx)
27             return 4;
28         if (i >= head->info_num)
29             return 2;
30
31         error_idx = i;
32         v_ptr = &v_info[i];
33         if (!add_name(&v_ptr->name, head, s))
34             return 7;
35     } else if (!v_ptr)
36         return 3;
37     else if (buf[0] == 'D') {
38         s = buf + 2;
39         if (!add_text(&v_ptr->text, head, s, FALSE))
40             return 7;
41     } else if (buf[0] == 'X') {
42         EFFECT_ID typ, rat, hgt, wid;
43         if (4 != sscanf(buf + 2, "%d:%d:%d:%d", &typ, &rat, &hgt, &wid))
44             return 1;
45
46         v_ptr->typ = (ROOM_IDX)typ;
47         v_ptr->rat = (PROB)rat;
48         v_ptr->hgt = (POSITION)hgt;
49         v_ptr->wid = (POSITION)wid;
50     } else
51         return 6;
52
53     return 0;
54 }