コード例 #1
0
int PyHandle::Cmp( bp::object other )
{
	// The thing to which we compare is NULL
	PyObject *pPyObject = other.ptr();
	if( pPyObject == Py_None ) {
		return Get() != NULL;
	}

	// We are NULL
	if( Get() == NULL )
	{
		return pPyObject != NULL;
	}

	// Check if it is directly a pointer to an entity
#ifdef CLIENT_DLL
	if( PyObject_IsInstance(pPyObject, bp::object(_entities.attr("C_BaseEntity")).ptr()) )
#else
	if( PyObject_IsInstance(pPyObject, bp::object(_entities.attr("CBaseEntity")).ptr()) )
#endif // CLIENT_DLL
	{
		CBaseEntity *pSelf = Get();
		CBaseEntity *pOther = boost::python::extract< CBaseEntity * >(other);
		if( pOther == pSelf )
		{
			return 0;
		}
		else if( pOther->entindex() > pSelf->entindex() )
		{
			return 1;
		}
		else
		{
			return -1;
		}
	}

	try
	{
		// Must be a handle
		CBaseHandle *pHandle = bp::extract< CBaseHandle * >( other );
		if( pHandle )
		{
			if( pHandle->ToInt() == ToInt() )
				return 0;
			else if( pHandle->GetEntryIndex() > GetEntryIndex() )
				return 1;
			else
				return -1;
		}
	}
	catch( bp::error_already_set & )
	{
		// Not a handle, just clear error and return -1
		PyErr_Clear();	
	}

	return -1;
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Returns an index from the given BaseHandle instance.
//-----------------------------------------------------------------------------
bool IndexFromBaseHandle( CBaseHandle hBaseHandle, unsigned int& output )
{
    if (!hBaseHandle.IsValid() || !hBaseHandle.ToInt())
        return false;

    int iEntityIndex = hBaseHandle.GetEntryIndex();
    if (iEntityIndex == INVALID_ENTITY_INDEX)
        return false;

    output = iEntityIndex;
    return true;
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Returns an IntHandle from the given BaseHandle instance.
//-----------------------------------------------------------------------------
bool IntHandleFromBaseHandle( CBaseHandle hBaseHandle, unsigned int& output )
{
	if (!hBaseHandle.IsValid())
		return false;

	unsigned int iEntityHandle = hBaseHandle.ToInt();
	if (!iEntityHandle)
		return false;

	output = iEntityHandle;
	return true;
}
コード例 #4
0
cell_t CHalfLife2::EntityToBCompatRef(CBaseEntity *pEntity)
{
	if (pEntity == NULL)
	{
		return INVALID_EHANDLE_INDEX;
	}

	IServerUnknown *pUnknown = (IServerUnknown *)pEntity;
	CBaseHandle hndl = pUnknown->GetRefEHandle();

	if (hndl == INVALID_EHANDLE_INDEX)
	{
		return INVALID_EHANDLE_INDEX;
	}
	
	if (hndl.GetEntryIndex() >= MAX_EDICTS)
	{
		return (hndl.ToInt() | (1<<31));
	}
	else
	{
		return hndl.GetEntryIndex();
	}
}
コード例 #5
0
cell_t CHalfLife2::EntityToReference(CBaseEntity *pEntity)
{
	IServerUnknown *pUnknown = (IServerUnknown *)pEntity;
	CBaseHandle hndl = pUnknown->GetRefEHandle();
	return (hndl.ToInt() | (1<<31));
}
コード例 #6
0
int CStaticProp::DrawModel( int flags )
{
#ifndef SWDS
	VPROF_BUDGET( "CStaticProp::DrawModel", VPROF_BUDGETGROUP_STATICPROP_RENDERING );

	if( !r_drawstaticprops.GetBool() )
	{
		return 0;
	}

#ifdef _DEBUG
	if (r_DrawSpecificStaticProp.GetInt() >= 0)
	{
		if ( (m_EntHandle.ToInt() & (~STATICPROP_EHANDLE_MASK) ) != r_DrawSpecificStaticProp.GetInt())
			return 0;
	}
#endif

	if ((m_Alpha == 0) || (!m_pModel))
		return 0;

	if( r_colorstaticprops.GetBool() )
	{
		Vector color;
		RandomColorFromModeInstanceHandle( m_ModelInstance, color );
		VectorCopy( color.Base(), r_colormod );
	}

	modelrender->UseLightcache( &m_LightCacheHandle );

#ifdef _DEBUG
	studiohdr_t *pStudioHdr = modelinfo->GetStudiomodel( m_pModel );
	Assert( pStudioHdr );
	if( !( pStudioHdr->flags & STUDIOHDR_FLAGS_STATIC_PROP ) )
	{
		return 0;
	}
#endif

	flags |= STUDIO_STATIC_LIGHTING;
#if 0
	Vector mins;
	Vector maxs;
	VectorAdd( m_RenderBBoxMin, m_Origin, mins );
	VectorAdd( m_RenderBBoxMax, m_Origin, maxs );
#endif	
	int drawn = modelrender->DrawModel( 
		flags, 
		this,
		m_ModelInstance,
		-1,		// no entity index
		m_pModel,
		m_Origin,
		m_Angles,
		0,		// sequence
		m_Skin,	// skin
		0,		// body
		0,		// hitboxset
#if 1
		NULL, NULL,
#else
		&mins, &maxs,
#endif
		&m_ModelToWorld
		);

	modelrender->UseLightcache();

	if ( vcollide_wireframe.GetBool() )
	{
		if ( m_pModel && m_nSolidType == SOLID_VPHYSICS )
		{
			// This works because VCollideForModel only uses modelindex for mod_brush
			// and props are always mod_Studio.
			vcollide_t * pCollide = CM_VCollideForModel( -1, m_pModel ); 
			if ( pCollide && pCollide->solidCount == 1 )
			{
				static color32 debugColor = {0,255,255,0};
				DebugDrawPhysCollide( pCollide->solids[0], NULL, m_ModelToWorld, debugColor );
			}
		}
	}

	return drawn;
#else
	return 0;
#endif
}
コード例 #7
0
bool CStaticPropMgr::IsStaticProp( CBaseHandle handle ) const
{
	return (handle.ToInt() & STATICPROP_EHANDLE_MASK) != 0;
}