static void NPC_Quiz_selectWindow( int meindex, int talker, int num)
{

	char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
	char token[1024];
	char buf[256];
  	char buf2[256];
  	char buf3[256];
  	
	int i = 0,k;
	int questionno = 0;
	int fd = getfdFromCharaIndex( talker);
	int buttontype = 0;
	int messagetype = 0;
	int windowno = 0;
	int len = 4;
	int p_no;
	int p_old;
	int loop=0;
	int ans;
	BOOL entryflg = TRUE;
	switch( num) {
	  case 0:
		if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){
			print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
		}
		if(NPC_Util_GetStrFromStrWithDelim( argstr,"StartMsg",
									token, sizeof( token)) == NULL){
			print("%sк║StartMsgдгжsжb", CHAR_getChar(meindex,CHAR_NAME));
			return;
		}
		buttontype = WINDOW_BUTTONTYPE_YESNO;
		messagetype = WINDOW_MESSAGETYPE_MESSAGE;
		windowno = CHAR_WINDOWTYPE_QUIZ_START;
		break;
	
	  case 1:
		if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){
			print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
		}
		if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem",
									buf2, sizeof( buf2)) != NULL){
			if(NPC_EntryItemCheck( talker, buf2) == FALSE){
				entryflg = FALSE;
			}
		}
		if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone",
									buf3, sizeof( buf3)) != NULL){
			if(NPC_EntryStoneCheck( talker, buf3) == FALSE){
				entryflg = FALSE;
			}
		}
		if(entryflg == FALSE){
			if(NPC_Util_GetStrFromStrWithDelim( argstr,"NoEntryMsg",
									token, sizeof( token)) != NULL) {
				buttontype = WINDOW_BUTTONTYPE_OK;
				messagetype = WINDOW_MESSAGETYPE_MESSAGE;
				windowno = CHAR_WINDOWTYPE_QUIZ_START;

			}
		
		}else if(NPC_PlayerCheck( meindex, talker) == FALSE) {
			/*--┐═┐Їекб╝е╨б╝---*/
			sprintf(token,"\n\n\n        ╜╨,╡y╡ед@дU"
						      "\nбббб г▒┼┘д╦д╜дєд╩д╦┴ъ╝ъд╟днд╩дддлдщ"
			);
			buttontype = WINDOW_BUTTONTYPE_OK;
			messagetype = WINDOW_MESSAGETYPE_MESSAGE;
			windowno = CHAR_WINDOWTYPE_QUIZ_START;

		}else{
			if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem",
									buf2, sizeof( buf2)) != NULL){
				if(NPC_EntryItemDel( talker, buf2)	==FALSE){
					print("╣DиуиSж│о°ев(%s)",CHAR_getChar(meindex,CHAR_NAME));
					return;
				}
			}
			if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone",
									buf3, sizeof( buf3)) != NULL){
				if(NPC_EntryStoneDel( talker, buf3)	==FALSE){
					print("кў┐·иSж│о°ев(%s)",CHAR_getChar(meindex,CHAR_NAME));
					return;
				}
			}
			NPC_Quiz_selectWindow(meindex, talker, 2);
			return;
		}
	  	break;

	  case 3:
		if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){
			print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
		}

		/*-- е╣е┐б╝е╚есе├е╗б╝е╕ --*/
		if(NPC_Util_GetStrFromStrWithDelim( argstr,"ItemFullMsg",
									token, sizeof( token)) == NULL)
		{
			print("%sк║ItemFullMsgдгжsжb", CHAR_getChar(meindex,CHAR_NAME));
			return;
		}
		
		buttontype = WINDOW_BUTTONTYPE_OK;
		messagetype = WINDOW_MESSAGETYPE_MESSAGE;
		windowno = CHAR_WINDOWTYPE_QUIZ_START;

	  	break;
	  case 2:
  		/*--еседеє--*/
  		{
			int *tbl;
			int point;
			int *pl_ptr;
			int warp_flg = -1;
			int floor=0,x=0,y=0;

			struct pl PLAYER;
			
			
			/*--е╤б╝е╞егб╝д╦д╩д├д╞д╩дддл--*/
			if(NPC_QUIZPARTY_CHAECK(meindex,talker)==FALSE){
				NPC_Quiz_selectWindow( meindex, talker, 4);
			}

			
			
			/*--▓Є┼·╝╘╚╓╣цдЄ╞└ды--*/
			p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT);
			point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + p_no);
			pl_ptr = (int *)point;
			
			/*-- есетеъд╬╞т═╞дЄ╣╜┬д┬╬д╦е│е╘б╝ --*/
			memcpy(&PLAYER, pl_ptr, sizeof(struct pl));
			
			/*--┴┤д╞д╬╠ф┬ъдм╜кдяд├д┐д╬д╟╖ы▓╠дЄ╩є╣Ё--*/
			if(PLAYER.quizno
			 == CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM))
			{
				double avg;
				int okflg;
				char buf2[512];

			  	/*-- argе╒ебедеыд╬╞╔д▀╣■д▀ --*/
				if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL)
				{
					print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
				}

				/*--└╡▓Є┐Їд╦▒■д╕д╞еведе╞ердЄ─╔▓├д╣ды---*/
				if(NPC_Util_GetStrFromStrWithDelim( argstr, "GetItem", buf, sizeof( buf) )
				!=NULL)
				{
					okflg = NPC_QuizBorderLine(PLAYER.answer,buf);
					if(okflg == -1)
					{
				
					}else{

						getStringFromIndexWithDelim(buf , "," , okflg+1, buf3, sizeof(buf3));
						if(NPC_QuizAddItem( talker, buf3) == FALSE) return ;

					}
				}

				/*--└╡▓Є┐Їд╦▒■д╕д╞еведе╞ердЄ─╔▓├д╣ды---*/
				if(NPC_Util_GetStrFromStrWithDelim( argstr, "Border", buf, sizeof( buf) )
				!=NULL)
				{
					okflg = NPC_QuizBorderLine(PLAYER.answer,buf);
					if(okflg == -1)
					{
						NPC_Util_GetStrFromStrWithDelim( argstr, "FailureMsg",
							buf2,sizeof(buf2));
				
							CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE);
				
					}else{

						getStringFromIndexWithDelim(buf , "," , okflg+1, buf2, sizeof(buf2));
						CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE);
					}
				}

				
				/*--└╡▓Є┐Їд╦▒■д╕д╞еяб╝е╫д╡д╗ды---*/
				if(NPC_Util_GetStrFromStrWithDelim( argstr, "Warp", buf, sizeof( buf) )
				!=NULL)
				{
					warp_flg = NPC_QuizWarpBorderLine(PLAYER.answer,buf);
					if(warp_flg != -1) {
						char warpbuf[32];
						
						getStringFromIndexWithDelim(buf , "," , warp_flg+1, buf2, sizeof(buf2));
						getStringFromIndexWithDelim(buf2 , "." , 1, warpbuf, sizeof(warpbuf));
						floor = atoi(warpbuf);
						getStringFromIndexWithDelim(buf2 , "." , 2, warpbuf, sizeof(warpbuf));
						x = atoi(warpbuf);
						getStringFromIndexWithDelim(buf2 , "." , 3, warpbuf, sizeof(warpbuf));
						y = atoi(warpbuf);
					}
				}


				
				/*-- еве┘еьб╝е╕(╩┐╢╤)дЄ╡сдсды -*/
				avg = (double)PLAYER.answer /
					CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) * 100;
