Exemplo n.º 1
0
    virtual void PXCAPI OnRecognition(const PXCSpeechRecognition::RecognitionData *data) {
        if (data->scores[0].label<0) {
            PrintConsole(m_hWnd,(pxcCHAR*)data->scores[0].sentence);
            if (data->scores[0].tags[0])
                PrintConsole(m_hWnd,(pxcCHAR*)data->scores[0].tags);
        } else {
            ClearScores(m_hWnd);
            for (int i=0; i<sizeof(data->scores)/sizeof(data->scores[0]); i++) {
                if (data->scores[i].label < 0 || data->scores[i].confidence == 0) continue;
                SetScore(m_hWnd,data->scores[i].label,data->scores[i].confidence);
            }

            // Dispatch differnt work here
            switch (data->scores[0].label) {
            case 0:
                PrintStatus(m_hWnd, (pxcCHAR*)L"Reading text for you, my pleasure.");
                break;
            case 1:
                PrintStatus(m_hWnd, (pxcCHAR*)L"Yes master, Avery and Lasse are smiling.");
                break;
            case 2:
                PrintStatus(m_hWnd, (pxcCHAR*)L"Today is sunday.");
                break;
            default:
                break;
            }

            if (data->scores[0].tags[0])
                PrintStatus(m_hWnd,(pxcCHAR*)data->scores[0].tags);
        }
    }
