示例#1
0
void COfConnectMgr::processPeerExitUnreach(CSmartPtr<CSwitch>& sw, INT4 reason)
{
    if (sw.isNotNull() && (sw->getState() == SW_STATE_UNREACHABLE))
    {
        //交换机状态恢复为STABLE
        sw->setState(SW_STATE_STABLE);

        //上报交换机事件EXIT_UNREACH
        CSwitchEventReportor::getInstance()->report(sw, EVENT_TYPE_SWITCH_EXIT_UNREACH, reason);

        //停止掉电检�?
        stopPowerOffCheck(sw);
    }
}
示例#2
0
文件: WebModules.cpp 项目: DrRenX/znc
void CWebAuth::RefusedLogin(const CString& sReason) {
	if (m_pWebSock) {
		CSmartPtr<CWebSession> spSession = m_pWebSock->GetSession();

		spSession->AddError("Invalid login!");
		spSession->SetUser(NULL);

		m_pWebSock->SetLoggedIn(false);
		m_pWebSock->UnPauseRead();
		m_pWebSock->Redirect("/?cookie_check=true");

		DEBUG("UNSUCCESSFUL login attempt ==> REASON [" + sReason + "] ==> SESSION [" + spSession->GetId() + "]");
	}
}
示例#3
0
//-----------------------------------------------------------------------------
// Chopper muzzle flashes
//-----------------------------------------------------------------------------
void MuzzleFlash_Chopper( ClientEntityHandle_t hEntity, int attachmentIndex )
{
	VPROF_BUDGET( "MuzzleFlash_Chopper", VPROF_BUDGETGROUP_PARTICLE_RENDERING );

	matrix3x4_t	matAttachment;
	// If the client hasn't seen this entity yet, bail.
	if ( !FX_GetAttachmentTransform( hEntity, attachmentIndex, matAttachment ) )
		return;
	
	CSmartPtr<CLocalSpaceEmitter> pSimple = CLocalSpaceEmitter::Create( "MuzzleFlash", hEntity, attachmentIndex );

	SimpleParticle *pParticle;
	Vector			forward(1,0,0), offset; //NOTENOTE: All coords are in local space

	float flScale = random->RandomFloat( 2.5f, 4.5f );

	// Flash
	for ( int i = 1; i < 7; i++ )
	{
		offset = (forward * (i*2.0f*flScale));

		pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), pSimple->GetPMaterial( VarArgs( "effects/combinemuzzle%d", random->RandomInt(1,2) ) ), offset );
			
		if ( pParticle == NULL )
			return;

		pParticle->m_flLifetime		= 0.0f;
		pParticle->m_flDieTime		= random->RandomFloat( 0.05f, 0.1f );

		pParticle->m_vecVelocity.Init();

		pParticle->m_uchColor[0]	= 255;
		pParticle->m_uchColor[1]	= 255;
		pParticle->m_uchColor[2]	= 255;

		pParticle->m_uchStartAlpha	= 255;
		pParticle->m_uchEndAlpha	= 128;

		pParticle->m_uchStartSize	= ( (random->RandomFloat( 6.0f, 8.0f ) * (10-(i))/7) * flScale );
		pParticle->m_uchEndSize		= pParticle->m_uchStartSize;
		pParticle->m_flRoll			= random->RandomInt( 0, 360 );
		pParticle->m_flRollDelta	= 0.0f;
	}
	
	// Grab the origin out of the transform for the attachment
	Vector		origin;
	MatrixGetColumn( matAttachment, 3, &origin );	
	CreateMuzzleflashELight( origin, 6, 128, 256, hEntity );
}
示例#4
0
void COfConnectMgr::processPeerPowerOff(CSmartPtr<CSwitch>& sw)
{
    if (sw.isNotNull() && (sw->getState() < SW_STATE_POWER_OFF))
    {
        sw->setState(SW_STATE_POWER_OFF);
        
        //上报交换机事件POWER_OFF
        CSwitchEventReportor::getInstance()->report(sw, EVENT_TYPE_SWITCH_POWER_OFF, EVENT_REASON_SWITCH_POWER_OFF);
        
        //停止掉电检�?
        stopPowerOffCheck(sw);

        processPeerQuit(sw, EVENT_REASON_SWITCH_POWER_OFF);
    }
}
示例#5
0
static void deleteCmsg(CMsgCommon* msg)
{
    if (NULL != msg)
    {
        CMsg* ofmsg = (CMsg*)msg;
        INT4 sockfd = ofmsg->getSockfd();

        ofmsg->~CMsg();

        CSmartPtr<COfRecvWorker> worker = CServer::getInstance()->mapOfRecvWorker(sockfd);
        if (worker.isNotNull())
            worker->getMemPool().release(ofmsg);
        else
            LOG_WARN_FMT("memory[%p] not released for none COfRecvWorker by sockfd[%d] !", ofmsg, sockfd);
    }
}
示例#6
0
文件: fail2ban.cpp 项目: bpcampbe/znc
	virtual EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth) {
		// e.g. webadmin ends up here
		const CString& sRemoteIP = Auth->GetRemoteIP();

		if (sRemoteIP.empty())
			return CONTINUE;

		unsigned int *pCount = m_Cache.GetItem(sRemoteIP);
		if (pCount && *pCount >= m_uiAllowedFailed) {
			// OnFailedLogin() will refresh their ban
			Auth->RefuseLogin("Please try again later - reconnecting too fast");
			return HALT;
		}

		return CONTINUE;
	}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_ObjectEMPGenerator::ClientThink( void )
{
	// Add particles at the target.
	float flCur = gpGlobals->frametime;
	while ( m_ParticleEvent.NextEvent( flCur ) )
	{
		Vector vPos = WorldSpaceCenter( );
		Vector vOffset = RandomVector( -1, 1 );
		VectorNormalize( vOffset );
		vPos += vOffset * RandomFloat( 0, 50 );
		
		SimpleParticle *pParticle = m_pEmitter->AddSimpleParticle( m_hParticleMaterial, vPos );
		if ( pParticle )
		{
			// Move the points along the path.
			pParticle->m_vecVelocity.Init();
			pParticle->m_flRoll = 0;
			pParticle->m_flRollDelta = 0;
			pParticle->m_flDieTime = 0.4f;
			pParticle->m_flLifetime = 0;
			pParticle->m_uchColor[0] = 255; 
			pParticle->m_uchColor[1] = 255;
			pParticle->m_uchColor[2] = 255;
			pParticle->m_uchStartAlpha = 32;
			pParticle->m_uchEndAlpha = 0;
			pParticle->m_uchStartSize = 6;
			pParticle->m_uchEndSize = 4;
			pParticle->m_iFlags = 0;
		}
	}
}
//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void C_PlasmaBeamNode::ClientThink(void)
{
	if (!m_bSprayOn)
	{
		return;
	}
	
	trace_t trace;
	Vector vEndTrace = GetAbsOrigin() + (0.3*GetAbsVelocity());
	UTIL_TraceLine( GetAbsOrigin(), vEndTrace, MASK_SHOT, NULL, COLLISION_GROUP_NONE, &trace );
	if ( trace.fraction != 1.0f || trace.startsolid)
	{
		m_bSprayOn = false;
		return;
	}

	PMaterialHandle handle = m_pFirePlasmaSpray->GetPMaterial( "sprites/plasmaember" );
	for (int i=0;i<SPRAYS_PER_THINK;i++)
	{
		SimpleParticle	*sParticle;

		//Make a new particle
		if ( random->RandomInt( 0, 2 ) == 0 )
		{
			float ranx = random->RandomFloat( -28.0f, 28.0f );
			float rany = random->RandomFloat( -28.0f, 28.0f );
			float ranz = random->RandomFloat( -28.0f, 28.0f );

			Vector vNewPos	=  GetAbsOrigin();
			Vector vAdd		=  Vector(GetAbsAngles().x,GetAbsAngles().y,GetAbsAngles().z)*random->RandomFloat(-60,120);
			vNewPos			+= vAdd;

			sParticle = (SimpleParticle *) m_pFirePlasmaSpray->AddParticle( sizeof(SimpleParticle), handle, vNewPos );
			
			sParticle->m_flLifetime		= 0.0f;
			sParticle->m_flDieTime		= PLASMASPARK_LIFETIME;

			sParticle->m_vecVelocity	= GetAbsVelocity();
			sParticle->m_vecVelocity.x	+= ranx;
			sParticle->m_vecVelocity.y	+= rany;
			sParticle->m_vecVelocity.z	+= ranz;
			m_pFirePlasmaSpray->m_pOwner	=  this;
		}
	}

	SetNextClientThink(gpGlobals->curtime + 0.05);
}
示例#9
0
INT4 COfRecvWorker::procRecvBuffer(INT4 sockfd, INT1* buffer, UINT4 len, CSmartPtr<CLoopBuffer>& recvBuffer)
{
    struct ofp_header* header = NULL;
    const UINT4 headerLen = sizeof(struct ofp_header);
    UINT2 lenTotal = 0;
    INT1* pdata = NULL, *pmsg = NULL;
    CMsg* ofmsg = NULL;
    CMsgTree& msgTree = CControl::getInstance()->getMsgTree();
    
    while (len >= headerLen)
    {
        header = (struct ofp_header*)buffer;
        lenTotal = ntohs(header->length);
        if (lenTotal < headerLen)
        {
            LOG_WARN_FMT("%s drop packet when invalid ofp_header.length %u !!!", toString(), lenTotal);
            return BNC_ERR;
        }
        if (len < lenTotal)
            break;

        procStats();

        pdata = (INT1*)m_memPool.alloc(lenTotal);
        if (NULL == pdata)
        {
            LOG_ERROR_FMT("alloc %u bytes failed!", lenTotal);
            return BNC_ERR;
        }
        memcpy(pdata, buffer, lenTotal);

        pmsg = (INT1*)m_memPool.alloc(sizeof(CMsg));
        if (NULL == pmsg)
        {
            LOG_ERROR_FMT("alloc CMsg failed !");
            m_memPool.release(pdata);
            return BNC_ERR;
        }
        ofmsg = new(pmsg) CMsg(sockfd, header->version, header->type, pdata, lenTotal);

        ofmsg->setPath();
        ofmsg->setKey();

        CSmartPtr<CMsgCommon> msg(ofmsg, deleteCmsg);
        if (msgTree.pushMsg(msg) != BNC_OK)
        {
            LOG_INFO_FMT("push msg[%s]key[%s] from sockfd[%d] into tree failed", 
                ofmsg->getPath().c_str(), ofmsg->getKey().c_str(), sockfd);
        }

        buffer += lenTotal;
        len -= lenTotal;
    }
    
    if (len > 0)
        recvBuffer->write(buffer, len);

    return BNC_OK;
}
示例#10
0
void COfConnectMgr::processPeerEnterStable(CSmartPtr<CSwitch>& sw)
{
    if (sw.isNotNull())
    {
        //上报交换机事件ENTER_STABLE
        CSwitchEventReportor::getInstance()->report(sw, EVENT_TYPE_SWITCH_ENTER_STABLE, EVENT_REASON_NONE);
    }
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_FireSmoke::UpdateEffects( void )
{
	if ( m_pEmberEmitter.IsValid() )
	{
		m_pEmberEmitter->SetSortOrigin( GetAbsOrigin() );
	}

	if ( m_pSmokeEmitter.IsValid() )
	{
		m_pSmokeEmitter->SetSortOrigin( GetAbsOrigin() );
	}

	if ( m_pFireOverlay != NULL )
	{
		m_pFireOverlay->m_vPos = GetAbsOrigin();
	}
}
示例#12
0
BOOL COfConnectMgr::needPowerOffCheck(CSmartPtr<CSwitch>& sw)
{
    if (sw.isNull() || (sw->getState() >= SW_STATE_POWER_OFF))
        return FALSE;

    CPortMap& ports = sw->getPorts();
    STL_FOR_LOOP(ports, it)
    {
        gn_port_t& port = it->second;
        if (PORT_STATE_UP == port.state)
        {
            //if (PORT_TYPE_EXTERNAL == port.type)
            //    return TRUE;
            if (PORT_TYPE_SWITCH == port.type)
                return TRUE;
        }
    }
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : flPerc - 
//-----------------------------------------------------------------------------
void C_MortarShell::AddRisingParticles( float flPerc )
{
	SimpleParticle *sParticle;

	Vector offset;
	float radius = m_flRadius * 0.25f * flPerc;

	float val = RemapValClamped( gpGlobals->curtime, m_flStarttime, m_flStarttime + m_flLifespan, 0.0f, 1.0f );

	float flCur = gpGlobals->frametime;

	// Anime ground effects
	while ( m_ParticleEvent.NextEvent( flCur ) )
	{
		offset.x = random->RandomFloat( -radius, radius );
		offset.y = random->RandomFloat( -radius, radius );
		offset.z = random->RandomFloat( -8.0f, 8.0f );

		offset += GetAbsOrigin();

		sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/spark" ), offset );
		
		if ( sParticle == NULL )
			return;

		sParticle->m_vecVelocity = Vector( Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( 32.0f, 256.0f ) * Bias( val, 0.25f ) );
		
		sParticle->m_uchStartSize	= random->RandomFloat( 4, 8 ) * flPerc;

		sParticle->m_flDieTime = random->RandomFloat( 0.5f, 1.0f );
		
		sParticle->m_flLifetime		= 0.0f;

		sParticle->m_flRoll			= Helper_RandomInt( 0, 360 );

		float alpha = 255 * flPerc;

		sParticle->m_flRollDelta	= Helper_RandomFloat( -8.0f * flPerc, 8.0f * flPerc );
		sParticle->m_uchColor[0]	= alpha;
		sParticle->m_uchColor[1]	= alpha;
		sParticle->m_uchColor[2]	= alpha;
		sParticle->m_uchStartAlpha	= alpha;
		sParticle->m_uchEndAlpha	= 0;
		sParticle->m_uchEndSize		= 0;
	}
}
示例#14
0
BOOL COfMsgTreeNode::checkMsg(CSmartPtr<CMsg>& msgPtr)
{
    if (msgPtr.isNull())
    {
        return FALSE;
    }

    //of消息类型检查
    UINT1* ofMsg = msgPtr->getData();
    struct ofp_header* header = (struct ofp_header*)ofMsg;
    if (header->type != getMsgType())
    {
        return FALSE;
    }

    return TRUE;
}
示例#15
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &data - 
//-----------------------------------------------------------------------------
void WheelDustCallback( const CEffectData &data )
{
	CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create( "dust" );
	pSimple->SetSortOrigin( data.m_vOrigin );
	pSimple->SetNearClip( 32, 64 );

	SimpleParticle	*pParticle;

	Vector	offset;

	//FIXME: Better sampling area
	offset = data.m_vOrigin + ( data.m_vNormal * data.m_flScale );
	
	//Find area ambient light color and use it to tint smoke
	Vector	worldLight = WorldGetLightForPoint( offset, true );

	//Throw puffs
	offset.Random( -(data.m_flScale*16.0f), data.m_flScale*16.0f );
	offset.z = 0.0f;
	offset += data.m_vOrigin + ( data.m_vNormal * data.m_flScale );

	pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof(SimpleParticle), g_Mat_DustPuff[0], offset );

	if ( pParticle != NULL )
	{			
		pParticle->m_flLifetime		= 0.0f;
		pParticle->m_flDieTime		= random->RandomFloat( 0.25f, 0.5f );
		
		pParticle->m_vecVelocity = RandomVector( -1.0f, 1.0f );
		VectorNormalize( pParticle->m_vecVelocity );
		pParticle->m_vecVelocity[2] += random->RandomFloat( 16.0f, 32.0f ) * (data.m_flScale*2.0f);

		int	color = random->RandomInt( 100, 150 );

		pParticle->m_uchColor[0] = 16 + ( worldLight[0] * (float) color );
		pParticle->m_uchColor[1] = 8 + ( worldLight[1] * (float) color );
		pParticle->m_uchColor[2] = ( worldLight[2] * (float) color );

		pParticle->m_uchStartAlpha	= random->RandomInt( 64.0f*data.m_flScale, 128.0f*data.m_flScale );
		pParticle->m_uchEndAlpha	= 0;
		pParticle->m_uchStartSize	= random->RandomInt( 16, 24 ) * data.m_flScale;
		pParticle->m_uchEndSize		= random->RandomInt( 32, 48 ) * data.m_flScale;
		pParticle->m_flRoll			= random->RandomInt( 0, 360 );
		pParticle->m_flRollDelta	= random->RandomFloat( -2.0f, 2.0f );
	}
}
示例#16
0
INT4 CMsgQueues::pushMsg(CSmartPtr<CMsgCommon>& msg)
{
    LOG_INFO_FMT("push oper[%d]msg[%s]key[%s] into queue of %s ...", 
        msg->getOperation(), msg->getPath().c_str(), msg->getKey().c_str(), 
        (NULL!=m_operator)?m_operator->toString():"producer");

#if defined(USING_LK_HASH_MAP)
    UINT4 index = m_queues.bucketIndex(msg->getKey());
    m_queues.bucketLock(index);
#endif

    CSmartPtr<CMsgQueue> queue = getQueue(msg->getKey());
    if (queue.isNull())
    {
        queue = createQueue(msg->getKey());
        if (queue.isNull())
        {
            LOG_WARN_FMT("%s[%p] createQueue for path[%s]key[%s] failed !", 
                (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str());
#if defined(USING_LK_HASH_MAP)
            m_queues.bucketUnlock(index);
#endif
            return BNC_ERR;
        }
    }

    LOG_INFO_FMT("%s[%p] before push, path[%s]key[%s] has msg count[%lu] ...", 
        (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str(), queue->size());
    push(queue, msg);
    LOG_INFO_FMT("%s[%p] after pushed and rearranged, path[%s]key[%s] has msg count[%lu] ...", 
        (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str(), queue->size());

#if defined(USING_LK_HASH_MAP)
    m_queues.bucketUnlock(index);
#endif

#if 0
    if ((NULL==m_operator)||
        !strcmp(m_operator->toString(),"CSwitchEventTester")||
        !strcmp(m_operator->toString(),"CLinkEventTester")||
        !strcmp(m_operator->toString(),"CPortEventTester"))
    {
        LOG_WARN_FMT("######%s[%p] after pushed and rearranged, path[%s]key[%s] has msg count[%lu] ...", 
            (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), msg->getKey().c_str(), queue->size());
        LOG_WARN_FMT("######%s[%p] after pushed msg, path[%s] has queues count[%lu] ...", 
            (NULL!=m_operator)?m_operator->toString():"producer", m_operator, m_path.c_str(), m_queues.size());
    }
#endif

    return BNC_OK;
}
示例#17
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_EnvStarfield::ClientThink( void )
{
	if ( !m_bOn || !m_flDensity ) 
		return;

	PMaterialHandle	hParticleMaterial = m_pEmitter->GetPMaterial( "effects/spark_noz" );

	// Find a start & end point for the particle
	// Start particles straight ahead of the client
	Vector vecViewOrigin = MainViewOrigin(engine->GetActiveSplitScreenPlayerSlot());

	// Determine the number of particles
	m_flNumParticles += 1.0 * (m_flDensity);
	int iNumParticles = floor(m_flNumParticles);
	m_flNumParticles -= iNumParticles;

	// Add particles
	for ( int i = 0; i < iNumParticles; i++ )
	{
		float flDiameter = cl_starfield_diameter.GetFloat();

		Vector vecStart = vecViewOrigin + (MainViewForward(engine->GetActiveSplitScreenPlayerSlot()) * cl_starfield_distance.GetFloat() );
		Vector vecEnd = vecViewOrigin + (MainViewRight(engine->GetActiveSplitScreenPlayerSlot()) * RandomFloat(-flDiameter,flDiameter)) + (MainViewUp(engine->GetActiveSplitScreenPlayerSlot()) * RandomFloat(-flDiameter,flDiameter));
		Vector vecDir = (vecEnd - vecStart);
		float flDistance = VectorNormalize( vecDir );
		float flTravelTime = 2.0;
		
		// Start a random amount along the path
		vecStart += vecDir * ( RandomFloat(0.1,0.3) * flDistance );

		TrailParticle *pParticle = (TrailParticle *) m_pEmitter->AddParticle( sizeof(TrailParticle), hParticleMaterial, vecStart );
		if ( pParticle )
		{
			pParticle->m_vecVelocity = vecDir * (flDistance / flTravelTime);
			pParticle->m_flDieTime = flTravelTime;
			pParticle->m_flLifetime = 0;
			pParticle->m_flWidth = RandomFloat( 1, 3 );
			pParticle->m_flLength = RandomFloat( 0.05, 0.4 );
			pParticle->m_color.r	= 255;
			pParticle->m_color.g	= 255;
			pParticle->m_color.b	= 255;
			pParticle->m_color.a	= 255;
		}
	}
}
示例#18
0
int main()
{
    //mq_unlink("/sensor");
    //mq_unlink("/actuator");

    CLogger().setStream(std::cout);

    Sensor      sen("/sensor", 0u, 0u);
    Actuator    act("/actuator", sizeof(int), 10u);

    sen.join();
    act.join();

    CSmartPtr<FOO> a;
    {
        CSmartPtr<FOO> b;
        {
            CSmartPtr<FOO> c(new FOO);
            a = c;
            b = a;
            c->foo();
            a->foo();
            b->foo();
        }
        a->foo();
        b->foo();
    }
    a->foo();

    return 0;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : flPerc - 
//-----------------------------------------------------------------------------
void C_MortarShell::AddExplodingParticles( float flPerc )
{
	SimpleParticle *sParticle;

	Vector offset;
	float radius = 48.0f * flPerc;

	float flCur = gpGlobals->frametime;

	// Anime ground effects
	while ( m_ParticleEvent.NextEvent( flCur ) )
	{
		offset.x = random->RandomFloat( -radius, radius );
		offset.y = random->RandomFloat( -radius, radius );
		offset.z = random->RandomFloat( -8.0f, 8.0f );

		offset += GetAbsOrigin();

		sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/spark" ), offset );
		
		if ( sParticle == NULL )
			return;

		sParticle->m_vecVelocity = RandomVector( -1.0f, 1.0f ) + Vector( 0, 0, 1 );
		sParticle->m_vecVelocity *= ( 750.0f * flPerc );
		
		sParticle->m_uchStartSize	= random->RandomFloat( 2, 4 ) * flPerc;

		sParticle->m_flDieTime = random->RandomFloat( 0.25f, 0.5f );
		
		sParticle->m_flLifetime		= 0.0f;

		sParticle->m_flRoll			= Helper_RandomInt( 0, 360 );

		float alpha = 255 * flPerc;

		sParticle->m_flRollDelta	= Helper_RandomFloat( -8.0f * flPerc, 8.0f * flPerc );
		sParticle->m_uchColor[0]	= alpha;
		sParticle->m_uchColor[1]	= alpha;
		sParticle->m_uchColor[2]	= alpha;
		sParticle->m_uchStartAlpha	= alpha;
		sParticle->m_uchEndAlpha	= 0;
		sParticle->m_uchEndSize		= 0;
	}
}
示例#20
0
文件: imapauth.cpp 项目: ConorOG/znc
void CIMAPSock::ReadLine(const CString& sLine) {
	if (!m_bSentLogin) {
		CString sUsername = m_spAuth->GetUsername();
		m_bSentLogin = true;

		const CString& sFormat = m_pIMAPMod->GetUserFormat();

		if (!sFormat.empty()) {
			if (sFormat.find('%') != CString::npos) {
				sUsername = sFormat.Replace_n("%", sUsername);
			} else {
				sUsername += sFormat;
			}
		}

		Write("AUTH LOGIN " + sUsername + " " + m_spAuth->GetPassword() + "\r\n");
	} else if (sLine.Left(5) == "AUTH ") {
		CUser* pUser = CZNC::Get().FindUser(m_spAuth->GetUsername());

		if (pUser && sLine.Equals("AUTH OK", false, 7)) {
			m_spAuth->AcceptLogin(*pUser);
			m_pIMAPMod->CacheLogin(CString(m_spAuth->GetUsername() + ":" + m_spAuth->GetPassword()).MD5()); // Use MD5 so passes don't sit in memory in plain text
			DEBUG("+++ Successful IMAP lookup");
		} else {
			m_spAuth->RefuseLogin("Invalid Password");
			DEBUG("--- FAILED IMAP lookup");
		}

		m_bSentReply = true;
		Close();
	}
}
示例#21
0
	CSmartPtr<T> InitSingleton( CSmartPtr<T> pEmitter )
	{
		if ( !pEmitter )
		{
			Error( "InitSingleton: pEmitter is NULL" );
		}
	
		pEmitter->GetBinding().SetDrawThruLeafSystem( false );				// Draw in DrawSingletons instead.
		pEmitter->SetSortOrigin( Vector( 0, 0, 0 ) );

		// Since we draw manually in DrawSingletons, we don't care about
		// the bbox, so don't waste cycles inserting it into the leaf system
		// when it's not going to draw through that anyway.
		// (TODO: SetDrawThruLeafSystem(false) should trigger this automatically
		// in CParticleMgr).
		pEmitter->GetBinding().SetBBox( Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
		return pEmitter;
	}
示例#22
0
文件: imapauth.cpp 项目: ConorOG/znc
	virtual EModRet OnLoginAttempt(CSmartPtr<CAuthBase> Auth) {
		CUser* pUser = CZNC::Get().FindUser(Auth->GetUsername());

		if (!pUser) { // @todo Will want to do some sort of && !m_bAllowCreate in the future
			Auth->RefuseLogin("Invalid User - Halting IMAP Lookup");
			return HALT;
		}

		if (pUser && m_Cache.HasItem(CString(Auth->GetUsername() + ":" + Auth->GetPassword()).MD5())) {
			DEBUG("+++ Found in cache");
			Auth->AcceptLogin(*pUser);
			return HALT;
		}

		CIMAPSock* pSock = new CIMAPSock(this, Auth);
		pSock->Connect(m_sServer, m_uPort, m_bSSL, 20);

		return HALT;
	}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_ObjectEMPGenerator::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );

	if ( updateType == DATA_UPDATE_CREATED )
	{
		m_pEmitter = CSimpleEmitter::Create( "C_ObjectEMPGenerator" );
		m_hParticleMaterial = m_pEmitter->GetPMaterial( "sprites/chargeball" );
	}
}
示例#24
0
INT4 CNatIcmpService::GetServiceType(CSmartPtr<CHost>& srcHost, CSmartPtr<CHost>& dstHost, UINT4 srcIp, UINT4 dstIp,  UINT2 srcPort, UINT2 dstPort, UINT2 proto )
{
	if ((((srcHost.isNotNull()&&(bnc::host::HOST_NORMAL == srcHost->getHostType()))
            &&(dstHost.isNull()||(bnc::host::HOST_EXTERNAL == dstHost->getHostType())))
          ||((srcHost.isNull()||(bnc::host::HOST_EXTERNAL == srcHost->getHostType()))
              &&(dstHost.isNotNull()&&(bnc::host::HOST_GATEWAY == dstHost->getHostType()))))
         &&(IPPROTO_ICMP == proto)&&(dstIp != 0xffffffff)&&(srcIp != 0xffffffff))
	{
		return BNC_OK;
	}
	return BNC_ERR;
}
示例#25
0
void CSwitchMgr::addSw(CSmartPtr<CSwitch>& sw)
{
    if (sw.isNull())
    {
        return;
    }
    m_oMutex.lock();
    m_switchList.push_back(sw);
    m_oMutex.unlock();
}
示例#26
0
void CSwitchMgr::addSwitchMap(INT4 sockfd, CSmartPtr<CSwitch>& sw)
{
    LOG_INFO_FMT("before add switch with sockfd[%d]ip[%x]port[%u], switch map size[%lu] ...", 
        sockfd, sw->getSwIp(), sw->getSwPort(), m_sws.size());

#if 0
    //m_mutex.lock();
    m_rwlock.wlock();
    m_sws.insert(CSwitchMap::value_type(sockfd, sw));
    //m_mutex.unlock();
    m_rwlock.unlock();
#else
    if (!m_sws.insert(sockfd, sw))
        LOG_WARN_FMT("add mapping sockfd[%d] to CSwitch failed !", sockfd);
#endif

    LOG_INFO_FMT("after add switch with sockfd[%d]ip[%x]port[%u], switch map size[%lu] ...", 
        sockfd, sw->getSwIp(), sw->getSwPort(), m_sws.size());
}
示例#27
0
bool MUSIKAPEDecoder::OpenMedia(const char *FileName)
{

	int nRetVal=0;
	CSmartPtr<wchar_t> wsFileName;
	wsFileName.Assign(GetUTF16FromANSI(FileName),TRUE);
	IAPEDecompress * pAPEDecompress = CreateIAPEDecompress(wsFileName, &nRetVal);
	if (pAPEDecompress != NULL)
	{
		m_ApeInfo.pAPEDecompress = pAPEDecompress;
		m_Info.bitrate = pAPEDecompress->GetInfo(APE_INFO_AVERAGE_BITRATE);
		m_Info.bits_per_sample = pAPEDecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE);
		m_Info.channels = pAPEDecompress->GetInfo(APE_INFO_CHANNELS);
		m_Info.frequency = pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE);
		m_Info.SampleCount = pAPEDecompress->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS);
		int bytesPerBlock = m_Info.channels * (m_Info.bits_per_sample >> 3);
		int decoder_buffer_size = bytesPerBlock * (int)((APEDecodeBufferSec * pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE)) + 0.5);
		m_Info.FileSize = pAPEDecompress->GetInfo(APE_INFO_APE_TOTAL_BYTES);
		return CreateBuffer(decoder_buffer_size);
	}
示例#28
0
//-----------------------------------------------------------------------------
// Purpose: Client-side think function for the entity
//-----------------------------------------------------------------------------
void C_Sparkler::ClientThink( void )
{
	// We must have a valid emitter
	if ( m_hEmitter == NULL )
		return;

	// We must be allowed to emit particles by the server
	if ( m_bEmit == false )
		return;

	SimpleParticle *pParticle;

	float curTime = gpGlobals->frametime;

	// Add as many particles as required this frame
	while ( m_tParticleTimer.NextEvent( curTime ) )
	{
		// Create the particle
		pParticle = m_hEmitter->AddSimpleParticle( m_hMaterial, GetAbsOrigin() );

		if ( pParticle == NULL )
			return;

		// Setup our size
		pParticle->m_uchStartSize = (unsigned char) m_flScale;
		pParticle->m_uchEndSize = 0;

		// Setup our roll
		pParticle->m_flRoll = random->RandomFloat( 0, 2*M_PI );
		pParticle->m_flRollDelta = random->RandomFloat( -DEG2RAD( 180 ), DEG2RAD( 180 ) );

		// Set our color
		pParticle->m_uchColor[0] = 255;
		pParticle->m_uchColor[1] = 255;
		pParticle->m_uchColor[2] = 255;

		// Setup our alpha values
		pParticle->m_uchStartAlpha = 255;
		pParticle->m_uchEndAlpha = 255;
		
		// Obtain a random direction
		Vector velocity = RandomVector( -1.0f, 1.0f );
		VectorNormalize( velocity );

		// Obtain a random speed
		float speed = random->RandomFloat( 4.0f, 8.0f ) * m_flScale;

		// Set our velocity
		pParticle->m_vecVelocity = velocity * speed;

		// Die in a short range of time
		pParticle->m_flDieTime = random->RandomFloat( 0.25f, 0.5f );
	}
}
示例#29
0
void COfPortStatusHandler::handle(CSmartPtr<CMsgQueue>& queue)
{
    LOG_DEBUG_FMT("%s recv new msg ..., queue size = %lu", toString().c_str(), queue->size());
    UINT1 version = 0;
    CSmartPtr<CMsg> msg;
    while (queue->try_pop(msg))
    {
        version = msg->getVersion();
        if (OFP13_VERSION == version)
        {
            handler13(msg);
        }
        else if (OFP10_VERSION == version)
        {
            handler10(msg);
        }

		
    }
}
示例#30
0
//-----------------------------------------------
//	readGeorges 
//
//-----------------------------------------------
void CSheet::readGeorges (const CSmartPtr<NLGEORGES::UForm> &form, const CSheetId &sheetId)
{
	// Load the form with given sheet id
	if (form)
	{
		if( !form->getRootNode().getValueByName(Alias, "Alias", NLGEORGES::UFormElm::NoEval) )
		{

		}
	}
}