Mercurial > otakunoraifu
annotate system/system_config.cc @ 47:5f548e5957a8
* get rid of the "deprecated conversion from string constant to ‘char*’" warnings
author | thib |
---|---|
date | Wed, 15 Apr 2009 20:26:32 +0000 |
parents | 651237260724 |
children | ed6c21dde840 |
rev | line source |
---|---|
0 | 1 /* system_config.cc |
2 * gameexe.ini ¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß | |
3 */ | |
4 | |
5 /* | |
6 * | |
7 * Copyright (C) 2000- Kazunori Ueno(JAGARL) <jagarl@creator.club.ne.jp> | |
8 * | |
9 * This program is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
27 | 19 * You should have received a copy of the GNU General Public License along |
20 * with this program; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
0 | 22 * |
23 */ | |
24 | |
25 #include <stdio.h> | |
26 #include <string.h> | |
27 #include <stdlib.h> | |
28 #include <stdarg.h> | |
29 #include <ctype.h> | |
30 #include <map> | |
31 #include <string> | |
32 #include "system_config.h" | |
33 #include "../system/file.h" | |
34 | |
35 using namespace std; | |
36 | |
37 // #define DEBUG_CONFIG | |
38 #ifdef DEBUG_CONFIG | |
39 # define dprintf(X) printf X | |
40 #else | |
41 # define dprintf(X) | |
42 #endif /* DEBUG_CONFIG */ | |
43 | |
44 #define MAXTOKEN 10 /* = ¤Ç¶èÀÚ¤é¤ì¤¿Îΰè¤ÎºÇÂç¿ô */ | |
45 #define MAXVARS 32 /* , ¤Ç¶èÀÚ¤é¤ì¤¿¿ôÃͤκÇÂç¿ô */ | |
46 | |
47 // ½é´ü²½¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß | |
48 /* config ¤Ï ʸ»úÎ󡢿ôÎ󡢤½¤ÎÊ£¹ç¤Ê¤É¡¢¤¤¤í¤¤¤í¤Ê·Á¼°¤¬¤¢¤ê¤¦¤ë */ | |
49 /* ʸ»úÎó¤È¿ôÎó¤Ï°ìÈÌ¤Ë AyuSys_Config ¥¯¥é¥¹¤Ë´Þ¤á¤ë */ | |
50 | |
51 | |
52 /**********************************************************/ | |
53 /* ¤È¤ê¤¢¤¨¤º¥Ï¥Ã¥·¥åÈæ³ÓÉդʸ»úÎó */ | |
54 class HashStr { | |
55 const char* str; | |
56 unsigned int hash; | |
57 public: | |
58 HashStr(const char*); | |
59 HashStr(const HashStr& orig); | |
60 ~HashStr() { | |
61 if (str) delete[] str; | |
62 } | |
63 const char* c_str(void) const { return str; } | |
64 friend inline int operator<(const HashStr& a, const HashStr& b) { | |
65 if (a.hash == b.hash) { | |
66 if (a.str == 0) return 1; | |
67 else if (b.str == 0) return 0; | |
68 else return strcmp(a.str, b.str); | |
69 } | |
70 else return a.hash < b.hash; | |
71 } | |
72 }; | |
73 HashStr::HashStr(const char* s ) { | |
74 if (s == 0 || s[0] == '\0') { | |
75 str = 0; hash = 0; return; /* invalid string */ | |
76 } | |
77 char* new_str = new char[strlen(s)+1]; | |
78 strcpy(new_str, s); | |
79 str = new_str; | |
80 /* calc hash... ŬÅö */ | |
81 int h = strlen(s); | |
82 while(*s != 0) { | |
83 h = *s + ((h * (0x9449+*s))>>7); | |
84 s++; | |
85 } | |
86 hash = (unsigned int)h; | |
87 } | |
88 HashStr::HashStr(const HashStr& orig) { | |
89 if (orig.str == 0 || orig.str[0] == '\0') { | |
90 str = 0; hash = 0; return; /* invalid */ | |
91 } | |
92 char* new_str = new char[strlen(orig.str)+1]; | |
93 strcpy(new_str, orig.str); | |
94 str = new_str; | |
95 hash = orig.hash; | |
96 } | |
97 | |
98 /********************************************************** | |
99 **AyuSys_Config_[String | Intlist] : | |
100 ** ÀßÄê¤ÎËÜÂÎ | |
101 ** original : ¸µÀßÄê | |
102 ** old_data : Á°²ó ClearDiff() ¤·¤¿¤È¤¤ÎÀßÄê | |
103 ** new_data : ClearDiff() °Ê¹ß¤ËÀßÄꤷ¤¿ÆâÍƤòÊݸ | |
104 ** ¥Ç¡¼¥¿ÀßÄꡧ | |
105 ** Init() : ¸µÀßÄê¤òºîÀ® | |
106 ** Set() : ÀßÄê¤òÊѹ¹ | |
107 ** Get() : ºÇ¤â¿·¤·¤¤ÀßÄê¤òÆÀ¤ë | |
108 ** | |
109 ** Êѹ¹¤ÎµÏ¿¡§ | |
110 ** Diff() : Á°²ó¤ÎClearDiff() ¤«¤éÊѹ¹¤·¤¿ÆâÍƤòÆÀ¤ë | |
111 ** DiffLen() : Diff() ¤ÇɬÍפÊʸ»úÎóŤòÆÀ¤ë | |
112 ** ClearDiff() : Êѹ¹µÏ¿¤ò¾Ã¤¹ | |
113 ** PatchOld() : Diff() ¤ÇÆÀ¤¿µÏ¿¤Ë´ð¤Å¤¡¢Êѹ¹Á°¤Î¾õÂÖ¤ËÌ᤹ | |
114 ** PatchNew() : Diff() ¤ÇÆÀ¤¿µÏ¿¤Ë´ð¤Å¤¡¢Êѹ¹¸å¤Î¾õÂÖ¤ËÌ᤹ | |
115 ** | |
116 ** ¸µÀßÄ꤫¤é¤ÎÊѹ¹¤ÎµÏ¿¡§ | |
117 ** SetOriginal() : ¸µÀßÄê¤ËÌ᤹ | |
118 ** DiffOriginal() : ¸µÀßÄ꤫¤é¸½ºß¤ÎÀßÄê¤ÎÊѹ¹¤òÆÀ¤ë | |
119 ** DiffOriginalLen() : DiffOriginal() ¤ÇɬÍפÊʸ»úÎóŤòÆÀ¤ë | |
120 ** PatchOriginal() : DiffOriginal() ¤ÇÆÀ¤¿µÏ¿¤Ë´ð¤Å¤¡¢ÀßÄê¤òÉüµì¤¹¤ë | |
121 */ | |
122 | |
123 /************************************************ | |
124 ** AyuSysConfigStringItem | |
125 ** ʸ»úÎó¤ò¥Ç¡¼¥¿¤È¤·¤Æ¤â¤ÄÀßÄê¹àÌÜ | |
126 */ | |
127 class AyuSysConfigStringItem { | |
128 char* original_data; | |
129 char* old_data; | |
130 char* new_data; | |
131 public: | |
132 AyuSysConfigStringItem(void) { | |
133 original_data = 0; | |
134 old_data = 0; | |
135 new_data = 0; | |
136 } | |
137 AyuSysConfigStringItem(const AyuSysConfigStringItem& o) { | |
138 original_data = 0; old_data = 0; new_data = 0; | |
139 if (o.original_data) { | |
140 original_data = new char[strlen(o.original_data)+1]; | |
141 strcpy(original_data, o.original_data); | |
142 } | |
143 if (o.old_data) { | |
144 old_data = new char[strlen(o.old_data)+1]; | |
145 strcpy(old_data, o.old_data); | |
146 } | |
147 if (o.new_data) { | |
148 new_data = new char[strlen(o.new_data)+1]; | |
149 strcpy(new_data, o.new_data); | |
150 } | |
151 } | |
152 /* ÀßÄꡧInit ¤Ç½é´ü²½¡¢Set ¤ÇÊѹ¹¡¢Get ¤ÇÊѹ¹¤òÍ¥À褷¤Æ¼è¤ê½Ð¤¹ */ | |
153 void Init(int deal, const char* str) { /* deal ¤Ï̵»ë */ | |
154 if (original_data) delete[] original_data; | |
155 int len = strlen(str); | |
156 original_data = new char[len+1]; | |
157 strcpy(original_data, str); | |
158 original_data[len] = '\0'; | |
159 } | |
160 void Set(int deal, const char* str) { /* deal ¤Ï̵»ë */ | |
161 if (new_data) delete[] new_data; | |
162 int len = strlen(str); | |
163 new_data = new char[len+1]; | |
164 strcpy(new_data, str); | |
165 new_data[len] = '\0'; | |
166 } | |
167 const char* Get(int deal) const {/* deal ¤Ï̵»ë */ | |
168 if (new_data) return new_data; | |
169 else if (old_data) return old_data; | |
170 return original_data; | |
171 } | |
172 const char* GetOriginal(int deal) const { | |
173 return original_data; | |
174 } | |
175 int Deal(void) const { | |
176 return 1; | |
177 } | |
178 /* ¥ª¥ê¥¸¥Ê¥ë¤«¤é¤ÎÊѲ½¤ÎÄ´ºº : | |
179 ** DiffOriginal ¤ÇÊѲ½¤òʸ»úÎó¤Ç¼è¤ê½Ð¤·¡¢PatchOriginal ¤Ç | |
180 ** ÊѲ½¤òÈ¿±Ç | |
181 */ | |
182 int DiffOriginalLen(void) { | |
183 if (new_data == 0) return 0; | |
184 return strlen(new_data)+1; | |
185 } | |
186 void DiffOriginal(string& data) { | |
187 if (new_data == 0) { /* ¤¢¤êÆÀ¤Ê¤¤ */ | |
188 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n"); | |
189 return; | |
190 } | |
191 char* out_data = new char[strlen(new_data)*2+1]; | |
192 char* buf = out_data; | |
193 int i; | |
194 for (i=0; new_data[i]!=0; i++) { | |
195 switch(new_data[i]) { | |
196 case '?': *buf++ = '?'; *buf++ = '0'; break; | |
197 case '"': *buf++ = '?'; *buf++ = '1'; break; | |
198 case '\'': *buf++ = '?'; *buf++ = '2'; break; | |
199 case ',': *buf++ = '?'; *buf++ = '3'; break; | |
200 case '.': *buf++ = '?'; *buf++ = '4'; break; | |
201 case ':': *buf++ = '?'; *buf++ = '5'; break; | |
202 case ';': *buf++ = '?'; *buf++ = '6'; break; | |
203 case '=': *buf++ = '?'; *buf++ = '7'; break; | |
204 case '<': *buf++ = '?'; *buf++ = '8'; break; | |
205 case '>': *buf++ = '?'; *buf++ = '9'; break; | |
206 default: *buf++ = new_data[i]; break; | |
207 } | |
208 } | |
209 *buf++ = 0; | |
210 data += out_data; | |
211 delete[] out_data; | |
212 return; | |
213 } | |
214 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
|
215 static const char* table = "?\"',.:;=<>"; |
0 | 216 if (new_data) delete[] new_data; |
217 if (old_data) delete[] old_data; | |
218 new_data = 0; old_data = 0; | |
219 new_data = new char[1024]; | |
220 int i,j = 0; | |
221 for (i=0; i<1020; i++) { | |
222 switch(data[j]) { | |
223 case '?': | |
224 if (data[j+1] >= '0' && data[j+1] <= '9') { | |
225 new_data[i] = table[ data[j+1] - '0']; | |
226 j += 2; | |
227 break; | |
228 } | |
229 case '"': case '\'': case ',': case '.': case ':': | |
230 case ';': case '=': case '<': case '>': | |
231 goto for_end; | |
232 default: new_data[i] = data[j++]; break; | |
233 } | |
234 } | |
235 for_end: | |
236 new_data[i] = 0; | |
237 return data; | |
238 } | |
239 void SetOriginal(void) { | |
240 if (new_data) delete[] new_data; | |
241 if (old_data) delete[] old_data; | |
242 new_data = 0; old_data = 0; | |
243 } | |
244 void Dump(FILE* f) const { | |
245 if (original_data) fprintf(f, "original %s ",original_data); | |
246 if (old_data) fprintf(f, "old_data %s ",old_data); | |
247 if (new_data) fprintf(f, "new_data %s ",new_data); | |
248 fprintf(f, "\n"); | |
249 } | |
250 }; | |
251 | |
252 /************************************************ | |
253 ** AyuSysConfigIntlistItem | |
254 ** ¿ôÃÍÎó¤ò¥Ç¡¼¥¿¤È¤·¤Æ¤â¤ÄÀßÄê¹àÌÜ | |
255 */ | |
256 class AyuSysConfigIntlistItem { | |
257 int item_deal; | |
258 int* original_data; | |
259 int* old_data; | |
260 int* new_data; | |
261 public: | |
262 AyuSysConfigIntlistItem(void) { | |
263 item_deal = 0; | |
264 original_data = 0; | |
265 old_data = 0; | |
266 new_data = 0; | |
267 } | |
268 AyuSysConfigIntlistItem(const AyuSysConfigIntlistItem& o) { | |
269 item_deal = o.item_deal; | |
270 original_data = 0; old_data = 0; new_data = 0; | |
271 if (o.original_data) { | |
272 original_data = new int[item_deal]; | |
273 memcpy(original_data, o.original_data, sizeof(int)*item_deal); | |
274 } | |
275 if (o.old_data) { | |
276 old_data = new int[item_deal]; | |
277 memcpy(old_data, o.old_data, sizeof(int)*item_deal); | |
278 } | |
279 if (o.new_data) { | |
280 new_data = new int[item_deal]; | |
281 memcpy(new_data, o.new_data, sizeof(int)*item_deal); | |
282 } | |
283 } | |
284 /* ÀßÄꡧInit ¤Ç½é´ü²½¡¢Set ¤ÇÊѹ¹¡¢Get ¤ÇÊѹ¹¤òÍ¥À褷¤Æ¼è¤ê½Ð¤¹ */ | |
285 void Init(int deal, const int* list) { /* deal ¤Ï̵»ë */ | |
286 if (original_data) delete[] original_data; | |
287 original_data = 0; | |
288 if (deal <= 0) { | |
289 item_deal = 0; return; | |
290 } | |
291 item_deal = deal; | |
292 original_data = new int[item_deal]; | |
293 memcpy(original_data, list, sizeof(int)*deal); | |
294 } | |
295 void Set(int deal, const int* list) { /* deal ¤Ï̵»ë */ | |
296 item_deal = deal; | |
297 if (new_data) delete[] new_data; | |
298 new_data = new int[item_deal]; | |
299 memcpy(new_data, list, sizeof(int)*item_deal); | |
300 } | |
301 const int* Get(int deal) const {/* deal ¤Ï̵»ë */ | |
302 if (item_deal == 0) return 0; | |
303 if (deal > item_deal) { | |
304 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal); | |
305 return 0; | |
306 } | |
307 if (new_data) return new_data; | |
308 else if (old_data) return old_data; | |
309 return original_data; | |
310 } | |
311 const int* GetOriginal(int deal) const {/* deal ¤Ï̵»ë */ | |
312 if (item_deal == 0) return 0; | |
313 if (deal > item_deal) { | |
314 fprintf(stderr,"AyuSysConfigIntlistItem::Get : invalid items deal %d (correct: %d)\n",deal,item_deal); | |
315 return 0; | |
316 } | |
317 return original_data; | |
318 } | |
319 int Deal(void) const { | |
320 return item_deal; | |
321 } | |
322 /* ¥ª¥ê¥¸¥Ê¥ë¤«¤é¤ÎÊѲ½¤ÎÄ´ºº : | |
323 ** DiffOriginal ¤ÇÊѲ½¤òʸ»úÎó¤Ç¼è¤ê½Ð¤·¡¢PatchOriginal ¤Ç | |
324 ** ÊѲ½¤òÈ¿±Ç | |
325 */ | |
326 int DiffOriginalLen(void) { | |
327 if (new_data == 0) return 0; | |
328 return 12 * item_deal + 1; | |
329 } | |
330 void DiffOriginal(string& data) { | |
331 if (new_data == 0) { /* ¤¢¤êÆÀ¤Ê¤¤ */ | |
332 fprintf(stderr,"AyuSysConfigStringItem::DiffOriginal : this method must not called if not required!\n"); | |
333 return; | |
334 } | |
335 int i; char buf[1024]; | |
336 for (i=0; i<item_deal; i++) { | |
337 sprintf(buf, "%d,",new_data[i]); | |
338 data += buf; | |
339 } | |
340 return; | |
341 } | |
342 const char* PatchOriginal(const char* data) { | |
343 if (old_data) delete[] old_data; | |
344 if (new_data) delete[] new_data; | |
345 old_data = 0; new_data = 0; | |
346 new_data = new int[item_deal]; | |
347 int i; | |
348 for (i=0; i<item_deal; i++) { | |
349 new_data[i] = atoi(data); | |
350 if (strchr(data, ',') == 0) break; | |
351 data = strchr(data, ',') + 1; | |
352 } | |
353 return data; | |
354 } | |
355 void SetOriginal(void) { | |
356 if (new_data) delete[] new_data; | |
357 if (old_data) delete[] old_data; | |
358 new_data = 0; old_data = 0; | |
359 } | |
360 void Dump(FILE* f) const { | |
361 fprintf(f, "item deal %d, ",item_deal); | |
362 if (original_data) { | |
363 fprintf(f, "(%d", original_data[0]); | |
364 int i;for (i=1; i<item_deal; i++) { | |
365 fprintf(f, ",%d",original_data[i]); | |
366 } | |
367 fprintf(f, ") "); | |
368 } | |
369 if (old_data) { | |
370 fprintf(f, "old %08x(%d", (unsigned int)(old_data), old_data[0]); | |
371 int i;for (i=1; i<item_deal; i++) { | |
372 fprintf(f, ",%d",old_data[i]); | |
373 } | |
374 fprintf(f, ") "); | |
375 } | |
376 if (new_data) { | |
377 fprintf(f, "new %08x(%d", (unsigned int)(new_data), new_data[0]); | |
378 int i;for (i=1; i<item_deal; i++) { | |
379 fprintf(f, ",%d",new_data[i]); | |
380 } | |
381 fprintf(f, ") "); | |
382 } | |
383 fprintf(f, "\n"); | |
384 } | |
385 }; | |
386 | |
387 // template map<HashStr, AyuSysConfigStringItem>; | |
388 // template map<HashStr, AyuSysConfigIntlistItem>; | |
389 | |
390 /************************************************ | |
391 ** AyuSysConfigItem | |
392 ** ¥Ç¡¼¥¿Ì¾ -> ¥Ç¡¼¥¿ËÜÂΤΠmap ¤È¡¢map Á´ÂÎ¤Ë | |
393 ** ÍÍ¡¹¤ÊÁàºî¤ò¹Ô¤¦¤¿¤á¤Î¥á¥½¥Ã¥É | |
394 */ | |
395 | |
396 template<class ItemType, class DataType> class AyuSysConfigItem { | |
397 typedef map<HashStr,ItemType> maptype; | |
398 typedef typename maptype::iterator mapiterator; | |
399 typedef typename maptype::const_iterator const_mapiterator; | |
400 maptype data; | |
401 public: | |
402 void SetOrig(HashStr& name, int deal, const DataType* str) { | |
403 if (str == 0) return; /* ̵¸ú */ | |
404 data[name].Init(deal, str); | |
405 } | |
406 void Set(HashStr& name, int deal, const DataType* new_data) { | |
407 if (new_data == 0) return; /* ̵¸ú */ | |
408 /* ÀßÄê¤ò¸¡º÷ */ | |
409 mapiterator it = data.find(name); | |
410 /* ÀßÄ꤬¸µÀßÄê¤Ë¸«¤Ä¤«¤é¤Ê¤¤¤Ê¤é¼ºÇÔ */ | |
411 if (it == data.end()) { | |
412 fprintf(stderr,"AyuSysConfigItem::Set : there is no '%s' parameter\n",name.c_str()); | |
413 return; | |
414 } | |
415 /* ÀßÄê¤òÊѹ¹ */ | |
416 it->second.Set(deal, new_data); | |
417 } | |
418 /* ¿·¤·¤¤ÀßÄê¤òÍ¥À褷¤ÆÊÖ¤¹ */ | |
419 const DataType* Get(int deal, HashStr& name) const { | |
420 const_mapiterator it = data.find(name); | |
421 if (it == data.end()) return 0; | |
422 return it->second.Get(deal); | |
423 } | |
424 const DataType* GetOriginal(int deal, HashStr& name) const { | |
425 const_mapiterator it = data.find(name); | |
426 if (it == data.end()) return 0; | |
427 return it->second.GetOriginal(deal); | |
428 } | |
429 int Deal(HashStr& name) const { | |
430 const_mapiterator it = data.find(name); | |
431 if (it == data.end()) return 0; | |
432 return it->second.Deal(); | |
433 } | |
434 /* ¥ª¥ê¥¸¥Ê¥ë¤«¤é¤ÎÊѲ½¤ÎÄ´ºº : | |
435 ** DiffOriginal ¤ÇÊѲ½¤òʸ»úÎó¤Ç¼è¤ê½Ð¤·¡¢PatchOriginal ¤Ç | |
436 ** ÊѲ½¤òÈ¿±Ç | |
437 */ | |
438 void DiffOriginal(string& ret_str) { | |
439 mapiterator it = data.begin(); | |
440 for (; it != data.end(); it++) { | |
441 int len = it->second.DiffOriginalLen(); | |
442 if (len) { | |
443 ret_str += it->first.c_str(); | |
444 ret_str += "="; | |
445 it->second.DiffOriginal(ret_str); | |
446 ret_str += ";"; | |
447 } | |
448 } | |
449 ret_str += ";"; | |
450 return; | |
451 } | |
452 const char* PatchOriginal(const char* diff_data) { | |
453 while(*diff_data != ';') { | |
454 char name[1024]; | |
455 const char* data_start = strchr(diff_data, '='); | |
456 if (data_start == 0) break; | |
457 strncpy(name, diff_data, data_start-diff_data); | |
458 name[data_start-diff_data] = 0; | |
459 data_start++; | |
460 mapiterator it = data.find(name); | |
461 if (it != data.end()) { | |
462 diff_data = data_start; | |
463 it->second.PatchOriginal(diff_data); | |
464 } | |
465 diff_data = strchr(diff_data, ';'); | |
466 if (diff_data) diff_data++; | |
467 } | |
468 if (*diff_data == ';') { | |
469 diff_data++; | |
470 } else { | |
471 fprintf(stderr,"AyusysConfigItem::PatchOriginal: invalid data %s\n",diff_data); | |
472 } | |
473 return diff_data; | |
474 } | |
475 void SetOriginal(void) { | |
476 mapiterator it = data.begin(); | |
477 for (; it != data.end(); it++) { | |
478 it->second.SetOriginal(); | |
479 } | |
480 } | |
481 void Dump(FILE* f) const { | |
482 const_mapiterator it = data.begin(); | |
483 for (; it != data.end(); it++) { | |
484 fprintf(f, "name %s: ",it->first.c_str()); | |
485 it->second.Dump(f); | |
486 } | |
487 } | |
488 }; | |
489 // template AyuSysConfigItem<AyuSysConfigStringItem, char>; | |
490 // template AyuSysConfigItem<AyuSysConfigIntlistItem, int>; | |
491 | |
492 /************************************************/ | |
493 /* ¥é¥Ã¥Ñ */ | |
494 struct AyuSysConfigString { | |
495 AyuSysConfigItem<AyuSysConfigStringItem,char> orig; | |
496 void Dump(FILE* f) const { | |
497 fprintf(f, "string config:\n"); | |
498 orig.Dump(f); | |
499 } | |
500 }; | |
501 struct AyuSysConfigIntlist { | |
502 AyuSysConfigItem<AyuSysConfigIntlistItem, int> orig; | |
503 void Dump(FILE* f) const { | |
504 fprintf(f, "integer array config:\n"); | |
505 orig.Dump(f); | |
506 } | |
507 }; | |
508 | |
509 /************************************************/ | |
510 /* AyuSysConfig ¥¯¥é¥¹ */ | |
511 int AyuSysConfig::SearchParam(const char* name) const{ | |
512 HashStr str(name); | |
513 if (str_config->orig.Get(1, str)) return 1; /* char* ¤Î¥Ñ¥é¥á¡¼¥¿ */ | |
514 else if (int_config->orig.Get(1, str)) return 2; /* int ¤Î¥Ñ¥é¥á¡¼¥¿ */ | |
515 /* XXX.015.XXX ¤ÎÎà¤Î¥¡¼Ì¾¤ò XXX.000.XXX ¤Î·Á¤Ëµ¬³Ê²½¤·¤ÆºÆ¸¡º÷ */ | |
516 char name_copy[1024]; | |
517 strncpy(name_copy, name, 1000); | |
518 name_copy[1000] = 0; | |
519 char* s; | |
520 for (s=name_copy; s != 0; s = strchr(s,'.')) { | |
521 if (isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3])) { | |
522 s[1] = '0'; s[2] = '0'; s[3] = '0'; | |
523 } | |
524 s++; | |
525 } | |
526 HashStr str2(name_copy); | |
527 if (str_config->orig.Get(1, str2)) return 1; /* char* ¤Î¥Ñ¥é¥á¡¼¥¿ */ | |
528 else if (int_config->orig.Get(1, str2)) return 2; /* int ¤Î¥Ñ¥é¥á¡¼¥¿ */ | |
529 else return 0; | |
530 } | |
531 const char* AyuSysConfig::GetParaStr(const char* name) const{ | |
532 HashStr str(name); | |
533 const char* ret = str_config->orig.Get(1,str); | |
534 if (ret == 0) { | |
535 // fprintf(stderr,"Cannot find config name '%s'\n",name); | |
536 } | |
537 return ret; | |
538 } | |
539 int AyuSysConfig::GetParam(const char* name, int deal, ...) const{ | |
540 HashStr str(name); | |
541 va_list va; int i; | |
542 const int* vars = int_config->orig.Get(deal, str); | |
543 if (vars == 0) { | |
544 // fprintf(stderr,"Cannot find config name '%s'\n",name); | |
545 va_start(va, deal); | |
546 for (i=0; i<deal; i++) { | |
547 int* var = va_arg(va, int*); | |
548 if (var) *var = 0; | |
549 } | |
550 return -1; | |
551 } else { | |
552 va_start(va, deal); | |
553 for (i=0; i<deal; i++) { | |
554 int* var = va_arg(va, int*); | |
555 if (var) *var = vars[i]; | |
556 } | |
557 } | |
558 return 0; | |
559 } | |
560 int AyuSysConfig::GetOriginalParam(const char* name, int deal, ...) const{ | |
561 HashStr str(name); | |
562 va_list va; int i; | |
563 const int* vars = int_config->orig.GetOriginal(deal, str); | |
564 if (vars == 0) { | |
565 // fprintf(stderr,"Cannot find config name '%s'\n",name); | |
566 va_start(va, deal); | |
567 for (i=0; i<deal; i++) { | |
568 int* var = va_arg(va, int*); | |
569 if (var) *var = 0; | |
570 } | |
571 return -1; | |
572 } else { | |
573 va_start(va, deal); | |
574 for (i=0; i<deal; i++) { | |
575 int* var = va_arg(va, int*); | |
576 if (var) *var = vars[i]; | |
577 } | |
578 } | |
579 return 0; | |
580 } | |
581 const int* AyuSysConfig::GetParamArray(const char* name, int& deal) const{ | |
582 HashStr str(name); | |
583 if (int_config->orig.Deal(str) == 0) { deal = 0; return 0; } | |
584 deal = int_config->orig.Deal(str); | |
585 const int* vars = int_config->orig.Get(deal, str); | |
586 if (vars == 0) { deal = 0; return 0; } | |
587 return vars; | |
588 } | |
589 void AyuSysConfig::SetParaStr(const char* name, const char* var) { | |
590 HashStr str(name); | |
591 dirty_flag = 1; change_flag = 1; | |
592 str_config->orig.Set(str, 1, var); | |
593 } | |
594 void AyuSysConfig::SetParam(const char* name, int deal, ...) { | |
595 if (deal >= MAXVARS) return ; | |
596 HashStr str(name); | |
597 int vars[MAXVARS]; va_list va; int i; | |
598 va_start(va, deal); | |
599 for (i=0; i<deal; i++) vars[i] = va_arg(va, int); | |
600 int_config->orig.Set(str, deal, vars); | |
601 dirty_flag = 1; change_flag = 1; | |
602 return; | |
603 } | |
604 void AyuSysConfig::SetOrigParaStr(const char* name, const char* var) { | |
605 HashStr str(name); | |
606 str_config->orig.SetOrig(str, 1, var); | |
607 change_flag = 1; | |
608 } | |
609 void AyuSysConfig::SetOrigParam(const char* name, int deal, ...) { | |
610 if (deal >= MAXVARS) return; | |
611 HashStr str(name); | |
612 int vars[MAXVARS]; va_list va; int i; | |
613 va_start(va, deal); | |
614 for(i=0; i<deal; i++) vars[i] = va_arg(va, int); | |
615 int_config->orig.SetOrig(str, deal, vars); | |
616 change_flag = 1; | |
617 } | |
618 void AyuSysConfig::SetOrigParamArray(const char* name, int deal, int* array) { | |
619 HashStr str(name); | |
620 int_config->orig.SetOrig(str, deal, array); | |
621 } | |
622 void AyuSysConfig::SetOriginal(void) { | |
623 /* Á´¤Æ¤ÎÀßÄê¤ò¸µ¤ËÌ᤹ */ | |
624 str_config->orig.SetOriginal(); | |
625 int_config->orig.SetOriginal(); | |
626 change_flag = 1; | |
627 } | |
628 void AyuSysConfig::DiffOriginal(string& data) { | |
629 str_config->orig.DiffOriginal(data); | |
630 int_config->orig.DiffOriginal(data); | |
631 return; | |
632 } | |
633 const char* AyuSysConfig::PatchOriginal(const char* data) { | |
634 data = str_config->orig.PatchOriginal(data); | |
635 data = int_config->orig.PatchOriginal(data); | |
636 return data; | |
637 } | |
638 | |
639 void AyuSysConfig::Dump(FILE* f) const { | |
640 str_config->Dump(f); | |
641 int_config->Dump(f); | |
642 } | |
643 | |
644 /************************************************ | |
645 ** AyuSysConfig ¤Î¥³¥ó¥¹¥È¥é¥¯¥¿¡§ | |
646 ** Á´¤Æ¤Î config ¹àÌܤò½é´ü²½¤¹¤ë | |
647 */ | |
648 AyuSysConfig::AyuSysConfig(void) { | |
649 int i; | |
650 | |
651 change_flag = 1; dirty_flag = 0; | |
652 str_config = new AyuSysConfigString; | |
653 int_config = new AyuSysConfigIntlist; | |
654 | |
655 /****** ʸ»úÎó *******/ | |
656 SetOrigParaStr("#WAKUPDT", "GRDAT"); /* ÏÈ¡¢¥Þ¥¦¥¹¥«¡¼¥½¥ë¤Ê¤É¤Î²èÁü¥Õ¥¡¥¤¥ë */ | |
657 SetOrigParaStr("#REGNAME", "xclannad"); /* ¥ì¥¸¥¹¥È¥ê̾¡£¥»¡¼¥Ö¥Õ¥¡¥¤¥ë¤ÎºîÀ®¤Ë»È¤¦ */ | |
658 SetOrigParaStr("#CAPTION", "xclannad"); /* ¥¦¥£¥ó¥É¥¦¤Î¥¿¥¤¥È¥ë */ | |
659 SetOrigParaStr("#SAVENAME","SAVE.INI"); /* ¥»¡¼¥Ö¥Õ¥¡¥¤¥ë¤Î̾Á° */ | |
660 SetOrigParaStr("#SAVETITLE", "This is save file"); /* ¥»¡¼¥Ö¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤Îʸ»úÎó */ | |
661 SetOrigParaStr("#SAVENOTITLE", "-----------------"); /* »È¤ï¤ì¤Æ¤Ê¤¤¥»¡¼¥Ö¥Ç¡¼¥¿¤Î̾Á° */ | |
662 SetOrigParaStr("#CGM_FILE", "MODE.CGM");/* CG mode ¤ÎÀßÄ꤬Êݸ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë̾ */ | |
663 SetOrigParaStr("#CGTABLE_FILE", "MODE.CGM");/* CG mode ¤ÎÀßÄ꤬Êݸ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë̾ */ | |
664 | |
665 SetOrigParaStr("#WAKU.000.000.NAME", ""); // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤ÎÁë¾þ¤ê²èÁü̾ | |
666 SetOrigParaStr("#WAKU.000.000.BACK", ""); // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Î¥Æ¥¥¹¥ÈÇطʲèÁü̾ | |
667 SetOrigParaStr("#WAKU.000.000.BTN", ""); // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Î¥Ü¥¿¥ó²èÁü̾ | |
668 | |
669 SetOrigParaStr("#MOUSE_CURSOR.000.NAME", ""); // ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤Î¥Õ¥¡¥¤¥ë̾ | |
670 SetOrigParaStr("#CURSOR.000.NAME", ""); // ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤Î¥Õ¥¡¥¤¥ë̾ | |
671 SetOrigParaStr("#SELBTN.000.NAME", ""); // ÁªÂò»èÇØ·Ê | |
672 SetOrigParaStr("#SELBTN.000.BACK", ""); // ÁªÂò»èÇØ·Ê | |
673 | |
674 char name_str[8] = "#NAME.A"; | |
675 for (i='A'; i<='Z'; i++) { | |
676 name_str[6] = i; | |
677 SetOrigParaStr(name_str, ""); | |
678 } | |
679 | |
680 /****** ¿ôÃÍÎó *******/ | |
681 SetOrigParam("#CANCELCALL", 2, 0,0); /* ¥¥ã¥ó¥»¥ë¥Ü¥¿¥ó(±¦¥¯¥ê¥Ã¥¯)¤·¤¿¤È¤¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¥µ¥Ö¥ë¡¼¥Á¥óÈÖ¹æ(¥á¥Ë¥å¡¼) */ | |
682 SetOrigParam("#COM2_TITLE", 1, 1); /* ¡© */ | |
683 SetOrigParam("#COM2_TITLE_COLOR", 1, 2); /* ÁªÂò»è¥¿¥¤¥È¥ë¤Î¿§ */ | |
684 SetOrigParam("#COM2_TITLE_INDENT", 1, 2); /* ¡© */ | |
685 SetOrigParam("#SAVEFILETIME", 1, 24); /* ¥»¡¼¥Ö¤¹¤ë¾ì½ê¤Î¿ô */ | |
686 SetOrigParam("#SEEN_START", 1, 0); /* ¥²¡¼¥à¤ò³«»Ï¤¹¤ë¥·¥Ê¥ê¥ªÈÖ¹æ */ | |
687 SetOrigParam("#SEEN_SRT", 1, 0); /* ¥²¡¼¥à¤ò³«»Ï¤¹¤ë¥·¥Ê¥ê¥ªÈÖ¹æ(¹¥¤¹¥¤Âç¹¥¤) */ | |
688 SetOrigParam("#SEEN_MENU", 1, 0); /* ¥á¥Ë¥å¡¼¤Î¥·¥Ê¥ê¥ªÈÖ¹æ */ | |
689 SetOrigParam("#SEEN_TEXT_CURRENT", 1, 0); /* seen.txt ¤ò root directory ¤ËÃÖ¤¯¤« */ | |
690 SetOrigParam("#FADE_TIME", 1, 40); /* ²èÌ̤Υե§¡¼¥É¡¦¥¢¥¦¥È¤Î®ÅÙ */ | |
691 SetOrigParam("#NVL_SYSTEM",1, 0); /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤¬Á´²èÌ̤«Èݤ« */ | |
692 SetOrigParam("#WINDOW_ATTR", 5, -1, 128,128, 190, 0); /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Î¿§ */ | |
693 SetOrigParam("#WINDOW_ATTR_AREA", 4, 4,4,4,4); /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤ÎÈÏ°Ï */ | |
694 SetOrigParam("#WINDOW_ATTR_TYPE", 1, 0); /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤òȾƩÌÀ¤Ë¤¹¤ë¤« */ | |
695 SetOrigParam("#WINDOW_MSG_POS", 2, 22, 350); /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Î°ÌÃÖ */ | |
696 SetOrigParam("#WINDOW_COM_POS", 2,450, 250); /* ÁªÂò¥¦¥£¥ó¥É¥¦¤Î°ÌÃÖ */ | |
697 SetOrigParam("#WINDOW_GRP_POS", 2, 16, 100); /* ¤Ê¤Ë¤«¤Î¥¦¥£¥ó¥É¥¦¤Î°ÌÃÖ */ | |
698 SetOrigParam("#WINDOW_SUB_POS", 2, 48, 100); /* ¤Ê¤Ë¤«¤Î¥¦¥£¥ó¥É¥¦¤Î°ÌÃÖ */ | |
699 SetOrigParam("#WINDOW_SYS_POS", 2, 32, 100); /* ¤Ê¤Ë¤«¤Î¥¦¥£¥ó¥É¥¦¤Î°ÌÃÖ */ | |
700 SetOrigParam("#WINDOW_WAKU_TYPE", 1, 0); /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤ÎÏȤμïÎà¡£xkanon Æȼ«ÀßÄê */ | |
701 SetOrigParam("#RETN_CONT", 1, 16); /* ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤Î¿ô */ | |
702 SetOrigParam("#RETN_SPEED",1,100); /* ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤ÎÆ°¤¯Â®ÅÙ */ | |
703 SetOrigParam("#RETN_XSIZE", 1, 16); /* ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤ÎÂ礤µ */ | |
704 SetOrigParam("#RETN_YSIZE", 1, 16); /* ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤ÎÂ礤µ */ | |
705 SetOrigParam("#FONT_SIZE", 1, 26); /* ¥Õ¥©¥ó¥È¤ÎÂ礤µ */ | |
706 SetOrigParam("#FONT_WEIGHT", 1, 100); /* ¥Õ¥©¥ó¥È¤Î weight */ | |
707 SetOrigParam("#MSG_MOJI_SIZE", 2, 12, 29); /* ʸ»ú¤ÎÂ礤µ(Ⱦ³Ñ) */ | |
708 SetOrigParam("#MESSAGE_SIZE", 2, 23, 3); /* ¥á¥Ã¥»¡¼¥¸¥¦¥£¥ó¥É¥¦¤Îʸ»ú¿ô */ | |
709 SetOrigParam("#COM_MESSAGE_SIZE", 2, 23, 3); /* ¥á¥Ã¥»¡¼¥¸¥¦¥£¥ó¥É¥¦¤Îʸ»ú¿ô */ | |
710 SetOrigParam("#INIT_MESSAGE_SPEED", 1, 30); /* ¥Æ¥¥¹¥Èɽ¼¨Â®ÅÙ */ | |
711 SetOrigParam("#INIT_MESSAGE_SPEED_MOD", 1, 0); /* ¥Æ¥¥¹¥Èɽ¼¨ no wait */ | |
712 SetOrigParam("#MESSAGE_KEY_WAIT_USE", 1, 0); /* ¥Æ¥¥¹¥È¿Ê¹Ô¥ª¡¼¥È¥â¡¼¥É */ | |
713 SetOrigParam("#MESSAGE_KEY_WAIT_TIME", 1, 1500); /* ¥ª¡¼¥È¥â¡¼¥É¤Ç¤Î¥¡¼ÂÔ¤Á»þ´Ö */ | |
714 | |
715 SetOrigParam("#GRP_DC_TIMES", 1, 4); /* ΢²èÌ̤οô */ | |
716 SetOrigParam("#MUSIC_LINEAR_PAC",1,0); /* PCM ¥Ç¡¼¥¿¤Î 8bit -> 16bit ÊÑ´¹¤ò¹Ô¤¦¤« */ | |
717 SetOrigParam("#MUSIC_TYPE",1,0); /* PCM ¥Ç¡¼¥¿¤Î¼ïÎà */ | |
718 SetOrigParam("#WINDOW_MSGBK_BOX",1,0); /* ¥Ð¥Ã¥¯¥í¥°ÍѤΥܥ¿¥ó */ | |
719 SetOrigParam("#WINDOW_MSGBK_LBOX_POS",4,15,7,8,0); /* ¥Ð¥Ã¥¯¥í¥°ÍѤΥܥ¿¥ó(º¸)¤Î°ÌÃÖ */ | |
720 SetOrigParam("#WINDOW_MSGBK_RBOX_POS",4,7,7,0,0); /* ¥Ð¥Ã¥¯¥í¥°ÍѤΥܥ¿¥ó(º¸)¤Î°ÌÃÖ */ | |
721 SetOrigParam("#MSGBK_MOD",1,0); /* ¥Ð¥Ã¥¯¥í¥°ÍѤΥܥ¿¥ó¤ò»ÈÍѤ¹¤ë¤« */ | |
722 | |
723 SetOrigParam("#WAKU.000.000.TYPE", 1, 5); | |
724 SetOrigParam("#WAKU.000.000.MOVE_BOX", 5, 0, 0, 0, 0, 0); // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Î°ÜÆ°Íѥܥ¿¥ó°ÌÃÖ | |
725 SetOrigParam("#WAKU.000.000.CLEAR_BOX", 5, 0, 0, 0, 0, 0); // °ì»þ¾ÃµîÍѥܥ¿¥ó°ÌÃÖ | |
726 SetOrigParam("#WAKU.000.000.READJUMP_BOX", 5, 0, 0, 0, 0, 0); // ¥¹¥¥Ã¥×Íѥܥ¿¥ó°ÌÃÖ | |
727 SetOrigParam("#WAKU.000.000.AUTOMODE_BOX", 5, 0, 0, 0, 0, 0); // ¥ª¡¼¥ÈÍѥܥ¿¥ó°ÌÃÖ | |
728 SetOrigParam("#WAKU.000.000.MSGBK_BOX", 5, 0, 0, 0, 0, 0); // ¥Ð¥Ã¥¯¥í¥°¥Ü¥¿¥ó°ÌÃÖ | |
729 SetOrigParam("#WAKU.000.000.MSGBKLEFT_BOX", 5, 0, 0, 0, 0, 0); // ¥Ð¥Ã¥¯¥í¥°¡Ê¿Ê¤á¤ë¡Ë¥Ü¥¿¥ó°ÌÃÖ | |
730 SetOrigParam("#WAKU.000.000.MSGBKRIGHT_BOX", 5, 0, 0, 0, 0, 0); // ¥Ð¥Ã¥¯¥í¥°¡ÊÌá¤ë¡Ë¥Ü¥¿¥ó°ÌÃÖ | |
731 SetOrigParam("#WAKU.000.000.EXBTN_000_BOX", 5, 0, 0, 0, 0, 0); // ¤½¤Î¾¥Ü¥¿¥ó£°°ÌÃÖ | |
732 SetOrigParam("#WAKU.000.000.EXBTN_001_BOX", 5, 0, 0, 0, 0, 0); // ¤½¤Î¾¥Ü¥¿¥ó£±°ÌÃÖ | |
733 SetOrigParam("#WAKU.000.000.EXBTN_002_BOX", 5, 0, 0, 0, 0, 0); // ¤½¤Î¾¥Ü¥¿¥ó£²°ÌÃÖ | |
734 | |
735 SetOrigParam("#WINDOW.000.MOJI_SIZE", 1, 21); // ʸ»ú¥µ¥¤¥º | |
736 SetOrigParam("#WINDOW.000.MOJI_REP", 2, -1, 2); // ʸ»ú¤Î;͵ | |
737 SetOrigParam("#WINDOW.000.MOJI_CNT", 2, 20, 3); // ¥¦¥£¥ó¥É¥¦Æâ¤Îʸ»ú¿ô | |
738 SetOrigParam("#WINDOW.000.MOJI_POS", 4, 100, 0, 180, 40); // ¥Æ¥¥¹¥È°ÌÃÖ¡£3¤ÄÌܤ¬x ¤Ç1¤ÄÌܤ¬y¤é¤·¤¤ | |
739 SetOrigParam("#WINDOW.000.MOJI_SHADOW", 1, 0); // ʸ»ú¤Ë±Æ¤òÉÕ¤±¤ë¤« | |
740 SetOrigParam("#WINDOW.000.LUBY_SIZE", 1, 8); // ¥ë¥Ó¤Îʸ»ú¥µ¥¤¥º | |
741 SetOrigParam("#WINDOW.000.MOJI_MIN", 2, 8, 1); // ʸ»úƱ»Î¤Î·ä´Ö¡© | |
742 SetOrigParam("#WINDOW.000.SELCOM_USE", 1, 0); // ÁªÂò»è¤Î¼ÂÁõÊýË¡ | |
743 SetOrigParam("#WINDOW.000.POS", 4, 100, 0, 0, 260); // ¥¦¥£¥ó¥É¥¦°ÌÃÖ | |
744 SetOrigParam("#WINDOW.000.ATTR_MOD", 1, 0); // ¥¦¥£¥ó¥É¥¦¿§ | |
745 SetOrigParam("#WINDOW.000.ATTR", 5, -1, -1, -1, -1, -1); // ¥¦¥£¥ó¥É¥¦¿§ | |
746 /* SELCOM ¤Ï¤è¤¯¤ï¤«¤é¤ó¤Î¤Ç̵»ë */ | |
747 SetOrigParam("#WINDOW.000.OPEN_ANM_MOD", 1, 0); // ¥¦¥£¥ó¥É¥¦¤ò³«¤¯¤È¤¤Î¸ú²Ì¤é¤·¤¤ | |
748 SetOrigParam("#WINDOW.000.OPEN_ANM_TIME", 1, 500); | |
749 SetOrigParam("#WINDOW.000.CLOSE_ANM_MOD", 1, 0); // ¥¦¥£¥ó¥É¥¦¤òÊĤ¸¤ë¤È¤¤Î¸ú²Ì¤é¤·¤¤ | |
750 SetOrigParam("#WINDOW.000.CLOSE_ANM_TIME", 1, 500); | |
751 SetOrigParam("#WINDOW.000.WAKU_SETNO", 1, 0); // ÏȤμïÎà | |
752 SetOrigParam("#WINDOW.000.MOVE_USE", 1, 0); // ¥¦¥£¥ó¥É¥¦ÏÈ°ÜÆ°¥Ü¥¿¥ó»ÈÍѤβÄÈÝ | |
753 SetOrigParam("#WINDOW.000.CLEAR_USE", 1, 0); // ¥¦¥£¥ó¥É¥¦ÏȾõî¥Ü¥¿¥ó»ÈÍѤβÄÈÝ | |
754 SetOrigParam("#WINDOW.000.READJUMP_USE", 1, 0); // ¥¹¥¥Ã¥×¥Ü¥¿¥ó»ÈÍѤβÄÈÝ | |
755 SetOrigParam("#WINDOW.000.AUTOMODE_USE", 1, 0); // ¥¹¥¥Ã¥×¥Ü¥¿¥ó»ÈÍѤβÄÈÝ | |
756 SetOrigParam("#WINDOW.000.MSGBK_USE", 1, 0); // ¥Ð¥Ã¥¯¥í¥°¥Ü¥¿¥ó»ÈÍѤβÄÈÝ | |
757 SetOrigParam("#WINDOW.000.MSGBKLEFT_USE", 1, 0); // ¥Ð¥Ã¥¯¥í¥°¡Ê¿Ê¤à¡Ë¥Ü¥¿¥ó»ÈÍѤβÄÈÝ | |
758 SetOrigParam("#WINDOW.000.MSGBKRIGHT_USE", 1, 0); // ¥Ð¥Ã¥¯¥í¥°¡ÊÌá¤ë¡Ë¥Ü¥¿¥ó»ÈÍѤβÄÈÝ | |
759 SetOrigParam("#WINDOW.000.EXBTN_000_USE", 1, 0); // ¤½¤Î¾¥Ü¥¿¥ó£°»ÈÍѤβÄÈÝ | |
760 SetOrigParam("#WINDOW.000.EXBTN_001_USE", 1, 0); // ¤½¤Î¾¥Ü¥¿¥ó£±»ÈÍѤβÄÈÝ | |
761 SetOrigParam("#WINDOW.000.EXBTN_002_USE", 1, 0); // ¤½¤Î¾¥Ü¥¿¥ó£²»ÈÍѤβÄÈÝ | |
762 SetOrigParam("#WINDOW.000.NAME_MOD", 1, 0); // ̾Á°¥¦¥£¥ó¥É¥¦¤òÊÌÅÓ»ÈÍѤ¹¤ë¤« | |
763 SetOrigParam("#WINDOW.000.NAME_MOJI_SIZE", 1, 20); // ̾Á°¥Õ¥©¥ó¥È¤Î¥µ¥¤¥º | |
764 SetOrigParam("#WINDOW.000.NAME_MOJI_POS", 2, 0, 0); // ̾Á°¥¦¥£¥ó¥É¥¦¤Îʸ»ú¤Î°ÌÃÖ | |
765 SetOrigParam("#WINDOW.000.NAME_MOJI_MIN", 1, 0); // ̾Á°¥¦¥£¥ó¥É¥¦¤ÎÉý | |
766 SetOrigParam("#WINDOW.000.NAME_CENTERING", 1, 1); // ̾Á°¤Î¥»¥ó¥¿¥ê¥ó¥°¤ÎÍ̵ | |
767 SetOrigParam("#WINDOW.000.NAME_POS", 2, 159, 78); // ̾Á°¥¦¥£¥ó¥É¥¦°ÌÃ֡ʺ¸²¼°ÌÃ֤餷¤¤¡Ë | |
768 SetOrigParam("#WINDOW.000.NAME_WAKU_SETNO", 1, -1); // ̾Á°¥¦¥£¥ó¥É¥¦°ÌÃ֡ʺ¸²¼°ÌÃ֤餷¤¤¡Ë | |
769 SetOrigParam("#WINDOW.000.FACE.000", 5, 0, 0, 1, 1, 1); // ´é¥¦¥£¥ó¥É¥¦°ÌÃÖ(»Ï¤á£²¤Ä¤¬x,y¡¢MOJI_POS¤«¤é¤ÎÁêÂаÌÃ֤ʤΤËÃí°Õ) | |
770 SetOrigParam("#WINDOW.000.KEYCUR_MOD", 3, 0, 0, 0); // ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤Î°ÌÃÖ | |
771 | |
772 | |
773 SetOrigParam("#CURSOR.000.SIZE", 2, 0, 0); // ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤ÎÂ礤µ | |
774 SetOrigParam("#CURSOR.000.CONT", 1, 50); // ¥ê¥¿¡¼¥ó¥«¡¼¥½¥ë¤Î·«¤êÊÖ¤·¿ô | |
775 SetOrigParam("#CURSOR.000.SPEED", 1, 1000); // ¥Ö¥ê¥ó¥¯¤¹¤ë®¤µ | |
776 | |
40 | 777 SetOrigParam("#SELBTN.000.CENTERING", 2, 0, 0); |
0 | 778 SetOrigParam("#SELBTN.000.BASEPOS", 2, 0, 0); // ÁªÂò»è¥¦¥£¥ó¥É¥¦¤Î°ÌÃÖ |
779 SetOrigParam("#SELBTN.000.REPPOS", 2, 0, 50); // ÁªÂò»è¥¦¥£¥ó¥É¥¦¤Î¼¡¤Î°ÌÃÖ¡ÊÁêÂÐ¡Ë | |
780 SetOrigParam("#SELBTN.000.MOJISIZE", 4, 26, 0,0,0); // ʸ»ú¤ÎÂ礤µ | |
781 SetOrigParam("#SELBTN.000.MOJIDEFAULTCOL", 1, 0); // ÈóÁªÂò»þ¤Îʸ»ú¿§ | |
782 SetOrigParam("#SELBTN.000.MOJISELECTCOL", 1, 0); // ÁªÂò»þ¤Îʸ»ú¿§ | |
783 | |
784 SetOrigParam("#COLOR_TABLE.000", 3, 255,255,255); | |
785 SetOrigParam("#SHAKE.000", 3, 0,0,0); | |
786 | |
787 SetOrigParam("#SELR.000",16,0,0,640,480,0,0,500,50,0,0,0,0,0,0,255,0); | |
788 SetOrigParam("#SEL.000", 15,0,0,639,479,0,0, 32, 4,0,0,0,0,0,0,0); | |
789 | |
790 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
|
791 |
92765a5661f7
added "new" label on last savegame and corrected StatSaveFile
thib
parents:
9
diff
changeset
|
792 SetOrigParam("#LASTSAVE", 1, 0); |
26 | 793 |
794 SetOrigParam("#VOLMOD", 4, 128, 128, 128, 128); | |
0 | 795 } |
9 | 796 AyuSysConfig::~AyuSysConfig(void) { |
797 delete str_config; | |
798 delete int_config; | |
799 } | |
0 | 800 |
801 static int SplitVar(const char* str, int* ret_var, int ret_size) { | |
802 /* , ¤¢¤ë¤¤¤Ï ),:( ¤ò¥»¥Ñ¥ì¡¼¥¿¤È¤·¤Æ¡¢-?[0-9]+ ¤Î | |
803 ** ¥Õ¥©¡¼¥Þ¥Ã¥È¤Î¿ôÃÍÎó¤òÆɤ߹þ¤à¡£ÀèƬ¤Ë (¡¢ËöÈø¤Ë ) ¤¬ÉÕ¤¤¦¤ë¡£ | |
804 ** (),-[0-9] °Ê³°¤Îʸ»ú¤¬¤¢¤Ã¤¿¤é¤½¤³¤Ç½ªÎ» | |
805 ** ÆÀ¤é¤ì¤¿¥Ç¡¼¥¿¿ô¤òÊÖ¤¹ | |
806 */ | |
807 if (*str == '(') str++; | |
808 int i; for (i=0; i<ret_size; i++) { | |
809 int c; int is_positive = 1; | |
810 /* ¥»¥Ñ¥ì¡¼¥¿¤ÎÆɤßÈô¤Ð¤· */ | |
811 c = *str; | |
812 if (c == ',' || c == ':') { | |
813 str++; | |
814 } else if (c == ')' && str[1] == '(') { | |
815 str += 2; | |
816 } | |
817 /* - ¤ò parse */ | |
818 c = *str; | |
819 if (c == '-' && isdigit(str[1])) { | |
820 is_positive = -1; str++; | |
821 } else if (! isdigit(c)) { | |
822 return i; /* °Û¾ï¤Êʸ»ú¤ò¸«¤Ä¤±¤¿¡§½ªÎ» */ | |
823 } | |
824 int number = 0; | |
825 /* ¿ô»úÆɤ߹þ¤ß */ | |
826 while(isdigit( (c=*str) )) { | |
827 number *= 10; | |
828 number += c-'0'; | |
829 str++; | |
830 } | |
831 ret_var[i] = is_positive * number; | |
832 } | |
833 return i; | |
834 } | |
835 /* ·è¤á¤é¤ì¤¿¿ô¤Î°ú¿ô¤òÆÀ¤ë¡£-1 ¤Ê¤é¥¨¥é¡¼¤¬À¸¤¸¤¿ */ | |
836 static inline int SplitVar(const char* str, int& var1) { | |
837 if (SplitVar(str, &var1, 1) != 1) return -1; | |
838 return 0; | |
839 } | |
840 static inline int SplitVar(const char* str, int& var1, int& var2) { | |
841 int vars[2]; | |
842 if (SplitVar(str, vars, 2) != 2) return -1; | |
843 var1 = vars[0]; var2 = vars[1]; | |
844 return 0; | |
845 } | |
846 static inline int SplitVar(const char* str, int& var1, int& var2, int& var3) { | |
847 int vars[3]; | |
848 if (SplitVar(str, vars, 3) != 3) return -1; | |
849 var1 = vars[0]; var2 = vars[1]; var3 = vars[2]; | |
850 return 0; | |
851 } | |
852 static inline int SplitVar(const char* str, int& var1, int& var2, int& var3, int& var4) { | |
853 int vars[4]; | |
854 if (SplitVar(str, vars, 4) != 4) return -1; | |
855 var1 = vars[0]; var2 = vars[1]; var3 = vars[2]; var4 = vars[3]; | |
856 return 0; | |
857 } | |
858 | |
859 bool AyuSysConfig::LoadInitFile(void) | |
860 { | |
861 char buf[1024]; int i; | |
862 char* tokens[MAXTOKEN]; int token_deal; int buf_ptr; | |
863 int numbers[MAXVARS]; | |
864 | |
865 ARCINFO* info = file_searcher.Find(FILESEARCH::ROOT, "gameexe.ini"); | |
866 if (info == NULL) return false; | |
867 int size = info->Size(); | |
868 unsigned char* buf_orig = (unsigned char*)info->Read(); | |
869 if (size <= 0 || buf_orig == 0) { | |
870 delete info; return false; | |
871 } | |
872 unsigned char* buf_end = buf_orig + size; | |
873 int line_count = 0; | |
874 while(buf_orig < buf_end) { | |
875 /* buf_orig ¤«¤é°ì¹ÔÆɤ߹þ¤à */ | |
876 /* ¤½¤ÎºÝ¤Ë¡¢ | |
877 ** ¡¦Æ¬¤¬ # °Ê³°¤Ê¤é¼¡¤Î¹Ô¤Þ¤Ç¤È¤Ð¤¹ | |
878 ** ¡¦"" ³°¤Î¥¹¥Ú¡¼¥¹¡¢TAB¤ò½é¤á¤È¤¹¤ëÀ©¸æʸ»ú (0x20 °Ê²¼¤ÎASCII¥³¡¼¥É)¤òºï½ü | |
879 ** ¡¦= ¤Ç¶èÀڤ롣¶èÀÚ¤ê¤ÏºÇÂç¤Ç10¸Ä¤Ç¡¢tokens ¤ËÂåÆþ¤µ¤ì¤ë | |
880 ** ¤Ê¤É¤ÎÁàºî¤ò¹Ô¤¦ | |
881 */ | |
882 | |
883 /* # ¥Á¥§¥Ã¥¯ */ | |
884 if (*buf_orig != '#') { | |
885 /* ¼¡¤Î '\n' ¤Þ¤ÇÆɤßÈô¤Ð¤· */ | |
886 while(buf_orig < buf_end && | |
887 *buf_orig != '\n' && *buf_orig != '\r') buf_orig++; | |
888 if (buf_orig < buf_end-1 && *buf_orig == '\r' && buf_orig[1] == '\n') buf_orig += 2; | |
889 else if (*buf_orig == '\r' || *buf_orig == '\n') buf_orig++; | |
890 line_count++; | |
891 continue; | |
892 } | |
893 /* ½é´ü²½ */ | |
894 token_deal = 1; tokens[0] = buf; buf_ptr = 0; | |
895 int in_quote = 0; | |
896 | |
897 while(buf_orig < buf_end && buf_ptr < 1023) { | |
898 if (in_quote) { | |
899 /* "" ¤ÎÃæ */ | |
900 int c = *buf_orig; | |
901 if (c == '\n' || c == '\r') { | |
902 break; | |
903 } else if (c == '\"') { | |
904 in_quote = 0; | |
905 } else { | |
906 buf[buf_ptr++] = c; | |
907 } | |
908 buf_orig++; | |
909 } else { /* quote ¤µ¤ì¤Æ¤Ê¤¤ */ | |
910 /* À©¸æʸ»ú¤òÆɤßÈô¤Ð¤¹ */ | |
911 while(*buf_orig <= 0x20 && buf_orig < buf_end && | |
912 *buf_orig != '\n' && *buf_orig != '\r') buf_orig++; | |
913 int c = *buf_orig; | |
914 if (c == '\n' || c == '\r') break; | |
915 /* = ¤Ê¤é¼¡¤Î token */ | |
916 if (c == '=') { | |
917 c = 0; tokens[token_deal++] = buf+buf_ptr+1; | |
918 if (token_deal >= MAXTOKEN) break; | |
919 } else if (c == '\"') { | |
920 in_quote = 1; buf_orig++; continue; | |
921 } | |
922 buf[buf_ptr++] = c; | |
923 buf_orig++; | |
924 } | |
925 } | |
926 buf[buf_ptr] = '\0'; | |
927 /* ËöÈø¤Î \r\n ¤ò¾Ãµî */ | |
928 if (buf_orig < buf_end-1 && buf_orig[0] == '\r' && buf_orig[1] == '\n') buf_orig += 2; | |
929 else if (buf_orig < buf_end && (buf_orig[0] == '\r' || buf_orig[0] == '\n')) buf_orig++; | |
930 /* ɬÍפʤé parse ÆâÍƤò½ÐÎÏ */ | |
931 dprintf(("line %3d ",line_count)); | |
932 for (i=0; i<token_deal; i++) { | |
933 dprintf(("%d:\"%s\", ",i,tokens[i])); | |
934 } | |
935 dprintf(("\n")); | |
936 if (in_quote) { | |
937 fprintf(stderr, "Warning : open quote is found while parsing gameexe.ini, line %d\n",line_count); | |
938 } | |
939 | |
940 | |
941 /* ÆÀ¤é¤ì¤¿ÆâÍƤò parse */ | |
942 | |
943 /* #NAME=<ʸ»úÎó> */ | |
944 int type = SearchParam(tokens[0]); | |
945 if (type == 1) { /* #NAME=<ʸ»úÎó> */ | |
946 if (token_deal != 2) { | |
947 dprintf(("Parse error, line %d, %s\n",line_count, tokens[0])); | |
948 goto parse_error; | |
949 } | |
950 SetOrigParaStr(tokens[0], tokens[1]); | |
951 goto parse_end; | |
952 } else if (type == 2) { /* #NAME=<¿ôÃÍÎó> */ | |
953 if (token_deal != 2) { | |
954 dprintf(("Parse error, line %d, %s\n",line_count, tokens[0])); | |
955 goto parse_error; | |
956 } | |
957 int number_deal = SplitVar(tokens[1], numbers, MAXVARS); | |
958 SetOrigParamArray(tokens[0], number_deal, numbers); | |
959 goto parse_end; | |
960 } | |
961 /* °ìÈÌŪ¤ÊÀßÄê°Ê³° : cdrom track ¤Ê¤É */ | |
962 if (strncmp(tokens[0],"#NAME.", 6) == 0) { | |
963 if (token_deal != 2) goto parse_error; | |
964 SetOrigParaStr(tokens[0], tokens[1]); | |
965 goto parse_end; | |
966 } else if (strncmp(tokens[0],"#DIRC.",6) == 0) { | |
967 if (token_deal != 3) goto parse_error; | |
968 /* ¥Õ¥¡¥¤¥ë·Á¼°¤Î»ØÄê */ | |
969 FILESEARCH::FILETYPE type; | |
970 char* name = tokens[0]+6; | |
971 if (strcmp(name, "PDT") == 0) type = FILESEARCH::PDT; | |
972 else if (strcmp(name, "G00") == 0) type = FILESEARCH::PDT; | |
973 else if (strcmp(name, "GRP") == 0) type = FILESEARCH::PDT; | |
974 else if (strcmp(name, "TXT") == 0) type = FILESEARCH::SCN; | |
975 else if (strcmp(name, "ANM") == 0) type = FILESEARCH::ANM; | |
976 else if (strcmp(name, "ARD") == 0) type = FILESEARCH::ARD; | |
977 else if (strcmp(name, "CUR") == 0) type = FILESEARCH::CUR; | |
978 else if (strcmp(name, "WAV") == 0) type = FILESEARCH::WAV; | |
979 else if (strcmp(name, "KOE") == 0) type = FILESEARCH::KOE; | |
980 else if (strcmp(name, "GAN") == 0) type = FILESEARCH::GAN; | |
981 else goto parse_error; /* ¾¤Ë ALL,ROOT,MID,KOE,BGM¡£¤¿¤Ö¤ó¡¢Â¸ºß¤·¤Ê¤¤ */ | |
982 if (tokens[2][0] == 'N') { /* directory */ | |
983 file_searcher.SetFileInformation(type, FILESEARCH::ATYPE_DIR, tokens[1]); | |
984 dprintf(("set file directory; type %s, directory %s\n",name,tokens[1])); | |
985 } else if (tokens[2][0] == 'P' && tokens[2][1] == ':') { /* ¥¢¡¼¥«¥¤¥Ö */ | |
986 file_searcher.SetFileInformation(type, FILESEARCH::ATYPE_ARC, tokens[2]+2); | |
987 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); | |
988 } else goto parse_error; | |
989 goto parse_end; | |
990 } | |
991 if (strncmp(tokens[0],"#ADRC.",6) == 0) { | |
992 if (token_deal != 3) goto parse_error; | |
993 /* ¥Õ¥¡¥¤¥ë·Á¼°¤Î»ØÄê */ | |
994 FILESEARCH::FILETYPE type; | |
995 char* name = tokens[0]+6; | |
996 if (strcmp(name, "PDT") == 0) type = FILESEARCH::PDT; | |
997 else if (strcmp(name, "G00") == 0) type = FILESEARCH::PDT; | |
998 else if (strcmp(name, "GRP") == 0) type = FILESEARCH::PDT; | |
999 else if (strcmp(name, "TXT") == 0) type = FILESEARCH::SCN; | |
1000 else if (strcmp(name, "ANM") == 0) type = FILESEARCH::ANM; | |
1001 else if (strcmp(name, "ARD") == 0) type = FILESEARCH::ARD; | |
1002 else if (strcmp(name, "CUR") == 0) type = FILESEARCH::CUR; | |
1003 else if (strcmp(name, "WAV") == 0) type = FILESEARCH::WAV; | |
1004 else if (strcmp(name, "KOE") == 0) type = FILESEARCH::KOE; | |
1005 else if (strcmp(name, "GAN") == 0) type = FILESEARCH::GAN; | |
1006 else goto parse_error; /* ¾¤Ë ALL,ROOT,MID,KOE,BGM¡£¤¿¤Ö¤ó¡¢Â¸ºß¤·¤Ê¤¤ */ | |
1007 if (tokens[2][0] == 'N') { /* directory */ | |
1008 file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_DIR, tokens[1]); | |
1009 dprintf(("set file directory; type %s, directory %s\n",name,tokens[1])); | |
1010 } else if (tokens[2][0] == 'P' && tokens[2][1] == ':') { /* ¥¢¡¼¥«¥¤¥Ö */ | |
1011 file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_ARC, tokens[2]+2); | |
1012 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); | |
1013 } else if (tokens[2][0] == 'R' && tokens[2][1] == ':') { /* ¤½¤ì»¶¤ë¥¢¡¼¥«¥¤¥Ö */ | |
1014 file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_ARC, tokens[2]+2); | |
1015 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); | |
1016 } else goto parse_error; | |
1017 goto parse_end; | |
1018 } | |
1019 if (strncmp(tokens[0],"#FOLDNAME.",10) == 0) { | |
1020 if (token_deal != 3) goto parse_error; | |
1021 /* ¥Õ¥¡¥¤¥ë·Á¼°¤Î»ØÄê */ | |
1022 FILESEARCH::FILETYPE type; | |
1023 char* name = tokens[0]+10; | |
1024 if (strcmp(name, "PDT") == 0) type = FILESEARCH::PDT; | |
1025 else if (strcmp(name, "G00") == 0) type = FILESEARCH::PDT; | |
1026 else if (strcmp(name, "GRP") == 0) type = FILESEARCH::PDT; | |
1027 else if (strcmp(name, "TXT") == 0) type = FILESEARCH::SCN; | |
1028 else if (strcmp(name, "ANM") == 0) type = FILESEARCH::ANM; | |
1029 else if (strcmp(name, "ARD") == 0) type = FILESEARCH::ARD; | |
1030 else if (strcmp(name, "CUR") == 0) type = FILESEARCH::CUR; | |
1031 else if (strcmp(name, "WAV") == 0) type = FILESEARCH::WAV; | |
1032 else if (strcmp(name, "BGM") == 0) type = FILESEARCH::BGM; | |
1033 else if (strcmp(name, "GAN") == 0) type = FILESEARCH::GAN; | |
1034 else goto parse_error; /* ¾¤Ë ALL,ROOT,MID,KOE,BGM¡£¤¿¤Ö¤ó¡¢Â¸ºß¤·¤Ê¤¤ */ | |
1035 if (tokens[2][0] == '0') { /* directory */ | |
1036 file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_DIR, tokens[1]); | |
1037 dprintf(("set file directory; type %s, directory %s\n",name,tokens[1])); | |
1038 } else if (tokens[2][0] == '1' && tokens[2][1] == ':') { /* ¥¢¡¼¥«¥¤¥Ö */ | |
1039 file_searcher.AppendFileInformation(type, FILESEARCH::ATYPE_SCN2k, tokens[2]+2); | |
1040 dprintf(("set file archive; type %s, file %s\n",name,tokens[2]+2)); | |
1041 } else goto parse_error; | |
1042 goto parse_end; | |
1043 } | |
1044 if (strcmp(tokens[0], "#CDTRACK") == 0) { | |
1045 if (token_deal != 3) goto parse_error; | |
1046 track_name.AddCDROM(tokens[2], atoi(tokens[1])); | |
1047 dprintf(("Set CDTRACK, name %s, track %d\n",tokens[2], atoi(tokens[1]))); | |
1048 goto parse_end; | |
1049 } | |
1050 if (strcmp(tokens[0], "#DSTRACK") == 0) { | |
1051 /* #DSTRACK=00000000-99999000-00782556="filename" ="name" */ | |
1052 /* #DSTRACK=00000000-99999000-00782556="name" */ | |
1053 /* ÂèÆó¥È¡¼¥¯¥ó¤Î£³¤Ä¤á¤Î¥Ñ¥é¥á¡¼¥¿¤òÆÀ¤ë¡Ê·«¤êÊÖ¤·¤Î»þ¤ÎºÆÀ¸³«»Ï°ÌÃÖ¡Ë */ | |
1054 int start_pt = 0; | |
1055 const char* tk1 = strchr(tokens[1], '-'); | |
1056 const char* tk2 = 0; | |
1057 if (tk1 && *tk1) tk2 = strchr(tk1+1, '-'); | |
1058 if (tk2 && *tk2) start_pt = atoi(tk2+1); | |
1059 if (token_deal == 3) { | |
1060 track_name.AddWave(tokens[2], tokens[2], start_pt); | |
1061 dprintf(("Set Wave track, name %s\n",tokens[2])); | |
1062 } else if (token_deal == 4) { | |
1063 track_name.AddWave(tokens[3], tokens[2], start_pt); | |
1064 dprintf(("Set Wave track, name %s, file %s\n",tokens[3], tokens[2])); | |
1065 } else goto parse_error; | |
1066 goto parse_end; | |
1067 } | |
1068 if (strncmp(tokens[0], "#SE.", 4) == 0) { | |
1069 /* SE.XXX="XXX"=X */ | |
1070 if (token_deal == 2) { | |
1071 track_name.AddSE(atoi(tokens[0]+4), tokens[1]); | |
1072 } else if (token_deal == 3) { | |
1073 if (atoi(tokens[2]) != 0) { | |
1074 track_name.AddSE(atoi(tokens[0]+4), tokens[1]); | |
1075 } | |
1076 } | |
1077 dprintf(("Set SE %d, name %s\n",atoi(tokens[0]+4), tokens[1])); | |
1078 goto parse_end; | |
1079 } | |
1080 /* ÀßÄê¹àÌܤ¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿ */ | |
1081 dprintf(("Cannot find configuration name: %s\n",tokens[0])); | |
1082 parse_error: | |
1083 parse_end: | |
1084 line_count++; | |
1085 } | |
1086 delete info; | |
1087 /* ¥Ç¥Õ¥©¥ë¥È¤Î¥ª¥×¥·¥ç¥ó¤ò»ØÄꤹ¤ë */ | |
1088 // set_game(GetParaStr("#REGNAME"), *this); | |
1089 return true; | |
1090 } | |
1091 | |
1092 TrackName::TrackName(void) { | |
1093 deal = 1; | |
1094 track = new char*[deal]; | |
1095 track_wave = new char*[deal]; | |
1096 track_num = new int[deal]; | |
1097 track_start = new int[deal]; | |
1098 int i; for (i=0; i<deal; i++) track[i] = 0; | |
1099 for (i=0; i<deal; i++) track_wave[i] = 0; | |
1100 se_deal = 10; | |
1101 se_track = new char*[se_deal]; | |
1102 for (i=0; i<se_deal; i++) se_track[i] = 0; | |
1103 } | |
1104 | |
1105 TrackName::~TrackName() { | |
1106 int i; for (i=0; i<deal; i++) { | |
1107 if (track[i] != 0) delete[] track[i]; | |
1108 if (track_wave[i] != 0) delete[] track_wave[i]; | |
1109 } | |
1110 for (i=0; i<se_deal; i++) { | |
1111 if (se_track[i]) delete[] se_track[i]; | |
1112 } | |
1113 delete[] track; | |
1114 delete[] track_wave; | |
1115 delete[] track_num; | |
1116 delete[] track_start; | |
1117 delete[] se_track; | |
1118 } | |
1119 void TrackName::Expand(void) { | |
1120 int new_deal = deal * 2; | |
1121 int* new_track_num = new int[new_deal]; | |
1122 int* new_track_start = new int[new_deal]; | |
1123 char** new_track = new char*[new_deal]; | |
1124 char** new_track_wave = new char*[new_deal]; | |
1125 int i; for (i=0; i<deal; i++) { | |
1126 new_track_num[i] = track_num[i]; | |
1127 new_track_start[i] = track_start[i]; | |
1128 new_track[i] = track[i]; | |
1129 new_track_wave[i] = track_wave[i]; | |
1130 } | |
1131 for (; i<new_deal; i++) { | |
1132 new_track_num[i] = 0; | |
1133 new_track_start[i] = 0; | |
1134 new_track[i] = 0; | |
1135 new_track_wave[i] = 0; | |
1136 } | |
1137 deal = new_deal; | |
1138 delete[] track; track = new_track; | |
1139 delete[] track_num; track_num= new_track_num; | |
1140 delete[] track_start; track_start= new_track_start; | |
1141 delete[] track_wave; track_wave = new_track_wave; | |
1142 } | |
1143 void TrackName::ExpandSE(int n) { | |
1144 if (n < 0) return; | |
1145 n += 10; | |
1146 if (se_deal >= n) return; | |
1147 char** new_se = new char*[n]; | |
1148 int i; for (i=0; i<se_deal; i++) new_se[i] = se_track[i]; | |
1149 for (; i<n; i++) new_se[i] = 0; | |
1150 delete[] se_track; | |
1151 se_deal = n; se_track = new_se; | |
1152 } | |
1153 void TrackName::AddCDROM(char* name, int tk) { | |
1154 if (CDTrack(name) != -1) return; | |
1155 int i; for (i=0; i<deal; i++) { | |
1156 if (track[i] == 0) break; | |
1157 } | |
1158 int num = i; | |
1159 if (i == deal) Expand(); | |
1160 track[num] = new char[strlen(name)+1]; | |
1161 for (i=0; name[i] != 0; i++) track[num][i] = tolower(name[i]); | |
1162 track[num][i] = 0; | |
1163 track_num[num] = tk; | |
1164 } | |
1165 void TrackName::AddWave(char* name, char* file, int pt) { | |
1166 if (CDTrack(name) != -1) return; | |
1167 int i; for (i=0; i<deal; i++) { | |
1168 if (track[i] == 0) break; | |
1169 } | |
1170 int num = i; | |
1171 if (i == deal) Expand(); | |
1172 track_num[num] = 0; | |
1173 track_start[num] = pt; | |
1174 track[num] = new char[strlen(name)+1]; | |
1175 for (i=0; name[i] != 0; i++) track[num][i] = tolower(name[i]); | |
1176 track[num][i] = 0; | |
1177 track_wave[num] = new char[strlen(file)+1]; strcpy(track_wave[num], file); | |
1178 } | |
1179 int TrackName::CDTrack(char* name) { | |
1180 char buf[1024]; | |
1181 int i; | |
1182 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]); | |
1183 buf[i]=0; | |
1184 for (i=0; i<deal; i++) { | |
1185 if (track[i] == 0) return -1; | |
1186 if (strcmp(track[i], buf) == 0) { | |
1187 return track_num[i]; | |
1188 } | |
1189 } | |
1190 return -1; | |
1191 } | |
1192 int TrackName::TrackStart(char* name) { | |
1193 char buf[1024]; | |
1194 int i; | |
1195 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]); | |
1196 buf[i]=0; | |
1197 for (i=0; i<deal; i++) { | |
1198 if (track[i] == 0) return -1; | |
1199 if (strcmp(track[i], buf) == 0) { | |
1200 return track_start[i]; | |
1201 } | |
1202 } | |
1203 return 0; | |
1204 } | |
1205 const char* TrackName::WaveTrack(char* name) { | |
1206 char buf[1024]; | |
1207 int i; | |
1208 for (i=0; name[i]!=0; i++) buf[i]=tolower(name[i]); | |
1209 buf[i]=0; | |
1210 for (i=0; i<deal; i++) { | |
1211 if (track[i] == 0) return 0; | |
1212 if (strcmp(track[i], buf) == 0) { | |
1213 return track_wave[i]; | |
1214 } | |
1215 } | |
1216 return 0; | |
1217 } | |
1218 const char* TrackName::SETrack(int n) { | |
1219 if (n < 0 || n >= se_deal) return 0; | |
1220 return se_track[n]; | |
1221 } | |
1222 void TrackName::AddSE(int n, char* file) { | |
1223 if (se_deal <= n) ExpandSE(n); | |
1224 if (se_track[n]) delete[] se_track[n]; | |
1225 se_track[n] = new char[strlen(file)+1]; | |
1226 strcpy(se_track[n], file); | |
1227 } | |
1228 |