Exemplo n.º 2
0
void Pause_Preload(struct Game* game) {
	//game->pause.bitmap = NULL;
	PrintConsole(game,"Pause preloaded.");
	if (!game->menu.loaded) {
		PrintConsole(game,"Pause: Preloading GAMESTATE_MENU...");
		Menu_Preload(game, NULL);
	}
}
Exemplo n.º 3
0
void PrintOutputScale(HANDLE hOut)
{
	COORD const pos = { 1, SPECTRUM_HEIGHT + 2 };
	PrintConsoleWithAttribute(hOut, { pos.X,     pos.Y }, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | BACKGROUND_RED,  "-");
	PrintConsoleWithAttribute(hOut, { pos.X + 2, pos.Y }, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | BACKGROUND_BLUE, "+");
	PrintConsole(hOut, { pos.X + 4, pos.Y }, "Output: %5.1f%%", output_scale * 100.0f);
}
Exemplo n.º 4
0
short C_USER_DB_Command::DSEventPreCheck( IN short evid, IN char * acc, IN char * chrName, short group )
{
	short result = 0;
	try
	{
		m_prEventPreCheck->ResetAccessor();
		m_prEventPreCheck->GetAccessor()->m_sEventID = evid;
		strncpy( m_prEventPreCheck->GetAccessor()->m_account, acc, 50 );
		strncpy( m_prEventPreCheck->GetAccessor()->m_chrName, chrName, en_charac_name_length );
		m_prEventPreCheck->GetAccessor()->m_sGroupNo = g_ForestNum;

		m_prEventPreCheck->GetAccessor()->m_result = 0;

		HRESULT hr = m_prEventPreCheck->OpenCommand( *m_session ) ;
		m_prEventPreCheck->CloseCommand() ;

		if( FAILED(hr) )
		{
			DBErrorOutput( hr ) ;
			throw "";
		}

		result = m_prEventPreCheck->GetAccessor()->m_result;

	}
	catch( ... )
	{
		PrintConsole( "[DB - EXCEPTION] Event Pre Check\n" );
		m_prEventPreCheck->CloseCommand();

		result = 0;
	}
	return result;
}
Exemplo n.º 5
0
bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
	if (!action->arguments) {
		action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
		action->arguments = TM_AddToArgs(action->arguments, (void*)al_create_bitmap(game->viewportWidth, game->viewportHeight));
	}
	float* fadeloop;
	ALLEGRO_BITMAP* fade_bitmap;
	fadeloop = (float*)action->arguments->value;
	fade_bitmap = (ALLEGRO_BITMAP*)action->arguments->next->value;
	if (state == TM_ACTIONSTATE_INIT) {
		*fadeloop = 0;
		al_set_target_bitmap(fade_bitmap);
		al_clear_to_color(al_map_rgb(0,0,0));
		al_set_target_bitmap(al_get_backbuffer(game->display));
	} else if (state == TM_ACTIONSTATE_RUNNING) {
		*fadeloop+=10;
		if (*fadeloop>=256) return true;
	} else if (state == TM_ACTIONSTATE_DRAW) {
		al_draw_tinted_bitmap(fade_bitmap,al_map_rgba_f(1,1,1,*fadeloop/255.0),0,0,0);
	} else if (state == TM_ACTIONSTATE_DESTROY) {
		PrintConsole(game, "Leaving level with %d HP", (int)(game->level.hp*100));
		al_destroy_bitmap(fade_bitmap);
		free(fadeloop);
		Level_Unload(game);
		game->gamestate = GAMESTATE_LOADING;
		game->loadstate = GAMESTATE_MAP;
		TM_DestroyArgs(action->arguments);
		action->arguments = NULL;
	}
	return false;
}
Exemplo n.º 6
0
void PrintKeyOctave(HANDLE hOut)
{
	COORD const pos = { 21, SPECTRUM_HEIGHT + 2 };
	PrintConsoleWithAttribute(hOut, { pos.X,     pos.Y }, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | BACKGROUND_RED,  "[");
	PrintConsoleWithAttribute(hOut, { pos.X + 2, pos.Y }, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | BACKGROUND_BLUE, "]");
	PrintConsole(hOut, { pos.X + 4, pos.Y }, "Key Octave: %d", keyboard_octave);
}
Exemplo n.º 7
0
CON(int, putchar(int character))
{
	wchar_t temp[2];
	temp[0] = character;
	temp[1] = 0;
	PrintConsole(temp);
	return character;
}
Exemplo n.º 8
0
void PrintAntialias(HANDLE hOut)
{
	COORD const pos = { 61, SPECTRUM_HEIGHT + 2 };
	PrintConsole(hOut, pos, "F12 Antialias:");
	if (use_antialias)
		PrintConsoleWithAttribute(hOut, { pos.X + 15, pos.Y }, FOREGROUND_GREEN, " ON");
	else
		PrintConsoleWithAttribute(hOut, { pos.X + 15, pos.Y }, FOREGROUND_RED,   "OFF");
}
Exemplo n.º 9
0
void tTVPApplication::CloseConsole() {
	wchar_t buf[100];
	DWORD len = TJS_snprintf(buf, 100, TVPExitCode, TVPTerminateCode);
	PrintConsole(buf, len);
	if( is_attach_console_ ) {
		::SetConsoleTitle( console_title_.c_str() );
		::FreeConsole();
		is_attach_console_ = false;
	}
}
Exemplo n.º 10
0
void Pause_Load(struct Game* game) {
	ALLEGRO_BITMAP *fade = al_create_bitmap(game->viewportWidth, game->viewportHeight);
	al_set_target_bitmap(fade);
	al_clear_to_color(al_map_rgb(0,0,0));
	al_set_target_bitmap(al_get_backbuffer(game->display));
	//game->pause.bitmap = fade;
	ChangeMenuState(game,MENUSTATE_PAUSE);
	PrintConsole(game,"Game paused.");
	al_play_sample_instance(game->menu.click);
}
Exemplo n.º 11
0
_FriendInfo * _j_MemeberQueue::GetNode(char * cName) 
{
	if( cName == NULL )
		return NULL ;

	if( cName[0] == 0 )
		return NULL ;

	_FriendInfo * pTemp = NULL ;

	int pos = 0;

	userpool_lock() ;
	pos = 100;
	try{
		FriendMapIter m_FriendMapIter = m_FriendMap.find(cName) ;

		pos = 1 ;
		
		// 맵에 없으면 큐에서 새로운 노드를 꺼내준다.
		if ( m_FriendMap.end() == m_FriendMapIter ) {
			pos = 2 ;
			if( !m_NodeQueue.empty() ) {
				pos = 3 ;
				pTemp =  m_NodeQueue.front() ;
				pos = 4 ;
				if( pTemp )
				{
					pTemp->releas() ;
					pTemp->SetName( cName ) ;		

					pos = 7 ;
					m_NodeQueue.pop() ;	
					pos = 6 ;					
					m_FriendMap[cName] = pTemp ;		// 맵에 등록
					pos = 9 ;
				}
			}
		}
		else
		{
			pos = 10 ;
			pTemp = m_FriendMapIter->second ;	
		}
		
	}
	catch (...) {
		PrintConsole("[EXCEPTION] _FriendInfo * _j_MemeberQueue::GetNode(char * cName) pos: %d\n", pos) ;
		pTemp = NULL  ;	
	}	
	userpool_unlock() ;	

	return pTemp ;
}
Exemplo n.º 12
0
SYMBOL_EXPORT struct Timeline* TM_Init(struct Game* game, struct GamestateResources* data, const char* name) {
	PrintConsole(game, "Timeline Manager[%s]: init", name);
	struct Timeline* timeline = malloc(sizeof(struct Timeline));
	timeline->game = game;
	timeline->lastid = 0;
	timeline->queue = NULL;
	timeline->background = NULL;
	timeline->name = strdup(name);
	timeline->data = data;
	AddTimeline(game, timeline);
	return timeline;
}
Exemplo n.º 13
0
CON(int, wvprintf(const wchar_t *fmt, va_list args))
{
	wchar_t wbuf[PRINTF_BUFSIZE];
	int len;

	wbuf[0] = 0;

	len = wvsprintf(wbuf, fmt, args);

	if(len >= PRINTF_BUFSIZE) {
		maPanic(1, "printf buffer overrun!");
	}

	PrintConsole(wbuf);

	len = wcslen(wbuf);
	return len;
}
Exemplo n.º 14
0
void PrintArg(unsigned long long number) {
  const char * chars = "0123456789abcdef";
  unsigned char _buf[32] = {0};
  _buf[0] = '0';
  _buf[1] = 'x';
  unsigned char * buf = _buf + 2;
  unsigned char len = 2, i;
  do {
    unsigned char nextDig = (unsigned char)(number & 0xf);
    buf[len++] = chars[nextDig];
    number >>= 4;
  } while (number > 0);
  for (i = 0; i < len / 2; i++) {
    unsigned char a = buf[len - i - 1];
    buf[len - i - 1] = buf[i];
    buf[i] = a;
  }
  PrintConsole((const char *)_buf);
}
Exemplo n.º 15
0
short C_USER_DB_Command::DSEventCheck( IN short evid, IN char * key, IN char * acc, IN char * chrName, 
									  IN short group, OUT int& index, OUT short& packageID )
{
	short result = 0;
	try
	{
		m_prEventCheckAndGive->ResetAccessor();
		// Input
		m_prEventCheckAndGive->GetAccessor()->m_sEventID = evid;
		strncpy( m_prEventCheckAndGive->GetAccessor()->m_key, key, _EVENT_KEY_MAX_LENGTH_ );
		strncpy( m_prEventCheckAndGive->GetAccessor()->m_account, acc, 50 );
		strncpy( m_prEventCheckAndGive->GetAccessor()->m_chrName, chrName, en_charac_name_length+1 );
		m_prEventCheckAndGive->GetAccessor()->m_sGroupNo = group;
		// Output 
		m_prEventCheckAndGive->GetAccessor()->m_idx = 0;
		m_prEventCheckAndGive->GetAccessor()->m_packageID = 0;
		m_prEventCheckAndGive->GetAccessor()->m_result = 0;

		HRESULT hr = m_prEventCheckAndGive->OpenCommand( *m_session ) ;
		m_prEventCheckAndGive->CloseCommand() ;

		if( FAILED(hr) )
		{
			DBErrorOutput( hr ) ;
			throw "";
		}

		index = m_prEventCheckAndGive->GetAccessor()->m_idx;
		packageID = m_prEventCheckAndGive->GetAccessor()->m_packageID;
		result = m_prEventCheckAndGive->GetAccessor()->m_result;
	}
	catch( ... )
	{
		PrintConsole( "[DB - EXCEPTION] Event Check And Give\n" );
		m_prEventCheckAndGive->CloseCommand();

		index = 0;
		packageID = 0;
		result = 0;
	}

	return result;
}
Exemplo n.º 16
0
VOID show(PSOCKADDR_IN addr, PCWSTR prefix)
{
    if (addr->sin_addr.S_un.S_addr == ML_IP_ADDRESS(183, 136, 128, 196))
    {
        SYSTEMTIME st;

        GetLocalTime(&st);

        AllocConsole();
        PrintConsole(
            L"%02d:%02d:%02d.%03d %s %d.%d.%d.%d\n",
            st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
            prefix,
            addr->sin_addr.S_un.S_un_b.s_b1,
            addr->sin_addr.S_un.S_un_b.s_b2,
            addr->sin_addr.S_un.S_un_b.s_b3,
            addr->sin_addr.S_un.S_un_b.s_b4
        );
    }
}
Exemplo n.º 17
0
void C_USER_DB_Command::DSEventSuccess( IN short evid, IN int index )
{
	try
	{
		m_prEventSuccess->ResetAccessor();
		m_prEventSuccess->GetAccessor()->m_sEventID = evid;
		m_prEventSuccess->GetAccessor()->m_idx = index;

		HRESULT hr = m_prEventSuccess->OpenCommand( *m_session ) ;
		m_prEventSuccess->CloseCommand() ;

		if( FAILED(hr) )
		{
			DBErrorOutput( hr ) ;
		}
	}
	catch( ... )
	{
		PrintConsole( "[DB - EXCEPTION] Event Success\n" );
		m_prEventSuccess->CloseCommand();
	}
}
Exemplo n.º 18
0
void C_USER_DB_Command::AddPlayTime( IN int iAccUid, IN char * acc, IN int time, IN short gn )
{
	try
	{
		m_prAddPlayTime->ResetAccessor();
		m_prAddPlayTime->GetAccessor()->SetUniqueID( iAccUid );
		m_prAddPlayTime->GetAccessor()->SetAccountName( acc );
		m_prAddPlayTime->GetAccessor()->SetTime( time );
		m_prAddPlayTime->GetAccessor()->SetGroup( gn );

		HRESULT hr = m_prAddPlayTime->OpenCommand( *m_session );
		m_prAddPlayTime->CloseCommand();

		if( FAILED(hr) )
		{
			DBErrorOutput( hr ) ;
		}		
	}
	catch( ... )
	{
		PrintConsole( "[DB - EXCEPTION] AddPlayTime\n" );
		m_prAddPlayTime->CloseCommand();
	}
}
Exemplo n.º 19
0
bool CLogSvr_Com::RestoreConnection()	// ozzywow
{		
	if( m_cssock )
		closesocket( m_cssock );
	m_cssock = 0 ;

	if( m_port == 0 )
	{
		m_bIsCreated = FALSE ;
		printf( "Don't use to the LogSvr\n" );
		return true ;
	}

	// cS 에 연결하기
	m_cssock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ) ;
	if( m_cssock == INVALID_SOCKET ) {
		printf( "INIT - LogSvr : Create ds socket failed\n" ) ;
		return false ;
		
	}

	SOCKADDR_IN addr;
	addr.sin_family = AF_INET ;
	addr.sin_port = htons( m_port ) ;
	addr.sin_addr.s_addr = inet_addr( m_ip ) ;		// 

	if( connect( m_cssock, (sockaddr*)&addr, sizeof(addr) ) == SOCKET_ERROR ) {
		closesocket(m_cssock) ;		//ozzywow add
		m_cssock = INVALID_SOCKET ;
		PrintConsole( "INIT - LogSvr : connect failed ( code = %d )\n", WSAGetLastError() ) ;
		return false ;
	}

	m_bIsCreated = TRUE ;
	return true ;
}
Exemplo n.º 20
0
unsigned long __stdcall	th_CSWorkThread( LPVOID lp)
{
	_packet *	pack = NULL ;
	u_char		Mainmsg = 0 ;	
	_h_DS_Com * pDSComm = NULL ;	
	_Party *	pParty ;
	list<_Member*> * pMemberList = NULL ;	
	list<_Member*>::iterator tempListItr;/* = NULL ;*/
	//list<_Server> * pServerList = NULL ;
	char		g_cServerNumList[MAX_SERVER_COUNT] ;

	int			iErrCount = 0;


	int			iRes = 0 ;
	short		sRes = 0 ;
	u_short		usRes = 0 ;
	bool		bRes = 0 ;
	int			pos = 0 ;

	_j_PartyManager *  pTempPartyManager = g_pPartyManager;

	//int i ;


	// Result MSG Initalize
	SMSG_CREATE_PARTY_RES_CS_GS msgCreatePartyRes = {0} ;
	msgCreatePartyRes.cMessage = SMSG_NO_CREATE_PARTY_RES_CS_GS ;
	msgCreatePartyRes.usLength = sizeof(SMSG_CREATE_PARTY_RES_CS_GS) ;

	SMSG_JOIN_PARTY_RES_CS_GS	msgJoinPartyRes = {0} ;
	msgJoinPartyRes.cMessage = SMSG_NO_JOIN_PARTY_RES_CS_GS ;
	msgJoinPartyRes.usLength = sizeof(SMSG_JOIN_PARTY_RES_CS_GS) ;

	SMSG_MOVE_PARTY_RES_CS_GS	msgMovePartyRes = {0} ;
	msgMovePartyRes.cMessage = SMSG_NO_MOVE_PARTY_RES_CS_GS ;
	msgMovePartyRes.usLength =  sizeof(SMSG_MOVE_PARTY_RES_CS_GS) ;

	SMSG_ENTRUST_RES_CS_GS		msgEntrustRes = {0} ;
	msgEntrustRes.cMessage  = SMSG_NO_ENTRUST_RES_CS_GS ;
	msgEntrustRes.usLength = sizeof(SMSG_ENTRUST_RES_CS_GS) ;

	SMSG_PARTY_INFO_RES_CS_GS	msgPartyInfoRes = {0} ;
	msgPartyInfoRes.cMessage = SMSG_NO_PARTY_INFO_RES_CS_GS ;
	msgPartyInfoRes.usLength = sizeof(SMSG_PARTY_INFO_RES_CS_GS) ;

	SMSG_DELETE_PARTY_RES_CS_GS	msgDeletePartyRes = {0} ;
	msgDeletePartyRes.cMessage = SMSG_NO_DELETE_PARTY_RES_CS_GS ;
	msgDeletePartyRes.usLength = sizeof(SMSG_DELETE_PARTY_RES_CS_GS) ;

	SMSG_KICK_PARTY_RES_CS_GS	msgKickPartyRes = {0} ;
	msgKickPartyRes.cMessage = SMSG_NO_KICK_PARTY_RES_CS_GS ;
	msgKickPartyRes.usLength = sizeof(SMSG_KICK_PARTY_RES_CS_GS) ;	

	SMSG_UPDATE_STATE		msgUpdateState;
	msgUpdateState.usLength = sizeof(SMSG_UPDATE_STATE);
	msgUpdateState.cMessage = SMSG_NO_UPDATE_STATE;


	while (g_Threading) {
		if( g_pCSPacketQ->empty() ) {

			Sleep(10) ;
			continue ;
		}
		else {
			pack = g_pCSPacketQ->get() ;


			if( pack == NULL ) {
				Sleep(10) ;
				continue ;
			}
			else {
				Mainmsg = static_cast<u_char>(pack->buf[2]) ;
				pDSComm = pack->pDSComm ;
				if( !pDSComm )	// 2004.6.17	ozzywow add
					continue ;
			}
		}


		try{
			switch( Mainmsg ) 
			{							

				//	파티 생성 요청
			case SMSG_NO_CREATE_PARTY_REQ_GS_CS:
				SMSG_CREATE_PARTY_REQ_GS_CS * pMsgCreatePartyReq ;
				pMsgCreatePartyReq = (SMSG_CREATE_PARTY_REQ_GS_CS *)pack->buf ;

#ifdef _TRACE_
				g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[RECV] SMSG_NO_CREATE_PARTY_REQ_GS_CS \n") ;
#endif

				try{

					short sProp = 0 ;
					sRes = g_pPartyManager->CreateParty(pMsgCreatePartyReq->cServerNum, 
						pMsgCreatePartyReq->uid1, pMsgCreatePartyReq->uid2, 
						pMsgCreatePartyReq->cCharacName1, pMsgCreatePartyReq->cCharacName2
						,sProp ) ;			
					msgCreatePartyRes.sMoonpaProp = sProp ;
					msgCreatePartyRes.sPartyIndex = sRes ;
					msgCreatePartyRes.uid1 = pMsgCreatePartyReq->uid1 ;
					msgCreatePartyRes.uid2 = pMsgCreatePartyReq->uid2 ;	



					if( pDSComm->Send(msgCreatePartyRes.usLength, (char*)&msgCreatePartyRes)  == false ){
						::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
					}

#ifdef _TRACE_
					if(sRes == 0) {
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY]Create party failed (Index:%d, chr1:%s chr2:%s )\n",sRes,pMsgCreatePartyReq->cCharacName1, pMsgCreatePartyReq->cCharacName2) ;
					}
					else {
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY]Create party success (Index:%d, chr1:%s chr2:%s )\n",sRes,pMsgCreatePartyReq->cCharacName1, pMsgCreatePartyReq->cCharacName2) ;
					}					
#endif
				}
				catch (...) {
					::PrintConsole("[EXCEPTION] case SMSG_NO_CREATE_PARTY_REQ_GS_CS : \n") ;
				}


				break;

			case SMSG_NO_DELETE_PARTY_REQ_GS_CS:	

				SMSG_DELETE_PARTY_REQ_GS_CS * pMsgDeletePartyReq ;
				pMsgDeletePartyReq = (SMSG_DELETE_PARTY_REQ_GS_CS *)pack->buf ;

#ifdef _TRACE_
				g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Recv 'SMSG_NO_DELETE_PARTY_REQ_GS_CS' (index:%d)\n", pMsgDeletePartyReq->sPartyIndex) ;
#endif


				try{
					pParty = g_pPartyManager->FindList(pMsgDeletePartyReq->sPartyIndex) ;
					if( !pParty ) {
#ifdef _TRACE_
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] !pParty == NULL (index : %d )\n", pMsgDeletePartyReq->sPartyIndex) ;
#endif
						continue ;
					}

					bRes = g_pPartyManager->DeleteParty(pParty) ;	// 맵에서 파티리스트를 완전히 삭제..	
					msgDeletePartyRes.sPartyIndex = pMsgDeletePartyReq->sPartyIndex ;

					// 결과 보낼 주소를 얻어옴..					
					memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;

					if ( bRes ) {	// 파티 삭제 성공
						msgDeletePartyRes.cResult = 1 ;				
						for( int i = 0 ; i < MAX_SERVER_COUNT ; i++ ) {
							if ( g_cServerNumList[i] == '&' ) {
								break ;
							}
							pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
							if(pDSComm){

								if(pDSComm->Send(msgDeletePartyRes.usLength, (char*)&msgDeletePartyRes) == false){
									::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
								}
							}					
						}
#ifdef _TRACE_
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Delete party success (Index%d)\n",pMsgDeletePartyReq->sPartyIndex) ;

#ifdef	_PARTY_LOG_WRITE
						g_pPartyLog->LogFileWrite("[PARTY] Delete party success (Index%d)\n",pMsgDeletePartyReq->sPartyIndex) ;
#endif

#endif

					}
					else{			// 실패
						msgDeletePartyRes.cResult = 0 ;

						if(pDSComm->Send(msgDeletePartyRes.usLength, (char*)&msgDeletePartyRes) == false ){
							::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
						}
#ifdef _TRACE_
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Delete party failed (Index%d)\n",pMsgDeletePartyReq->sPartyIndex) ;

#ifdef	_PARTY_LOG_WRITE
						g_pPartyLog->LogFileWrite("[PARTY] Delete party failed (Index%d)\n",pMsgDeletePartyReq->sPartyIndex) ;
#endif

#endif
					}

				}
				catch (...) {
					::PrintConsole("[EXCEPTION] case SMSG_NO_DELETE_PARTY_REQ_GS_CS : \n") ;
				}				

				break;

			case SMSG_NO_KICK_PARTY_REQ_GS_CS:
				SMSG_KICK_PARTY_REQ_GS_CS * pMsgKickPartyReq ;
				pMsgKickPartyReq = (SMSG_KICK_PARTY_REQ_GS_CS*)pack->buf ;

#ifdef _TRACE_
				g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Recv 'SMSG_NO_KICK_PARTY_REQ_GS_CS' index:%d \n", pMsgKickPartyReq->sPartyIndex) ;
#endif			

				try{
					pParty = g_pPartyManager->FindList( pMsgKickPartyReq->sPartyIndex ) ;
					if( !pParty ) {
#ifdef _TRACE_
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] pParty == NULL (index : %d ) \n", pMsgKickPartyReq->sPartyIndex) ;
#endif
						continue ;
					}


					iRes = g_pPartyManager->KickParty(pParty, pMsgKickPartyReq->cSlotNo) ;
#ifdef _TRACE_
					g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] KieckParty() return value = (%d) / uid(%d), slot(%d)  \n", iRes, pMsgKickPartyReq->uid, pMsgKickPartyReq->cSlotNo ) ;
