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