예제 #1
0
void CPlayer::Init(unsigned int nUserUID, unsigned int nSessionID )
{
    m_bIsWaitingAsyncRequest = false ;
    m_nSessionID = nSessionID ;
    m_nUserUID = nUserUID ;
    m_eSate = ePlayerState_Online ;
    m_nDisconnectTime = 0 ;
    /// new components ;here ;
    m_vAllComponents[ePlayerComponent_BaseData] = new CPlayerBaseData(this) ;
    m_vAllComponents[ePlayerComponent_Mail] = new CPlayerMailComponent(this);
    m_vAllComponents[ePlayerComponent_PlayerGameData] = new CPlayerGameData(this);
    //m_vAllComponents[ePlayerComponent_PlayerItemMgr] = new CPlayerItemComponent(this);
    //m_vAllComponents[ePlayerComponent_PlayerMission] = new CPlayerMission(this);
    //m_vAllComponents[ePlayerComponent_PlayerShop] = new CPlayerShop(this);
    m_vAllComponents[ePlayerComponent_Friend] = new CPlayerFriend(this);
    for ( int i = ePlayerComponent_None; i < ePlayerComponent_Max ; ++i )
    {
        IPlayerComponent* p = m_vAllComponents[i] ;
        if ( p )
        {
            p->Init();
        }
    }

    m_tTimerSave.setCallBack(timer_bind_obj_func(this,CPlayer::OnTimerSave )) ;
    m_tTimerSave.setIsAutoRepeat(true) ;
    m_tTimerSave.setInterval(TIME_SAVE);
    m_tTimerSave.start() ;
}
예제 #2
0
void CPlayer::Init(unsigned int nUserUID, unsigned int nSessionID )
{
	m_nSessionID = nSessionID ;
	m_nUserUID = nUserUID ;
	m_eSate = ePlayerState_Online ;
	m_pTimerSave = NULL ;
	m_nDisconnectTime = 0 ;
	/// new components ;here ;
	m_vAllComponents[ePlayerComponent_BaseData] = new CPlayerBaseData(this) ;
	m_vAllComponents[ePlayerComponent_Mail] = new CPlayerMailComponent(this);
	//m_vAllComponents[ePlayerComponent_PlayerItemMgr] = new CPlayerItemComponent(this);
	m_vAllComponents[ePlayerComponent_PlayerMission] = new CPlayerMission(this);
	//m_vAllComponents[ePlayerComponent_PlayerShop] = new CPlayerShop(this);
	m_nTaxasRoomID = 0 ;
	for ( int i = ePlayerComponent_None; i < ePlayerComponent_Max ; ++i )
	{
		IPlayerComponent* p = m_vAllComponents[i] ;
		if ( p )
		{
			p->Init();
		}
	}

	if ( m_pTimerSave == NULL )
	{
		m_pTimerSave = CGameServerApp::SharedGameServerApp()->GetTimerMgr()->AddTimer(this,cc_selector_timer(CPlayer::OnTimerSave)) ;
		m_pTimerSave->SetDelayTime( TIME_SAVE * 0.5 ) ;
		m_pTimerSave->SetInterval(TIME_SAVE) ;
		m_pTimerSave->Start();
	}
}