#endif								

					msgKickPartyRes.sPartyIndex = pMsgKickPartyReq->sPartyIndex ;					
					msgKickPartyRes.uid = pMsgKickPartyReq->uid ;					
					msgKickPartyRes.cResult = (char)iRes ;
					msgKickPartyRes.cMode = pMsgKickPartyReq->cMode ;
					msgKickPartyRes.cSlotNo = pMsgKickPartyReq->cSlotNo ;
					if( iRes == 2)	// 자동 위임..
					{						
						msgKickPartyRes.cCapNo = g_pPartyManager->EntrustCaptain(pParty, 0, 0) ;						
					}
					memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;

					if ( iRes >= 0 ) {	// 탈퇴가 성공했거나, 파티가 깨졌을경우
						for( int i = 0 ; i < MAX_SERVER_COUNT ; i++ ) {
							if ( g_cServerNumList[i] == '&' ) {
								break ;
							}
							pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
							if(pDSComm){

								if(pDSComm->Send(msgKickPartyRes.usLength, (char*)&msgKickPartyRes) == false){
									::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
								}						
							}
						}
#ifdef _TRACE_
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Kick party success (result:%d,Index:%d, uid:%d) \n",msgKickPartyRes.cResult, pMsgKickPartyReq->sPartyIndex, pMsgKickPartyReq->uid) ;

#ifdef	_PARTY_LOG_WRITE
						g_pPartyLog->LogFileWrite("[PARTY] Kick party success (result:%d,Index:%d, uid:%d) \n",msgKickPartyRes.cResult, pMsgKickPartyReq->sPartyIndex, pMsgKickPartyReq->uid) ;
#endif

#endif
					}
					else {	// 실패

						if(pDSComm->Send(msgKickPartyRes.usLength, (char*)&msgKickPartyRes) == false){
							::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
						}
#ifdef _TRACE_
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Kick party failed (result:%d,Index:%d, uid:%d) \n",msgKickPartyRes.cResult, pMsgKickPartyReq->sPartyIndex, pMsgKickPartyReq->uid) ;

#ifdef	_PARTY_LOG_WRITE
						g_pPartyLog->LogFileWrite("[PARTY] Kick party failed (result:%d,Index:%d, uid:%d) \n",msgKickPartyRes.cResult, pMsgKickPartyReq->sPartyIndex, pMsgKickPartyReq->uid) ;
#endif

#endif
					}
				}
				catch (...) {
					::PrintConsole("[EXCEPTION] case SMSG_NO_KICK_PARTY_REQ_GS_CS : \n") ;
				}

				break;

			case SMSG_NO_JOIN_PARTY_REQ_GS_CS:
				SMSG_JOIN_PARTY_REQ_GS_CS * pMsgJoinPartyReq ;
				pMsgJoinPartyReq = (SMSG_JOIN_PARTY_REQ_GS_CS *) pack->buf ;				

#ifdef _TRACE_
				g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[RECV] SMSG_NO_JOIN_PARTY_REQ_GS_CS \n") ;
