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