#if 0
				sprintf(token,"бббббббббббббб"
							"\n\nзAк║е┐╜T╕╤╡к▓vмO %d├Dдд  %d ├D "
							"\nе┐╜Tдё▓v %d БУ"
							"\n\n%s",
					CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM),
					PLAYER.answer,
					(int)avg,
					buf2
				);
#endif				
				
				/*--е╫еьедефб╝д╬еяб╝еп╬╬░шдЄ╜щ┤№▓╜ -*/
				CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + 
							CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ,-1);
	
//				print("\n %s %d╢}йё",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr);

				/*--есетеъ╬╬░ш│л╩№--*/
				free(PLAYER.ptr);
				
#if 0				
				/*-д│д│д╟┴ў┐од╣ды--*/
				lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, 
						WINDOW_BUTTONTYPE_OK, 
						CHAR_WINDOWTYPE_QUIZ_START,
						CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
						token);
#endif

				//┴┤д╞д╬╜к╬╗╜ш═¤дм╜кдяд├д╞длдщеяб╝е╫д╡д╗дыбг
				if(warp_flg != -1){
					CHAR_warpToSpecificPoint(talker, floor, x, y);
				}
				return;
				
			}

			/*--д│д╬г╬г╨г├д╦└▀─ъд╡дьд╞ддды╛Є╖яд╬╠ф┬ъ╚╓╣цдЄ╚┤дн╜╨д╣--*/
			tbl =  NPC_GetQuestion( meindex);
			
			
			/*--╠ф┬ъ┐Їд╬е┴езе├еп tbl[0]д╦д╧╛Є╖ядЄ╦■д┐д╖д┐╠ф┬ъ┐Їдмд╧ддд├д╞ддды --*/
			if( CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) > ( tbl[0] - 1))
			{
				/*--╠ф┬ъдм┬ндъд╩дд--*/
				/*--есетеъ╬╬░ш│л╩№--*/
				free(PLAYER.ptr);
				return ;
			}

			/*--╠ф┬ъдЄг╟г┼г╘--*/
			while(1){
				loop++;
				i = rand()%( tbl[0]);
				if(i == 0) continue;
				questionno = tbl[i];
		
				/*--╜┼╩ге┴езе├еп--*/
				for( k = 0 ; k < OLDNO ; k++){
					if(PLAYER.oldno[k] == questionno) {
						loop = 0;
						break;
					}
				}
				if(k == OLDNO) break;
				
				/*--╠╡╕┬еыб╝е╫┴╦╗▀--*/
				if(loop == 5000) {
					print("░▌├Dдгимiе■│бнл┬╨дFj");
				 	break;
				}
			}

			p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT);
			p_old = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC);

			PLAYER.quizno++;
			
			/*-- ║гд▐д╟д╬╠ф┬ъ╚╓╣цдЄ╡н▓▒д╖д╞дкдп--*/
			PLAYER.oldno[p_old] = questionno;
			p_old++;
			CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, p_old);

			strncpy( buf, Quiz[questionno].question, 
							sizeof( Quiz[questionno].question));

			/*--епеде║д╬╠ф┬ъд╬─╣д╡д╦дшд├д╞бв┴к┬Є═єд╬╔╜╝и░╠├╓дЄ╩╤диды--*/
			if(strlen( buf) < 40) {
				strcat( buf, "\n");
			}else if(strlen( buf) > 79) {
				len = 5;
			}	

			/*--├▒╕ье▐е├е┴--*/
			if( Quiz[questionno].answertype == 4) {
				
				if(strlen( buf) < 40) {
					strcat( buf,"\n\n");
				}else if( strlen( buf) < 80) {
					strcat( buf,"\n\n");
				}else{
					strcat( buf,"\n");
				}

				/*--╜ёдн╠ф┬ъ--*/
				sprintf( token,"   quiz ▓─ %d ├D"
						  	"\n%s "
				  			"\nбї╝gжb│o╕╠\n"
				  			"Б@(╝gз╣╜╨лЎв▌в┘)",
				  			PLAYER.quizno,
				  			buf);

				buttontype = WINDOW_BUTTONTYPE_OK;
				messagetype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT;
				windowno = CHAR_WINDOWTYPE_QUIZ_MAIN;

				/*--╕╜║▀д╬╛ї╢╖дЄесетеъд╦╡н▓▒д╡д╗д╞дкдп--*/
				memcpy(pl_ptr,&PLAYER,sizeof(struct pl));
				
				break;
			
			/*--ббг│┬Є╠ф┬ъбб--*/
			}else if( Quiz[questionno].answertype == 2) {
				char work1[128];
				char work2[128];
				char work3[128];

				ans = (rand() % 3) + 1;

				ans = NPC_QuizRandAnswer(p_no,questionno,3, work1,work2,work3);
				PLAYER.ansno = ans;

				/*-- епеде║▓ш╠╠(г│┬Єб╦ --*/
				sprintf(token,"%d\n   quiz ▓─ %d ├D"
						  	"\n%s "
							"\n\nв░бD %s"
							"\nв▒бD %s"
				  			"\nв▓бD %s",
				  			len,
				  			PLAYER.quizno,
				  			buf,
				  			work1,
				  			work2,
				  			work3
				);
				
			/*-- г▓┬Є╠ф┬ъ --*/
			}else if( Quiz[questionno].answertype == 1){
				char work1[128];
				char work2[128];
				char work3[128];
				
				strcpy(work3,"-1");
				ans = NPC_QuizRandAnswer(p_no,questionno,2, work1,work2,work3);
				PLAYER.ansno = ans;

				/*-- епеде║▓ш╠╠(г▓┬Єб╦ --*/
				sprintf(token,"%d\n   quiz ▓─ %d ├D"
							"\n%s "
							"\n\nв░бD %s"
							"\nв▒бD %s",
							len,
							PLAYER.quizno,
							buf,
							work1,
							work2
				);
			}
			buttontype = WINDOW_BUTTONTYPE_CANCEL;
		  	messagetype = WINDOW_MESSAGETYPE_SELECT;
			windowno = CHAR_WINDOWTYPE_QUIZ_MAIN;

			memcpy(pl_ptr,&PLAYER,sizeof(struct pl));

		}
		break;
		
	  case 4:
		/*-- argе╒ебедеыд╬╞╔д▀╣■д▀ --*/
		if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL)
		{
			print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
		}

		if(NPC_Util_GetStrFromStrWithDelim( argstr,"Party",
								token, sizeof( token)) != NULL) 
		{
			buttontype = WINDOW_BUTTONTYPE_OK;
			messagetype = WINDOW_MESSAGETYPE_MESSAGE;
			windowno = CHAR_WINDOWTYPE_QUIZ_START;
		}

		break;

	}
	 
	/*-д│д│д╟┴ў┐од╣ды--*/
	lssproto_WN_send( fd, messagetype, 
					buttontype, 
					windowno,
					CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
					token);
}
Exemple #2
0
static void NPC_Quiz_selectWindow( int meindex, int talker, int num)
{

    char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
    char token[1024];
    char buf[256];
    char buf2[256];
    char buf3[256];

    int i = 0,k;
    int questionno = 0;
    int fd = getfdFromCharaIndex( talker);
    int buttontype = 0;
    int messagetype = 0;
    int windowno = 0;
    int len = 4;
    int p_no;
    int p_old;
    int loop=0;
    int ans;
    BOOL entryflg = TRUE;
    switch( num) {
    case 0:
        if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) {
            print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
        }
        if(NPC_Util_GetStrFromStrWithDelim( argstr,"StartMsg",token, sizeof( token)) == NULL) {
            print("%sµÄStartMsg²»´æÔÚ", CHAR_getChar(meindex,CHAR_NAME));
            return;
        }
        buttontype = WINDOW_BUTTONTYPE_YESNO;
        messagetype = WINDOW_MESSAGETYPE_MESSAGE;
        windowno = CHAR_WINDOWTYPE_QUIZ_START;
        break;

    case 1:
        if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) {
            print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
        }
        if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem",	buf2, sizeof( buf2)) != NULL) {
            if(NPC_EntryItemCheck( talker, buf2) == FALSE) {
                entryflg = FALSE;
            }
        }
        if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone",buf3, sizeof( buf3)) != NULL) {
            if(NPC_EntryStoneCheck( talker, buf3) == FALSE) {
                entryflg = FALSE;
            }
        }
        if(entryflg == FALSE) {
            if(NPC_Util_GetStrFromStrWithDelim( argstr,"NoEntryMsg",token, sizeof( token)) != NULL) {
                buttontype = WINDOW_BUTTONTYPE_OK;
                messagetype = WINDOW_MESSAGETYPE_MESSAGE;
                windowno = CHAR_WINDOWTYPE_QUIZ_START;

            }

        } else if(NPC_PlayerCheck( meindex, talker) == FALSE) {
            /*--ÚÐÐÑ×ó¡õÌï¡õ---*/
            sprintf(token,"\n\n\n        Çë,ÉÔµÈÒ»ÏÂ"
                    "\n£û£û ¨àÕº±å¹«ÊÏئ±åÇÂÅìÆ¥ÎåئÖо®ÈÕ"
                   );
            buttontype = WINDOW_BUTTONTYPE_OK;
            messagetype = WINDOW_MESSAGETYPE_MESSAGE;
            windowno = CHAR_WINDOWTYPE_QUIZ_START;

        } else {
            if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem",buf2, sizeof( buf2)) != NULL) {
                if(NPC_EntryItemDel( talker, buf2)	==FALSE) {
                    print("µÀ¾ßûÓÐÏûʧ(%s)",CHAR_getChar(meindex,CHAR_NAME));
                    return;
                }
            }
            if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone",buf3, sizeof( buf3)) != NULL) {
                if(NPC_EntryStoneDel( talker, buf3)	==FALSE) {
                    print("½ðǮûÓÐÏûʧ(%s)",CHAR_getChar(meindex,CHAR_NAME));
                    return;
                }
            }
            NPC_Quiz_selectWindow(meindex, talker, 2);
            return;
        }
        break;

    case 3:
        if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) {
            print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
        }

        /*-- µ©Õý¡õÐþ¶ªÓÀ±¾¡õ³â --*/
        if(NPC_Util_GetStrFromStrWithDelim( argstr,"ItemFullMsg",	token, sizeof( token)) == NULL)
        {
            print("%sµÄItemFullMsg²»´æÔÚ", CHAR_getChar(meindex,CHAR_NAME));
            return;
        }

        buttontype = WINDOW_BUTTONTYPE_OK;
        messagetype = WINDOW_MESSAGETYPE_MESSAGE;
        windowno = CHAR_WINDOWTYPE_QUIZ_START;

        break;
    case 2:
        /*--¶ªÄ̼þ--*/
    {
        int *tbl;
        int point;
        int *pl_ptr;
        int warp_flg = -1;
        int floor=0,x=0,y=0;

        struct pl PLAYER;


        if(NPC_QUIZPARTY_CHAECK(meindex,talker)==FALSE) {
            NPC_Quiz_selectWindow( meindex, talker, 4);
        }



        p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT);
        point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + p_no);
        pl_ptr = (int *)point;

        memcpy(&PLAYER, pl_ptr, sizeof(struct pl));

        if(PLAYER.quizno
                == CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM))
        {
            double avg;
            int okflg;
            char buf2[512];

            if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL)
            {
                print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
            }

            if(NPC_Util_GetStrFromStrWithDelim( argstr, "GetItem", buf, sizeof( buf) )!=NULL)
            {
                okflg = NPC_QuizBorderLine(PLAYER.answer,buf);
                if(okflg == -1)
                {

                } else {

                    getStringFromIndexWithDelim(buf , "," , okflg+1, buf3, sizeof(buf3));
                    if(NPC_QuizAddItem( talker, buf3) == FALSE) return ;

                }
            }

            if(NPC_Util_GetStrFromStrWithDelim( argstr, "Border", buf, sizeof( buf) )!=NULL)
            {
                okflg = NPC_QuizBorderLine(PLAYER.answer,buf);
                if(okflg == -1)
                {
                    NPC_Util_GetStrFromStrWithDelim( argstr, "FailureMsg",
                                                     buf2,sizeof(buf2));

                    CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE);

                } else {

                    getStringFromIndexWithDelim(buf , "," , okflg+1, buf2, sizeof(buf2));
                    CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE);
                }
            }


            /*--¿ÒÝ©ÐѱåɱԪ»¯·¥¡õÃó½ñÁùÔÂ---*/
            if(NPC_Util_GetStrFromStrWithDelim( argstr, "Warp", buf, sizeof( buf) )!=NULL)
            {
                warp_flg = NPC_QuizWarpBorderLine(PLAYER.answer,buf);
                if(warp_flg != -1) {
                    char warpbuf[32];

                    getStringFromIndexWithDelim(buf , "," , warp_flg+1, buf2, sizeof(buf2));
                    getStringFromIndexWithDelim(buf2 , "." , 1, warpbuf, sizeof(warpbuf));
                    floor = atoi(warpbuf);
                    getStringFromIndexWithDelim(buf2 , "." , 2, warpbuf, sizeof(warpbuf));
                    x = atoi(warpbuf);
                    getStringFromIndexWithDelim(buf2 , "." , 3, warpbuf, sizeof(warpbuf));
                    y = atoi(warpbuf);
                }
            }



            avg = (double)PLAYER.answer /
                  CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) * 100;

            CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 +
                             CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ,-1);