#endif

				try{
					pParty = g_pPartyManager->FindList( pMsgJoinPartyReq->sPartyIndex ) ;
					if( !pParty ) continue ;

					short sProp = 0 ;
					iRes = g_pPartyManager->JoinParty(pParty, pMsgJoinPartyReq->uid, pMsgJoinPartyReq->cCharacName, sProp ) ;
					msgJoinPartyRes.sMoonpaProp = sProp ;


					msgJoinPartyRes.sPartyIndex = pMsgJoinPartyReq->sPartyIndex ; 
					msgJoinPartyRes.cServerNum = pMsgJoinPartyReq->cServerNum ;
					msgJoinPartyRes.uid = pMsgJoinPartyReq->uid ;
					memcpy( msgJoinPartyRes.cCharacName, pMsgJoinPartyReq->cCharacName, 13 ) ;
					msgJoinPartyRes.cSlotNo = (char)iRes ;
					msgJoinPartyRes.sInnerLevel = pMsgJoinPartyReq->sInnerLevel ;

#ifdef _TRACE_
					g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Join party Result (Index:%d, slot:%d, result:%d) \n",pMsgJoinPartyReq->sPartyIndex , msgJoinPartyRes.cSlotNo, iRes) ;

#ifdef	_PARTY_LOG_WRITE
					g_pPartyLog->LogFileWrite("[PARTY] Join party Result (Index:%d, slot:%d, result:%d) \n",pMsgJoinPartyReq->sPartyIndex , msgJoinPartyRes.cSlotNo, iRes) ;
#endif

#endif


					memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;

					if ( iRes >= 0 ) {	// 파티 참가가 성공했을경우
						for( int i = 0 ; i < MAX_SERVER_COUNT ; i++ ) {
							if ( g_cServerNumList[i] == '&' ) {
								break ;
							}
							pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
							if(pDSComm){

								if(pDSComm->Send(msgJoinPartyRes.usLength, (char*)&msgJoinPartyRes) == false){
									::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
								}
							}					
						}

					}
					else{

						if(pDSComm->Send(msgJoinPartyRes.usLength, (char*)&msgJoinPartyRes) == false){
							::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
						}	
					}
				}
				catch (...) {
					::PrintConsole("[EXCEPTION] case SMSG_NO_JOIN_PARTY_REQ_GS_CS : \n") ;
				}


				break;

			case SMSG_NO_MOVE_PARTY_REQ_GS_CS:
				{				
					SMSG_MOVE_PARTY_REQ_GS_CS * pMsgMovePartyReq ;
					pMsgMovePartyReq = (SMSG_MOVE_PARTY_REQ_GS_CS *) pack->buf ;

					try{
						pParty = g_pPartyManager->FindList( pMsgMovePartyReq->sPartyIndex ) ;
						if ( pParty == NULL ) continue ;
						//pParty->lock() ;
						//memcpy( g_cServerNumList, pParty->cServerNumList, sizeof(g_cServerNumList) ) ;
						//pParty->unlock() ;

						bRes = g_pPartyManager->MoveParty(pParty, pMsgMovePartyReq->cServerNum, 
							pMsgMovePartyReq->uid, pMsgMovePartyReq->cSlotNo) ;			

						if( bRes == false ) {

							msgMovePartyRes.cServerNum = 0 ;
							msgMovePartyRes.uid = pMsgMovePartyReq->uid ;
							msgMovePartyRes.sPartyIndex =pMsgMovePartyReq->sPartyIndex ;
							msgMovePartyRes.cSlotNo = pMsgMovePartyReq->cSlotNo ;	


							if(pDSComm->Send(msgMovePartyRes.usLength, (char*)&msgMovePartyRes)  == false){
								::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
							}
						}			
					}
					catch (...) {
						::PrintConsole("[EXCEPTION] case SMSG_NO_MOVE_PARTY_REQ_GS_CS : \n") ;
					}
				}
				break;

			case SMSG_NO_PARTY_INFO_REQ_GS_CS:
				{				
					SMSG_PARTY_INFO_REQ_GS_CS * pMsgPartyInfoReq = reinterpret_cast<SMSG_PARTY_INFO_REQ_GS_CS *>(pack->buf);

					msgPartyInfoRes.bCreateAble = pMsgPartyInfoReq->bCreateAble ;

					if( pMsgPartyInfoReq->sPartyIndex < 0 )
					{
						::PrintConsole("[ERROR] SMSG_NO_PARTY_INFO_REQ_GS_CS / if( pMsgPartyInfoReq->sPartyIndex(%d) < 0 ) \n", pMsgPartyInfoReq->sPartyIndex) ;
						continue ;
					}

					pos = 0 ;

					
					try{
						// 이해할 수 없지만 이 부분에서 가끔 exception이 발생한다. 도무지 못찾겠다. ㅠ.ㅠ
						pParty = g_pPartyManager->FindList(pMsgPartyInfoReq->sPartyIndex) ;

						pos = 1 ;
						if ( NULL == pParty ) {				

							SMSG_DELETE_PARTY_RES_CS_GS msgDeletePartyRes = {0} ;
							msgDeletePartyRes.cMessage = SMSG_NO_DELETE_PARTY_RES_CS_GS ;
							msgDeletePartyRes.usLength = sizeof(SMSG_DELETE_PARTY_RES_CS_GS) ;
							msgDeletePartyRes.sPartyIndex = pMsgPartyInfoReq->sPartyIndex ;
							msgDeletePartyRes.cResult = true ;

							pos = 2 ;

							if(pDSComm->Send(msgDeletePartyRes.usLength, (char*)&msgDeletePartyRes)  == false){
								::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
							}

							pos = 3 ;

							continue ;
						}

						iRes = 0 ;
						_Member * pMember = NULL ;	

						pParty->party_lock();

						try
						{
							for( iRes = 0; iRes < MAX_PARTY_MEMBER; iRes++ ) 
							{
								memset(&msgPartyInfoRes.member[iRes], 0, sizeof(SMSG_PARTY_INFO_RES_CS_GS::IN_MEMBER) ) ;
								pMember = pParty->GetPartyMemberInfo(iRes) ;
								if( pMember && pMember->pCharac )
								{							
									msgPartyInfoRes.member[iRes].uid = pMember->uid ;
									memcpy( msgPartyInfoRes.member[iRes].cCharacName, pMember->pCharac->CHARAC_BASIC.cChrName, 13 ) ;
									msgPartyInfoRes.member[iRes].cServerNum = static_cast<char>(pMember->pCharac->CHARAC_CUR_BASIC.sZone) ;
									msgPartyInfoRes.member[iRes].sInnerLevel = pMember->pCharac->CHARAC_STATE.sInnerLevel ;
									msgPartyInfoRes.member[iRes].cCheck = pMember->cCheck ;
									msgPartyInfoRes.member[iRes].cMoonpa = pMember->pCharac->CHARAC_BASIC.cParty ;
									msgPartyInfoRes.member[iRes].cClass = pMember->pCharac->CHARAC_BASIC.cClass ;
#ifdef _PD_PARTY_INFO_CLASSGRADE_
									msgPartyInfoRes.member[iRes].cClassGrade = pMember->pCharac->CHARAC_BASIC.cClassGrade ;
#endif
									msgPartyInfoRes.member[iRes].iHonor = pMember->pCharac->CHARAC_STATE.iHonor ;
								}						
							}		
						}
						catch( ... )
						{
							if( iErrCount++ % 500 == 0 )
								PrintConsole( "[EXCEPTION] PARTY_INFR_REQ_GS_CS - for(%u)\n", GetLastError() );
						}

						pParty->party_unlock();

						pos = 4 ;

						msgPartyInfoRes.sPartyIndex = pMsgPartyInfoReq->sPartyIndex ;

						if(pDSComm->Send(msgPartyInfoRes.usLength, (char*)&msgPartyInfoRes)  == false){
							::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;				
						}					
						pos = 5 ;

					}
					catch (...) {
						if( iErrCount++ % 1000 == 0 )
							PrintConsole( "[EXCEPTION] PARTY_INFO_REQ_GS_CS : P(%d) <pos. %d>\n", pMsgPartyInfoReq->sPartyIndex, pos ) ;
					}				
				}
				break;

			case SMSG_NO_ENTRUST_REQ_GS_CS :
				{
				
					SMSG_ENTRUST_REQ_GS_CS * pMsgEntrustReq ;
					pMsgEntrustReq = (SMSG_ENTRUST_REQ_GS_CS *)pack->buf ;

					try{
						pParty = g_pPartyManager->FindList( pMsgEntrustReq->sPartyIndex ) ;
						if ( !pParty ) {			
							continue ;
						}

						char cRes = g_pPartyManager->EntrustCaptain(pParty, pMsgEntrustReq->cSlotNo ,pMsgEntrustReq->uid) ;

						msgEntrustRes.sPartyIndex = pMsgEntrustReq->sPartyIndex ;
						msgEntrustRes.uid = pMsgEntrustReq->uid ;
						msgEntrustRes.cSlotNo = cRes ;


						memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;
						if ( cRes >= 0 ) {	
							for( int i = 0 ; i < MAX_SERVER_COUNT ; i++ ) {
								if ( g_cServerNumList[i] == '&' ) {
									break ;
								}
								pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
								if(pDSComm){

									if(pDSComm->Send(msgEntrustRes.usLength, (char*)&msgEntrustRes)== false){
										::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
									}
								}					
							}
						}
						else {

							if(pDSComm->Send(msgEntrustRes.usLength, (char*)&msgEntrustRes) == false){
								::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
							}
						}
					}
					catch (...) {
						::PrintConsole("[EXCEPTION] case SMSG_NO_ENTRUST_REQ_GS_CS : \n") ;
					}

					break;	
				}

			case SMSG_NO_CHANGE_ITEM_PROP:
				SMSG_CHANGE_PROP * pMsgChangeItemProp ;
				pMsgChangeItemProp = (SMSG_CHANGE_PROP*)pack->buf ;

				pParty = g_pPartyManager->FindList(pMsgChangeItemProp->sPartyIndex) ;
				if ( !pParty ) {				
					continue ;
				}

				// 아이템 분배 설정 방식 변경..
				pParty->SetExpShareType( pMsgChangeItemProp->cProperty ) ;

				memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;
				try{
					for( int i = 0 ; i < MAX_SERVER_COUNT ; i++ ) {
						if ( g_cServerNumList[i] == '&' ) {
							break ;
						}
						pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
						if(pDSComm){

							if(pDSComm->Send(pMsgChangeItemProp->usLength, (char*)pMsgChangeItemProp)== false){
								::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
							}
						}					
					}
#ifdef _TRACE_
					g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Change item prop (Index:%d) \n", pMsgChangeItemProp->sPartyIndex ) ;
#endif
				}
				catch (...) {
					::PrintConsole("[EXCEPTION] case SMSG_NO_CHANGE_ITEM_PROP : \n") ;
				}
				break; 

			case SMSG_NO_CHANGE_EXP_PROP:
				SMSG_CHANGE_PROP * pMsgChangeExpProp ;
				pMsgChangeExpProp = (SMSG_CHANGE_PROP*)pack->buf ;

				pParty = g_pPartyManager->FindList(pMsgChangeExpProp->sPartyIndex) ;
				if ( !pParty ) {				
					continue ;
				}

				// 아이템 분배 설정 방식 변경..
				pParty->SetExpShareType( pMsgChangeExpProp->cProperty ) ;

				memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;
				try{
					for( int i = 0 ; i < MAX_SERVER_COUNT ; i++ ) {
						if ( g_cServerNumList[i] == '&' ) {
							break ;
						}
						pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
						if(pDSComm){

							if(pDSComm->Send(pMsgChangeExpProp->usLength, (char*)pMsgChangeExpProp)== false){
								::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
							}
						}					
					}
#ifdef _TRACE_
					g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Change exp prop (Index:%d) \n", pMsgChangeExpProp->sPartyIndex ) ;
#endif
				}
				catch (...) {
					::PrintConsole("[EXCEPTION] case SMSG_NO_CHANGE_EXP_PROP : \n") ;
				}
				break;


			case SMSG_NO_MOVE_COMPLETE :
				SMSG_MOVE_COMPLETE * pMsgMoveComplete ;
				pMsgMoveComplete = (SMSG_MOVE_COMPLETE*)pack->buf ;

#ifdef _TRACE_
				g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] Recv Move complete (%d) \n", pMsgMoveComplete->uid) ;
