/* * 澀爛白央奶伙毛 氏匹隙爛今木凶windowno及犯□正毛本永玄允月 * * 婁醒「 * meindex int 仇及NPC及charaindex * windowno int 它奴件玉它 寞 * */ static BOOL NPC_FmLetter_readData( int meindex, int windowno, BOOL chkflg) { int i; int linenum = 0; int endflg = FALSE; int buttonendflg; int winno = -1; int buttonconfmode; int b_mode; int selectnum ; int messagepos; BOOL errflg = FALSE; BOOL readflg = TRUE; FILE *fp; char argstr1[NPC_UTIL_GETARGSTR_BUFSIZE]; char *argstr; char filename[64]; char opfile[128]; char line[1024]; char firstToken[1024]; char secondToken[1024]; /* 它奴件玉它及澀爛毛 曰 戈厭瞻 */ argstr = NPC_Util_GetArgStr( meindex, argstr1, sizeof( argstr1)); /* 澀爛白央奶伙 潸 */ NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); sprintf( opfile, "%s/", getNpcdir( ) ); strcat( opfile, filename); fp = fopen( opfile, "r"); if( fp == NULL ) { print( "fmletter:file open error [%s]\n", opfile); return FALSE; } while( readflg == TRUE ) { endflg = FALSE; buttonendflg = TRUE; buttonconfmode = FALSE; selectnum = 0; messagepos = 0; winno = -1; b_mode = -1; errflg = FALSE; /* 賡渝祭 */ w.windowno = -1; w.windowtype = -1; w.buttontype = -1; w.takeitem = -1; w.giveitem = -1; w.message[0] = '\0'; for( i = 0; i < arraysizeof( buttonproc); i ++ ) { buttonproc[i].use = FALSE; buttonproc[i].checkhaveitem = -1; buttonproc[i].checkhaveitemgotowin = -1; buttonproc[i].checkdonthaveitem = -1; buttonproc[i].checkdonthaveitemgotowin = -1; buttonproc[i].warp = -1; buttonproc[i].battle = -1; buttonproc[i].gotowin = -1; } while( 1) { char buf[256]; int ret; if( !fgets( line, sizeof( line), fp)){ readflg = FALSE; break; } linenum ++; /* 戊丟件玄反 骰 */ if( line[0] == '#' || line[0] == '\n') continue; /* 荼墊潸月 */ chomp( line ); /* 墊毛幫溥允月 */ /* 引內 tab 毛 " " 卞 五晶尹月 */ replaceString( line, '\t' , ' ' ); /* 燮 及旦矢□旦毛潸月〔*/ for( i = 0; i < strlen( line); i ++) { if( line[i] != ' ' ) { break; } strcpy( buf, &line[i]); } if( i != 0 ) strcpy( line, buf); /* delim "=" 匹 賡(1)及玄□弁件毛 月*/ ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, sizeof( firstToken ) ); if( ret == FALSE ){ print( "Find error at %s in line %d. Ignore\n", filename , linenum); continue; } /* delim "=" 匹2 及玄□弁件毛 月*/ ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, sizeof( secondToken ) ); if( ret == FALSE ){ print( "Find error at %s in line %d. Ignore\n", filename , linenum); continue; } if( strcasecmp( firstToken, "winno") == 0 ) { if( winno != -1 ) { print( "fmletter:已有winno卻重新定義winno\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; readflg = FALSE; break; } /* 它奴件玉它No毛忡繡 */ winno = atoi( secondToken); continue; } /* 它奴件玉它No 互瑁引勻化中卅中凜及墊反 骰允月 */ if( winno == -1 ) { print( "fmletter:winno 尚未定義,資料卻已設定。\n"); print( "filename:[%s] line[%d]\n", filename, linenum); readflg = FALSE; errflg = FALSE; break; } /* 它奴件玉它No 互域譙仄凶凜反橢瘀毛 戈〔 * 公木動陸反 骰允月 */ if( (chkflg == FALSE && winno == windowno )|| chkflg == TRUE) { if( buttonconfmode == TRUE ) { if( strcasecmp( firstToken, "gotowin") == 0 ) { buttonproc[b_mode].gotowin = atoi( secondToken); } else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { buttonproc[b_mode].checkhaveitem = atoi( secondToken); } else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); } else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); } else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); } else if( strcasecmp( firstToken, "endbutton") == 0 ) { if( buttonproc[b_mode].gotowin == - 1 ) { if( buttonproc[b_mode].checkhaveitem == -1 && buttonproc[b_mode].checkdonthaveitem == -1) { errflg = TRUE; } else { /* 升勻切井井凶勻吊分仃匹手澀爛今木化中木壬 */ if( !((buttonproc[b_mode].checkhaveitem != -1 && buttonproc[b_mode].checkhaveitemgotowin != -1) || (buttonproc[b_mode].checkdonthaveitem != -1 && buttonproc[b_mode].checkdonthaveitemgotowin != -1))) { errflg = TRUE; } } } if( errflg == TRUE) { print( "fmletter: 找不到gotowin\n"); print( "filename:[%s] line[%d]\n", filename, linenum); readflg = FALSE; errflg = TRUE; break; } buttonproc[b_mode].use = TRUE; buttonconfmode = FALSE; buttonendflg = TRUE; } } else { w.windowno = winno; sprintf( buf, "letter%d", CHAR_getInt( meindex, CHAR_FMINDEX) ); /* 它奴件玉它正奶皿及澀爛 */ if( strcasecmp( firstToken, "wintype") == 0 ) { w.windowtype = atoi( secondToken); } /* 示正件正奶皿及澀爛 */ else if( strcasecmp( firstToken, "buttontype") == 0 ) { w.buttontype = NPC_FmLetter_restoreButtontype( secondToken); } /* getitem及澀爛 */ else if( strcasecmp( firstToken, "takeitem") == 0 ) { w.takeitem = atoi( secondToken); } /* giveitem及澀爛 */ else if( strcasecmp( firstToken, "giveitem") == 0 ) { w.giveitem = atoi( secondToken); } else if( strcasecmp( firstToken, buf) == 0 ) { w.letter = atoi( secondToken); } /* message及澀爛 */ else if( strcasecmp( firstToken, "message") == 0 ) { if( messagepos == 0 ) { strcpy( w.message, secondToken); messagepos = strlen( w.message); } else { w.message[messagepos]='\n'; messagepos++; strcpy( &w.message[messagepos], secondToken); messagepos+=strlen(secondToken); } } /* 示正件毛瓷仄凶凜及澀爛 */ else if( strcasecmp( firstToken, "okpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 0; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 1; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "yespressed") == 0 ) { buttonconfmode = TRUE; b_mode = 2; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "nopressed") == 0 ) { buttonconfmode = TRUE; b_mode = 3; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "prevpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 4; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "nextpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 5; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "selected") == 0 ) { buttonconfmode = TRUE; b_mode = 6 + selectnum; buttonendflg = FALSE; selectnum ++; } /* 澀爛蔽歹曰 */ else if( strcasecmp( firstToken, "endwin") == 0 ) { endflg = TRUE; if( chkflg == FALSE) { readflg = FALSE; } break; } else { //print( "fmletter:設定是不可能的參數\n"); //print( "filename:[%s] line[%d]\n", filename, linenum); } } } else { if( strcasecmp( firstToken, "endwin") == 0 ) { winno = -1; } } } if( buttonendflg == FALSE) { print( "fmletter: 找不到endbutton\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } if( winno != -1 ) { if( w.windowtype == -1 ) { print( "fmletter: 找不到wintype\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } if( w.buttontype == -1 ) { print( "fmletter: 找不到button\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } if( strlen( w.message) == 0 ) { print( "fmletter: 找不到message\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } } } fclose( fp); if( chkflg == FALSE && w.windowno == -1 ) { print( "fmletter: 找不到所指定的windowno\n"); print( "filename:[%s] line[%d]\n", filename, linenum); return FALSE; } if( winno != -1 && endflg == FALSE) { print( "fmletter: 找不到endwin\n"); print( "filename:[%s] line[%d]\n", filename, linenum); return FALSE; } if( errflg == TRUE) return FALSE; return TRUE; }
/* * ÀßÄê¥Õ¥¡¥¤¥ë¤ò ¤ó¤Ç»ØÄꤵ¤ì¤¿windowno¤Î¥Ç¡¼¥¿¤ò¥»¥Ã¥È¤¹¤ë * * °ú¿ô¡u * meindex int ¤³¤ÎNPC¤Îcharaindex * windowno int ¥¦¥£¥ó¥É¥¦ ¹æ * */ static BOOL NPC_FmLetter_readData( int meindex, int windowno, BOOL chkflg) { int i; int linenum = 0; int endflg = FALSE; int buttonendflg; int winno = -1; int buttonconfmode; int b_mode; int selectnum ; int messagepos; BOOL errflg = FALSE; BOOL readflg = TRUE; FILE *fp; char argstr1[NPC_UTIL_GETARGSTR_BUFSIZE]; char *argstr; char filename[64]; char opfile[128]; char line[1024]; char firstToken[1024]; char secondToken[1024]; /* ¥¦¥£¥ó¥É¥¦¤ÎÀßÄê¤ò ¤ê ¤à¹½Â¤ */ argstr = NPC_Util_GetArgStr( meindex, argstr1, sizeof( argstr1)); /* ÀßÄê¥Õ¥¡¥¤¥ë ¼è */ NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); sprintf( opfile, "%s/", getNpcdir( ) ); strcat( opfile, filename); fp = fopen( opfile, "r"); if( fp == NULL ) { print( "fmletter:file open error [%s]\n", opfile); return FALSE; } while( readflg == TRUE ) { endflg = FALSE; buttonendflg = TRUE; buttonconfmode = FALSE; selectnum = 0; messagepos = 0; winno = -1; b_mode = -1; errflg = FALSE; /* ½é´ü²½ */ w.windowno = -1; w.windowtype = -1; w.buttontype = -1; w.takeitem = -1; w.giveitem = -1; w.message[0] = '\0'; for( i = 0; i < arraysizeof( buttonproc); i ++ ) { buttonproc[i].use = FALSE; buttonproc[i].checkhaveitem = -1; buttonproc[i].checkhaveitemgotowin = -1; buttonproc[i].checkdonthaveitem = -1; buttonproc[i].checkdonthaveitemgotowin = -1; buttonproc[i].warp = -1; buttonproc[i].battle = -1; buttonproc[i].gotowin = -1; } while( 1) { char buf[256]; int ret; if( !fgets( line, sizeof( line), fp)){ readflg = FALSE; break; } linenum ++; /* ¥³¥á¥ó¥È¤Ï »ë */ if( line[0] == '#' || line[0] == '\n') continue; /* ²þ¹Ô¼è¤ë */ chomp( line ); /* ¹Ô¤òÀ°·Á¤¹¤ë */ /* ¤Þ¤º tab ¤ò " " ¤Ë ¤´¹¤¨¤ë */ replaceString( line, '\t' , ' ' ); /* Àè ¤Î¥¹¥Ú¡¼¥¹¤ò¼è¤ë¡e*/ for( i = 0; i < strlen( line); i ++) { if( line[i] != ' ' ) { break; } strcpy( buf, &line[i]); } if( i != 0 ) strcpy( line, buf); /* delim "=" ¤Ç ½é(1)¤Î¥È¡¼¥¯¥ó¤ò ¤ë*/ ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, sizeof( firstToken ) ); if( ret == FALSE ){ print( "Find error at %s in line %d. Ignore\n", filename , linenum); continue; } /* delim "=" ¤Ç2 ¤Î¥È¡¼¥¯¥ó¤ò ¤ë*/ ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, sizeof( secondToken ) ); if( ret == FALSE ){ print( "Find error at %s in line %d. Ignore\n", filename , linenum); continue; } if( strcasecmp( firstToken, "winno") == 0 ) { if( winno != -1 ) { print( "fmletter:¤w¦³winno«o«·s©w¸qwinno\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; readflg = FALSE; break; } /* ¥¦¥£¥ó¥É¥¦No¤òÊݸ */ winno = atoi( secondToken); continue; } /* ¥¦¥£¥ó¥É¥¦No ¤¬·è¤Þ¤Ã¤Æ¤¤¤Ê¤¤»þ¤Î¹Ô¤Ï »ë¤¹¤ë */ if( winno == -1 ) { print( "fmletter:winno ©|¥¼©w¸q¡A¸ê®Æ«o¤w³]©w¡C\n"); print( "filename:[%s] line[%d]\n", filename, linenum); readflg = FALSE; errflg = FALSE; break; } /* ¥¦¥£¥ó¥É¥¦No ¤¬°ìÃפ·¤¿»þ¤Ï¾ò·ï¤ò ¤à¡e * ¤½¤ì°Ê³°¤Ï »ë¤¹¤ë */ if( (chkflg == FALSE && winno == windowno )|| chkflg == TRUE) { if( buttonconfmode == TRUE ) { if( strcasecmp( firstToken, "gotowin") == 0 ) { buttonproc[b_mode].gotowin = atoi( secondToken); } else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { buttonproc[b_mode].checkhaveitem = atoi( secondToken); } else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); } else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); } else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); } else if( strcasecmp( firstToken, "endbutton") == 0 ) { if( buttonproc[b_mode].gotowin == - 1 ) { if( buttonproc[b_mode].checkhaveitem == -1 && buttonproc[b_mode].checkdonthaveitem == -1) { errflg = TRUE; } else { /* ¤É¤Ã¤Á¤«¤«¤¿¤Ã¦Q¤À¤±¤Ç¤âÀßÄꤵ¤ì¤Æ¤¤¤ì¤Ð */ if( !((buttonproc[b_mode].checkhaveitem != -1 && buttonproc[b_mode].checkhaveitemgotowin != -1) || (buttonproc[b_mode].checkdonthaveitem != -1 && buttonproc[b_mode].checkdonthaveitemgotowin != -1))) { errflg = TRUE; } } } if( errflg == TRUE) { print( "fmletter: §ä¤£¨ìgotowin\n"); print( "filename:[%s] line[%d]\n", filename, linenum); readflg = FALSE; errflg = TRUE; break; } buttonproc[b_mode].use = TRUE; buttonconfmode = FALSE; buttonendflg = TRUE; } } else { w.windowno = winno; sprintf( buf, "letter%d", CHAR_getInt( meindex, CHAR_FMINDEX) ); /* ¥¦¥£¥ó¥É¥¦¥¿¥¤¥×¤ÎÀßÄê */ if( strcasecmp( firstToken, "wintype") == 0 ) { w.windowtype = atoi( secondToken); } /* ¥Ü¥¿¥ó¥¿¥¤¥×¤ÎÀßÄê */ else if( strcasecmp( firstToken, "buttontype") == 0 ) { w.buttontype = NPC_FmLetter_restoreButtontype( secondToken); } /* getitem¤ÎÀßÄê */ else if( strcasecmp( firstToken, "takeitem") == 0 ) { w.takeitem = atoi( secondToken); } /* giveitem¤ÎÀßÄê */ else if( strcasecmp( firstToken, "giveitem") == 0 ) { w.giveitem = atoi( secondToken); } else if( strcasecmp( firstToken, buf) == 0 ) { w.letter = atoi( secondToken); } /* message¤ÎÀßÄê */ else if( strcasecmp( firstToken, "message") == 0 ) { if( messagepos == 0 ) { strcpy( w.message, secondToken); messagepos = strlen( w.message); } else { w.message[messagepos]='\n'; messagepos++; strcpy( &w.message[messagepos], secondToken); messagepos+=strlen(secondToken); } } /* ¥Ü¥¿¥ó¤ò²¡¤·¤¿»þ¤ÎÀßÄê */ else if( strcasecmp( firstToken, "okpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 0; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 1; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "yespressed") == 0 ) { buttonconfmode = TRUE; b_mode = 2; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "nopressed") == 0 ) { buttonconfmode = TRUE; b_mode = 3; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "prevpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 4; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "nextpressed") == 0 ) { buttonconfmode = TRUE; b_mode = 5; buttonendflg = FALSE; } else if( strcasecmp( firstToken, "selected") == 0 ) { buttonconfmode = TRUE; b_mode = 6 + selectnum; buttonendflg = FALSE; selectnum ++; } /* ÀßÄ꽪¤ï¤ê */ else if( strcasecmp( firstToken, "endwin") == 0 ) { endflg = TRUE; if( chkflg == FALSE) { readflg = FALSE; } break; } else { //print( "fmletter:³]©w¬O¤£¥i¯àªº°Ñ¼Æ\n"); //print( "filename:[%s] line[%d]\n", filename, linenum); } } } else { if( strcasecmp( firstToken, "endwin") == 0 ) { winno = -1; } } } if( buttonendflg == FALSE) { print( "fmletter: §ä¤£¨ìendbutton\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } if( winno != -1 ) { if( w.windowtype == -1 ) { print( "fmletter: §ä¤£¨ìwintype\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } if( w.buttontype == -1 ) { print( "fmletter: §ä¤£¨ìbutton\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } if( strlen( w.message) == 0 ) { print( "fmletter: §ä¤£¨ìmessage\n"); print( "filename:[%s] line[%d]\n", filename, linenum); errflg = TRUE; break; } } } fclose( fp); if( chkflg == FALSE && w.windowno == -1 ) { print( "fmletter: §ä¤£¨ì©Ò«ü©wªºwindowno\n"); print( "filename:[%s] line[%d]\n", filename, linenum); return FALSE; } if( winno != -1 && endflg == FALSE) { print( "fmletter: §ä¤£¨ìendwin\n"); print( "filename:[%s] line[%d]\n", filename, linenum); return FALSE; } if( errflg == TRUE) return FALSE; return TRUE; }