//				print("\n %s %d¿ª·Å",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr);

            free(PLAYER.ptr);

            if(warp_flg != -1) {
                CHAR_warpToSpecificPoint(talker, floor, x, y);
            }
            return;

        }

        tbl =  NPC_GetQuestion( meindex);


        if( CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) > ( tbl[0] - 1))
        {
            free(PLAYER.ptr);
            return ;
        }

        while(1) {
            loop++;
            i = rand()%( tbl[0]);
            if(i == 0) continue;
            questionno = tbl[i];

            for( k = 0 ; k < OLDNO ; k++) {
                if(PLAYER.oldno[k] == questionno) {
                    loop = 0;
                    break;
                }
            }
            if(k == OLDNO) break;

            if(loop == 5000) {
                print("ÎÊÌâ²»×ãiÈ«²¿Öظ²ÁËj");
                break;
            }
        }

        p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT);
        p_old = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC);

        PLAYER.quizno++;

        PLAYER.oldno[p_old] = questionno;
        p_old++;
        CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, p_old);

        strncpy( buf, Quiz[questionno].question,
                 sizeof( Quiz[questionno].question));

        if(strlen( buf) < 40) {
            strcat( buf, "\n");
        } else if(strlen( buf) > 79) {
            len = 5;
        }

        /*--Ç©»ßѨÓÀÃñ--*/
        if( Quiz[questionno].answertype == 4) {

            if(strlen( buf) < 40) {
                strcat( buf,"\n\n");
            } else if( strlen( buf) < 80) {
                strcat( buf,"\n\n");
            } else {
                strcat( buf,"\n");
            }

            sprintf( token,"   quiz µÚ %d Ìâ"
                     "\n%s "
                     "\n¡ýдÔÚÕâÀï\n"
                     "?(дÍêÇë°´£Ï£Ë)",
                     PLAYER.quizno,
                     buf);

            buttontype = WINDOW_BUTTONTYPE_OK;
            messagetype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT;
            windowno = CHAR_WINDOWTYPE_QUIZ_MAIN;

            /*--òØ»þ¼°ÇÁÐë붪ƹØø±å·¤Ê¢½ñÁù»¯ÔÆÈÊ--*/
            memcpy(pl_ptr,&PLAYER,sizeof(struct pl));

            break;

        } else if( Quiz[questionno].answertype == 2) {
            char work1[128];
            char work2[128];
            char work3[128];

            ans = (rand() % 3) + 1;

            ans = NPC_QuizRandAnswer(p_no,questionno,3, work1,work2,work3);
            PLAYER.ansno = ans;

            sprintf(token,"%d\n   quiz µÚ %d Ìâ"
                    "\n%s "
                    "\n\n£±£® %s"
                    "\n£²£® %s"
                    "\n£³£® %s",
                    len,
                    PLAYER.quizno,
                    buf,
                    work1,
                    work2,
                    work3
                   );

        } else if( Quiz[questionno].answertype == 1) {
            char work1[128];
            char work2[128];
            char work3[128];

            strcpy(work3,"-1");
            ans = NPC_QuizRandAnswer(p_no,questionno,2, work1,work2,work3);
            PLAYER.ansno = ans;

            sprintf(token,"%d\n   quiz µÚ %d Ìâ"
                    "\n%s "
                    "\n\n£±£® %s"
                    "\n£²£® %s",
                    len,
                    PLAYER.quizno,
                    buf,
                    work1,
                    work2
                   );
        }
        buttontype = WINDOW_BUTTONTYPE_CANCEL;
        messagetype = WINDOW_MESSAGETYPE_SELECT;
        windowno = CHAR_WINDOWTYPE_QUIZ_MAIN;

        memcpy(pl_ptr,&PLAYER,sizeof(struct pl));

    }
    break;

    case 4:
        if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL)
        {
            print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME));
        }

        if(NPC_Util_GetStrFromStrWithDelim( argstr,"Party",	token, sizeof( token)) != NULL)
        {
            buttontype = WINDOW_BUTTONTYPE_OK;
            messagetype = WINDOW_MESSAGETYPE_MESSAGE;
            windowno = CHAR_WINDOWTYPE_QUIZ_START;
        }

        break;

    }

    /*-³ð³ðƥ˪ññÔÊÔÂ--*/
    lssproto_WN_send( fd, messagetype,
                      buttontype,
                      windowno,
                      CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
                      token);
}