#endif

				pos = 0 ;

				try{
					pParty = g_pPartyManager->FindList(pMsgMoveComplete->sPartyIndex) ;
					if ( !pParty ) {				
						continue ;
					}

					_Member * pMember = pParty->GetPartyMemberInfo( pMsgMoveComplete->cSlotNo) ;

					if( pMember && pMember->uid ==  pMsgMoveComplete->uid )
					{
						msgMovePartyRes.sPartyIndex = pMsgMoveComplete->sPartyIndex ;				
						msgMovePartyRes.uid = pMsgMoveComplete->uid ;
						msgMovePartyRes.cSlotNo = pMsgMoveComplete->cSlotNo ;
						memcpy(msgMovePartyRes.cCharacName, pMember->pCharac->CHARAC_BASIC.cChrName, 13 ) ;
						msgMovePartyRes.cServerNum = static_cast<char>(pMember->pCharac->CHARAC_CUR_BASIC.sZone) ;

						g_pPartyManager->MoveComplete(pMsgMoveComplete->uid, pMsgMoveComplete->cSlotNo) ;

						pos = 2 ;


						// 새로운 서버에 들어왔으므로 서버번호를 추가..
						pParty->SetServer( static_cast<char>(pMember->pCharac->CHARAC_CUR_BASIC.sZone) ) ;


						// 서버 이동 관련 특성상 서버이동이 완료한 후에 서버 리스트를 가져와야 한다..(잘생각해봐ㅡㅡ)
						memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;
						pos = 4 ;

						int i ;
						for( i = 0 ; i < MAX_SERVER_COUNT ; i++ ) {
							if ( g_cServerNumList[i] == '&' ) {
								break ;
							}
							pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
							if(pDSComm){								
								if(pDSComm->Send(msgMovePartyRes.usLength, (char*)&msgMovePartyRes) == false){
									::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
								}
							}					
						}						

						pos = 5 ;

#ifdef _TRACE_
						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] SMSG_NO_MOVE_COMPLETE : Sever move complete (Index:%d, uid:%d) \n"
							, pMsgMoveComplete->sPartyIndex, pMsgMoveComplete->uid ) ;
#endif

					}




					else{
						// 서버 이동 시간이 초과되어 Timer에 의해서 해당 파티원이 삭제된 경우라 볼수 있다.
						msgMovePartyRes.cServerNum = 0 ;	// 서버 번호를 0을 보내면 실패임.

						pos = 6 ;

						if ( pDSComm ) {

							if(pDSComm->Send( msgMovePartyRes.usLength, (char*)&msgMovePartyRes ) == false){
								::PrintConsole( "[SO_ERR] pDSComm->send_request : code = %d\n", iRes ) ;
							}
						}					

						g_pTrace->OutputString( _TRACE_CLASS_MESSAGE, "[PARTY] pParty->pMember[pMsgMoveComplete->cSlotNo] == NULL \n" ) ;
					}			



				}
				catch (...) {
					::PrintConsole("[EXCEPTION] case SMSG_NO_MOVE_COMPLETE : (pos. %d)\n", pos ) ;
				}


				break;

			case SMSG_NO_UPDATE_STATE:
				{
					SMSG_UPDATE_STATE * pMsgUpdateState = reinterpret_cast<SMSG_UPDATE_STATE*>(pack->buf);

					pos = 0 ;

					try{
						pParty = g_pPartyManager->FindList(pMsgUpdateState->sPartyIndex) ;
						if ( !pParty ) 
							continue;

						_Member * pMember = pParty->GetPartyMemberInfo( pMsgUpdateState->slot) ;
						if( pMember )
						{
							// 처리.
							pMember->attribute.ucAbsent = pMsgUpdateState->ucMode ? 1 : 0;

							msgUpdateState.ucMode = pMsgUpdateState->ucMode;
							msgUpdateState.sPartyIndex = pMsgUpdateState->sPartyIndex;
							msgUpdateState.slot = pMsgUpdateState->slot;
							msgUpdateState.usValue = pMsgUpdateState->usValue;

							memcpy( g_cServerNumList, pParty->GetServerList(), sizeof(g_cServerNumList) ) ;
							for(int i = 0 ; i < MAX_SERVER_COUNT ; i++ ) 
							{
								if ( g_cServerNumList[i] == '&' ) 
									break ;

								pDSComm = g_pServerInfo->GetDSCom(g_cServerNumList[i]) ;
								if(pDSComm)
									pDSComm->Send(msgUpdateState.usLength, (char*)&msgUpdateState);
							}
							
						}
					}
					catch ( ... ) 
					{
						PrintConsole( "[EXCEPTION] case SMSG_NO_UPDATE_STATE(%d)\n", pos );
					}
				}
				break;
				
#ifdef _PD_MASTER_PUPIL_
			case CMSG_NO_MASTER_AND_PUPIL:
				{
					CMSG_MASTER_AND_PUPIL * pMP = reinterpret_cast<CMSG_MASTER_AND_PUPIL*>(pack->buf);
					switch( pMP->ucMP_Mode )
					{
					case en_dg_mp_mode_info_req:
						g_pMPSet->DSProc_MasterInfoReq( static_cast<CMSG_MP_INFO_REQ *>(pMP), pDSComm );
						break;
					case en_dg_mp_mode_add_point:
						g_pMPSet->DSProc_AddPoint( static_cast<CMSG_MP_ADD_POINT*>(pMP) );	
						break;
					case en_dg_mp_mode_add_kill_count:
						g_pMPSet->DSProc_AddKillCount( static_cast<CMSG_MP_ADD_KILL_COUNT*>(pMP) );	
						break;
					case en_dg_mp_mode_create_mp_req:
						{
							CMSG_MP_CREATE_MP_REQ * p = static_cast<CMSG_MP_CREATE_MP_REQ*>(pMP);
							_C_CHARAC * pCharac = g_pAccMapManager->Find_Charac( p->cFromName );

							if( pCharac )
							{
								g_pMPSet->DSProc_CreateMPReq( p, pCharac, pDSComm );
							}
							else
							{
								// 시스템 에러를 보낸다.
								CMSG_MP_CREATE_FAIL pkFail;
								pkFail.SetName( p->cFromName );
								pkFail.iMasterIndex = p->iMasterIndex;
								pkFail.ucFailCode = 250;				// 시스템 에러.

								PrintConsole( "[MP] Create MP Info Fail : Not found user<%s>\n", p->cFromName );

								pDSComm->Send( pkFail.usLength, (char*)&pkFail );
							}
						}
						break;
					case en_dg_mp_mode_notice_connection:
						g_pMPSet->DSProc_NoticeCon( static_cast<CMSG_MP_NOTICE_CONNECTION *>(pMP) );
						break;
					case en_dg_mp_mode_change_master_nick_req:
						g_pMPSet->DSProc_ChangeMasterNick( static_cast<CMSG_MP_CHANGE_MASTER_NICK_REQ*>(pMP) );
						break;
					case en_dg_mp_mode_chat:
						g_pMPSet->DSProc_GroupChat( static_cast<CMSG_MP_CHAT*>(pMP) );
						break;
					case en_dg_mp_mode_gd_apply_for_pupil:
						// 스승을 찾아 보낸다.
						g_pMPSet->DSProc_ApplyForPupil( static_cast<CMSG_MP_GD_APPLY_FOR_PUPIL*>(pMP), pDSComm );
						break;
					case en_dg_mp_mode_apply_for_pupil_error:
						g_pMPSet->DSProc_ApplyForPupilError( static_cast<CMSG_MP_APPLY_FOR_PUPIL_ERROR*>(pMP) );
						break;
					case en_dg_mp_mode_answer_yes:
						g_pMPSet->DSProc_ApplyAnswerYes( static_cast<CMSG_MP_ANSWER_YES*>(pMP), pDSComm );
						break;
					case en_dg_mp_mode_answer_apply_to_pupil_no:
						g_pMPSet->DSProc_ApplyAnswerNo( static_cast<CMSG_MP_ANSWER_APPLY_TO_PUPIL_NO*>(pMP) );
						break;
					case en_dg_mp_mode_complete_join_pupil:
						break;
					case en_dg_mp_mode_apply_error:
						g_pMPSet->DSProc_ApplyError( static_cast<CMSG_MP_APPLY_ERROR*>(pMP) );
						break;
					case en_dg_mp_mode_strike_pupil_req:
						g_pMPSet->DSProc_StrikeReq( static_cast<CMSG_MP_STRIKE_PUPIL_REQ*>(pMP), pDSComm );
						break;
					case en_dg_mp_mode_leave_req:
						g_pMPSet->DSProc_LeaveReq( static_cast<CMSG_MP_LEAVE_REQ*>(pMP), pDSComm );
						break;
					case en_dg_mp_mode_accept_pupil_mode:
						// 없어짐.
						break;
					case en_dg_mp_mode_board_initial_req:
						g_pMPSet->DSProc_BoardInitialReq( static_cast<CMSG_MP_BOARD_INITIAL_REQ*>(pMP), pDSComm );
						break;
					case en_dg_mp_mode_board_req_page:
						g_pMPSet->DSProc_BoardPageReq( static_cast<CMSG_MP_BOARD_REQ_PAGE*>(pMP), pDSComm );
						break;
					case en_dg_mp_mode_del_from_memory:
						break;

					}

				}
				break;
