本文整理汇总了C++中ASSERTSZ函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERTSZ函数的具体用法?C++ ASSERTSZ怎么用?C++ ASSERTSZ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERTSZ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AngularMove
/*
=============
AngularMove
calculate pev->velocity and pev->nextthink to reach vecDest from
pev->origin traveling at flSpeed
Just like LinearMove, but rotational.
===============
*/
void CBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed )
{
ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!");
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined");
m_vecFinalAngle = vecDestAngle;
// Already there?
if (vecDestAngle == pev->angles)
{
AngularMoveDone();
return;
}
// set destdelta to the vector needed to move
Vector vecDestDelta = vecDestAngle - pev->angles;
// divide by speed to get time to reach dest
float flTravelTime = vecDestDelta.Length() / flSpeed;
if( flTravelTime < 0.1f )
{
pev->avelocity = g_vecZero;
pev->nextthink = pev->ltime + 0.1f;
return;
}
// set nextthink to trigger a call to AngularMoveDone when dest is reached
pev->nextthink = pev->ltime + flTravelTime;
SetThink( &CBaseToggle::AngularMoveDone );
// scale the destdelta vector by the time spent traveling to get velocity
pev->avelocity = vecDestDelta / flTravelTime;
}
示例2: ASSERTSZ
//-----------------------------------------------------------------------------
// Purpose: Calculate m_vecVelocity and m_flNextThink to reach vecDest from
// GetLocalOrigin() traveling at flSpeed. Just like LinearMove, but rotational.
// Input : vecDestAngle -
// flSpeed -
//-----------------------------------------------------------------------------
void CBaseToggle::AngularMove( const QAngle &vecDestAngle, float flSpeed )
{
ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!");
m_vecFinalAngle = vecDestAngle;
m_movementType = MOVE_TOGGLE_ANGULAR;
// Already there?
if (vecDestAngle == GetLocalAngles())
{
MoveDone();
return;
}
// set destdelta to the vector needed to move
QAngle vecDestDelta = vecDestAngle - GetLocalAngles();
// divide by speed to get time to reach dest
float flTravelTime = vecDestDelta.Length() / flSpeed;
const float MinTravelTime = 0.01f;
if ( flTravelTime < MinTravelTime )
{
// If we only travel for a short time, we can fail WillSimulateGamePhysics()
flTravelTime = MinTravelTime;
flSpeed = vecDestDelta.Length() / flTravelTime;
}
// set m_flNextThink to trigger a call to AngularMoveDone when dest is reached
SetMoveDoneTime( flTravelTime );
// scale the destdelta vector by the time spent traveling to get velocity
SetLocalAngularVelocity( vecDestDelta * (1.0 / flTravelTime) );
}
示例3: PostSpawn
//LRC
void CBaseDoor :: PostSpawn( void )
{
if (m_pMoveWith)
m_vecPosition1 = pev->origin - m_pMoveWith->pev->origin;
else
m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs( pev->movedir.x * (pev->size.x-2) ) + fabs( pev->movedir.y * (pev->size.y-2) ) + fabs( pev->movedir.z * (pev->size.z-2) ) - m_flLip));
ASSERTSZ(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal");
if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) )
{ // swap pos1 and pos2, put door at pos2
if (m_pMoveWith)
{
m_vecSpawnOffset = m_vecSpawnOffset + (m_vecPosition2 + m_pMoveWith->pev->origin) - pev->origin;
UTIL_AssignOrigin(this, m_vecPosition2 + m_pMoveWith->pev->origin);
}
else
{
m_vecSpawnOffset = m_vecSpawnOffset + m_vecPosition2 - pev->origin;
UTIL_AssignOrigin(this, m_vecPosition2);
}
Vector vecTemp = m_vecPosition2;
m_vecPosition2 = m_vecPosition1;
m_vecPosition1 = vecTemp;
// ALERT(at_console, "func_door postspawn: origin %f %f %f\n", pev->origin.x, pev->origin.y, pev->origin.z);
}
}
示例4: SetMovedir
void CMomentaryDoor::Spawn( void )
{
SetMovedir (pev);
pev->solid = SOLID_BSP;
pev->movetype = MOVETYPE_PUSH;
UTIL_SetOrigin(pev, pev->origin);
SET_MODEL( ENT(pev), STRING(pev->model) );
if (pev->speed == 0)
pev->speed = 100;
if (pev->dmg == 0)
pev->dmg = 2;
m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs( pev->movedir.x * (pev->size.x-2) ) + fabs( pev->movedir.y * (pev->size.y-2) ) + fabs( pev->movedir.z * (pev->size.z-2) ) - m_flLip));
ASSERTSZ(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal");
if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) )
{ // swap pos1 and pos2, put door at pos2
UTIL_SetOrigin(pev, m_vecPosition2);
m_vecPosition2 = m_vecPosition1;
m_vecPosition1 = pev->origin;
}
SetTouch( NULL );
Precache();
}
示例5: InitTrigger
//-----------------------------------------------------------------------------
// Purpose: Called when spawning, after keyvalues have been handled.
//-----------------------------------------------------------------------------
void CASW_Jump_Trigger::Spawn( void )
{
BaseClass::Spawn();
InitTrigger();
if ( m_flWait == 0 )
{
m_flWait = 0.2;
}
ASSERTSZ( m_iHealth == 0, "trigger_asw_jump with health" );
// find the target this use area is attached to
m_iNumJumpDests = 0;
CBaseEntity *pEnt = gEntList.FindEntityByName( NULL, m_JumpDestName, NULL );
while ( pEnt )
{
m_vecJumpDestination[m_iNumJumpDests] = pEnt->GetAbsOrigin();
m_iNumJumpDests++;
pEnt = gEntList.FindEntityByName(pEnt, m_JumpDestName, NULL);
}
if ( m_iNumJumpDests > 0 || m_bForceJump )
{
SetTouch( &CASW_Jump_Trigger::VolumeTouch );
}
else
{
Msg("Error: trigger_asw_jump has no valid destinations.\n");
}
//Assert(!m_hUseTarget);
}
示例6: LinearMove
/*
=============
LinearMove
calculate pev->velocity and pev->nextthink to reach vecDest from
pev->origin traveling at flSpeed
===============
*/
void CBaseToggle :: LinearMove( Vector vecDest, float flSpeed )
{
ASSERTSZ(flSpeed != 0, "LinearMove: no speed is defined!");
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined");
m_vecFinalDest = vecDest;
// Already there?
if (vecDest == pev->origin)
{
LinearMoveDone();
return;
}
// set destdelta to the vector needed to move
Vector vecDestDelta = vecDest - pev->origin;
// divide vector length by speed to get time to reach dest
float flTravelTime = vecDestDelta.Length() / flSpeed;
// set nextthink to trigger a call to LinearMoveDone when dest is reached
pev->nextthink = pev->ltime + flTravelTime;
SetThink( &CBaseToggle::LinearMoveDone );
// scale the destdelta vector by the time spent traveling to get velocity
pev->velocity = vecDestDelta / flTravelTime;
}
示例7: Precache
void CRotButton::Spawn( void )
{
Precache();
// set the axis of rotation
AxisDir( pev );
// check for clockwise rotation
if( FBitSet( pev->spawnflags, SF_ROTBUTTON_ROTATE_BACKWARDS ))
pev->movedir = pev->movedir * -1;
pev->movetype = MOVETYPE_PUSH;
if( FBitSet( pev->spawnflags, SF_ROTBUTTON_PASSABLE ))
pev->solid = SOLID_NOT;
else pev->solid = SOLID_BSP;
// shared code use this flag as BUTTON_DONTMOVE so we need to clear it here
ClearBits( pev->spawnflags, SF_ROTBUTTON_PASSABLE );
ClearBits( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF );
ClearBits( pev->spawnflags, SF_BUTTON_DAMAGED_AT_LASER );
SET_MODEL( edict(), GetModel() );
if( pev->speed == 0 )
pev->speed = 40;
if( m_flWait == 0 )
m_flWait = 1;
if( pev->health > 0 )
{
pev->takedamage = DAMAGE_YES;
}
m_iState = STATE_OFF;
m_vecAngle1 = GetLocalAngles();
m_vecAngle2 = GetLocalAngles() + pev->movedir * m_flMoveDistance;
ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal" );
m_fStayPushed = (m_flWait == -1) ? TRUE : FALSE;
m_fRotating = TRUE;
// if the button is flagged for USE button activation only, take away it's touch function and add a use function
if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ))
{
SetTouch( NULL );
SetUse( &CBaseButton::ButtonUse );
}
else
{
// touchable button
SetTouch( &CBaseButton::ButtonTouch );
}
UTIL_SetOrigin( this, GetLocalOrigin( ));
m_pUserData = WorldPhysic->CreateKinematicBodyFromEntity( this );
}
示例8: GetLocalAngles
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CRotDoor::Spawn( void )
{
BaseClass::Spawn();
// set the axis of rotation
CBaseToggle::AxisDir();
// check for clockwise rotation
if ( HasSpawnFlags(SF_DOOR_ROTATE_BACKWARDS) )
m_vecMoveAng = m_vecMoveAng * -1;
//m_flWait = 2; who the hell did this? (sjb)
m_vecAngle1 = GetLocalAngles();
m_vecAngle2 = GetLocalAngles() + m_vecMoveAng * m_flMoveDistance;
ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal\n");
// Starting open allows a func_door to be lighted in the closed position but
// spawn in the open position
//
// SF_DOOR_START_OPEN_OBSOLETE is an old broken way of spawning open that has
// been deprecated.
if ( HasSpawnFlags(SF_DOOR_START_OPEN_OBSOLETE) )
{
// swap pos1 and pos2, put door at pos2, invert movement direction
QAngle vecNewAngles = m_vecAngle2;
m_vecAngle2 = m_vecAngle1;
m_vecAngle1 = vecNewAngles;
m_vecMoveAng = -m_vecMoveAng;
// We've already had our physics setup in BaseClass::Spawn, so teleport to our
// current position. If we don't do this, our vphysics shadow will not update.
Teleport( NULL, &m_vecAngle1, NULL );
m_toggle_state = TS_AT_BOTTOM;
}
else if ( m_eSpawnPosition == FUNC_DOOR_SPAWN_OPEN )
{
// We've already had our physics setup in BaseClass::Spawn, so teleport to our
// current position. If we don't do this, our vphysics shadow will not update.
Teleport( NULL, &m_vecAngle2, NULL );
m_toggle_state = TS_AT_TOP;
}
else
{
m_toggle_state = TS_AT_BOTTOM;
}
#ifdef HL1_DLL
SetSolid( SOLID_VPHYSICS );
#endif
// Slam the object back to solid - if we really want it to be solid.
if ( m_bSolidBsp )
{
SetSolid( SOLID_BSP );
}
}
示例9: ButtonSound
void CRotButton::Spawn( void )
{
char *pszSound;
//----------------------------------------------------
//determine sounds for buttons
//a sound of 0 should not make a sound
//----------------------------------------------------
pszSound = ButtonSound( m_sounds );
PRECACHE_SOUND(pszSound);
pev->noise = ALLOC_STRING(pszSound);
// set the axis of rotation
CBaseToggle::AxisDir( pev );
// check for clockwise rotation
if ( FBitSet (pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS) )
pev->movedir = pev->movedir * -1;
pev->movetype = MOVETYPE_PUSH;
if ( pev->spawnflags & SF_ROTBUTTON_NOTSOLID )
pev->solid = SOLID_NOT;
else
pev->solid = SOLID_BSP;
SET_MODEL(ENT(pev), STRING(pev->model));
if (pev->speed == 0)
pev->speed = 40;
if (m_flWait == 0)
m_flWait = 1;
if (pev->health > 0)
{
pev->takedamage = DAMAGE_YES;
}
m_toggle_state = TS_AT_BOTTOM;
m_vecAngle1 = pev->angles;
m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance;
ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal");
m_fStayPushed = (m_flWait == -1 ? TRUE : FALSE);
m_fRotating = TRUE;
// if the button is flagged for USE button activation only, take away it's touch function and add a use function
if ( !FBitSet ( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) )
{
SetTouch ( NULL );
SetUse ( &CBaseButton::ButtonUse );
}
else // touchable button
SetTouch( &CBaseButton::ButtonTouch );
//SetTouch( ButtonTouch );
}
示例10: Precache
void CBaseDoor::Spawn( )
{
Precache();
SetMovedir (pev);
if ( pev->skin == 0 )
{//normal door
if ( FBitSet (pev->spawnflags, SF_DOOR_PASSABLE) )
pev->solid = SOLID_NOT;
else
pev->solid = SOLID_BSP;
}
else
{// special contents
pev->solid = SOLID_NOT;
SetBits( pev->spawnflags, SF_DOOR_SILENT ); // water is silent for now
}
pev->movetype = MOVETYPE_PUSH;
UTIL_SetOrigin(pev, pev->origin);
SET_MODEL( ENT(pev), STRING(pev->model) );
// added by jason
if( !stricmp( STRING( pev->classname ), "func_water" ) )
{
pev->skin = CONTENTS_WATER;
pev->rendermode = kRenderTransAlpha;
}
if (pev->speed == 0)
pev->speed = 100;
m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs( pev->movedir.x * (pev->size.x-2) ) + fabs( pev->movedir.y * (pev->size.y-2) ) + fabs( pev->movedir.z * (pev->size.z-2) ) - m_flLip));
ASSERTSZ(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal");
if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) )
{ // swap pos1 and pos2, put door at pos2
UTIL_SetOrigin(pev, m_vecPosition2);
m_vecPosition2 = m_vecPosition1;
m_vecPosition1 = pev->origin;
}
m_toggle_state = TS_AT_BOTTOM;
// if the door is flagged for USE button activation only, use NULL touch function
if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) )
{
SetTouch ( NULL );
}
else // touchable button
SetTouch( DoorTouch );
}
示例11: Precache
void CRotDoor::Spawn( void )
{
Precache();
// set the axis of rotation
CBaseToggle::AxisDir( pev );
// check for clockwise rotation
if ( FBitSet (pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS) )
pev->movedir = pev->movedir * -1;
//m_flWait = 2; who the hell did this? (sjb)
m_vecAngle1 = pev->angles;
m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance;
ASSERTSZ(m_vecAngle1 != m_vecAngle2, "rotating door start/end positions are equal");
if ( FBitSet (pev->spawnflags, SF_DOOR_PASSABLE) )
pev->solid = SOLID_NOT;
else
pev->solid = SOLID_BSP;
pev->movetype = MOVETYPE_PUSH;
UTIL_SetOrigin(pev, pev->origin);
SET_MODEL(ENT(pev), STRING(pev->model) );
if (pev->speed == 0)
pev->speed = 100;
// DOOR_START_OPEN is to allow an entity to be lighted in the closed position
// but spawn in the open position
if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) )
{ // swap pos1 and pos2, put door at pos2, invert movement direction
pev->angles = m_vecAngle2;
Vector vecSav = m_vecAngle1;
m_vecAngle2 = m_vecAngle1;
m_vecAngle1 = vecSav;
pev->movedir = pev->movedir * -1;
}
m_toggle_state = TS_AT_BOTTOM;
/*
if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) )
{
SetTouch ( NULL );
}
else // touchable button
*/
//sys test
SetTouch( DoorTouch );
}
示例12: Precache
void CBaseDoor::Spawn()
{
Precache();
SetMovedir( this );
if( GetSkin() == 0 )
{//normal door
if( GetSpawnFlags().Any( SF_DOOR_PASSABLE ) )
SetSolidType( SOLID_NOT );
else
SetSolidType( SOLID_BSP );
}
else
{// special contents
SetSolidType( SOLID_NOT );
GetSpawnFlags().AddFlags( SF_DOOR_SILENT ); // water is silent for now
}
SetMoveType( MOVETYPE_PUSH );
SetAbsOrigin( GetAbsOrigin() );
SetModel( GetModelName() );
if( GetSpeed() == 0 )
SetSpeed( 100 );
m_vecPosition1 = GetAbsOrigin();
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + ( GetMoveDir() * ( fabs( GetMoveDir().x * ( GetBounds().x - 2 ) ) + fabs( GetMoveDir().y * ( GetBounds().y - 2 ) ) + fabs( GetMoveDir().z * ( GetBounds().z - 2 ) ) - m_flLip ) );
ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" );
if( GetSpawnFlags().Any( SF_DOOR_START_OPEN ) )
{ // swap pos1 and pos2, put door at pos2
SetAbsOrigin( m_vecPosition2 );
m_vecPosition2 = m_vecPosition1;
m_vecPosition1 = GetAbsOrigin();
}
m_toggle_state = TS_AT_BOTTOM;
// if the door is flagged for USE button activation only, use NULL touch function
if( GetSpawnFlags().Any( SF_DOOR_USE_ONLY ) )
{
SetTouch( NULL );
}
else // touchable button
SetTouch( &CBaseDoor::DoorTouch );
}
示例13: SetMovedir
void CMomentaryDoor::Spawn( void )
{
SetMovedir (pev);
pev->solid = SOLID_BSP;
pev->movetype = MOVETYPE_PUSH;
UTIL_SetOrigin(this, pev->origin);
SET_MODEL( ENT(pev), STRING(pev->model) );
// if (pev->speed == 0)
// pev->speed = 100;
if (pev->dmg == 0)
pev->dmg = 2;
m_iState = STATE_OFF;
m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (fabs( pev->movedir.x * (pev->size.x-2) ) + fabs( pev->movedir.y * (pev->size.y-2) ) + fabs( pev->movedir.z * (pev->size.z-2) ) - m_flLip));
ASSERTSZ(m_vecPosition1 != m_vecPosition2, "door start/end positions are equal");
//LRC: FIXME, move to PostSpawn
if ( FBitSet (pev->spawnflags, SF_DOOR_START_OPEN) )
{ // swap pos1 and pos2, put door at pos2
UTIL_AssignOrigin(this, m_vecPosition2);
Vector vecTemp = m_vecPosition2;
m_vecPosition2 = m_vecPosition1;
m_vecPosition1 = vecTemp;
}
if (m_pMoveWith)
{
m_vecPosition1 = m_vecPosition1 - m_pMoveWith->pev->origin;
m_vecPosition2 = m_vecPosition2 - m_pMoveWith->pev->origin;
}
Precache();
SetTouch( NULL );
}
示例14: AngularMove
/*
=============
AngularMove
calculate pev->velocity and pev->nextthink to reach vecDest from
pev->origin traveling at flSpeed
Just like LinearMove, but rotational.
===============
*/
void CBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed )
{
ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!");
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined");
m_vecFinalAngle = vecDestAngle;
m_flAngularMoveSpeed = flSpeed;
// if ((m_pMoveWith || m_pChildMoveWith))// && !bNow)
// {
// ALERT(at_console,"Setting AngularMoveNow to happen after %f\n",gpGlobals->time);
SetThink(&CBaseToggle :: AngularMoveNow );
UTIL_DesiredThink( this );
// ExternalThink( 0.01 );
// pev->nextthink = pev->ltime + 0.01;
// }
// else
// {
// AngularMoveNow(); // starring Martin Sheen and Marlon Brando
// }
}
示例15: LinearMove
void CBaseToggle :: LinearMove( Vector vecInput, float flSpeed, float flAccel, float flDecel )//, BOOL bNow ) // AJH Call this to use acceleration
{
// ALERT(at_console, "LMove %s: %f %f %f, speed %f, accel %f \n", STRING(pev->targetname), vecInput.x, vecInput.y, vecInput.z, flSpeed, flAccel);
ASSERTSZ(flSpeed != 0, "LinearMove: no speed is defined!");
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined");
m_flLinearMoveSpeed = flSpeed;
m_flLinearAccel = flAccel;
m_flLinearDecel = flDecel;
m_flCurrentTime = 0;
if(m_flLinearAccel>0){
m_flAccelTime = m_flLinearMoveSpeed/m_flLinearAccel;
}else{
m_flLinearAccel=-1;
m_flAccelTime=0;
}
if(m_flLinearDecel>0){
m_flDecelTime = m_flLinearMoveSpeed/m_flLinearDecel;
}else{
m_flLinearDecel=-1;
m_flDecelTime=0;
}
m_vecFinalDest = vecInput;
// if ((m_pMoveWith || m_pChildMoveWith))// && !bNow)
// {
// ALERT(at_console,"Setting LinearMoveNow to happen after %f\n",gpGlobals->time);
SetThink(&CBaseToggle :: LinearMoveNow );
UTIL_DesiredThink( this );
//pev->nextthink = pev->ltime + 0.01;
// }
// else
// {
// LinearMoveNow(); // starring Martin Sheen and Marlon Brando
// }
}