annotate system/system_config.cc @ 69:c3d4f9ee2cf1

Convert the last non-Unicode japanese comments.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 01 Apr 2011 22:15:37 +0200
parents 4416cfac86ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /* system_config.cc
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
2 * gameexe.ini ファイルの読み込み
0
223b71206888 Initial import
thib
parents:
diff changeset
3 */
223b71206888 Initial import
thib
parents:
diff changeset
4
223b71206888 Initial import
thib
parents:
diff changeset
5 /*
223b71206888 Initial import
thib
parents:
diff changeset
6 *
223b71206888 Initial import
thib
parents:
diff changeset
7 * Copyright (C) 2000- Kazunori Ueno(JAGARL) <jagarl@creator.club.ne.jp>
223b71206888 Initial import
thib
parents:
diff changeset
8 *
223b71206888 Initial import
thib
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
223b71206888 Initial import
thib
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
223b71206888 Initial import
thib
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
223b71206888 Initial import
thib
parents:
diff changeset
12 * (at your option) any later version.
223b71206888 Initial import
thib
parents:
diff changeset
13 *
223b71206888 Initial import
thib
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
223b71206888 Initial import
thib
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
223b71206888 Initial import
thib
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223b71206888 Initial import
thib
parents:
diff changeset
17 * GNU General Public License for more details.
223b71206888 Initial import
thib
parents:
diff changeset
18 *
27
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 26
diff changeset
19 * You should have received a copy of the GNU General Public License along
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 26
diff changeset
20 * with this program; if not, write to the Free Software Foundation, Inc.,
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 26
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0
223b71206888 Initial import
thib
parents:
diff changeset
22 *
223b71206888 Initial import
thib
parents:
diff changeset
23 */
223b71206888 Initial import
thib
parents:
diff changeset
24
223b71206888 Initial import
thib
parents:
diff changeset
25 #include <stdio.h>
223b71206888 Initial import
thib
parents:
diff changeset
26 #include <string.h>
223b71206888 Initial import
thib
parents:
diff changeset
27 #include <stdlib.h>
223b71206888 Initial import
thib
parents:
diff changeset
28 #include <stdarg.h>
223b71206888 Initial import
thib
parents:
diff changeset
29 #include <ctype.h>
223b71206888 Initial import
thib
parents:
diff changeset
30 #include <map>
223b71206888 Initial import
thib
parents:
diff changeset
31 #include <string>
223b71206888 Initial import
thib
parents:
diff changeset
32 #include "system_config.h"
223b71206888 Initial import
thib
parents:
diff changeset
33 #include "../system/file.h"
223b71206888 Initial import
thib
parents:
diff changeset
34
223b71206888 Initial import
thib
parents:
diff changeset
35 using namespace std;
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 // #define DEBUG_CONFIG
223b71206888 Initial import
thib
parents:
diff changeset
38 #ifdef DEBUG_CONFIG
223b71206888 Initial import
thib
parents:
diff changeset
39 # define dprintf(X) printf X
223b71206888 Initial import
thib
parents:
diff changeset
40 #else
223b71206888 Initial import
thib
parents:
diff changeset
41 # define dprintf(X)
223b71206888 Initial import
thib
parents:
diff changeset
42 #endif /* DEBUG_CONFIG */
223b71206888 Initial import
thib
parents:
diff changeset
43
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
44 #define MAXTOKEN 10 /* = で区切られた領域の最大数 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
45 #define MAXVARS 32 /* , で区切られた数値の最大数 */
0
223b71206888 Initial import
thib
parents:
diff changeset
46
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
47 // 初期化ファイルの読み込み
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
48 /* config は 文字列、数列、その複合など、いろいろな形式がありうる */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
49 /* 文字列と数列は一般に AyuSys_Config クラスに含める */
0
223b71206888 Initial import
thib
parents:
diff changeset
50
223b71206888 Initial import
thib
parents:
diff changeset
51
223b71206888 Initial import
thib
parents:
diff changeset
52 /**********************************************************/
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
53 /* とりあえずハッシュ比較付き文字列 */
0
223b71206888 Initial import
thib
parents:
diff changeset
54 class HashStr {
223b71206888 Initial import
thib
parents:
diff changeset
55 const char* str;
223b71206888 Initial import
thib
parents:
diff changeset
56 unsigned int hash;
223b71206888 Initial import
thib
parents:
diff changeset
57 public:
223b71206888 Initial import
thib
parents:
diff changeset
58 HashStr(const char*);
223b71206888 Initial import
thib
parents:
diff changeset
59 HashStr(const HashStr& orig);
223b71206888 Initial import
thib
parents:
diff changeset
60 ~HashStr() {
223b71206888 Initial import
thib
parents:
diff changeset
61 if (str) delete[] str;
223b71206888 Initial import
thib
parents:
diff changeset
62 }
223b71206888 Initial import
thib
parents:
diff changeset
63 const char* c_str(void) const { return str; }
223b71206888 Initial import
thib
parents:
diff changeset
64 friend inline int operator<(const HashStr& a, const HashStr& b) {
223b71206888 Initial import
thib
parents:
diff changeset
65 if (a.hash == b.hash) {
223b71206888 Initial import
thib
parents:
diff changeset
66 if (a.str == 0) return 1;
223b71206888 Initial import
thib
parents:
diff changeset
67 else if (b.str == 0) return 0;
223b71206888 Initial import
thib
parents:
diff changeset
68 else return strcmp(a.str, b.str);
223b71206888 Initial import
thib
parents:
diff changeset
69 }
223b71206888 Initial import
thib
parents:
diff changeset
70 else return a.hash < b.hash;
223b71206888 Initial import
thib
parents:
diff changeset
71 }
223b71206888 Initial import
thib
parents:
diff changeset
72 };
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
73
0
223b71206888 Initial import
thib
parents:
diff changeset
74 HashStr::HashStr(const char* s ) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
75 if (s == NULL || s[0] == '\0') {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
76 str = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
77 hash = 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
78 return; /* invalid string */
0
223b71206888 Initial import
thib
parents:
diff changeset
79 }
223b71206888 Initial import
thib
parents:
diff changeset
80 char* new_str = new char[strlen(s)+1];
223b71206888 Initial import
thib
parents:
diff changeset
81 strcpy(new_str, s);
223b71206888 Initial import
thib
parents:
diff changeset
82 str = new_str;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
83 /* calc hash... 適当 */
0
223b71206888 Initial import
thib
parents:
diff changeset
84 int h = strlen(s);
223b71206888 Initial import
thib
parents:
diff changeset
85 while(*s != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
86 h = *s + ((h * (0x9449+*s))>>7);
223b71206888 Initial import
thib
parents:
diff changeset
87 s++;
223b71206888 Initial import
thib
parents:
diff changeset
88 }
223b71206888 Initial import
thib
parents:
diff changeset
89 hash = (unsigned int)h;
223b71206888 Initial import
thib
parents:
diff changeset
90 }
223b71206888 Initial import
thib
parents:
diff changeset
91 HashStr::HashStr(const HashStr& orig) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
92 if (orig.str == NULL || orig.str[0] == '\0') {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
93 str = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
94 hash = 0; return; /* invalid */
0
223b71206888 Initial import
thib
parents:
diff changeset
95 }
223b71206888 Initial import
thib
parents:
diff changeset
96 char* new_str = new char[strlen(orig.str)+1];
223b71206888 Initial import
thib
parents:
diff changeset
97 strcpy(new_str, orig.str);
223b71206888 Initial import
thib
parents:
diff changeset
98 str = new_str;
223b71206888 Initial import
thib
parents:
diff changeset
99 hash = orig.hash;
223b71206888 Initial import
thib
parents:
diff changeset
100 }
223b71206888 Initial import
thib
parents:
diff changeset
101
223b71206888 Initial import
thib
parents:
diff changeset
102 /**********************************************************
223b71206888 Initial import
thib
parents:
diff changeset
103 **AyuSys_Config_[String | Intlist] :
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
104 ** 設定の本体
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
105 ** original : 元設定
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
106 ** old_data : 前回 ClearDiff() したときの設定
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
107 ** new_data : ClearDiff() 以降に設定した内容を保存
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
108 ** データ設定:
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
109 ** Init() : 元設定を作成
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
110 ** Set() : 設定を変更
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
111 ** Get() : 最も新しい設定を得る
0
223b71206888 Initial import
thib
parents:
diff changeset
112 **
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
113 ** 変更の記録:
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
114 ** Diff() : 前回のClearDiff() から変更した内容を得る
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
115 ** DiffLen() : Diff() で必要な文字列長を得る
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
116 ** ClearDiff() : 変更記録を消す
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
117 ** PatchOld() : Diff() で得た記録に基づき、変更前の状態に戻す
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
118 ** PatchNew() : Diff() で得た記録に基づき、変更後の状態に戻す
0
223b71206888 Initial import
thib
parents:
diff changeset
119 **
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
120 ** 元設定からの変更の記録:
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
121 ** SetOriginal() : 元設定に戻す
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
122 ** DiffOriginal() : 元設定から現在の設定の変更を得る
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
123 ** DiffOriginalLen() : DiffOriginal() で必要な文字列長を得る
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
124 ** PatchOriginal() : DiffOriginal() で得た記録に基づき、設定を復旧する
0
223b71206888 Initial import
thib
parents:
diff changeset
125 */
223b71206888 Initial import
thib
parents:
diff changeset
126
223b71206888 Initial import
thib
parents:
diff changeset
127 /************************************************
223b71206888 Initial import
thib
parents:
diff changeset
128 ** AyuSysConfigStringItem
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
129 ** 文字列をデータとしてもつ設定項目
0
223b71206888 Initial import
thib
parents:
diff changeset
130 */
223b71206888 Initial import
thib
parents:
diff changeset
131 class AyuSysConfigStringItem {
223b71206888 Initial import
thib
parents:
diff changeset
132 char* original_data;
223b71206888 Initial import
thib
parents:
diff changeset
133 char* old_data;
223b71206888 Initial import
thib
parents:
diff changeset
134 char* new_data;
223b71206888 Initial import
thib
parents:
diff changeset
135 public:
223b71206888 Initial import
thib
parents:
diff changeset
136 AyuSysConfigStringItem(void) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
137 original_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
138 old_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
139 new_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
140 }
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
141 ~AyuSysConfigStringItem(void) {
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
142 if (original_data) delete[] original_data;
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
143 if (old_data) delete[] old_data;
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
144 if (new_data) delete[] new_data;
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
145 }
0
223b71206888 Initial import
thib
parents:
diff changeset
146 AyuSysConfigStringItem(const AyuSysConfigStringItem& o) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
147 original_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
148 old_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
149 new_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
150 if (o.original_data) {
223b71206888 Initial import
thib
parents:
diff changeset
151 original_data = new char[strlen(o.original_data)+1];
223b71206888 Initial import
thib
parents:
diff changeset
152 strcpy(original_data, o.original_data);
223b71206888 Initial import
thib
parents:
diff changeset
153 }
223b71206888 Initial import
thib
parents:
diff changeset
154 if (o.old_data) {
223b71206888 Initial import
thib
parents:
diff changeset
155 old_data = new char[strlen(o.old_data)+1];
223b71206888 Initial import
thib
parents:
diff changeset
156 strcpy(old_data, o.old_data);
223b71206888 Initial import
thib
parents:
diff changeset
157 }
223b71206888 Initial import
thib
parents:
diff changeset
158 if (o.new_data) {
223b71206888 Initial import
thib
parents:
diff changeset
159 new_data = new char[strlen(o.new_data)+1];
223b71206888 Initial import
thib
parents:
diff changeset
160 strcpy(new_data, o.new_data);
223b71206888 Initial import
thib
parents:
diff changeset
161 }
223b71206888 Initial import
thib
parents:
diff changeset
162 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
163 /* 設定:Init で初期化、Set で変更、Get で変更を優先して取り出す */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
164 void Init(int deal, const char* str) { /* deal は無視 */
0
223b71206888 Initial import
thib
parents:
diff changeset
165 if (original_data) delete[] original_data;
223b71206888 Initial import
thib
parents:
diff changeset
166 int len = strlen(str);
223b71206888 Initial import
thib
parents:
diff changeset
167 original_data = new char[len+1];
223b71206888 Initial import
thib
parents:
diff changeset
168 strcpy(original_data, str);
223b71206888 Initial import
thib
parents:
diff changeset
169 original_data[len] = '\0';
223b71206888 Initial import
thib
parents:
diff changeset
170 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
171 void Set(int deal, const char* str) { /* deal は無視 */
0
223b71206888 Initial import
thib
parents:
diff changeset
172 if (new_data) delete[] new_data;
223b71206888 Initial import
thib
parents:
diff changeset
173 int len = strlen(str);
223b71206888 Initial import
thib
parents:
diff changeset
174 new_data = new char[len+1];
223b71206888 Initial import
thib
parents:
diff changeset
175 strcpy(new_data, str);
223b71206888 Initial import
thib
parents:
diff changeset
176 new_data[len] = '\0';
223b71206888 Initial import
thib
parents:
diff changeset
177 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
178 const char* Get(int deal) const {/* deal は無視 */
0
223b71206888 Initial import
thib
parents:
diff changeset
179 if (new_data) return new_data;
223b71206888 Initial import
thib
parents:
diff changeset
180 else if (old_data) return old_data;
223b71206888 Initial import
thib
parents:
diff changeset
181 return original_data;
223b71206888 Initial import
thib
parents:
diff changeset
182 }
223b71206888 Initial import
thib
parents:
diff changeset
183 const char* GetOriginal(int deal) const {
223b71206888 Initial import
thib
parents:
diff changeset
184 return original_data;
223b71206888 Initial import
thib
parents:
diff changeset
185 }
223b71206888 Initial import
thib
parents:
diff changeset
186 int Deal(void) const {
223b71206888 Initial import
thib
parents:
diff changeset
187 return 1;
223b71206888 Initial import
thib
parents:
diff changeset
188 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
189 /* オリジナルからの変化の調査 :
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
190 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
191 ** 変化を反映
0
223b71206888 Initial import
thib
parents:
diff changeset
192 */
223b71206888 Initial import
thib
parents:
diff changeset
193 int DiffOriginalLen(void) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
194 if (new_data == NULL) return 0;
0
223b71206888 Initial import
thib
parents:
diff changeset
195 return strlen(new_data)+1;
223b71206888 Initial import
thib
parents:
diff changeset
196 }
223b71206888 Initial import
thib
parents:
diff changeset
197 void DiffOriginal(string& data) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
198 if (new_data == NULL) { /* あり得ない */
0
223b71206888 Initial import
thib
parents:
diff changeset
199 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n");
223b71206888 Initial import
thib
parents:
diff changeset
200 return;
223b71206888 Initial import
thib
parents:
diff changeset
201 }
223b71206888 Initial import
thib
parents:
diff changeset
202 char* out_data = new char[strlen(new_data)*2+1];
223b71206888 Initial import
thib
parents:
diff changeset
203 char* buf = out_data;
223b71206888 Initial import
thib
parents:
diff changeset
204 int i;
223b71206888 Initial import
thib
parents:
diff changeset
205 for (i=0; new_data[i]!=0; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
206 switch(new_data[i]) {
223b71206888 Initial import
thib
parents:
diff changeset
207 case '?': *buf++ = '?'; *buf++ = '0'; break;
223b71206888 Initial import
thib
parents:
diff changeset
208 case '"': *buf++ = '?'; *buf++ = '1'; break;
223b71206888 Initial import
thib
parents:
diff changeset
209 case '\'': *buf++ = '?'; *buf++ = '2'; break;
223b71206888 Initial import
thib
parents:
diff changeset
210 case ',': *buf++ = '?'; *buf++ = '3'; break;
223b71206888 Initial import
thib
parents:
diff changeset
211 case '.': *buf++ = '?'; *buf++ = '4'; break;
223b71206888 Initial import
thib
parents:
diff changeset
212 case ':': *buf++ = '?'; *buf++ = '5'; break;
223b71206888 Initial import
thib
parents:
diff changeset
213 case ';': *buf++ = '?'; *buf++ = '6'; break;
223b71206888 Initial import
thib
parents:
diff changeset
214 case '=': *buf++ = '?'; *buf++ = '7'; break;
223b71206888 Initial import
thib
parents:
diff changeset
215 case '<': *buf++ = '?'; *buf++ = '8'; break;
223b71206888 Initial import
thib
parents:
diff changeset
216 case '>': *buf++ = '?'; *buf++ = '9'; break;
223b71206888 Initial import
thib
parents:
diff changeset
217 default: *buf++ = new_data[i]; break;
223b71206888 Initial import
thib
parents:
diff changeset
218 }
223b71206888 Initial import
thib
parents:
diff changeset
219 }
223b71206888 Initial import
thib
parents:
diff changeset
220 *buf++ = 0;
223b71206888 Initial import
thib
parents:
diff changeset
221 data += out_data;
223b71206888 Initial import
thib
parents:
diff changeset
222 delete[] out_data;
223b71206888 Initial import
thib
parents:
diff changeset
223 return;
223b71206888 Initial import
thib
parents:
diff changeset
224 }
223b71206888 Initial import
thib
parents:
diff changeset
225 const char* PatchOriginal(const char* data) {
47
5f548e5957a8 * get rid of the "deprecated conversion from string constant to ‘char*’" warnings
thib
parents: 40
diff changeset
226 static const char* table = "?\"',.:;=<>";
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
227 if (new_data != NULL) delete[] new_data;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
228 if (old_data != NULL) delete[] old_data;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
229 old_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
230 new_data = new char[1024];
223b71206888 Initial import
thib
parents:
diff changeset
231 int i,j = 0;
223b71206888 Initial import
thib
parents:
diff changeset
232 for (i=0; i<1020; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
233 switch(data[j]) {
223b71206888 Initial import
thib
parents:
diff changeset
234 case '?':
223b71206888 Initial import
thib
parents:
diff changeset
235 if (data[j+1] >= '0' && data[j+1] <= '9') {
223b71206888 Initial import
thib
parents:
diff changeset
236 new_data[i] = table[ data[j+1] - '0'];
223b71206888 Initial import
thib
parents:
diff changeset
237 j += 2;
223b71206888 Initial import
thib
parents:
diff changeset
238 break;
223b71206888 Initial import
thib
parents:
diff changeset
239 }
223b71206888 Initial import
thib
parents:
diff changeset
240 case '"': case '\'': case ',': case '.': case ':':
223b71206888 Initial import
thib
parents:
diff changeset
241 case ';': case '=': case '<': case '>':
223b71206888 Initial import
thib
parents:
diff changeset
242 goto for_end;
223b71206888 Initial import
thib
parents:
diff changeset
243 default: new_data[i] = data[j++]; break;
223b71206888 Initial import
thib
parents:
diff changeset
244 }
223b71206888 Initial import
thib
parents:
diff changeset
245 }
223b71206888 Initial import
thib
parents:
diff changeset
246 for_end:
223b71206888 Initial import
thib
parents:
diff changeset
247 new_data[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
248 return data;
223b71206888 Initial import
thib
parents:
diff changeset
249 }
223b71206888 Initial import
thib
parents:
diff changeset
250 void SetOriginal(void) {
223b71206888 Initial import
thib
parents:
diff changeset
251 if (new_data) delete[] new_data;
223b71206888 Initial import
thib
parents:
diff changeset
252 if (old_data) delete[] old_data;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
253 new_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
254 old_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
255 }
223b71206888 Initial import
thib
parents:
diff changeset
256 void Dump(FILE* f) const {
223b71206888 Initial import
thib
parents:
diff changeset
257 if (original_data) fprintf(f, "original %s ",original_data);
223b71206888 Initial import
thib
parents:
diff changeset
258 if (old_data) fprintf(f, "old_data %s ",old_data);
223b71206888 Initial import
thib
parents:
diff changeset
259 if (new_data) fprintf(f, "new_data %s ",new_data);
223b71206888 Initial import
thib
parents:
diff changeset
260 fprintf(f, "\n");
223b71206888 Initial import
thib
parents:
diff changeset
261 }
223b71206888 Initial import
thib
parents:
diff changeset
262 };
223b71206888 Initial import
thib
parents:
diff changeset
263
223b71206888 Initial import
thib
parents:
diff changeset
264 /************************************************
223b71206888 Initial import
thib
parents:
diff changeset
265 ** AyuSysConfigIntlistItem
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
266 ** 数値列をデータとしてもつ設定項目
0
223b71206888 Initial import
thib
parents:
diff changeset
267 */
223b71206888 Initial import
thib
parents:
diff changeset
268 class AyuSysConfigIntlistItem {
223b71206888 Initial import
thib
parents:
diff changeset
269 int item_deal;
223b71206888 Initial import
thib
parents:
diff changeset
270 int* original_data;
223b71206888 Initial import
thib
parents:
diff changeset
271 int* old_data;
223b71206888 Initial import
thib
parents:
diff changeset
272 int* new_data;
223b71206888 Initial import
thib
parents:
diff changeset
273 public:
223b71206888 Initial import
thib
parents:
diff changeset
274 AyuSysConfigIntlistItem(void) {
223b71206888 Initial import
thib
parents:
diff changeset
275 item_deal = 0;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
276 original_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
277 old_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
278 new_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
279 }
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
280 ~AyuSysConfigIntlistItem(void) {
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
281 if (original_data) delete[] original_data;
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
282 if (old_data) delete[] old_data;
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
283 if (new_data) delete[] new_data;
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
284 }
0
223b71206888 Initial import
thib
parents:
diff changeset
285 AyuSysConfigIntlistItem(const AyuSysConfigIntlistItem& o) {
223b71206888 Initial import
thib
parents:
diff changeset
286 item_deal = o.item_deal;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
287 original_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
288 old_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
289 new_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
290 if (o.original_data) {
223b71206888 Initial import
thib
parents:
diff changeset
291 original_data = new int[item_deal];
223b71206888 Initial import
thib
parents:
diff changeset
292 memcpy(original_data, o.original_data, sizeof(int)*item_deal);
223b71206888 Initial import
thib
parents:
diff changeset
293 }
223b71206888 Initial import
thib
parents:
diff changeset
294 if (o.old_data) {
223b71206888 Initial import
thib
parents:
diff changeset
295 old_data = new int[item_deal];
223b71206888 Initial import
thib
parents:
diff changeset
296 memcpy(old_data, o.old_data, sizeof(int)*item_deal);
223b71206888 Initial import
thib
parents:
diff changeset
297 }
223b71206888 Initial import
thib
parents:
diff changeset
298 if (o.new_data) {
223b71206888 Initial import
thib
parents:
diff changeset
299 new_data = new int[item_deal];
223b71206888 Initial import
thib
parents:
diff changeset
300 memcpy(new_data, o.new_data, sizeof(int)*item_deal);
223b71206888 Initial import
thib
parents:
diff changeset
301 }
223b71206888 Initial import
thib
parents:
diff changeset
302 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
303 /* 設定:Init で初期化、Set で変更、Get で変更を優先して取り出す */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
304 void Init(int deal, const int* list) { /* deal は無視 */
0
223b71206888 Initial import
thib
parents:
diff changeset
305 if (original_data) delete[] original_data;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
306 original_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
307 if (deal <= 0) {
223b71206888 Initial import
thib
parents:
diff changeset
308 item_deal = 0; return;
223b71206888 Initial import
thib
parents:
diff changeset
309 }
223b71206888 Initial import
thib
parents:
diff changeset
310 item_deal = deal;
223b71206888 Initial import
thib
parents:
diff changeset
311 original_data = new int[item_deal];
223b71206888 Initial import
thib
parents:
diff changeset
312 memcpy(original_data, list, sizeof(int)*deal);
223b71206888 Initial import
thib
parents:
diff changeset
313 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
314 void Set(int deal, const int* list) { /* deal は無視 */
0
223b71206888 Initial import
thib
parents:
diff changeset
315 item_deal = deal;
223b71206888 Initial import
thib
parents:
diff changeset
316 if (new_data) delete[] new_data;
223b71206888 Initial import
thib
parents:
diff changeset
317 new_data = new int[item_deal];
223b71206888 Initial import
thib
parents:
diff changeset
318 memcpy(new_data, list, sizeof(int)*item_deal);
223b71206888 Initial import
thib
parents:
diff changeset
319 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
320 const int* Get(int deal) const {/* deal は無視 */
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
321 if (item_deal == 0) return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
322 if (deal > item_deal) {
223b71206888 Initial import
thib
parents:
diff changeset
323 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
324 return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
325 }
223b71206888 Initial import
thib
parents:
diff changeset
326 if (new_data) return new_data;
223b71206888 Initial import
thib
parents:
diff changeset
327 else if (old_data) return old_data;
223b71206888 Initial import
thib
parents:
diff changeset
328 return original_data;
223b71206888 Initial import
thib
parents:
diff changeset
329 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
330 const int* GetOriginal(int deal) const {/* deal は無視 */
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
331 if (item_deal == 0) return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
332 if (deal > item_deal) {
223b71206888 Initial import
thib
parents:
diff changeset
333 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
334 return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
335 }
223b71206888 Initial import
thib
parents:
diff changeset
336 return original_data;
223b71206888 Initial import
thib
parents:
diff changeset
337 }
223b71206888 Initial import
thib
parents:
diff changeset
338 int Deal(void) const {
223b71206888 Initial import
thib
parents:
diff changeset
339 return item_deal;
223b71206888 Initial import
thib
parents:
diff changeset
340 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
341 /* オリジナルからの変化の調査 :
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
342 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
343 ** 変化を反映
0
223b71206888 Initial import
thib
parents:
diff changeset
344 */
223b71206888 Initial import
thib
parents:
diff changeset
345 int DiffOriginalLen(void) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
346 if (new_data == NULL) return 0;
0
223b71206888 Initial import
thib
parents:
diff changeset
347 return 12 * item_deal + 1;
223b71206888 Initial import
thib
parents:
diff changeset
348 }
223b71206888 Initial import
thib
parents:
diff changeset
349 void DiffOriginal(string& data) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
350 if (new_data == NULL) { /* あり得ない */
0
223b71206888 Initial import
thib
parents:
diff changeset
351 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n");
223b71206888 Initial import
thib
parents:
diff changeset
352 return;
223b71206888 Initial import
thib
parents:
diff changeset
353 }
223b71206888 Initial import
thib
parents:
diff changeset
354 int i; char buf[1024];
223b71206888 Initial import
thib
parents:
diff changeset
355 for (i=0; i<item_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
356 sprintf(buf, "%d,",new_data[i]);
223b71206888 Initial import
thib
parents:
diff changeset
357 data += buf;
223b71206888 Initial import
thib
parents:
diff changeset
358 }
223b71206888 Initial import
thib
parents:
diff changeset
359 return;
223b71206888 Initial import
thib
parents:
diff changeset
360 }
223b71206888 Initial import
thib
parents:
diff changeset
361 const char* PatchOriginal(const char* data) {
223b71206888 Initial import
thib
parents:
diff changeset
362 if (old_data) delete[] old_data;
223b71206888 Initial import
thib
parents:
diff changeset
363 if (new_data) delete[] new_data;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
364 old_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
365 new_data = new int[item_deal];
223b71206888 Initial import
thib
parents:
diff changeset
366 int i;
223b71206888 Initial import
thib
parents:
diff changeset
367 for (i=0; i<item_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
368 new_data[i] = atoi(data);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
369 if (strchr(data, ',') == NULL) break;
0
223b71206888 Initial import
thib
parents:
diff changeset
370 data = strchr(data, ',') + 1;
223b71206888 Initial import
thib
parents:
diff changeset
371 }
223b71206888 Initial import
thib
parents:
diff changeset
372 return data;
223b71206888 Initial import
thib
parents:
diff changeset
373 }
223b71206888 Initial import
thib
parents:
diff changeset
374 void SetOriginal(void) {
223b71206888 Initial import
thib
parents:
diff changeset
375 if (new_data) delete[] new_data;
223b71206888 Initial import
thib
parents:
diff changeset
376 if (old_data) delete[] old_data;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
377 new_data = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
378 old_data = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
379 }
223b71206888 Initial import
thib
parents:
diff changeset
380 void Dump(FILE* f) const {
223b71206888 Initial import
thib
parents:
diff changeset
381 fprintf(f, "item deal %d, ",item_deal);
223b71206888 Initial import
thib
parents:
diff changeset
382 if (original_data) {
223b71206888 Initial import
thib
parents:
diff changeset
383 fprintf(f, "(%d", original_data[0]);
223b71206888 Initial import
thib
parents:
diff changeset
384 int i;for (i=1; i<item_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
385 fprintf(f, ",%d",original_data[i]);
223b71206888 Initial import
thib
parents:
diff changeset
386 }
223b71206888 Initial import
thib
parents:
diff changeset
387 fprintf(f, ") ");
223b71206888 Initial import
thib
parents:
diff changeset
388 }
223b71206888 Initial import
thib
parents:
diff changeset
389 if (old_data) {
48
ed6c21dde840 * use correct format (%p) for pointers
thib
parents: 47
diff changeset
390 fprintf(f, "old %p(%d", old_data, old_data[0]);
0
223b71206888 Initial import
thib
parents:
diff changeset
391 int i;for (i=1; i<item_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
392 fprintf(f, ",%d",old_data[i]);
223b71206888 Initial import
thib
parents:
diff changeset
393 }
223b71206888 Initial import
thib
parents:
diff changeset
394 fprintf(f, ") ");
223b71206888 Initial import
thib
parents:
diff changeset
395 }
223b71206888 Initial import
thib
parents:
diff changeset
396 if (new_data) {
48
ed6c21dde840 * use correct format (%p) for pointers
thib
parents: 47
diff changeset
397 fprintf(f, "new %p(%d", new_data, new_data[0]);
0
223b71206888 Initial import
thib
parents:
diff changeset
398 int i;for (i=1; i<item_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
399 fprintf(f, ",%d",new_data[i]);
223b71206888 Initial import
thib
parents:
diff changeset
400 }
223b71206888 Initial import
thib
parents:
diff changeset
401 fprintf(f, ") ");
223b71206888 Initial import
thib
parents:
diff changeset
402 }
223b71206888 Initial import
thib
parents:
diff changeset
403 fprintf(f, "\n");
223b71206888 Initial import
thib
parents:
diff changeset
404 }
223b71206888 Initial import
thib
parents:
diff changeset
405 };
223b71206888 Initial import
thib
parents:
diff changeset
406
223b71206888 Initial import
thib
parents:
diff changeset
407 // template map<HashStr, AyuSysConfigStringItem>;
223b71206888 Initial import
thib
parents:
diff changeset
408 // template map<HashStr, AyuSysConfigIntlistItem>;
223b71206888 Initial import
thib
parents:
diff changeset
409
223b71206888 Initial import
thib
parents:
diff changeset
410 /************************************************
223b71206888 Initial import
thib
parents:
diff changeset
411 ** AyuSysConfigItem
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
412 ** データ名 -> データ本体の map と、map 全体に
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
413 ** 様々な操作を行うためのメソッド
0
223b71206888 Initial import
thib
parents:
diff changeset
414 */
223b71206888 Initial import
thib
parents:
diff changeset
415
223b71206888 Initial import
thib
parents:
diff changeset
416 template<class ItemType, class DataType> class AyuSysConfigItem {
223b71206888 Initial import
thib
parents:
diff changeset
417 typedef map<HashStr,ItemType> maptype;
223b71206888 Initial import
thib
parents:
diff changeset
418 typedef typename maptype::iterator mapiterator;
223b71206888 Initial import
thib
parents:
diff changeset
419 typedef typename maptype::const_iterator const_mapiterator;
223b71206888 Initial import
thib
parents:
diff changeset
420 maptype data;
223b71206888 Initial import
thib
parents:
diff changeset
421 public:
223b71206888 Initial import
thib
parents:
diff changeset
422 void SetOrig(HashStr& name, int deal, const DataType* str) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
423 if (str == NULL) return; /* 無効 */
0
223b71206888 Initial import
thib
parents:
diff changeset
424 data[name].Init(deal, str);
223b71206888 Initial import
thib
parents:
diff changeset
425 }
223b71206888 Initial import
thib
parents:
diff changeset
426 void Set(HashStr& name, int deal, const DataType* new_data) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
427 if (new_data == NULL) return; /* 無効 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
428 /* 設定を検索 */
0
223b71206888 Initial import
thib
parents:
diff changeset
429 mapiterator it = data.find(name);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
430 /* 設定が元設定に見つからないなら失敗 */
0
223b71206888 Initial import
thib
parents:
diff changeset
431 if (it == data.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
432 fprintf(stderr,"AyuSysConfigItem::Set : there is no '%s' parameter\n",name.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
433 return;
223b71206888 Initial import
thib
parents:
diff changeset
434 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
435 /* 設定を変更 */
0
223b71206888 Initial import
thib
parents:
diff changeset
436 it->second.Set(deal, new_data);
223b71206888 Initial import
thib
parents:
diff changeset
437 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
438 /* 新しい設定を優先して返す */
0
223b71206888 Initial import
thib
parents:
diff changeset
439 const DataType* Get(int deal, HashStr& name) const {
223b71206888 Initial import
thib
parents:
diff changeset
440 const_mapiterator it = data.find(name);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
441 if (it == data.end()) return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
442 return it->second.Get(deal);
223b71206888 Initial import
thib
parents:
diff changeset
443 }
223b71206888 Initial import
thib
parents:
diff changeset
444 const DataType* GetOriginal(int deal, HashStr& name) const {
223b71206888 Initial import
thib
parents:
diff changeset
445 const_mapiterator it = data.find(name);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
446 if (it == data.end()) return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
447 return it->second.GetOriginal(deal);
223b71206888 Initial import
thib
parents:
diff changeset
448 }
223b71206888 Initial import
thib
parents:
diff changeset
449 int Deal(HashStr& name) const {
223b71206888 Initial import
thib
parents:
diff changeset
450 const_mapiterator it = data.find(name);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
451 if (it == data.end()) return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
452 return it->second.Deal();
223b71206888 Initial import
thib
parents:
diff changeset
453 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
454 /* オリジナルからの変化の調査 :
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
455 ** DiffOriginal で変化を文字列で取り出し、PatchOriginal で
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
456 ** 変化を反映
0
223b71206888 Initial import
thib
parents:
diff changeset
457 */
223b71206888 Initial import
thib
parents:
diff changeset
458 void DiffOriginal(string& ret_str) {
223b71206888 Initial import
thib
parents:
diff changeset
459 mapiterator it = data.begin();
223b71206888 Initial import
thib
parents:
diff changeset
460 for (; it != data.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
461 int len = it->second.DiffOriginalLen();
223b71206888 Initial import
thib
parents:
diff changeset
462 if (len) {
223b71206888 Initial import
thib
parents:
diff changeset
463 ret_str += it->first.c_str();
223b71206888 Initial import
thib
parents:
diff changeset
464 ret_str += "=";
223b71206888 Initial import
thib
parents:
diff changeset
465 it->second.DiffOriginal(ret_str);
223b71206888 Initial import
thib
parents:
diff changeset
466 ret_str += ";";
223b71206888 Initial import
thib
parents:
diff changeset
467 }
223b71206888 Initial import
thib
parents:
diff changeset
468 }
223b71206888 Initial import
thib
parents:
diff changeset
469 ret_str += ";";
223b71206888 Initial import
thib
parents:
diff changeset
470 return;
223b71206888 Initial import
thib
parents:
diff changeset
471 }
223b71206888 Initial import
thib
parents:
diff changeset
472 const char* PatchOriginal(const char* diff_data) {
223b71206888 Initial import
thib
parents:
diff changeset
473 while(*diff_data != ';') {
223b71206888 Initial import
thib
parents:
diff changeset
474 char name[1024];
223b71206888 Initial import
thib
parents:
diff changeset
475 const char* data_start = strchr(diff_data, '=');
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
476 if (data_start == NULL) break;
0
223b71206888 Initial import
thib
parents:
diff changeset
477 strncpy(name, diff_data, data_start-diff_data);
223b71206888 Initial import
thib
parents:
diff changeset
478 name[data_start-diff_data] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
479 data_start++;
223b71206888 Initial import
thib
parents:
diff changeset
480 mapiterator it = data.find(name);
223b71206888 Initial import
thib
parents:
diff changeset
481 if (it != data.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
482 diff_data = data_start;
223b71206888 Initial import
thib
parents:
diff changeset
483 it->second.PatchOriginal(diff_data);
223b71206888 Initial import
thib
parents:
diff changeset
484 }
223b71206888 Initial import
thib
parents:
diff changeset
485 diff_data = strchr(diff_data, ';');
223b71206888 Initial import
thib
parents:
diff changeset
486 if (diff_data) diff_data++;
223b71206888 Initial import
thib
parents:
diff changeset
487 }
223b71206888 Initial import
thib
parents:
diff changeset
488 if (*diff_data == ';') {
223b71206888 Initial import
thib
parents:
diff changeset
489 diff_data++;
223b71206888 Initial import
thib
parents:
diff changeset
490 } else {
223b71206888 Initial import
thib
parents:
diff changeset
491 fprintf(stderr,"AyusysConfigItem::PatchOriginal: invalid data %s\n",diff_data);
223b71206888 Initial import
thib
parents:
diff changeset
492 }
223b71206888 Initial import
thib
parents:
diff changeset
493 return diff_data;
223b71206888 Initial import
thib
parents:
diff changeset
494 }
223b71206888 Initial import
thib
parents:
diff changeset
495 void SetOriginal(void) {
223b71206888 Initial import
thib
parents:
diff changeset
496 mapiterator it = data.begin();
223b71206888 Initial import
thib
parents:
diff changeset
497 for (; it != data.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
498 it->second.SetOriginal();
223b71206888 Initial import
thib
parents:
diff changeset
499 }
223b71206888 Initial import
thib
parents:
diff changeset
500 }
223b71206888 Initial import
thib
parents:
diff changeset
501 void Dump(FILE* f) const {
223b71206888 Initial import
thib
parents:
diff changeset
502 const_mapiterator it = data.begin();
223b71206888 Initial import
thib
parents:
diff changeset
503 for (; it != data.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
504 fprintf(f, "name %s: ",it->first.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
505 it->second.Dump(f);
223b71206888 Initial import
thib
parents:
diff changeset
506 }
223b71206888 Initial import
thib
parents:
diff changeset
507 }
223b71206888 Initial import
thib
parents:
diff changeset
508 };
223b71206888 Initial import
thib
parents:
diff changeset
509 // template AyuSysConfigItem<AyuSysConfigStringItem, char>;
223b71206888 Initial import
thib
parents:
diff changeset
510 // template AyuSysConfigItem<AyuSysConfigIntlistItem, int>;
223b71206888 Initial import
thib
parents:
diff changeset
511
223b71206888 Initial import
thib
parents:
diff changeset
512 /************************************************/
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
513 /* ラッパ */
0
223b71206888 Initial import
thib
parents:
diff changeset
514 struct AyuSysConfigString {
223b71206888 Initial import
thib
parents:
diff changeset
515 AyuSysConfigItem<AyuSysConfigStringItem,char> orig;
223b71206888 Initial import
thib
parents:
diff changeset
516 void Dump(FILE* f) const {
223b71206888 Initial import
thib
parents:
diff changeset
517 fprintf(f, "string config:\n");
223b71206888 Initial import
thib
parents:
diff changeset
518 orig.Dump(f);
223b71206888 Initial import
thib
parents:
diff changeset
519 }
223b71206888 Initial import
thib
parents:
diff changeset
520 };
223b71206888 Initial import
thib
parents:
diff changeset
521 struct AyuSysConfigIntlist {
223b71206888 Initial import
thib
parents:
diff changeset
522 AyuSysConfigItem<AyuSysConfigIntlistItem, int> orig;
223b71206888 Initial import
thib
parents:
diff changeset
523 void Dump(FILE* f) const {
223b71206888 Initial import
thib
parents:
diff changeset
524 fprintf(f, "integer array config:\n");
223b71206888 Initial import
thib
parents:
diff changeset
525 orig.Dump(f);
223b71206888 Initial import
thib
parents:
diff changeset
526 }
223b71206888 Initial import
thib
parents:
diff changeset
527 };
223b71206888 Initial import
thib
parents:
diff changeset
528
223b71206888 Initial import
thib
parents:
diff changeset
529 /************************************************/
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
530 /* AyuSysConfig クラス */
0
223b71206888 Initial import
thib
parents:
diff changeset
531 int AyuSysConfig::SearchParam(const char* name) const{
223b71206888 Initial import
thib
parents:
diff changeset
532 HashStr str(name);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
533 if (str_config->orig.Get(1, str)) return 1; /* char* のパラメータ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
534 else if (int_config->orig.Get(1, str)) return 2; /* int のパラメータ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
535 /* XXX.015.XXX の類のキー名を XXX.000.XXX の形に規格化して再検索 */
0
223b71206888 Initial import
thib
parents:
diff changeset
536 char name_copy[1024];
223b71206888 Initial import
thib
parents:
diff changeset
537 strncpy(name_copy, name, 1000);
223b71206888 Initial import
thib
parents:
diff changeset
538 name_copy[1000] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
539 char* s;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
540 for (s=name_copy; s != NULL; s = strchr(s,'.')) {
0
223b71206888 Initial import
thib
parents:
diff changeset
541 if (isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3])) {
223b71206888 Initial import
thib
parents:
diff changeset
542 s[1] = '0'; s[2] = '0'; s[3] = '0';
223b71206888 Initial import
thib
parents:
diff changeset
543 }
223b71206888 Initial import
thib
parents:
diff changeset
544 s++;
223b71206888 Initial import
thib
parents:
diff changeset
545 }
223b71206888 Initial import
thib
parents:
diff changeset
546 HashStr str2(name_copy);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
547 if (str_config->orig.Get(1, str2)) return 1; /* char* のパラメータ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
548 else if (int_config->orig.Get(1, str2)) return 2; /* int のパラメータ */
0
223b71206888 Initial import
thib
parents:
diff changeset
549 else return 0;
223b71206888 Initial import
thib
parents:
diff changeset
550 }
223b71206888 Initial import
thib
parents:
diff changeset
551 const char* AyuSysConfig::GetParaStr(const char* name) const{
223b71206888 Initial import
thib
parents:
diff changeset
552 HashStr str(name);
223b71206888 Initial import
thib
parents:
diff changeset
553 const char* ret = str_config->orig.Get(1,str);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
554 if (ret == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
555 // fprintf(stderr,"Cannot find config name '%s'\n",name);
223b71206888 Initial import
thib
parents:
diff changeset
556 }
223b71206888 Initial import
thib
parents:
diff changeset
557 return ret;
223b71206888 Initial import
thib
parents:
diff changeset
558 }
223b71206888 Initial import
thib
parents:
diff changeset
559 int AyuSysConfig::GetParam(const char* name, int deal, ...) const{
223b71206888 Initial import
thib
parents:
diff changeset
560 HashStr str(name);
223b71206888 Initial import
thib
parents:
diff changeset
561 va_list va; int i;
223b71206888 Initial import
thib
parents:
diff changeset
562 const int* vars = int_config->orig.Get(deal, str);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
563 if (vars == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
564 // fprintf(stderr,"Cannot find config name '%s'\n",name);
223b71206888 Initial import
thib
parents:
diff changeset
565 va_start(va, deal);
223b71206888 Initial import
thib
parents:
diff changeset
566 for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
567 int* var = va_arg(va, int*);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
568 if (var != NULL) *var = 0;
0
223b71206888 Initial import
thib
parents:
diff changeset
569 }
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
570 va_end(va);
0
223b71206888 Initial import
thib
parents:
diff changeset
571 return -1;
223b71206888 Initial import
thib
parents:
diff changeset
572 } else {
223b71206888 Initial import
thib
parents:
diff changeset
573 va_start(va, deal);
223b71206888 Initial import
thib
parents:
diff changeset
574 for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
575 int* var = va_arg(va, int*);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
576 if (var != NULL) *var = vars[i];
0
223b71206888 Initial import
thib
parents:
diff changeset
577 }
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
578 va_end(va);
0
223b71206888 Initial import
thib
parents:
diff changeset
579 }
223b71206888 Initial import
thib
parents:
diff changeset
580 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
581 }
223b71206888 Initial import
thib
parents:
diff changeset
582 int AyuSysConfig::GetOriginalParam(const char* name, int deal, ...) const{
223b71206888 Initial import
thib
parents:
diff changeset
583 HashStr str(name);
223b71206888 Initial import
thib
parents:
diff changeset
584 va_list va; int i;
223b71206888 Initial import
thib
parents:
diff changeset
585 const int* vars = int_config->orig.GetOriginal(deal, str);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
586 if (vars == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
587 // fprintf(stderr,"Cannot find config name '%s'\n",name);
223b71206888 Initial import
thib
parents:
diff changeset
588 va_start(va, deal);
223b71206888 Initial import
thib
parents:
diff changeset
589 for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
590 int* var = va_arg(va, int*);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
591 if (var != NULL) *var = 0;
0
223b71206888 Initial import
thib
parents:
diff changeset
592 }
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
593 va_end(va);
0
223b71206888 Initial import
thib
parents:
diff changeset
594 return -1;
223b71206888 Initial import
thib
parents:
diff changeset
595 } else {
223b71206888 Initial import
thib
parents:
diff changeset
596 va_start(va, deal);
223b71206888 Initial import
thib
parents:
diff changeset
597 for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
598 int* var = va_arg(va, int*);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
599 if (var != NULL) *var = vars[i];
0
223b71206888 Initial import
thib
parents:
diff changeset
600 }
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
601 va_end(va);
0
223b71206888 Initial import
thib
parents:
diff changeset
602 }
223b71206888 Initial import
thib
parents:
diff changeset
603 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
604 }
223b71206888 Initial import
thib
parents:
diff changeset
605 const int* AyuSysConfig::GetParamArray(const char* name, int& deal) const{
223b71206888 Initial import
thib
parents:
diff changeset
606 HashStr str(name);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
607 if (int_config->orig.Deal(str) == 0) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
608 deal = 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
609 return NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
610 }
0
223b71206888 Initial import
thib
parents:
diff changeset
611 deal = int_config->orig.Deal(str);
223b71206888 Initial import
thib
parents:
diff changeset
612 const int* vars = int_config->orig.Get(deal, str);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
613 if (vars == NULL) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
614 deal = 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
615 return NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
616 }
0
223b71206888 Initial import
thib
parents:
diff changeset
617 return vars;
223b71206888 Initial import
thib
parents:
diff changeset
618 }
223b71206888 Initial import
thib
parents:
diff changeset
619 void AyuSysConfig::SetParaStr(const char* name, const char* var) {
223b71206888 Initial import
thib
parents:
diff changeset
620 HashStr str(name);
223b71206888 Initial import
thib
parents:
diff changeset
621 dirty_flag = 1; change_flag = 1;
223b71206888 Initial import
thib
parents:
diff changeset
622 str_config->orig.Set(str, 1, var);
223b71206888 Initial import
thib
parents:
diff changeset
623 }
223b71206888 Initial import
thib
parents:
diff changeset
624 void AyuSysConfig::SetParam(const char* name, int deal, ...) {
223b71206888 Initial import
thib
parents:
diff changeset
625 if (deal >= MAXVARS) return ;
223b71206888 Initial import
thib
parents:
diff changeset
626 HashStr str(name);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
627 int vars[deal]; va_list va; int i;
0
223b71206888 Initial import
thib
parents:
diff changeset
628 va_start(va, deal);
223b71206888 Initial import
thib
parents:
diff changeset
629 for (i=0; i<deal; i++) vars[i] = va_arg(va, int);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
630 va_end(va);
0
223b71206888 Initial import
thib
parents:
diff changeset
631 int_config->orig.Set(str, deal, vars);
223b71206888 Initial import
thib
parents:
diff changeset
632 dirty_flag = 1; change_flag = 1;
223b71206888 Initial import
thib
parents:
diff changeset
633 return;
223b71206888 Initial import
thib
parents:
diff changeset
634 }
223b71206888 Initial import
thib
parents:
diff changeset
635 void AyuSysConfig::SetOrigParaStr(const char* name, const char* var) {
223b71206888 Initial import
thib
parents:
diff changeset
636 HashStr str(name);
223b71206888 Initial import
thib
parents:
diff changeset
637 str_config->orig.SetOrig(str, 1, var);
223b71206888 Initial import
thib
parents:
diff changeset
638 change_flag = 1;
223b71206888 Initial import
thib
parents:
diff changeset
639 }
223b71206888 Initial import
thib
parents:
diff changeset
640 void AyuSysConfig::SetOrigParam(const char* name, int deal, ...) {
223b71206888 Initial import
thib
parents:
diff changeset
641 if (deal >= MAXVARS) return;
223b71206888 Initial import
thib
parents:
diff changeset
642 HashStr str(name);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
643 int vars[deal]; va_list va; int i;
0
223b71206888 Initial import
thib
parents:
diff changeset
644 va_start(va, deal);
223b71206888 Initial import
thib
parents:
diff changeset
645 for(i=0; i<deal; i++) vars[i] = va_arg(va, int);
50
35ce1a30f3f9 * Added va_end where there is a va_start
thib
parents: 48
diff changeset
646 va_end(va);
0
223b71206888 Initial import
thib
parents:
diff changeset
647 int_config->orig.SetOrig(str, deal, vars);
223b71206888 Initial import
thib
parents:
diff changeset
648 change_flag = 1;
223b71206888 Initial import
thib
parents:
diff changeset
649 }
223b71206888 Initial import
thib
parents:
diff changeset
650 void AyuSysConfig::SetOrigParamArray(const char* name, int deal, int* array) {
223b71206888 Initial import
thib
parents:
diff changeset
651 HashStr str(name);
223b71206888 Initial import
thib
parents:
diff changeset
652 int_config->orig.SetOrig(str, deal, array);
223b71206888 Initial import
thib
parents:
diff changeset
653 }
223b71206888 Initial import
thib
parents:
diff changeset
654 void AyuSysConfig::SetOriginal(void) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
655 /* 全ての設定を元に戻す */
0
223b71206888 Initial import
thib
parents:
diff changeset
656 str_config->orig.SetOriginal();
223b71206888 Initial import
thib
parents:
diff changeset
657 int_config->orig.SetOriginal();
223b71206888 Initial import
thib
parents:
diff changeset
658 change_flag = 1;
223b71206888 Initial import
thib
parents:
diff changeset
659 }
223b71206888 Initial import
thib
parents:
diff changeset
660 void AyuSysConfig::DiffOriginal(string& data) {
223b71206888 Initial import
thib
parents:
diff changeset
661 str_config->orig.DiffOriginal(data);
223b71206888 Initial import
thib
parents:
diff changeset
662 int_config->orig.DiffOriginal(data);
223b71206888 Initial import
thib
parents:
diff changeset
663 return;
223b71206888 Initial import
thib
parents:
diff changeset
664 }
223b71206888 Initial import
thib
parents:
diff changeset
665 const char* AyuSysConfig::PatchOriginal(const char* data) {
223b71206888 Initial import
thib
parents:
diff changeset
666 data = str_config->orig.PatchOriginal(data);
223b71206888 Initial import
thib
parents:
diff changeset
667 data = int_config->orig.PatchOriginal(data);
223b71206888 Initial import
thib
parents:
diff changeset
668 return data;
223b71206888 Initial import
thib
parents:
diff changeset
669 }
223b71206888 Initial import
thib
parents:
diff changeset
670
223b71206888 Initial import
thib
parents:
diff changeset
671 void AyuSysConfig::Dump(FILE* f) const {
223b71206888 Initial import
thib
parents:
diff changeset
672 str_config->Dump(f);
223b71206888 Initial import
thib
parents:
diff changeset
673 int_config->Dump(f);
223b71206888 Initial import
thib
parents:
diff changeset
674 }
223b71206888 Initial import
thib
parents:
diff changeset
675
223b71206888 Initial import
thib
parents:
diff changeset
676 /************************************************
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
677 ** AyuSysConfig のコンストラクタ:
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
678 ** 全ての config 項目を初期化する
0
223b71206888 Initial import
thib
parents:
diff changeset
679 */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
680
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
681 AyuSysConfig * AyuSysConfig::_singleton = NULL;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
682
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
683 AyuSysConfig* AyuSysConfig::GetInstance(void)
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
684 {
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
685 if (_singleton == NULL)
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
686 _singleton = new AyuSysConfig;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
687 return _singleton;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
688 }
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
689
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
690 void AyuSysConfig::Quit(void)
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
691 {
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
692 if (_singleton != NULL) {
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
693 delete _singleton;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
694 _singleton = NULL;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
695 }
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
696 }
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
697
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
698
0
223b71206888 Initial import
thib
parents:
diff changeset
699 AyuSysConfig::AyuSysConfig(void) {
223b71206888 Initial import
thib
parents:
diff changeset
700 int i;
223b71206888 Initial import
thib
parents:
diff changeset
701
223b71206888 Initial import
thib
parents:
diff changeset
702 change_flag = 1; dirty_flag = 0;
223b71206888 Initial import
thib
parents:
diff changeset
703 str_config = new AyuSysConfigString;
223b71206888 Initial import
thib
parents:
diff changeset
704 int_config = new AyuSysConfigIntlist;
223b71206888 Initial import
thib
parents:
diff changeset
705
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
706 /****** 文字列 *******/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
707 SetOrigParaStr("#WAKUPDT", "GRDAT"); /* 枠、マウスカーソルなどの画像ファイル */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
708 SetOrigParaStr("#REGNAME", "xclannad"); /* レジストリ名。セーブファイルの作成に使う */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
709 SetOrigParaStr("#CAPTION", "xclannad"); /* ウィンドウのタイトル */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
710 SetOrigParaStr("#SAVENAME","SAVE.INI"); /* セーブファイルの名前 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
711 SetOrigParaStr("#SAVETITLE", "This is save file"); /* セーブファイルの先頭の文字列 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
712 SetOrigParaStr("#SAVENOTITLE", "-----------------"); /* 使われてないセーブデータの名前 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
713 SetOrigParaStr("#CGM_FILE", "MODE.CGM");/* CG mode の設定が保存されたファイル名 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
714 SetOrigParaStr("#CGTABLE_FILE", "MODE.CGM");/* CG mode の設定が保存されたファイル名 */
0
223b71206888 Initial import
thib
parents:
diff changeset
715
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
716 SetOrigParaStr("#WAKU.000.000.NAME", ""); // テキストウィンドウの窓飾り画像名
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
717 SetOrigParaStr("#WAKU.000.000.BACK", ""); // テキストウィンドウのテキスト背景画像名
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
718 SetOrigParaStr("#WAKU.000.000.BTN", ""); // テキストウィンドウのボタン画像名
0
223b71206888 Initial import
thib
parents:
diff changeset
719
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
720 SetOrigParaStr("#MOUSE_CURSOR.000.NAME", ""); // マウスカーソルのファイル名
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
721 SetOrigParaStr("#CURSOR.000.NAME", ""); // リターンカーソルのファイル名
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
722 SetOrigParaStr("#SELBTN.000.NAME", ""); // 選択肢背景
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
723 SetOrigParaStr("#SELBTN.000.BACK", ""); // 選択肢背景
0
223b71206888 Initial import
thib
parents:
diff changeset
724
223b71206888 Initial import
thib
parents:
diff changeset
725 char name_str[8] = "#NAME.A";
223b71206888 Initial import
thib
parents:
diff changeset
726 for (i='A'; i<='Z'; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
727 name_str[6] = i;
223b71206888 Initial import
thib
parents:
diff changeset
728 SetOrigParaStr(name_str, "");
223b71206888 Initial import
thib
parents:
diff changeset
729 }
223b71206888 Initial import
thib
parents:
diff changeset
730
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
731 /****** 数値列 *******/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
732 SetOrigParam("#CANCELCALL", 2, 0,0); /* キャンセルボタン(右クリック)したときに呼び出されるサブルーチン番号(メニュー) */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
733 SetOrigParam("#COM2_TITLE", 1, 1); /* ? */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
734 SetOrigParam("#COM2_TITLE_COLOR", 1, 2); /* 選択肢タイトルの色 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
735 SetOrigParam("#COM2_TITLE_INDENT", 1, 2); /* ? */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
736 SetOrigParam("#SAVEFILETIME", 1, 24); /* セーブする場所の数 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
737 SetOrigParam("#SEEN_START", 1, 0); /* ゲームを開始するシナリオ番号 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
738 SetOrigParam("#SEEN_SRT", 1, 0); /* ゲームを開始するシナリオ番号(好き好き大好き) */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
739 SetOrigParam("#SEEN_MENU", 1, 0); /* メニューのシナリオ番号 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
740 SetOrigParam("#SEEN_TEXT_CURRENT", 1, 0); /* seen.txt を root directory に置くか */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
741 SetOrigParam("#FADE_TIME", 1, 40); /* 画面のフェード・アウトの速度 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
742 SetOrigParam("#NVL_SYSTEM",1, 0); /* テキストウィンドウが全画面か否か */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
743 SetOrigParam("#WINDOW_ATTR", 5, -1, 128,128, 190, 0); /* テキストウィンドウの色 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
744 SetOrigParam("#WINDOW_ATTR_AREA", 4, 4,4,4,4); /* テキストウィンドウの範囲 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
745 SetOrigParam("#WINDOW_ATTR_TYPE", 1, 0); /* テキストウィンドウを半透明にするか */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
746 SetOrigParam("#WINDOW_MSG_POS", 2, 22, 350); /* テキストウィンドウの位置 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
747 SetOrigParam("#WINDOW_COM_POS", 2,450, 250); /* 選択ウィンドウの位置 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
748 SetOrigParam("#WINDOW_GRP_POS", 2, 16, 100); /* なにかのウィンドウの位置 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
749 SetOrigParam("#WINDOW_SUB_POS", 2, 48, 100); /* なにかのウィンドウの位置 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
750 SetOrigParam("#WINDOW_SYS_POS", 2, 32, 100); /* なにかのウィンドウの位置 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
751 SetOrigParam("#WINDOW_WAKU_TYPE", 1, 0); /* テキストウィンドウの枠の種類。xkanon 独自設定 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
752 SetOrigParam("#RETN_CONT", 1, 16); /* リターンカーソルの数 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
753 SetOrigParam("#RETN_SPEED",1,100); /* リターンカーソルの動く速度 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
754 SetOrigParam("#RETN_XSIZE", 1, 16); /* リターンカーソルの大きさ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
755 SetOrigParam("#RETN_YSIZE", 1, 16); /* リターンカーソルの大きさ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
756 SetOrigParam("#FONT_SIZE", 1, 26); /* フォントの大きさ */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
757 SetOrigParam("#FONT_WEIGHT", 1, 100); /* フォントの weight */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
758 SetOrigParam("#MSG_MOJI_SIZE", 2, 12, 29); /* 文字の大きさ(半角) */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
759 SetOrigParam("#MESSAGE_SIZE", 2, 23, 3); /* メッセージウィンドウの文字数 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
760 SetOrigParam("#COM_MESSAGE_SIZE", 2, 23, 3); /* メッセージウィンドウの文字数 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
761 SetOrigParam("#INIT_MESSAGE_SPEED", 1, 30); /* テキスト表示速度 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
762 SetOrigParam("#INIT_MESSAGE_SPEED_MOD", 1, 0); /* テキスト表示 no wait */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
763 SetOrigParam("#MESSAGE_KEY_WAIT_USE", 1, 0); /* テキスト進行オートモード */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
764 SetOrigParam("#MESSAGE_KEY_WAIT_TIME", 1, 1500); /* オートモードでのキー待ち時間 */
0
223b71206888 Initial import
thib
parents:
diff changeset
765
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
766 SetOrigParam("#GRP_DC_TIMES", 1, 4); /* 裏画面の数 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
767 SetOrigParam("#MUSIC_LINEAR_PAC",1,0); /* PCM データの 8bit -> 16bit 変換を行うか */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
768 SetOrigParam("#MUSIC_TYPE",1,0); /* PCM データの種類 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
769 SetOrigParam("#WINDOW_MSGBK_BOX",1,0); /* バックログ用のボタン */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
770 SetOrigParam("#WINDOW_MSGBK_LBOX_POS",4,15,7,8,0); /* バックログ用のボタン(左)の位置 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
771 SetOrigParam("#WINDOW_MSGBK_RBOX_POS",4,7,7,0,0); /* バックログ用のボタン(左)の位置 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
772 SetOrigParam("#MSGBK_MOD",1,0); /* バックログ用のボタンを使用するか */
0
223b71206888 Initial import
thib
parents:
diff changeset
773
223b71206888 Initial import
thib
parents:
diff changeset
774 SetOrigParam("#WAKU.000.000.TYPE", 1, 5);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
775 SetOrigParam("#WAKU.000.000.MOVE_BOX", 5, 0, 0, 0, 0, 0); // テキストウィンドウの移動用ボタン位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
776 SetOrigParam("#WAKU.000.000.CLEAR_BOX", 5, 0, 0, 0, 0, 0); // 一時消去用ボタン位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
777 SetOrigParam("#WAKU.000.000.READJUMP_BOX", 5, 0, 0, 0, 0, 0); // スキップ用ボタン位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
778 SetOrigParam("#WAKU.000.000.AUTOMODE_BOX", 5, 0, 0, 0, 0, 0); // オート用ボタン位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
779 SetOrigParam("#WAKU.000.000.MSGBK_BOX", 5, 0, 0, 0, 0, 0); // バックログボタン位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
780 SetOrigParam("#WAKU.000.000.MSGBKLEFT_BOX", 5, 0, 0, 0, 0, 0); // バックログ(進める)ボタン位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
781 SetOrigParam("#WAKU.000.000.MSGBKRIGHT_BOX", 5, 0, 0, 0, 0, 0); // バックログ(戻る)ボタン位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
782 SetOrigParam("#WAKU.000.000.EXBTN_000_BOX", 5, 0, 0, 0, 0, 0); // その他ボタン0位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
783 SetOrigParam("#WAKU.000.000.EXBTN_001_BOX", 5, 0, 0, 0, 0, 0); // その他ボタン1位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
784 SetOrigParam("#WAKU.000.000.EXBTN_002_BOX", 5, 0, 0, 0, 0, 0); // その他ボタン2位置
0
223b71206888 Initial import
thib
parents:
diff changeset
785
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
786 SetOrigParam("#WINDOW.000.MOJI_SIZE", 1, 21); // 文字サイズ
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
787 SetOrigParam("#WINDOW.000.MOJI_REP", 2, -1, 2); // 文字の余裕
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
788 SetOrigParam("#WINDOW.000.MOJI_CNT", 2, 20, 3); // ウィンドウ内の文字数
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
789 SetOrigParam("#WINDOW.000.MOJI_POS", 4, 100, 0, 180, 40); // テキスト位置。3つ目がx で1つ目がyらしい
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
790 SetOrigParam("#WINDOW.000.MOJI_SHADOW", 1, 0); // 文字に影を付けるか
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
791 SetOrigParam("#WINDOW.000.LUBY_SIZE", 1, 8); // ルビの文字サイズ
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
792 SetOrigParam("#WINDOW.000.MOJI_MIN", 2, 8, 1); // 文字同士の隙間?
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
793 SetOrigParam("#WINDOW.000.SELCOM_USE", 1, 0); // 選択肢の実装方法
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
794 SetOrigParam("#WINDOW.000.POS", 4, 100, 0, 0, 260); // ウィンドウ位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
795 SetOrigParam("#WINDOW.000.ATTR_MOD", 1, 0); // ウィンドウ色
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
796 SetOrigParam("#WINDOW.000.ATTR", 5, -1, -1, -1, -1, -1); // ウィンドウ色
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
797 /* SELCOM はよくわからんので無視 */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
798 SetOrigParam("#WINDOW.000.OPEN_ANM_MOD", 1, 0); // ウィンドウを開くときの効果らしい
0
223b71206888 Initial import
thib
parents:
diff changeset
799 SetOrigParam("#WINDOW.000.OPEN_ANM_TIME", 1, 500);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
800 SetOrigParam("#WINDOW.000.CLOSE_ANM_MOD", 1, 0); // ウィンドウを閉じるときの効果らしい
0
223b71206888 Initial import
thib
parents:
diff changeset
801 SetOrigParam("#WINDOW.000.CLOSE_ANM_TIME", 1, 500);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
802 SetOrigParam("#WINDOW.000.WAKU_SETNO", 1, 0); // 枠の種類
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
803 SetOrigParam("#WINDOW.000.MOVE_USE", 1, 0); // ウィンドウ枠移動ボタン使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
804 SetOrigParam("#WINDOW.000.CLEAR_USE", 1, 0); // ウィンドウ枠消去ボタン使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
805 SetOrigParam("#WINDOW.000.READJUMP_USE", 1, 0); // スキップボタン使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
806 SetOrigParam("#WINDOW.000.AUTOMODE_USE", 1, 0); // スキップボタン使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
807 SetOrigParam("#WINDOW.000.MSGBK_USE", 1, 0); // バックログボタン使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
808 SetOrigParam("#WINDOW.000.MSGBKLEFT_USE", 1, 0); // バックログ(進む)ボタン使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
809 SetOrigParam("#WINDOW.000.MSGBKRIGHT_USE", 1, 0); // バックログ(戻る)ボタン使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
810 SetOrigParam("#WINDOW.000.EXBTN_000_USE", 1, 0); // その他ボタン0使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
811 SetOrigParam("#WINDOW.000.EXBTN_001_USE", 1, 0); // その他ボタン1使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
812 SetOrigParam("#WINDOW.000.EXBTN_002_USE", 1, 0); // その他ボタン2使用の可否
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
813 SetOrigParam("#WINDOW.000.NAME_MOD", 1, 0); // 名前ウィンドウを別途使用するか
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
814 SetOrigParam("#WINDOW.000.NAME_MOJI_SIZE", 1, 20); // 名前フォントのサイズ
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
815 SetOrigParam("#WINDOW.000.NAME_MOJI_POS", 2, 0, 0); // 名前ウィンドウの文字の位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
816 SetOrigParam("#WINDOW.000.NAME_MOJI_MIN", 1, 0); // 名前ウィンドウの幅
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
817 SetOrigParam("#WINDOW.000.NAME_CENTERING", 1, 1); // 名前のセンタリングの有無
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
818 SetOrigParam("#WINDOW.000.NAME_POS", 2, 159, 78); // 名前ウィンドウ位置(左下位置らしい)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
819 SetOrigParam("#WINDOW.000.NAME_WAKU_SETNO", 1, -1); // 名前ウィンドウ位置(左下位置らしい)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
820 SetOrigParam("#WINDOW.000.FACE.000", 5, 0, 0, 1, 1, 1); // 顔ウィンドウ位置(始め2つがx,y、MOJI_POSからの相対位置なのに注意)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
821 SetOrigParam("#WINDOW.000.KEYCUR_MOD", 3, 0, 0, 0); // リターンカーソルの位置
0
223b71206888 Initial import
thib
parents:
diff changeset
822
223b71206888 Initial import
thib
parents:
diff changeset
823
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
824 SetOrigParam("#CURSOR.000.SIZE", 2, 0, 0); // リターンカーソルの大きさ
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
825 SetOrigParam("#CURSOR.000.CONT", 1, 50); // リターンカーソルの繰り返し数
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
826 SetOrigParam("#CURSOR.000.SPEED", 1, 1000); // ブリンクする速さ
0
223b71206888 Initial import
thib
parents:
diff changeset
827
40
651237260724 * Center button-type selects
thib
parents: 27
diff changeset
828 SetOrigParam("#SELBTN.000.CENTERING", 2, 0, 0);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
829 SetOrigParam("#SELBTN.000.BASEPOS", 2, 0, 0); // 選択肢ウィンドウの位置
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
830 SetOrigParam("#SELBTN.000.REPPOS", 2, 0, 50); // 選択肢ウィンドウの次の位置(相対)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
831 SetOrigParam("#SELBTN.000.MOJISIZE", 4, 26, 0,0,0); // 文字の大きさ
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
832 SetOrigParam("#SELBTN.000.MOJIDEFAULTCOL", 1, 0); // 非選択時の文字色
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
833 SetOrigParam("#SELBTN.000.MOJISELECTCOL", 1, 0); // 選択時の文字色
0
223b71206888 Initial import
thib
parents:
diff changeset
834
223b71206888 Initial import
thib
parents:
diff changeset
835 SetOrigParam("#COLOR_TABLE.000", 3, 255,255,255);
223b71206888 Initial import
thib
parents:
diff changeset
836 SetOrigParam("#SHAKE.000", 3, 0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
837
223b71206888 Initial import
thib
parents:
diff changeset
838 SetOrigParam("#SELR.000",16,0,0,640,480,0,0,500,50,0,0,0,0,0,0,255,0);
223b71206888 Initial import
thib
parents:
diff changeset
839 SetOrigParam("#SEL.000", 15,0,0,639,479,0,0, 32, 4,0,0,0,0,0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
840
223b71206888 Initial import
thib
parents:
diff changeset
841 SetOrigParam("#SCREENSIZE_MOD", 1, 0); /* 0 = 640x480; 1 = 800x600 */
16
92765a5661f7 added "new" label on last savegame and corrected StatSaveFile
thib
parents: 9
diff changeset
842
92765a5661f7 added "new" label on last savegame and corrected StatSaveFile
thib
parents: 9
diff changeset
843 SetOrigParam("#LASTSAVE", 1, 0);
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 16
diff changeset
844
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 16
diff changeset
845 SetOrigParam("#VOLMOD", 4, 128, 128, 128, 128);
0
223b71206888 Initial import
thib
parents:
diff changeset
846 }
9
b6d6c0ffb423 Fixed some memory leaks
thib
parents: 0
diff changeset
847 AyuSysConfig::~AyuSysConfig(void) {
b6d6c0ffb423 Fixed some memory leaks
thib
parents: 0
diff changeset
848 delete str_config;
b6d6c0ffb423 Fixed some memory leaks
thib
parents: 0
diff changeset
849 delete int_config;
b6d6c0ffb423 Fixed some memory leaks
thib
parents: 0
diff changeset
850 }
0
223b71206888 Initial import
thib
parents:
diff changeset
851
223b71206888 Initial import
thib
parents:
diff changeset
852 static int SplitVar(const char* str, int* ret_var, int ret_size) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
853 /* , あるいは ),:( をセパレータとして、-?[0-9]+ の
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
854 ** フォーマットの数値列を読み込む。先頭に (、末尾に ) が付きうる。
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
855 ** (),-[0-9] 以外の文字があったらそこで終了
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
856 ** 得られたデータ数を返す
0
223b71206888 Initial import
thib
parents:
diff changeset
857 */
223b71206888 Initial import
thib
parents:
diff changeset
858 if (*str == '(') str++;
223b71206888 Initial import
thib
parents:
diff changeset
859 int i; for (i=0; i<ret_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
860 int c; int is_positive = 1;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
861 /* セパレータの読み飛ばし */
0
223b71206888 Initial import
thib
parents:
diff changeset
862 c = *str;
223b71206888 Initial import
thib
parents:
diff changeset
863 if (c == ',' || c == ':') {
223b71206888 Initial import
thib
parents:
diff changeset
864 str++;
223b71206888 Initial import
thib
parents:
diff changeset
865 } else if (c == ')' && str[1] == '(') {
223b71206888 Initial import
thib
parents:
diff changeset
866 str += 2;
223b71206888 Initial import
thib
parents:
diff changeset
867 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
868 /* - を parse */
0
223b71206888 Initial import
thib
parents:
diff changeset
869 c = *str;
223b71206888 Initial import
thib
parents:
diff changeset
870 if (c == '-' && isdigit(str[1])) {
223b71206888 Initial import
thib
parents:
diff changeset
871 is_positive = -1; str++;
223b71206888 Initial import
thib
parents:
diff changeset
872 } else if (! isdigit(c)) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
873 return i; /* 異常な文字を見つけた:終了 */
0
223b71206888 Initial import
thib
parents:
diff changeset
874 }
223b71206888 Initial import
thib
parents:
diff changeset
875 int number = 0;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
876 /* 数字読み込み */
0
223b71206888 Initial import
thib
parents:
diff changeset
877 while(isdigit( (c=*str) )) {
223b71206888 Initial import
thib
parents:
diff changeset
878 number *= 10;
223b71206888 Initial import
thib
parents:
diff changeset
879 number += c-'0';
223b71206888 Initial import
thib
parents:
diff changeset
880 str++;
223b71206888 Initial import
thib
parents:
diff changeset
881 }
223b71206888 Initial import
thib
parents:
diff changeset
882 ret_var[i] = is_positive * number;
223b71206888 Initial import
thib
parents:
diff changeset
883 }
223b71206888 Initial import
thib
parents:
diff changeset
884 return i;
223b71206888 Initial import
thib
parents:
diff changeset
885 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
886 /* 決められた数の引数を得る。-1 ならエラーが生じた */
0
223b71206888 Initial import
thib
parents:
diff changeset
887 static inline int SplitVar(const char* str, int& var1) {
223b71206888 Initial import
thib
parents:
diff changeset
888 if (SplitVar(str, &var1, 1) != 1) return -1;
223b71206888 Initial import
thib
parents:
diff changeset
889 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
890 }
223b71206888 Initial import
thib
parents:
diff changeset
891 static inline int SplitVar(const char* str, int& var1, int& var2) {
223b71206888 Initial import
thib
parents:
diff changeset
892 int vars[2];
223b71206888 Initial import
thib
parents:
diff changeset
893 if (SplitVar(str, vars, 2) != 2) return -1;
223b71206888 Initial import
thib
parents:
diff changeset
894 var1 = vars[0]; var2 = vars[1];
223b71206888 Initial import
thib
parents:
diff changeset
895 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
896 }
223b71206888 Initial import
thib
parents:
diff changeset
897 static inline int SplitVar(const char* str, int& var1, int& var2, int& var3) {
223b71206888 Initial import
thib
parents:
diff changeset
898 int vars[3];
223b71206888 Initial import
thib
parents:
diff changeset
899 if (SplitVar(str, vars, 3) != 3) return -1;
223b71206888 Initial import
thib
parents:
diff changeset
900 var1 = vars[0]; var2 = vars[1]; var3 = vars[2];
223b71206888 Initial import
thib
parents:
diff changeset
901 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
902 }
223b71206888 Initial import
thib
parents:
diff changeset
903 static inline int SplitVar(const char* str, int& var1, int& var2, int& var3, int& var4) {
223b71206888 Initial import
thib
parents:
diff changeset
904 int vars[4];
223b71206888 Initial import
thib
parents:
diff changeset
905 if (SplitVar(str, vars, 4) != 4) return -1;
223b71206888 Initial import
thib
parents:
diff changeset
906 var1 = vars[0]; var2 = vars[1]; var3 = vars[2]; var4 = vars[3];
223b71206888 Initial import
thib
parents:
diff changeset
907 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
908 }
223b71206888 Initial import
thib
parents:
diff changeset
909
223b71206888 Initial import
thib
parents:
diff changeset
910 bool AyuSysConfig::LoadInitFile(void)
223b71206888 Initial import
thib
parents:
diff changeset
911 {
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
912 FileSearcher* file_searcher = FileSearcher::GetInstance();
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
913
0
223b71206888 Initial import
thib
parents:
diff changeset
914 char buf[1024]; int i;
223b71206888 Initial import
thib
parents:
diff changeset
915 char* tokens[MAXTOKEN]; int token_deal; int buf_ptr;
223b71206888 Initial import
thib
parents:
diff changeset
916 int numbers[MAXVARS];
223b71206888 Initial import
thib
parents:
diff changeset
917
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
918 ARCINFO* info = file_searcher->Find(FileSearcher::ROOT, "gameexe.ini");
0
223b71206888 Initial import
thib
parents:
diff changeset
919 if (info == NULL) return false;
223b71206888 Initial import
thib
parents:
diff changeset
920 int size = info->Size();
223b71206888 Initial import
thib
parents:
diff changeset
921 unsigned char* buf_orig = (unsigned char*)info->Read();
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
922 if (size <= 0 || buf_orig == NULL) {
0
223b71206888 Initial import
thib
parents:
diff changeset
923 delete info; return false;
223b71206888 Initial import
thib
parents:
diff changeset
924 }
223b71206888 Initial import
thib
parents:
diff changeset
925 unsigned char* buf_end = buf_orig + size;
223b71206888 Initial import
thib
parents:
diff changeset
926 int line_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
927 while(buf_orig < buf_end) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
928 /* buf_orig から一行読み込む */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
929 /* その際に、
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
930 ** ・頭が # 以外なら次の行までとばす
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
931 ** ・"" 外のスペース、TABを初めとする制御文字 (0x20 以下のASCIIコード)を削除
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
932 ** ・= で区切る。区切りは最大で10個で、tokens に代入される
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
933 ** などの操作を行う
0
223b71206888 Initial import
thib
parents:
diff changeset
934 */
223b71206888 Initial import
thib
parents:
diff changeset
935
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
936 /* # チェック */
0
223b71206888 Initial import
thib
parents:
diff changeset
937 if (*buf_orig != '#') {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
938 /* 次の '\n' まで読み飛ばし */
0
223b71206888 Initial import
thib
parents:
diff changeset
939 while(buf_orig < buf_end &&
223b71206888 Initial import
thib
parents:
diff changeset
940 *buf_orig != '\n' && *buf_orig != '\r') buf_orig++;
223b71206888 Initial import
thib
parents:
diff changeset
941 if (buf_orig < buf_end-1 && *buf_orig == '\r' && buf_orig[1] == '\n') buf_orig += 2;
223b71206888 Initial import
thib
parents:
diff changeset
942 else if (*buf_orig == '\r' || *buf_orig == '\n') buf_orig++;
223b71206888 Initial import
thib
parents:
diff changeset
943 line_count++;
223b71206888 Initial import
thib
parents:
diff changeset
944 continue;
223b71206888 Initial import
thib
parents:
diff changeset
945 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
946 /* 初期化 */
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
947 token_deal = 1;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
948 tokens[0] = buf;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
949 buf_ptr = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
950 int in_quote = 0;
223b71206888 Initial import
thib
parents:
diff changeset
951
223b71206888 Initial import
thib
parents:
diff changeset
952 while(buf_orig < buf_end && buf_ptr < 1023) {
223b71206888 Initial import
thib
parents:
diff changeset
953 if (in_quote) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
954 /* "" の中 */
0
223b71206888 Initial import
thib
parents:
diff changeset
955 int c = *buf_orig;
223b71206888 Initial import
thib
parents:
diff changeset
956 if (c == '\n' || c == '\r') {
223b71206888 Initial import
thib
parents:
diff changeset
957 break;
223b71206888 Initial import
thib
parents:
diff changeset
958 } else if (c == '\"') {
223b71206888 Initial import
thib
parents:
diff changeset
959 in_quote = 0;
223b71206888 Initial import
thib
parents:
diff changeset
960 } else {
223b71206888 Initial import
thib
parents:
diff changeset
961 buf[buf_ptr++] = c;
223b71206888 Initial import
thib
parents:
diff changeset
962 }
223b71206888 Initial import
thib
parents:
diff changeset
963 buf_orig++;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
964 } else { /* quote されてない */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
965 /* 制御文字を読み飛ばす */
0
223b71206888 Initial import
thib
parents:
diff changeset
966 while(*buf_orig <= 0x20 && buf_orig < buf_end &&
223b71206888 Initial import
thib
parents:
diff changeset
967 *buf_orig != '\n' && *buf_orig != '\r') buf_orig++;
223b71206888 Initial import
thib
parents:
diff changeset
968 int c = *buf_orig;
223b71206888 Initial import
thib
parents:
diff changeset
969 if (c == '\n' || c == '\r') break;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
970 /* = なら次の token */
0
223b71206888 Initial import
thib
parents:
diff changeset
971 if (c == '=') {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
972 c = 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
973 tokens[token_deal++] = buf+buf_ptr+1;
0
223b71206888 Initial import
thib
parents:
diff changeset
974 if (token_deal >= MAXTOKEN) break;
223b71206888 Initial import
thib
parents:
diff changeset
975 } else if (c == '\"') {
223b71206888 Initial import
thib
parents:
diff changeset
976 in_quote = 1; buf_orig++; continue;
223b71206888 Initial import
thib
parents:
diff changeset
977 }
223b71206888 Initial import
thib
parents:
diff changeset
978 buf[buf_ptr++] = c;
223b71206888 Initial import
thib
parents:
diff changeset
979 buf_orig++;
223b71206888 Initial import
thib
parents:
diff changeset
980 }
223b71206888 Initial import
thib
parents:
diff changeset
981 }
223b71206888 Initial import
thib
parents:
diff changeset
982 buf[buf_ptr] = '\0';
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
983 /* 末尾の \r\n を消去 */
0
223b71206888 Initial import
thib
parents:
diff changeset
984 if (buf_orig < buf_end-1 && buf_orig[0] == '\r' && buf_orig[1] == '\n') buf_orig += 2;
223b71206888 Initial import
thib
parents:
diff changeset
985 else if (buf_orig < buf_end && (buf_orig[0] == '\r' || buf_orig[0] == '\n')) buf_orig++;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
986 /* 必要なら parse 内容を出力 */
0
223b71206888 Initial import
thib
parents:
diff changeset
987 dprintf(("line %3d ",line_count));
223b71206888 Initial import
thib
parents:
diff changeset
988 for (i=0; i<token_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
989 dprintf(("%d:\"%s\", ",i,tokens[i]));
223b71206888 Initial import
thib
parents:
diff changeset
990 }
223b71206888 Initial import
thib
parents:
diff changeset
991 dprintf(("\n"));
223b71206888 Initial import
thib
parents:
diff changeset
992 if (in_quote) {
223b71206888 Initial import
thib
parents:
diff changeset
993 fprintf(stderr, "Warning : open quote is found while parsing gameexe.ini, line %d\n",line_count);
223b71206888 Initial import
thib
parents:
diff changeset
994 }
223b71206888 Initial import
thib
parents:
diff changeset
995
223b71206888 Initial import
thib
parents:
diff changeset
996
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
997 /* 得られた内容を parse */
0
223b71206888 Initial import
thib
parents:
diff changeset
998
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
999 /* #NAME=<文字列> */
0
223b71206888 Initial import
thib
parents:
diff changeset
1000 int type = SearchParam(tokens[0]);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1001 if (type == 1) { /* #NAME=<文字列> */
0
223b71206888 Initial import
thib
parents:
diff changeset
1002 if (token_deal != 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1003 dprintf(("Parse error, line %d, %s\n",line_count, tokens[0]));
223b71206888 Initial import
thib
parents:
diff changeset
1004 goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1005 }
223b71206888 Initial import
thib
parents:
diff changeset
1006 SetOrigParaStr(tokens[0], tokens[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1007 goto parse_end;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1008 } else if (type == 2) { /* #NAME=<数値列> */
0
223b71206888 Initial import
thib
parents:
diff changeset
1009 if (token_deal != 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1010 dprintf(("Parse error, line %d, %s\n",line_count, tokens[0]));
223b71206888 Initial import
thib
parents:
diff changeset
1011 goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1012 }
223b71206888 Initial import
thib
parents:
diff changeset
1013 int number_deal = SplitVar(tokens[1], numbers, MAXVARS);
223b71206888 Initial import
thib
parents:
diff changeset
1014 SetOrigParamArray(tokens[0], number_deal, numbers);
223b71206888 Initial import
thib
parents:
diff changeset
1015 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1016 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1017 /* 一般的な設定以外 : cdrom track など */
0
223b71206888 Initial import
thib
parents:
diff changeset
1018 if (strncmp(tokens[0],"#NAME.", 6) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1019 if (token_deal != 2) goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1020 SetOrigParaStr(tokens[0], tokens[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1021 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1022 } else if (strncmp(tokens[0],"#DIRC.",6) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1023 if (token_deal != 3) goto parse_error;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1024 /* ファイル形式の指定 */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1025 FileSearcher::FILETYPE type;
0
223b71206888 Initial import
thib
parents:
diff changeset
1026 char* name = tokens[0]+6;
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1027 if (strcmp(name, "PDT") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1028 else if (strcmp(name, "G00") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1029 else if (strcmp(name, "GRP") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1030 else if (strcmp(name, "TXT") == 0) type = FileSearcher::SCN;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1031 else if (strcmp(name, "ANM") == 0) type = FileSearcher::ANM;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1032 else if (strcmp(name, "ARD") == 0) type = FileSearcher::ARD;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1033 else if (strcmp(name, "CUR") == 0) type = FileSearcher::CUR;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1034 else if (strcmp(name, "WAV") == 0) type = FileSearcher::WAV;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1035 else if (strcmp(name, "KOE") == 0) type = FileSearcher::KOE;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1036 else if (strcmp(name, "GAN") == 0) type = FileSearcher::GAN;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1037 else goto parse_error; /* 他に ALL,ROOT,MID,KOE,BGM。たぶん、存在しない */
0
223b71206888 Initial import
thib
parents:
diff changeset
1038 if (tokens[2][0] == 'N') { /* directory */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1039 file_searcher->SetFileInformation(type, FileSearcher::ATYPE_DIR, tokens[1]);
0
223b71206888 Initial import
thib
parents:
diff changeset
1040 dprintf(("set file directory; type %s, directory %s\n",name,tokens[1]));
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1041 } else if (tokens[2][0] == 'P' && tokens[2][1] == ':') { /* アーカイブ */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1042 file_searcher->SetFileInformation(type, FileSearcher::ATYPE_ARC, tokens[2]+2);
0
223b71206888 Initial import
thib
parents:
diff changeset
1043 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2));
223b71206888 Initial import
thib
parents:
diff changeset
1044 } else goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1045 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1046 }
223b71206888 Initial import
thib
parents:
diff changeset
1047 if (strncmp(tokens[0],"#ADRC.",6) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1048 if (token_deal != 3) goto parse_error;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1049 /* ファイル形式の指定 */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1050 FileSearcher::FILETYPE type;
0
223b71206888 Initial import
thib
parents:
diff changeset
1051 char* name = tokens[0]+6;
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1052 if (strcmp(name, "PDT") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1053 else if (strcmp(name, "G00") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1054 else if (strcmp(name, "GRP") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1055 else if (strcmp(name, "TXT") == 0) type = FileSearcher::SCN;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1056 else if (strcmp(name, "ANM") == 0) type = FileSearcher::ANM;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1057 else if (strcmp(name, "ARD") == 0) type = FileSearcher::ARD;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1058 else if (strcmp(name, "CUR") == 0) type = FileSearcher::CUR;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1059 else if (strcmp(name, "WAV") == 0) type = FileSearcher::WAV;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1060 else if (strcmp(name, "KOE") == 0) type = FileSearcher::KOE;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1061 else if (strcmp(name, "GAN") == 0) type = FileSearcher::GAN;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1062 else goto parse_error; /* 他に ALL,ROOT,MID,KOE,BGM。たぶん、存在しない */
0
223b71206888 Initial import
thib
parents:
diff changeset
1063 if (tokens[2][0] == 'N') { /* directory */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1064 file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_DIR, tokens[1]);
0
223b71206888 Initial import
thib
parents:
diff changeset
1065 dprintf(("set file directory; type %s, directory %s\n",name,tokens[1]));
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1066 } else if (tokens[2][0] == 'P' && tokens[2][1] == ':') { /* アーカイブ */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1067 file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_ARC, tokens[2]+2);
0
223b71206888 Initial import
thib
parents:
diff changeset
1068 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2));
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1069 } else if (tokens[2][0] == 'R' && tokens[2][1] == ':') { /* それ散るアーカイブ */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1070 file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_ARC, tokens[2]+2);
0
223b71206888 Initial import
thib
parents:
diff changeset
1071 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2));
223b71206888 Initial import
thib
parents:
diff changeset
1072 } else goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1073 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1074 }
223b71206888 Initial import
thib
parents:
diff changeset
1075 if (strncmp(tokens[0],"#FOLDNAME.",10) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1076 if (token_deal != 3) goto parse_error;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1077 /* ファイル形式の指定 */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1078 FileSearcher::FILETYPE type;
0
223b71206888 Initial import
thib
parents:
diff changeset
1079 char* name = tokens[0]+10;
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1080 if (strcmp(name, "PDT") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1081 else if (strcmp(name, "G00") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1082 else if (strcmp(name, "GRP") == 0) type = FileSearcher::PDT;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1083 else if (strcmp(name, "TXT") == 0) type = FileSearcher::SCN;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1084 else if (strcmp(name, "ANM") == 0) type = FileSearcher::ANM;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1085 else if (strcmp(name, "ARD") == 0) type = FileSearcher::ARD;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1086 else if (strcmp(name, "CUR") == 0) type = FileSearcher::CUR;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1087 else if (strcmp(name, "WAV") == 0) type = FileSearcher::WAV;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1088 else if (strcmp(name, "BGM") == 0) type = FileSearcher::BGM;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1089 else if (strcmp(name, "GAN") == 0) type = FileSearcher::GAN;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1090 else goto parse_error; /* 他に ALL,ROOT,MID,KOE,BGM。たぶん、存在しない */
0
223b71206888 Initial import
thib
parents:
diff changeset
1091 if (tokens[2][0] == '0') { /* directory */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1092 file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_DIR, tokens[1]);
0
223b71206888 Initial import
thib
parents:
diff changeset
1093 dprintf(("set file directory; type %s, directory %s\n",name,tokens[1]));
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1094 } else if (tokens[2][0] == '1' && tokens[2][1] == ':') { /* アーカイブ */
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
1095 file_searcher->AppendFileInformation(type, FileSearcher::ATYPE_SCN2k, tokens[2]+2);
0
223b71206888 Initial import
thib
parents:
diff changeset
1096 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2));
223b71206888 Initial import
thib
parents:
diff changeset
1097 } else goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1098 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1099 }
223b71206888 Initial import
thib
parents:
diff changeset
1100 if (strcmp(tokens[0], "#CDTRACK") == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1101 if (token_deal != 3) goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1102 track_name.AddCDROM(tokens[2], atoi(tokens[1]));
223b71206888 Initial import
thib
parents:
diff changeset
1103 dprintf(("Set CDTRACK, name %s, track %d\n",tokens[2], atoi(tokens[1])));
223b71206888 Initial import
thib
parents:
diff changeset
1104 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1105 }
223b71206888 Initial import
thib
parents:
diff changeset
1106 if (strcmp(tokens[0], "#DSTRACK") == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1107 /* #DSTRACK=00000000-99999000-00782556="filename" ="name" */
223b71206888 Initial import
thib
parents:
diff changeset
1108 /* #DSTRACK=00000000-99999000-00782556="name" */
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1109 /* 第二トークンの3つめのパラメータを得る(繰り返しの時の再生開始位置) */
0
223b71206888 Initial import
thib
parents:
diff changeset
1110 int start_pt = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1111 const char* tk1 = strchr(tokens[1], '-');
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
1112 const char* tk2 = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
1113 if (tk1 && *tk1) tk2 = strchr(tk1+1, '-');
223b71206888 Initial import
thib
parents:
diff changeset
1114 if (tk2 && *tk2) start_pt = atoi(tk2+1);
223b71206888 Initial import
thib
parents:
diff changeset
1115 if (token_deal == 3) {
223b71206888 Initial import
thib
parents:
diff changeset
1116 track_name.AddWave(tokens[2], tokens[2], start_pt);
223b71206888 Initial import
thib
parents:
diff changeset
1117 dprintf(("Set Wave track, name %s\n",tokens[2]));
223b71206888 Initial import
thib
parents:
diff changeset
1118 } else if (token_deal == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
1119 track_name.AddWave(tokens[3], tokens[2], start_pt);
223b71206888 Initial import
thib
parents:
diff changeset
1120 dprintf(("Set Wave track, name %s, file %s\n",tokens[3], tokens[2]));
223b71206888 Initial import
thib
parents:
diff changeset
1121 } else goto parse_error;
223b71206888 Initial import
thib
parents:
diff changeset
1122 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1123 }
223b71206888 Initial import
thib
parents:
diff changeset
1124 if (strncmp(tokens[0], "#SE.", 4) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1125 /* SE.XXX="XXX"=X */
223b71206888 Initial import
thib
parents:
diff changeset
1126 if (token_deal == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1127 track_name.AddSE(atoi(tokens[0]+4), tokens[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1128 } else if (token_deal == 3) {
223b71206888 Initial import
thib
parents:
diff changeset
1129 if (atoi(tokens[2]) != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1130 track_name.AddSE(atoi(tokens[0]+4), tokens[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1131 }
223b71206888 Initial import
thib
parents:
diff changeset
1132 }
223b71206888 Initial import
thib
parents:
diff changeset
1133 dprintf(("Set SE %d, name %s\n",atoi(tokens[0]+4), tokens[1]));
223b71206888 Initial import
thib
parents:
diff changeset
1134 goto parse_end;
223b71206888 Initial import
thib
parents:
diff changeset
1135 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1136 /* 設定項目が見つからなかった */
0
223b71206888 Initial import
thib
parents:
diff changeset
1137 dprintf(("Cannot find configuration name: %s\n",tokens[0]));
223b71206888 Initial import
thib
parents:
diff changeset
1138 parse_error:
223b71206888 Initial import
thib
parents:
diff changeset
1139 parse_end:
223b71206888 Initial import
thib
parents:
diff changeset
1140 line_count++;
223b71206888 Initial import
thib
parents:
diff changeset
1141 }
223b71206888 Initial import
thib
parents:
diff changeset
1142 delete info;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 54
diff changeset
1143 /* デフォルトのオプションを指定する */
0
223b71206888 Initial import
thib
parents:
diff changeset
1144 // set_game(GetParaStr("#REGNAME"), *this);
223b71206888 Initial import
thib
parents:
diff changeset
1145 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1146 }
223b71206888 Initial import
thib
parents:
diff changeset
1147
223b71206888 Initial import
thib
parents:
diff changeset
1148 TrackName::TrackName(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1149 deal = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1150 track = new char*[deal];
223b71206888 Initial import
thib
parents:
diff changeset
1151 track_wave = new char*[deal];
223b71206888 Initial import
thib
parents:
diff changeset
1152 track_num = new int[deal];
223b71206888 Initial import
thib
parents:
diff changeset
1153 track_start = new int[deal];
223b71206888 Initial import
thib
parents:
diff changeset
1154 int i; for (i=0; i<deal; i++) track[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1155 for (i=0; i<deal; i++) track_wave[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1156 se_deal = 10;
223b71206888 Initial import
thib
parents:
diff changeset
1157 se_track = new char*[se_deal];
223b71206888 Initial import
thib
parents:
diff changeset
1158 for (i=0; i<se_deal; i++) se_track[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1159 }
223b71206888 Initial import
thib
parents:
diff changeset
1160
223b71206888 Initial import
thib
parents:
diff changeset
1161 TrackName::~TrackName() {
223b71206888 Initial import
thib
parents:
diff changeset
1162 int i; for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1163 if (track[i] != 0) delete[] track[i];
223b71206888 Initial import
thib
parents:
diff changeset
1164 if (track_wave[i] != 0) delete[] track_wave[i];
223b71206888 Initial import
thib
parents:
diff changeset
1165 }
223b71206888 Initial import
thib
parents:
diff changeset
1166 for (i=0; i<se_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1167 if (se_track[i]) delete[] se_track[i];
223b71206888 Initial import
thib
parents:
diff changeset
1168 }
223b71206888 Initial import
thib
parents:
diff changeset
1169 delete[] track;
223b71206888 Initial import
thib
parents:
diff changeset
1170 delete[] track_wave;
223b71206888 Initial import
thib
parents:
diff changeset
1171 delete[] track_num;
223b71206888 Initial import
thib
parents:
diff changeset
1172 delete[] track_start;
223b71206888 Initial import
thib
parents:
diff changeset
1173 delete[] se_track;
223b71206888 Initial import
thib
parents:
diff changeset
1174 }
223b71206888 Initial import
thib
parents:
diff changeset
1175 void TrackName::Expand(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1176 int new_deal = deal * 2;
223b71206888 Initial import
thib
parents:
diff changeset
1177 int* new_track_num = new int[new_deal];
223b71206888 Initial import
thib
parents:
diff changeset
1178 int* new_track_start = new int[new_deal];
223b71206888 Initial import
thib
parents:
diff changeset
1179 char** new_track = new char*[new_deal];
223b71206888 Initial import
thib
parents:
diff changeset
1180 char** new_track_wave = new char*[new_deal];
223b71206888 Initial import
thib
parents:
diff changeset
1181 int i; for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1182 new_track_num[i] = track_num[i];
223b71206888 Initial import
thib
parents:
diff changeset
1183 new_track_start[i] = track_start[i];
223b71206888 Initial import
thib
parents:
diff changeset
1184 new_track[i] = track[i];
223b71206888 Initial import
thib
parents:
diff changeset
1185 new_track_wave[i] = track_wave[i];
223b71206888 Initial import
thib
parents:
diff changeset
1186 }
223b71206888 Initial import
thib
parents:
diff changeset
1187 for (; i<new_deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1188 new_track_num[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1189 new_track_start[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1190 new_track[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1191 new_track_wave[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1192 }
223b71206888 Initial import
thib
parents:
diff changeset
1193 deal = new_deal;
223b71206888 Initial import
thib
parents:
diff changeset
1194 delete[] track; track = new_track;
223b71206888 Initial import
thib
parents:
diff changeset
1195 delete[] track_num; track_num= new_track_num;
223b71206888 Initial import
thib
parents:
diff changeset
1196 delete[] track_start; track_start= new_track_start;
223b71206888 Initial import
thib
parents:
diff changeset
1197 delete[] track_wave; track_wave = new_track_wave;
223b71206888 Initial import
thib
parents:
diff changeset
1198 }
223b71206888 Initial import
thib
parents:
diff changeset
1199 void TrackName::ExpandSE(int n) {
223b71206888 Initial import
thib
parents:
diff changeset
1200 if (n < 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1201 n += 10;
223b71206888 Initial import
thib
parents:
diff changeset
1202 if (se_deal >= n) return;
223b71206888 Initial import
thib
parents:
diff changeset
1203 char** new_se = new char*[n];
223b71206888 Initial import
thib
parents:
diff changeset
1204 int i; for (i=0; i<se_deal; i++) new_se[i] = se_track[i];
223b71206888 Initial import
thib
parents:
diff changeset
1205 for (; i<n; i++) new_se[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1206 delete[] se_track;
223b71206888 Initial import
thib
parents:
diff changeset
1207 se_deal = n; se_track = new_se;
223b71206888 Initial import
thib
parents:
diff changeset
1208 }
223b71206888 Initial import
thib
parents:
diff changeset
1209 void TrackName::AddCDROM(char* name, int tk) {
223b71206888 Initial import
thib
parents:
diff changeset
1210 if (CDTrack(name) != -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1211 int i; for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1212 if (track[i] == 0) break;
223b71206888 Initial import
thib
parents:
diff changeset
1213 }
223b71206888 Initial import
thib
parents:
diff changeset
1214 int num = i;
223b71206888 Initial import
thib
parents:
diff changeset
1215 if (i == deal) Expand();
223b71206888 Initial import
thib
parents:
diff changeset
1216 track[num] = new char[strlen(name)+1];
223b71206888 Initial import
thib
parents:
diff changeset
1217 for (i=0; name[i] != 0; i++) track[num][i] = tolower(name[i]);
223b71206888 Initial import
thib
parents:
diff changeset
1218 track[num][i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1219 track_num[num] = tk;
223b71206888 Initial import
thib
parents:
diff changeset
1220 }
223b71206888 Initial import
thib
parents:
diff changeset
1221 void TrackName::AddWave(char* name, char* file, int pt) {
223b71206888 Initial import
thib
parents:
diff changeset
1222 if (CDTrack(name) != -1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1223 int i; for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1224 if (track[i] == 0) break;
223b71206888 Initial import
thib
parents:
diff changeset
1225 }
223b71206888 Initial import
thib
parents:
diff changeset
1226 int num = i;
223b71206888 Initial import
thib
parents:
diff changeset
1227 if (i == deal) Expand();
223b71206888 Initial import
thib
parents:
diff changeset
1228 track_num[num] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1229 track_start[num] = pt;
223b71206888 Initial import
thib
parents:
diff changeset
1230 track[num] = new char[strlen(name)+1];
223b71206888 Initial import
thib
parents:
diff changeset
1231 for (i=0; name[i] != 0; i++) track[num][i] = tolower(name[i]);
223b71206888 Initial import
thib
parents:
diff changeset
1232 track[num][i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1233 track_wave[num] = new char[strlen(file)+1]; strcpy(track_wave[num], file);
223b71206888 Initial import
thib
parents:
diff changeset
1234 }
223b71206888 Initial import
thib
parents:
diff changeset
1235 int TrackName::CDTrack(char* name) {
223b71206888 Initial import
thib
parents:
diff changeset
1236 char buf[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1237 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1238 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]);
223b71206888 Initial import
thib
parents:
diff changeset
1239 buf[i]=0;
223b71206888 Initial import
thib
parents:
diff changeset
1240 for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1241 if (track[i] == 0) return -1;
223b71206888 Initial import
thib
parents:
diff changeset
1242 if (strcmp(track[i], buf) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1243 return track_num[i];
223b71206888 Initial import
thib
parents:
diff changeset
1244 }
223b71206888 Initial import
thib
parents:
diff changeset
1245 }
223b71206888 Initial import
thib
parents:
diff changeset
1246 return -1;
223b71206888 Initial import
thib
parents:
diff changeset
1247 }
223b71206888 Initial import
thib
parents:
diff changeset
1248 int TrackName::TrackStart(char* name) {
223b71206888 Initial import
thib
parents:
diff changeset
1249 char buf[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1250 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1251 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]);
223b71206888 Initial import
thib
parents:
diff changeset
1252 buf[i]=0;
223b71206888 Initial import
thib
parents:
diff changeset
1253 for (i=0; i<deal; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1254 if (track[i] == 0) return -1;
223b71206888 Initial import
thib
parents:
diff changeset
1255 if (strcmp(track[i], buf) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1256 return track_start[i];
223b71206888 Initial import
thib
parents:
diff changeset
1257 }
223b71206888 Initial import
thib
parents:
diff changeset
1258 }
223b71206888 Initial import
thib
parents:
diff changeset
1259 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
1260 }
223b71206888 Initial import
thib
parents:
diff changeset
1261 const char* TrackName::WaveTrack(char* name) {
223b71206888 Initial import
thib
parents:
diff changeset
1262 char buf[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1263 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1264 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]);
223b71206888 Initial import
thib
parents:
diff changeset
1265 buf[i]=0;
223b71206888 Initial import
thib
parents:
diff changeset
1266 for (i=0; i<deal; i++) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
1267 if (track[i] == 0) return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
1268 if (strcmp(track[i], buf) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1269 return track_wave[i];
223b71206888 Initial import
thib
parents:
diff changeset
1270 }
223b71206888 Initial import
thib
parents:
diff changeset
1271 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
1272 return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
1273 }
223b71206888 Initial import
thib
parents:
diff changeset
1274 const char* TrackName::SETrack(int n) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
1275 if (n < 0 || n >= se_deal) return NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
1276 return se_track[n];
223b71206888 Initial import
thib
parents:
diff changeset
1277 }
54
d7cde171a1de * scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents: 53
diff changeset
1278
0
223b71206888 Initial import
thib
parents:
diff changeset
1279 void TrackName::AddSE(int n, char* file) {
223b71206888 Initial import
thib
parents:
diff changeset
1280 if (se_deal <= n) ExpandSE(n);
223b71206888 Initial import
thib
parents:
diff changeset
1281 if (se_track[n]) delete[] se_track[n];
223b71206888 Initial import
thib
parents:
diff changeset
1282 se_track[n] = new char[strlen(file)+1];
223b71206888 Initial import
thib
parents:
diff changeset
1283 strcpy(se_track[n], file);
223b71206888 Initial import
thib
parents:
diff changeset
1284 }
223b71206888 Initial import
thib
parents:
diff changeset
1285