#endif
			}
		}
		catch (...) {
			::PrintConsole("[EXCEPTION] th_WorkThread \n") ;
		}



	}

	printf("[THREAD] th_CSWorkThread Exit thread \n") ;
	return 0 ;

}
Exemplo n.º 21
0
bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
	int* count;
	if (!action->arguments) {
		action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(int)));
	}
	count = (int*)action->arguments->value;
	if (state == TM_ACTIONSTATE_INIT) {
		*count = 0;
	}
	else if (state == TM_ACTIONSTATE_RUNNING) {
		if (rand()%(10000/(int)(85*game->level.speed_modifier))<=3) {
			PrintConsole(game, "OBSTACLE %d", *count);
			(*count)++;
			struct Obstacle *obst = malloc(sizeof(struct Obstacle));
			obst->prev = NULL;
			obst->x = 100;
			obst->y = (rand()%91)-1;
			obst->speed = 1;
			obst->points = -10;
			obst->hit = false;
			obst->rows = 1;
			obst->cols = 1;
			obst->pos = 0;
			obst->blanks = 0;
			obst->anim_speed = 0;
			obst->tmp_pos = 0;
			obst->angle = 0;
			if (rand()%100<=50) {
				obst->callback= NULL;
				obst->data = NULL;
				obst->points = -5;
				obst->bitmap = &(game->level.dodger.obst_bmps.badmuffin);
			} else if (rand()%100<=12) {
				obst->callback= &Obst_RotateSin;
				obst->data = malloc(sizeof(float));
				*((float*)obst->data) = 0;
				obst->points = 8;
				obst->bitmap = &(game->level.dodger.obst_bmps.muffin);
			} else if (rand()%100<=12) {
				obst->callback= &Obst_RotateSin;
				obst->data = malloc(sizeof(float));
				*((float*)obst->data) = 0;
				obst->points = 4;
				obst->bitmap = &(game->level.dodger.obst_bmps.cherry);
			} else if (rand()%100<=65) {
				obst->callback= &Obst_MoveUp;
				if (rand()%100<=80) obst->bitmap = &(game->level.dodger.obst_bmps.pie1);
				else {
					obst->bitmap = &(game->level.dodger.obst_bmps.pie2);
					obst->points = -12;
				}
				obst->data = malloc(sizeof(float));
				*((float*)obst->data) = 0.25+(rand()%50/100.0);
				obst->y*=1.8;
				obst->angle = ((rand()%50)/100.0)-0.25;
			} else if (rand()%100<=80) {
				obst->callback = &Obst_MoveSin;
				obst->data = malloc(sizeof(float));
				*((float*)obst->data) = 0;
				obst->bitmap = &(game->level.dodger.obst_bmps.pig);
				obst->rows = 3;
				obst->cols = 3;
				obst->speed = 1.2;
				obst->anim_speed = 2;
				obst->points = -20;
			} else {
				obst->callback = &Obst_MoveUpDown;
				obst->bitmap = &(game->level.dodger.obst_bmps.screwball);
				obst->data = malloc(sizeof(bool));
				*((bool*)obst->data) = rand()%2;
				obst->rows = 4;
				obst->cols = 4;
				obst->speed = 1.1;
				obst->anim_speed = 2;
				obst->points = -25;
			}
			if (game->level.dodger.obstacles) {
				game->level.dodger.obstacles->prev = obst;
				obst->next = game->level.dodger.obstacles;
			} else {
				obst->next = NULL;
			}
			game->level.dodger.obstacles = obst;
			if (*count > 128) return true;
		}
	} else if (state == TM_ACTIONSTATE_DESTROY) {
		free(action->arguments->value);
		TM_DestroyArgs(action->arguments);
		action->arguments = NULL;
	}
	return false;
}
Exemplo n.º 22
0
int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {

	if (ev->keyboard.keycode==ALLEGRO_KEY_UP) {
		game->menu.selected--;
		if ((game->menu.menustate==MENUSTATE_VIDEO) && (game->menu.selected==1) && (game->menu.options.fullscreen)) game->menu.selected--;
		al_play_sample_instance(game->menu.click);
	} else if (ev->keyboard.keycode==ALLEGRO_KEY_DOWN) {
		game->menu.selected++;
		if ((game->menu.menustate==MENUSTATE_VIDEO) && (game->menu.selected==1) && (game->menu.options.fullscreen)) game->menu.selected++;
		al_play_sample_instance(game->menu.click);
	}

	if (ev->keyboard.keycode==ALLEGRO_KEY_ENTER) {
		char *text;
		al_play_sample_instance(game->menu.click);
		switch (game->menu.menustate) {
			case MENUSTATE_MAIN:
				switch (game->menu.selected) {
					case 0:
						UnloadGameState(game);
						game->gamestate = GAMESTATE_LOADING;
						game->loadstate = GAMESTATE_DISCLAIMER;
						break;
					case 1:
						ChangeMenuState(game,MENUSTATE_OPTIONS);
						break;
					case 2:
						UnloadGameState(game);
						game->gamestate = GAMESTATE_LOADING;
						game->loadstate = GAMESTATE_ABOUT;
						break;
					case 3:
						return 1;
						break;
				}
				break;
			case MENUSTATE_AUDIO:
				text = malloc(255*sizeof(char));
				switch (game->menu.selected) {
					case 0:
						game->music--;
						if (game->music<0) game->music=10;
						sprintf(text, "%d", game->music);
						SetConfigOption("SuperDerpy", "music", text);
						al_set_mixer_gain(game->audio.music, game->music/10.0);
						break;
					case 1:
						game->fx--;
						if (game->fx<0) game->fx=10;
						sprintf(text, "%d", game->fx);
						SetConfigOption("SuperDerpy", "fx", text);
						al_set_mixer_gain(game->audio.fx, game->fx/10.0);
						break;
					case 2:
						game->voice--;
						if (game->voice<0) game->voice=10;
						sprintf(text, "%d", game->voice);
						SetConfigOption("SuperDerpy", "voice", text);
						al_set_mixer_gain(game->audio.voice, game->voice/10.0);
						break;
					case 3:
						ChangeMenuState(game,MENUSTATE_OPTIONS);
						break;
				}
				free(text);
				break;
			case MENUSTATE_OPTIONS:
				switch (game->menu.selected) {
					case 0:
						ChangeMenuState(game,MENUSTATE_CONTROLS);
						break;
					case 1:
						ChangeMenuState(game,MENUSTATE_VIDEO);
						break;
					case 2:
						ChangeMenuState(game,MENUSTATE_AUDIO);
						break;
					case 3:
						ChangeMenuState(game,MENUSTATE_MAIN);
						break;
					default:
						break;
				}
				break;
			case MENUSTATE_PAUSE:
				switch (game->menu.selected){
					case 0:
						PrintConsole(game,"Game resumed.");
						al_destroy_bitmap(game->pause.bitmap);
						game->pause.bitmap = NULL;
						ResumeGameState(game);
						game->gamestate = game->loadstate;
						break;
					case 1:
						game->gamestate=game->loadstate;
						UnloadGameState(game);
						game->gamestate = GAMESTATE_LOADING;
						game->loadstate = GAMESTATE_MAP;
						break;
					case 2:
						ChangeMenuState(game,MENUSTATE_OPTIONS);
						break;
					case 3:
						return 1;
					default:
						break;
				}
				break;
			case MENUSTATE_CONTROLS:
				switch (game->menu.selected) {
					case 3:
						ChangeMenuState(game,MENUSTATE_OPTIONS);
						break;
					default:
						break;
				}
				break;
			case MENUSTATE_VIDEO:
				switch (game->menu.selected) {
					case 0:
						game->menu.options.fullscreen = !game->menu.options.fullscreen;
						if (game->menu.options.fullscreen)
							SetConfigOption("SuperDerpy", "fullscreen", "1");
						else
							SetConfigOption("SuperDerpy", "fullscreen", "0");
						break;
					case 3:
						if ((game->menu.options.fullscreen==game->fullscreen) && (game->menu.options.fps==game->fps) && (game->menu.options.width==game->width) && (game->menu.options.height==game->height)) {
							ChangeMenuState(game,MENUSTATE_OPTIONS);
						} else {
							PrintConsole(game, "video settings changed, restarting...");
							game->restart = true;
							return 1;
						}
						break;
					default:
						break;
				}
				break;
			default:
				return 1;
				break;
		}
	} else if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
		switch (game->menu.menustate) {
			case MENUSTATE_OPTIONS:
				ChangeMenuState(game,MENUSTATE_MAIN);
				break;
			case MENUSTATE_VIDEO:
				ChangeMenuState(game,MENUSTATE_OPTIONS);
				break;
			case MENUSTATE_AUDIO:
				ChangeMenuState(game,MENUSTATE_OPTIONS);
				break;
			case MENUSTATE_CONTROLS:
				ChangeMenuState(game,MENUSTATE_OPTIONS);
				break;
			case MENUSTATE_PAUSE:
				PrintConsole(game,"Game resumed.");
				al_destroy_bitmap(game->pause.bitmap);
				game->pause.bitmap = NULL;
				ResumeGameState(game);
				game->gamestate = game->loadstate;
				break;
			default:
				return 1;
				break;
		}
	}

	if (game->menu.selected==-1) game->menu.selected=3;
	if (game->menu.selected==4) game->menu.selected=0;
	return 0;
}
Exemplo n.º 23
0
void ChangeMenuState(struct Game *game, enum menustate_enum state) {
	game->menu.menustate=state;
	game->menu.selected=0;
	PrintConsole(game, "menu state changed %d", state);
}
Exemplo n.º 24
0
void Menu_Logic(struct Game *game) {
	game->menu.cloud_position-=0.1;
	game->menu.cloud2_position-=0.025;
	if (game->menu.cloud_position<-80) { game->menu.cloud_position=100; PrintConsole(game, "cloud_position"); }
	if (game->menu.cloud2_position<0) { game->menu.cloud2_position=100; PrintConsole(game, "cloud2_position"); }
}
Exemplo n.º 25
0
void Menu_Draw(struct Game *game) {
	if (!game->menu.loaded) {
		game->gamestate=GAMESTATE_LOADING;
		game->loadstate=GAMESTATE_MENU;
		return;
	}

	al_set_target_bitmap(game->menu.pinkcloud_bitmap);
	al_clear_to_color(al_map_rgba(0,0,0,0));
	float x = 1.5;
	int minus;
	if (game->menu.cloud_position>0) minus=1; else minus=-1;
	al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*5+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.7, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.88+(fmod(-1.8*(game->menu.cloud_position+80), 6))/20.0), 0);
	al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*3+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/3.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.78+(fmod(-2.8*(game->menu.cloud_position+80), 4))/18.0), 0);
	al_draw_scaled_bitmap(game->menu.rain_bitmap, 0, 0, al_get_bitmap_width(game->menu.rain_bitmap), al_get_bitmap_height(game->menu.rain_bitmap), fmod(minus*game->menu.cloud_position,3)*x*6+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.87+(fmod(-4.9*(game->menu.cloud_position+80), 8))/26.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.4, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.08, 0);
	al_draw_bitmap(game->menu.pinkcloud, 0, 0, 0);
	al_set_target_bitmap(al_get_backbuffer(game->display));

	al_clear_to_color(al_map_rgb(183,234,193));
	float tint = (sin((game->menu.cloud_position-80)/15)+1)/2;
	if (tint < 0.000004) { PrintConsole(game, "random tint %f", tint); game->menu.mountain_position = (game->viewportWidth*(rand()/(float)RAND_MAX)/2)+game->viewportWidth/2; }
	al_draw_tinted_bitmap(game->menu.mountain,al_map_rgba_f(tint,tint,tint,tint),game->menu.mountain_position, 0,0);
	al_draw_scaled_bitmap(game->menu.cloud,0,0,al_get_bitmap_width(game->menu.cloud), al_get_bitmap_height(game->menu.cloud), game->viewportWidth*(sin((game->menu.cloud_position/40)-4.5)-0.3), game->viewportHeight*0.35, al_get_bitmap_width(game->menu.cloud)/2, al_get_bitmap_height(game->menu.cloud)/2,0);
	al_draw_bitmap(game->menu.cloud2,game->viewportWidth*(game->menu.cloud2_position/100.0), game->viewportHeight-(game->viewportWidth*(1240.0/3910.0))*0.7,0);
	al_draw_bitmap(game->menu.image,0, game->viewportHeight-(game->viewportWidth*(1240.0/3910.0)),0);

	al_draw_bitmap(game->menu.pinkcloud_bitmap,(game->viewportWidth*0.12) + (cos((game->menu.cloud_position/25+80)*1.74444))*40, 0,0);
	al_draw_bitmap(game->menu.cloud,game->viewportWidth*game->menu.cloud_position/100, game->viewportHeight*0.1,0);

	al_draw_bitmap(game->menu.pie_bitmap, game->viewportWidth/2, game->viewportHeight*(game->menu.cloud_position)/10,0);

	/* GLASS EFFECT */
	al_set_target_bitmap(game->menu.blurbg);

	al_clear_to_color(al_map_rgb(183,234,193));
	al_draw_scaled_bitmap(game->menu.cloud,0,0,al_get_bitmap_width(game->menu.cloud), al_get_bitmap_height(game->menu.cloud), game->viewportWidth*(sin((game->menu.cloud_position/40)-4.5)-0.3) - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), game->viewportHeight*0.35-(game->viewportHeight*0.1), al_get_bitmap_width(game->menu.cloud)/2, al_get_bitmap_height(game->menu.cloud)/2,0);
	al_draw_bitmap(game->menu.pinkcloud_bitmap,(game->viewportWidth*0.12) + (cos((game->menu.cloud_position/25+80)*1.74444))*40 - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), -(game->viewportHeight*0.1),0);
	al_draw_bitmap(game->menu.cloud,game->viewportWidth*game->menu.cloud_position/100 - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), game->viewportHeight*0.1-(game->viewportHeight*0.1),0);
	al_draw_bitmap(game->menu.pie_bitmap, game->viewportWidth/2 - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), game->viewportHeight*(game->menu.cloud_position)/10 -(game->viewportHeight*0.1),0);

	/*al_draw_bitmap_region(al_get_backbuffer(game->display), (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2), (game->viewportHeight*0.1), al_get_bitmap_width(game->menu.logo), al_get_bitmap_height(game->menu.logo), 0, 0, 0);*/

	al_set_target_bitmap(game->menu.blurbg2);
	al_clear_to_color(al_map_rgba(0,0,0,0));

	float alpha = (1.0/8.0);
	ALLEGRO_COLOR color = al_map_rgba_f(alpha, alpha, alpha, alpha);
	int bx = 0, by = 0;
	for (by = -2; by <= 2; by++) {
		for (bx = -2; bx <= 2; bx++) {
			if (sqrt(bx*bx+by*by) <= 2)
				al_draw_tinted_bitmap(game->menu.blurbg, color, bx*2, by*2, 0);
		}
	}
	al_draw_bitmap(game->menu.glass, 0, 0, 0);
	al_set_blender(ALLEGRO_ADD, ALLEGRO_ZERO, ALLEGRO_ALPHA);
	al_draw_bitmap(game->menu.logo, 0, 0, 0);
	al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
	al_set_target_bitmap(al_get_backbuffer(game->display));
	al_draw_bitmap(game->menu.blurbg2, (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2), (game->viewportHeight*0.1), 0);

	al_draw_bitmap(game->menu.logoblur, (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2)-2, (game->viewportHeight*0.1)-2, 0);
	al_draw_tinted_bitmap(game->menu.logo, al_map_rgba_f(0.1, 0.1, 0.1, 0.1), (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2), (game->viewportHeight*0.1), 0);
	/* END OF GLASS EFFECT */

	al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.1, ALLEGRO_ALIGN_CENTRE, "Przygody Super Kuca");
	al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.275, ALLEGRO_ALIGN_CENTRE, "Prętulino");

	DrawMenuState(game);
}
Exemplo n.º 26
0
bool CConsole::KeyPressed(int code, bool bCtrlDown)
{
	if (!IsOpen())
		return false;

	if (code == TINKER_KEY_ESCAPE)
	{
		m_hInput->SetText("");
		CApplication::Get()->CloseConsole();
		return true;
	}

	if (m_asHistory.size())
	{
		if (code == TINKER_KEY_DOWN)
		{
			if (m_iHistory >= 0 && m_iHistory < (int)m_asHistory.size()-1)
			{
				m_iHistory++;

				m_hInput->SetText(m_asHistory[m_iHistory]);
				m_hInput->SetCursorPosition(-1);
			}
			else if (m_iHistory == (int)m_asHistory.size()-1)
			{
				m_iHistory = -1;
				m_hInput->SetText("");
			}
		}
		else if (code == TINKER_KEY_UP)
		{
			if (m_iHistory == -1)
				m_iHistory = m_asHistory.size()-1;
			else if (m_iHistory > 1)
				m_iHistory--;

			m_hInput->SetText(m_asHistory[m_iHistory]);
			m_hInput->SetCursorPosition(-1);
		}
		else
			m_iHistory = -1;
	}

	bool bReturn = BaseClass::KeyPressed(code, bCtrlDown);

	if (bReturn && !(code == TINKER_KEY_ENTER || code == TINKER_KEY_KP_ENTER))
		return true;

	if (code == TINKER_KEY_ENTER || code == TINKER_KEY_KP_ENTER)
	{
		tstring sText = m_hInput->GetText();
		m_hInput->SetText("");

		PrintConsole(tstring("] ") + sText + "\n");

		CCommand::Run(sText);

		if (trim(sText).length())
			m_asHistory.push_back(trim(sText));
		m_iHistory = -1;

		return true;
	}

	return false;
}
Exemplo n.º 27
0
void Pause_Unload(struct Game* game) {
	game->gamestate=game->loadstate;
	UnloadGameState(game);
	PrintConsole(game, "Pause: Unloading GAMESTATE_MENU...");
	Menu_Unload(game);
}
Exemplo n.º 28
0
void Pause_Unload_Real(struct Game* game) {
	PrintConsole(game,"Pause unloaded.");
	//if (game->pause.bitmap) al_destroy_bitmap(game->pause.bitmap);
	//al_destroy_bitmap(game->pause.derpy);
}
Exemplo n.º 29
0
SYMBOL_EXPORT void TM_Process(struct Timeline* timeline, double delta) {
	// NOTICE: if you create background actions from running action,
	// newly created ones have no way to know how much time has been
	// "eaten" by the one that created it, which may result in incorrect
	// result when calling TM_Process with huge delta. This behaviour
	// may change in the future.

	// TODO: make sure new action STARTS in the same tick as the old one
	// DESTROYS, but make it RUNNING only in the next tick (or when there's
	// some remaining delta).

	/* process first element from queue.
		 if returns true, delete it and repeat for the next one */
	double origDelta = delta;
	while (delta > 0.0) {
		if (timeline->queue) {
			if (timeline->queue->active && timeline->queue->delay > 0.0) {
				timeline->queue->delay -= delta;
				if (timeline->queue->delay <= 0.0) {
					delta = -timeline->queue->delay;
					timeline->queue->delta = delta;
					if (timeline->queue->function) {
						PrintConsole(timeline->game, "Timeline Manager[%s]: queue: run action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
						timeline->queue->state = TM_ACTIONSTATE_START;
						(*timeline->queue->function)(timeline->game, timeline->data, timeline->queue);
					} else {
						PrintConsole(timeline->game, "Timeline Manager[%s]: queue: delay reached (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
					}
					timeline->queue->started = true;
					timeline->queue->delay = 0.0;
				} else {
					delta = 0.0;
				}
			}

			timeline->queue->delta = delta;
			if (timeline->queue->function) {
				if (!timeline->queue->started) {
					timeline->queue->active = true;
					timeline->queue->started = true;
					PrintConsole(timeline->game, "Timeline Manager[%s]: queue: run action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
					timeline->queue->state = TM_ACTIONSTATE_START;
					(*timeline->queue->function)(timeline->game, timeline->data, timeline->queue);
				}
				timeline->queue->state = TM_ACTIONSTATE_RUNNING;
				if ((*timeline->queue->function)(timeline->game, timeline->data, timeline->queue)) {
					struct TM_Action* tmp = timeline->queue;
					PrintConsole(timeline->game, "Timeline Manager[%s]: queue: stop action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
					tmp->state = TM_ACTIONSTATE_STOP;
					(*tmp->function)(timeline->game, timeline->data, tmp);
					PrintConsole(timeline->game, "Timeline Manager[%s]: queue: destroy action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
					delta = timeline->queue->delta;
					timeline->queue = timeline->queue->next;
					tmp->state = TM_ACTIONSTATE_DESTROY;
					(*tmp->function)(timeline->game, timeline->data, tmp);
					DestroyArgs(tmp->arguments);
					free(tmp->name);
					free(tmp);
				} else {
					SUPPRESS_WARNING("-Wfloat-equal") // we're literally checking if the value remained unchanged
					if (delta == timeline->queue->delta) {
						// an action that repeats itself but doesn't eat any delta may potentially run infinitely, so don't let it.
						// actions that eat delta don't have this issue - eventually there will be no delta left.
						delta = 0.0;
					} else {
						delta = timeline->queue->delta;
					}
					SUPPRESS_END
				}
			} else {
				/* delay handling */
				if (timeline->queue->started) { // delay has ended (an action would start now)
					struct TM_Action* tmp = timeline->queue;
					timeline->queue = timeline->queue->next;
					free(tmp->name);
					free(tmp);
				} else {
					if (!timeline->queue->active) {
						PrintConsole(timeline->game, "Timeline Manager[%s]: queue: delay started %d ms (%d - %s)", timeline->name, (int)(timeline->queue->delay * 1000), timeline->queue->id, timeline->queue->name);
						timeline->queue->active = true;
					}
				}
			}
		} else {
Exemplo n.º 30
0
void __cdecl main(int argc, char **argv)
{
	HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	int running = 1;

#ifdef WIN32
	if (IsDebuggerPresent())
	{
		// turn on floating-point exceptions
		unsigned int prev;
		_clearfp();
		_controlfp_s(&prev, 0, _EM_ZERODIVIDE|_EM_INVALID);
	}
#endif

	// check the correct BASS was loaded
	if (HIWORD(BASS_GetVersion()) != BASSVERSION)
	{
		fprintf(stderr, "An incorrect version of BASS.DLL was loaded");
		return;
	}

	// set the window title
	SetConsoleTitle(TEXT(title_text));

	// set the console buffer size
	static const COORD bufferSize = { 80, 50 };
	SetConsoleScreenBufferSize(hOut, bufferSize);

	// set the console window size
	static const SMALL_RECT windowSize = { 0, 0, 79, 49 };
	SetConsoleWindowInfo(hOut, TRUE, &windowSize);

	// clear the window
	Clear(hOut);

	// hide the cursor
	static const CONSOLE_CURSOR_INFO cursorInfo = { 100, FALSE };
	SetConsoleCursorInfo(hOut, &cursorInfo);

	// set input mode
	SetConsoleMode(hIn, 0);

	// 10ms update period
	const DWORD STREAM_UPDATE_PERIOD = 10;
	BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, STREAM_UPDATE_PERIOD);

	// initialize BASS sound library
	const DWORD STREAM_FREQUENCY = 48000;
	if (!BASS_Init(-1, STREAM_FREQUENCY, BASS_DEVICE_LATENCY, 0, NULL))
		Error("Can't initialize device");

	// get device info
	BASS_GetInfo(&info);

	// if the device's output rate is unknown default to stream frequency
	if (!info.freq) info.freq = STREAM_FREQUENCY;

	// debug print info
	DebugPrint("frequency: %d (min %d, max %d)\n", info.freq, info.minrate, info.maxrate);
	DebugPrint("device latency: %dms\n", info.latency);
	DebugPrint("device minbuf: %dms\n", info.minbuf);
	DebugPrint("ds version: %d (effects %s)\n", info.dsver, info.dsver < 8 ? "disabled" : "enabled");

	// default buffer size = update period + 'minbuf' + 1ms extra margin
	BASS_SetConfig(BASS_CONFIG_BUFFER, STREAM_UPDATE_PERIOD + info.minbuf + 1);
	DebugPrint("using a %dms buffer\r", BASS_GetConfig(BASS_CONFIG_BUFFER));

	// create a stream, stereo so that effects sound nice
	stream = BASS_StreamCreate(info.freq, 2, BASS_SAMPLE_FLOAT, (STREAMPROC*)WriteStream, 0);

	// set channel to apply effects
	fx_channel = stream;

#ifdef BANDLIMITED_SAWTOOTH
	// initialize bandlimited sawtooth tables
	InitSawtooth();
#endif

	// initialize waves
	InitWave();

	// enable the first oscillator
	osc_config[0].enable = true;

	// reset all controllers
	Control::ResetAll();

	// start playing the audio stream
	BASS_ChannelPlay(stream, FALSE);

	// get the number of midi devices
	UINT midiInDevs = Midi::Input::GetNumDevices();
	DebugPrint("MIDI input devices: %d\n", midiInDevs);

	// print device names
	for (UINT i = 0; i < midiInDevs; ++i)
	{
		MIDIINCAPS midiInCaps;
		if (Midi::Input::GetDeviceCaps(i, midiInCaps) == 0)
		{
			DebugPrint("%d: %s\n", i, midiInCaps.szPname);
		}
	}

	// if there are any devices available...
	if (midiInDevs > 0)
	{
		// open and start midi input
		// TO DO: select device number via a configuration setting
		Midi::Input::Open(0);
		Midi::Input::Start();
	}

	// initialize to middle c
	note_most_recent = 60;
	voice_note[voice_most_recent] = unsigned char(note_most_recent);

	DisplaySpectrumAnalyzer displaySpectrumAnalyzer;
	DisplayKeyVolumeEnvelope displayKeyVolumeEnvelope;
	DisplayOscillatorWaveform displayOscillatorWaveform;
	DisplayOscillatorFrequency displayOscillatorFrequency;
	DisplayLowFrequencyOscillator displayLowFrequencyOscillator;
	DisplayFilterFrequency displayFilterFrequency;

	// initialize spectrum analyzer
	displaySpectrumAnalyzer.Init(stream, info);

	// initialize key display
	displayKeyVolumeEnvelope.Init(hOut);

	// show output scale and key octave
	PrintOutputScale(hOut);
	PrintKeyOctave(hOut);
	PrintGoToEffects(hOut);
	PrintAntialias(hOut);

	// show main page
	Menu::SetActivePage(hOut, Menu::PAGE_MAIN);

	while (running)
	{
		// if there are any pending input events...
		DWORD numEvents = 0;
		while (GetNumberOfConsoleInputEvents(hIn, &numEvents) && numEvents > 0)
		{
			// get the next input event
			INPUT_RECORD keyin;
			ReadConsoleInput(hIn, &keyin, 1, &numEvents);
			if (keyin.EventType == KEY_EVENT)
			{
				// handle interface keys
				if (keyin.Event.KeyEvent.bKeyDown)
				{
					WORD code = keyin.Event.KeyEvent.wVirtualKeyCode;
					DWORD modifiers = keyin.Event.KeyEvent.dwControlKeyState;
					if (code == VK_ESCAPE)
					{
						running = 0;
						break;
					}
					else if (code == VK_OEM_MINUS || code == VK_SUBTRACT)
					{
						Menu::UpdatePercentageProperty(output_scale, -1, modifiers, 0, 4);
						PrintOutputScale(hOut);
					}
					else if (code == VK_OEM_PLUS || code == VK_ADD)
					{
						Menu::UpdatePercentageProperty(output_scale, +1, modifiers, 0, 4);
						PrintOutputScale(hOut);
					}
					else if (code == VK_OEM_4)	// '['
					{
						if (keyboard_octave > 1)
						{
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOff(k + keyboard_octave * 12);
							}
							--keyboard_octave;
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOn(k + keyboard_octave * 12);
							}
							PrintKeyOctave(hOut);
						}
					}
					else if (code == VK_OEM_6)	// ']'
					{
						if (keyboard_octave < 9)
						{
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOff(k + keyboard_octave * 12);
							}
							++keyboard_octave;
							for (int k = 0; k < KEYS; ++k)
							{
								if (key_down[k])
									NoteOn(k + keyboard_octave * 12);
							}
							PrintKeyOctave(hOut);
						}
					}
					else if (code == VK_F12)
					{
						use_antialias = !use_antialias;
						PrintAntialias(hOut);
					}
					else if (code >= VK_F1 && code < VK_F10)
					{
						Menu::SetActiveMenu(hOut, code - VK_F1);
					}
					else if (code == VK_F10)
					{
						PrintGoToEffects(hOut);
						Menu::SetActivePage(hOut, Menu::PAGE_MAIN);
					}
					else if (code == VK_F11)
					{
						PrintGoToMain(hOut);
						Menu::SetActivePage(hOut, Menu::PAGE_FX);
					}
					else if (code == VK_TAB)
					{
						if (modifiers & SHIFT_PRESSED)
							Menu::PrevMenu(hOut);
						else
							Menu::NextMenu(hOut);
					}
					else if (code == VK_UP || code == VK_DOWN || code == VK_RIGHT || code == VK_LEFT)
					{
						Menu::Handler(hOut, code, modifiers);
					}
				}

				// handle note keys
				for (int k = 0; k < KEYS; k++)
				{
					if (keyin.Event.KeyEvent.wVirtualKeyCode == keys[k])
					{
						// key down
						bool down = (keyin.Event.KeyEvent.bKeyDown != 0);

						// if key down state changed...
						if (key_down[k] != down)
						{
							// update state
							key_down[k] = down;

							// if pressing the key
							if (down)
							{
								// note on
								NoteOn(k + keyboard_octave * 12);
							}
							else
							{
								// note off
								NoteOff(k + keyboard_octave * 12);
							}
						}
						break;
					}
				}
			}
		}

		// center frequency of the zeroth semitone band
		// (one octave down from the lowest key)
		float const freq_min = powf(2, float(keyboard_octave - 6)) * middle_c_frequency;

		// update the spectrum analyzer display
		displaySpectrumAnalyzer.Update(hOut, stream, info, freq_min);

		// update note key volume envelope display
		displayKeyVolumeEnvelope.Update(hOut);

		if (Menu::active_page == Menu::PAGE_MAIN)
		{
			// update the oscillator waveform display
			displayOscillatorWaveform.Update(hOut, info, voice_most_recent);

			// update the oscillator frequency displays
			for (int o = 0; o < NUM_OSCILLATORS; ++o)
			{
				if (osc_config[o].enable)
					displayOscillatorFrequency.Update(hOut, voice_most_recent, o);
			}

			// update the low-frequency oscillator display
			displayLowFrequencyOscillator.Update(hOut);

			// update the filter frequency display
			if (flt_config.enable)
				displayFilterFrequency.Update(hOut, voice_most_recent);
		}

		// show CPU usage
		PrintConsole(hOut, { 73, 49 }, "%6.2f%%", BASS_GetCPU());

		// sleep for 1/60th of second
		Sleep(16);
	}

	if (midiInDevs)
	{
		// stop and close midi input
		Midi::Input::Stop();
		Midi::Input::Close();
	}

	// clean up spectrum analyzer
	displaySpectrumAnalyzer.Cleanup(stream);

	// clear the window
	Clear(hOut);

	BASS_Free();
}