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