Esempio n. 1
0
bool CPlayer::OnMessage( Json::Value& recvValue , uint16_t nmsgType, eMsgPort eSenderPort )
{
    for ( int i = ePlayerComponent_None; i < ePlayerComponent_Max ; ++i )
    {
        IPlayerComponent* p = m_vAllComponents[i] ;
        if ( p )
        {
            if ( p->OnMessage(recvValue,nmsgType,eSenderPort) )
            {
                return true;
            }
        }
    }

    LOGFMTE("Unprocessed msg id = %d, from = %d  uid = %d",nmsgType,eSenderPort,GetUserUID() ) ;

    return false ;
}
Esempio n. 2
0
bool CPlayer::OnMessage( stMsg* pMsg , eMsgPort eSenderPort )
{
    if ( ProcessPublicPlayerMsg(pMsg,eSenderPort) )
    {
        return true;
    }

    for ( int i = ePlayerComponent_None; i < ePlayerComponent_Max ; ++i )
    {
        IPlayerComponent* p = m_vAllComponents[i] ;
        if ( p )
        {
            if ( p->OnMessage(pMsg,eSenderPort) )
            {
                return true;
            }
        }
    }

    LOGFMTE("Unprocessed msg id = %d, from = %d  uid = %d",pMsg->usMsgType,eSenderPort,GetUserUID() ) ;

    return false ;

// 	switch ( pMsg->usMsgType )
// 	{
// 	case MSG_PLAYER_CREATE_PRIVATE_ROOM:
// 		{
// 			//stMsgPlayerCreatePrivateRoomRet msgBack ;
// 			//msgBack.nRet = 0 ;
// 			//msgBack.nPassword = 0;
// 			//msgBack.nRoomID = 0 ;
// 			//if ( GetState() != ePlayerState_Free )
// 			//{
// 			//	msgBack.nRet = 1 ;
// 			//	SendMsgToClient((char*)&msgBack,sizeof(msgBack) ) ;
// 			//	return ;
// 			//}
//
// 			//stMsgPlayerCreatePrivateRoom* pMsgRet = (stMsgPlayerCreatePrivateRoom*)pMsg;
// 			//
// 			//if ( (pMsgRet->bDiamond && GetBaseData()->GetAllDiamoned() < pMsgRet->nOwnMoneyNeedToEnter) || (pMsgRet->bDiamond == false && GetBaseData()->GetAllCoin() < pMsgRet->nOwnMoneyNeedToEnter) )
// 			//{
// 			//	msgBack.nRet = 3 ;
// 			//	SendMsgToClient((char*)&msgBack,sizeof(msgBack) ) ;
// 			//	return ;
// 			//}
//
// 			//if ( pMsgRet->nBigBinld > pMsgRet->nOwnMoneyNeedToEnter )
// 			//{
// 			//	msgBack.nRet = 4 ;
// 			//	SendMsgToClient((char*)&msgBack,sizeof(msgBack) ) ;
// 			//	return ;
// 			//}
//
// 			//LOGFMTE("do you have create private room card ? " ) ;
// 			//CPlayerItemComponent* pItemMgr = (CPlayerItemComponent*)GetComponent(ePlayerComponent_PlayerItemMgr);
// 			//if ( !pItemMgr->OnUserItem(ITEM_ID_CREATE_ROOM) )
// 			//{
// 			//	msgBack.nRet = 2 ;
// 			//	SendMsgToClient((char*)&msgBack,sizeof(msgBack) ) ;
// 			//	return ;
// 			//}
//
// 			//CRoomBase* pBase = CGameServerApp::SharedGameServerApp()->GetRoomMgr()->CreateRoom(eRoom_TexasPoker_Private,eRoomLevel_Junior) ;
// 			//if ( !pBase )
// 			//{
// 			//	LOGFMTE("create room failed") ;
// 			//	msgBack.nRet = 5 ;
// 			//	SendMsgToClient((char*)&msgBack,sizeof(msgBack) ) ;
// 			//	pItemMgr->AddItemByID(ITEM_ID_CREATE_ROOM);
// 			//	return ;
// 			//}
// 			//pBase->SetRoomName(pMsgRet->cRoomName);
// 			//pBase->SetIsDiamonedRoom(pMsgRet->bDiamond) ;
// 			//pBase->SetPassword(pMsgRet->nPassword) ;
// 			//pBase->SetAntesCoin(pMsgRet->nOwnMoneyNeedToEnter) ;
// 			//((CRoomTexasPoker*)pBase)->SetBigBlindBet(pMsgRet->nBigBinld) ;
// 			//msgBack.nPassword = pMsgRet->nPassword ;
// 			//msgBack.nRoomID = pBase->GetRoomID() ;
// 			//SendMsgToClient((char*)&msgBack,sizeof(msgBack) ) ;
//
// 			//// after crate success , you default enter the room you create ;
// 			//CRoomPeer* peer = (CTaxasPokerPeer*)GetComponent(ePlayerComponent_RoomPeerTaxasPoker) ;
// 			//pBase->AddPeer(peer) ;
// 			//peer->SetRoom(pBase) ;
// 			//m_eSate = ePlayerState_InRoom ;
// 			//pBase->SendCurRoomInfoToPlayer(peer) ;
// 		}
// 		return ;
// 	case MSG_ROOM_ENTER:
// 		{
// 			stMsgRoomEnterRet msgRet ;
// 			msgRet.nRet = 0 ;
// 			if ( m_eSate == ePlayerState_InRoom )
// 			{
// 				msgRet.nRet = 3 ;   // aready in room ;
// 				SendMsgToClient((char*)&msgRet,sizeof(msgRet)) ;
// 				return ;
// 			}
//
// 			stMsgRoomEnter* msgEnter = (stMsgRoomEnter*)pMsg ;
// 			CRoomBaseNew* pRoom = CGameServerApp::SharedGameServerApp()->GetRoomMgr()->GetRoom(msgEnter->nRoomType,msgEnter->nRoomLevel,msgEnter->nRoomID) ;
// 			if ( pRoom == NULL )
// 			{
// 				pRoom = CGameServerApp::SharedGameServerApp()->GetRoomMgr()->CreateRoom(msgEnter->nRoomType,msgEnter->nRoomLevel);
// 			}
//
// 			if ( pRoom == NULL )
// 			{
// 				msgRet.nRet = 6 ;   // room is NULL;
// 				SendMsgToClient((char*)&msgRet,sizeof(msgRet)) ;
// 				return ;
// 			}
//
// 			unsigned char nRet = pRoom->CheckCanJoinThisRoom(this);
// 			if ( nRet != 0 )
// 			{
// 				msgRet.nRet = 5 ;   // room is NULL;
// 				SendMsgToClient((char*)&msgRet,sizeof(msgRet)) ;
// 				return ;
// 			}
// 			SendMsgToClient((char*)&msgRet,sizeof(msgRet)) ;
// 			pRoom->Enter(this);
// 			m_pCurRoom = pRoom ;
// 			m_eSate = ePlayerState_InRoom ;
// 		}
// 		return ;
// 	default:
// 		break;
// 	}

}