llvm::Value *CodeGen::CallMulWithOverflow(llvm::Value *left, llvm::Value *right, llvm::Value *&overflow_bit) { PELOTON_ASSERT(left->getType() == right->getType()); llvm::Function *mul_func = llvm::Intrinsic::getDeclaration( &GetModule(), llvm::Intrinsic::smul_with_overflow, left->getType()); // Perform the multiplication llvm::Value *mul_result = CallFunc(mul_func, {left, right}); // Pull out the overflow bit from the resulting aggregate/struct overflow_bit = GetBuilder().CreateExtractValue(mul_result, 1); // Pull out the actual result of the subtraction return GetBuilder().CreateExtractValue(mul_result, 0); }
//----------------------------------------------------------------------------- // Purpose: Player has waved his crosshair over this entity. Display appropriate hints. //----------------------------------------------------------------------------- void C_BaseObject::DisplayHintTo( C_BasePlayer *pPlayer ) { bool bHintPlayed = false; C_TFPlayer *pTFPlayer = ToTFPlayer(pPlayer); if ( InSameTeam( pPlayer ) ) { // We're looking at a friendly object. if ( HasSapper() ) { bHintPlayed = pPlayer->HintMessage( HINT_OBJECT_HAS_SAPPER, true, true ); } if ( pTFPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) ) { // I'm an engineer. // If I'm looking at a constructing object, let me know I can help build it (but not // if I built it myself, since I've already got that hint from the wrench). if ( !bHintPlayed && IsBuilding() && GetBuilder() != pTFPlayer ) { bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_USE_WRENCH_ONOTHER, false, true ); } // If it's damaged, I can repair it if ( !bHintPlayed && !IsBuilding() && GetHealth() < GetMaxHealth() ) { bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_REPAIR_OBJECT, false, true ); } } } }
//----------------------------------------------------------------------------- // Receive a teleporting player //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterReceive( CTFPlayer *pPlayer, float flDelay ) { if ( !pPlayer ) return; SetTeleportingPlayer( pPlayer ); Vector origin = GetAbsOrigin(); CPVSFilter filter( origin ); int iTeam = pPlayer->GetTeamNumber(); if ( pPlayer->m_Shared.InCond( TF_COND_DISGUISED ) ) { iTeam = pPlayer->m_Shared.GetDisguiseTeam(); } const char *pszEffectName = ConstructTeamParticle( "teleportedin_%s", iTeam ); TE_TFParticleEffect( filter, 0.0, pszEffectName, origin, vec3_angle ); EmitSound( "Building_Teleporter.Receive" ); SetState( TELEPORTER_STATE_RECEIVING ); m_flMyNextThink = gpGlobals->curtime + BUILD_TELEPORTER_FADEOUT_TIME; if ( pPlayer != GetBuilder() ) m_iTimesUsed++; }
CObjectTeleporter* CObjectTeleporter::FindMatch( void ) { int iObjType = GetType(); int iOppositeType = ( iObjType == OBJ_TELEPORTER_ENTRANCE ) ? OBJ_TELEPORTER_EXIT : OBJ_TELEPORTER_ENTRANCE; CObjectTeleporter *pMatch = NULL; CTFPlayer *pBuilder = GetBuilder(); Assert( pBuilder ); if ( !pBuilder ) { return NULL; } int i; int iNumObjects = pBuilder->GetObjectCount(); for ( i=0;i<iNumObjects;i++ ) { CBaseObject *pObj = pBuilder->GetObject(i); if ( pObj && pObj->GetType() == iOppositeType && !pObj->IsDisabled() ) { pMatch = ( CObjectTeleporter * )pObj; break; } } return pMatch; }
xercesc::DOMDocument* CDoc::LoadFromString(const tstring& sXml) { xercesc::DOMBuilder* pBuilder = GetBuilder(); m_bBuilder = true; InternalErrorHandler oErrorHandler; pBuilder->setErrorHandler(&oErrorHandler); static const char gMemBufId[] = "Processing"; xercesc::MemBufInputSource* memBufIS = new xercesc::MemBufInputSource( (const XMLByte*)(sXml.c_str()), sXml.length() * sizeof(TCHAR), gMemBufId, false ); xercesc::Wrapper4InputSource source(memBufIS); xercesc::DOMDocument* pDoc = pBuilder->parse(source); //delete memBufIS; pBuilder->setErrorHandler(NULL); oErrorHandler.ReportErrors(); if (pDoc == NULL) CXmlException(1, _T("Could not load xml string")); return pDoc; }
llvm::Value *CodeGen::CallSubWithOverflow(llvm::Value *left, llvm::Value *right, llvm::Value *&overflow_bit) { PELOTON_ASSERT(left->getType() == right->getType()); // Get the intrinsic that does the addition with overflow checking llvm::Function *sub_func = llvm::Intrinsic::getDeclaration( &GetModule(), llvm::Intrinsic::ssub_with_overflow, left->getType()); // Perform the subtraction llvm::Value *sub_result = CallFunc(sub_func, {left, right}); // Pull out the overflow bit from the resulting aggregate/struct overflow_bit = GetBuilder().CreateExtractValue(sub_result, 1); // Pull out the actual result of the subtraction return GetBuilder().CreateExtractValue(sub_result, 0); }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterTouch( CBaseEntity *pOther ) { if ( IsDisabled() ) { return; } // if it's not a player, ignore if ( !pOther->IsPlayer() ) return; CTFPlayer *pPlayer = ToTFPlayer( pOther ); CTFPlayer *pBuilder = GetBuilder(); Assert( pBuilder ); if ( !pBuilder ) { return; } // if its not a teammate of the builder, notify the builder if ( pBuilder->GetTeamNumber() != pOther->GetTeamNumber() ) { // Don't teleport enemies return; } // is this an entrance and do we have an exit? if ( GetType() == OBJ_TELEPORTER_ENTRANCE ) { if ( ( m_iState == TELEPORTER_STATE_READY ) ) { // are we able to teleport? if ( pPlayer->HasTheFlag() ) { // If they have the flag, print a warning that you can't tele with the flag CSingleUserRecipientFilter filter( pPlayer ); TFGameRules()->SendHudNotification( filter, HUD_NOTIFY_NO_TELE_WITH_FLAG ); return; } // get the velocity of the player touching the teleporter if ( pPlayer->GetAbsVelocity().Length() < 5.0 ) { CObjectTeleporter *pDest = GetMatchingTeleporter(); if ( pDest ) { TeleporterSend( pPlayer ); } } } } }
xercesc::DOMDocument* CDoc::Load(const tstring& sURI) { xercesc::DOMBuilder* pBuilder = GetBuilder(); m_bBuilder = true; InternalErrorHandler oErrorHandler; pBuilder->setErrorHandler(&oErrorHandler); xercesc::DOMDocument* pDoc = pBuilder->parseURI(X(sURI)); pBuilder->setErrorHandler(NULL); oErrorHandler.ReportErrors(); if (pDoc == NULL) CXmlException(1, tstring(_T("Could not load ")) + sURI); return pDoc; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CObjectSentrygun::OnGoActive( void ) { CTFPlayer *pBuilder = GetBuilder(); Assert( pBuilder ); if ( !pBuilder ) return; SetModel( SENTRY_MODEL_LEVEL_1 ); m_iState.Set( SENTRY_STATE_SEARCHING ); // Orient it QAngle angles = GetAbsAngles(); m_vecCurAngles.y = UTIL_AngleMod( angles.y ); m_iRightBound = UTIL_AngleMod( (int)angles.y - 50 ); m_iLeftBound = UTIL_AngleMod( (int)angles.y + 50 ); if ( m_iRightBound > m_iLeftBound ) { m_iRightBound = m_iLeftBound; m_iLeftBound = UTIL_AngleMod( (int)angles.y - 50); } // Start it rotating m_vecGoalAngles.y = m_iRightBound; m_vecGoalAngles.x = m_vecCurAngles.x = 0; m_bTurningRight = true; EmitSound( "Building_Sentrygun.Built" ); // if our eye pos is underwater, we're waterlevel 3, else 0 bool bUnderwater = ( UTIL_PointContents( EyePosition() ) & MASK_WATER ) ? true : false; SetWaterLevel( ( bUnderwater ) ? 3 : 0 ); m_iAmmoShells = m_iMaxAmmoShells; // Init attachments for level 1 sentry gun m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE] = LookupAttachment( "muzzle" ); m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE_ALT] = 0; m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_L] = 0; m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_R] = 0; BaseClass::OnGoActive(); }
void CodeGen::ThrowIfOverflow(llvm::Value *overflow) const { PELOTON_ASSERT(overflow->getType() == BoolType()); // Get the overflow basic block for the currently generating function auto *func = code_context_.GetCurrentFunction(); auto *overflow_bb = func->GetOverflowBB(); // Construct a new block that we jump if there *isn't* an overflow llvm::BasicBlock *no_overflow_bb = llvm::BasicBlock::Create(GetContext(), "cont", func->GetFunction()); // Create a branch that goes to the overflow BB if an overflow exists auto &builder = GetBuilder(); builder.CreateCondBr(overflow, overflow_bb, no_overflow_bb); // Start insertion in the block builder.SetInsertPoint(no_overflow_bb); }
void CodeGen::ThrowIfDivideByZero(llvm::Value *divide_by_zero) const { PELOTON_ASSERT(divide_by_zero->getType() == BoolType()); // Get the divide-by-zero basic block for the currently generating function auto *func = code_context_.GetCurrentFunction(); auto *div0_bb = func->GetDivideByZeroBB(); // Construct a new block that we jump if there *isn't* a divide-by-zero llvm::BasicBlock *no_div0_bb = llvm::BasicBlock::Create(GetContext(), "cont", func->GetFunction()); // Create a branch that goes to the divide-by-zero BB if an error exists auto &builder = GetBuilder(); builder.CreateCondBr(divide_by_zero, div0_bb, no_div0_bb); // Start insertion in the block builder.SetInsertPoint(no_div0_bb); }
// ----------------------------------------------------------------------------- /// Inserts into destWindow's gadgets. bool TBarDescr::Create(TGadgetWindow& destWindow) { // Build toolbar from resource and from descriptor string if (BarRes && BarRes->IsOK()) { if(!Gadgets->Size()) CreateGadgets(Gadgets, *GetBuilder(), BarRes); int numRows = BarRes->GetBitmap().Height()/BarRes->GetHeight(); TCelArray* cellArray = new TCelArray(TSize(BarRes->GetWidth(), BarRes->GetHeight()), 0, BarRes->GetCount(), 5, numRows); cellArray->RemoveAll(); destWindow.SetCelArray(cellArray); for (int i=0,j=0; i < (int)Gadgets->Size(); i++){ destWindow.Insert(*(*Gadgets)[i]->Gadget); if((*Gadgets)[i]->UseGlyph) cellArray->Add(*CelArray, j++); } return true; } return false; }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::OnGoActive( void ) { CTFPlayer *pBuilder = GetBuilder(); Assert( pBuilder ); if ( !pBuilder ) return; SetModel( TELEPORTER_MODEL_LIGHT ); SetActivity( ACT_OBJ_IDLE ); SetContextThink( &CObjectTeleporter::TeleporterThink, gpGlobals->curtime + 0.1, TELEPORTER_THINK_CONTEXT ); SetTouch( &CObjectTeleporter::TeleporterTouch ); SetState( TELEPORTER_STATE_IDLE ); BaseClass::OnGoActive(); SetPlaybackRate( 0.0f ); m_flLastStateChangeTime = 0.0f; // used as a flag to initialize the playback rate to 0 in the first DeterminePlaybackRate }
CObjectTeleporter* CObjectTeleporter::FindMatch( void ) { int iObjMode = GetObjectMode(); int iOppositeMode = ( iObjMode == TELEPORTER_TYPE_ENTRANCE ) ? TELEPORTER_TYPE_EXIT : TELEPORTER_TYPE_ENTRANCE; CObjectTeleporter *pMatch = NULL; CTFPlayer *pBuilder = GetBuilder(); if ( !pBuilder ) { return NULL; } int i; int iNumObjects = pBuilder->GetObjectCount(); for ( i=0;i<iNumObjects;i++ ) { CBaseObject *pObj = pBuilder->GetObject(i); if ( pObj && pObj->GetType() == GetType() && pObj->GetObjectMode() == iOppositeMode && !pObj->IsDisabled() ) { pMatch = ( CObjectTeleporter * )pObj; // Copy upgrade state from higher level end. bool bCopyFrom = pMatch->GetUpgradeLevel() > GetUpgradeLevel(); if ( pMatch->GetUpgradeLevel() == GetUpgradeLevel() ) { // If same level use it if it has more metal. bCopyFrom = pMatch->m_iUpgradeMetal > m_iUpgradeMetal; } CopyUpgradeStateToMatch( pMatch, bCopyFrom ); break; } } return pMatch; }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterThink( void ) { SetContextThink( &CObjectTeleporter::TeleporterThink, gpGlobals->curtime + BUILD_TELEPORTER_NEXT_THINK, TELEPORTER_THINK_CONTEXT ); // At any point, if our match is not ready, revert to IDLE if ( IsDisabled() || IsMatchingTeleporterReady() == false ) { if ( GetState() != TELEPORTER_STATE_IDLE ) { SetState( TELEPORTER_STATE_IDLE ); ShowDirectionArrow( false ); } return; } if ( m_flMyNextThink && m_flMyNextThink > gpGlobals->curtime ) return; // pMatch is not NULL and is not building CObjectTeleporter *pMatch = GetMatchingTeleporter(); Assert( pMatch ); Assert( pMatch->m_iState != TELEPORTER_STATE_BUILDING ); switch ( m_iState ) { // Teleporter is not yet active, do nothing case TELEPORTER_STATE_BUILDING: break; default: case TELEPORTER_STATE_IDLE: // Do we have a match that is active? if ( IsMatchingTeleporterReady() ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); if ( GetType() == OBJ_TELEPORTER_ENTRANCE ) { ShowDirectionArrow( true ); } } break; case TELEPORTER_STATE_READY: break; case TELEPORTER_STATE_SENDING: { pMatch->TeleporterReceive( m_hTeleportingPlayer, 1.0 ); m_flRechargeTime = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEOUT_TIME + BUILD_TELEPORTER_FADEIN_TIME + TELEPORTER_RECHARGE_TIME ); // change state to recharging... SetState( TELEPORTER_STATE_RECHARGING ); } break; case TELEPORTER_STATE_RECEIVING: { // get the position we'll move the player to Vector newPosition = GetAbsOrigin(); newPosition.z += TELEPORTER_MAXS.z + 1; // Telefrag anyone in the way CBaseEntity *pEnts[256]; Vector mins, maxs; Vector expand( 4, 4, 4 ); mins = newPosition + VEC_HULL_MIN - expand; maxs = newPosition + VEC_HULL_MAX + expand; CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); // move the player if ( pTeleportingPlayer ) { CUtlVector<CBaseEntity*> hPlayersToKill; bool bClear = true; // Telefrag any players in the way int numEnts = UTIL_EntitiesInBox( pEnts, 256, mins, maxs, 0 ); if ( numEnts ) { //Iterate through the list and check the results for ( int i = 0; i < numEnts && bClear; i++ ) { if ( pEnts[i] == NULL ) continue; if ( pEnts[i] == this ) continue; // kill players and NPCs if ( pEnts[i]->IsPlayer() || pEnts[i]->IsNPC() ) { if ( !pTeleportingPlayer->InSameTeam(pEnts[i]) ) { hPlayersToKill.AddToTail( pEnts[i] ); } continue; } if ( pEnts[i]->IsBaseObject() ) continue; // Solid entities will prevent a teleport if ( pEnts[i]->IsSolid() && pEnts[i]->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), MASK_ALL ) && g_pGameRules->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), pEnts[i]->GetCollisionGroup() ) ) { // We're going to teleport into something solid. Abort & destroy this exit. bClear = false; } } } if ( bClear ) { // Telefrag all enemy players we've found for ( int player = 0; player < hPlayersToKill.Count(); player++ ) { hPlayersToKill[player]->TakeDamage( CTakeDamageInfo( pTeleportingPlayer, this, 1000, DMG_CRUSH ) ); } pTeleportingPlayer->Teleport( &newPosition, &(GetAbsAngles()), &vec3_origin ); // Unzoom if we are a sniper zoomed! if ( ( pTeleportingPlayer->GetPlayerClass()->GetClassIndex() == TF_CLASS_SNIPER ) && pTeleportingPlayer->m_Shared.InCond( TF_COND_AIMING ) ) { CTFWeaponBase *pWpn = pTeleportingPlayer->GetActiveTFWeapon(); if ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_SNIPERRIFLE ) { CTFSniperRifle *pRifle = static_cast<CTFSniperRifle*>( pWpn ); pRifle->ToggleZoom(); } } pTeleportingPlayer->SetFOV( pTeleportingPlayer, 0, tf_teleporter_fov_time.GetFloat(), tf_teleporter_fov_start.GetInt() ); color32 fadeColor = {255,255,255,100}; UTIL_ScreenFade( pTeleportingPlayer, fadeColor, 0.25, 0.4, FFADE_IN ); } else { DetonateObject(); } } SetState( TELEPORTER_STATE_RECEIVING_RELEASE ); m_flMyNextThink = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEIN_TIME ); } break; case TELEPORTER_STATE_RECEIVING_RELEASE: { CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); if ( pTeleportingPlayer ) { pTeleportingPlayer->TeleportEffect(); pTeleportingPlayer->m_Shared.RemoveCond( TF_COND_SELECTED_TO_TELEPORT ); CTF_GameStats.Event_PlayerUsedTeleport( GetBuilder(), pTeleportingPlayer ); pTeleportingPlayer->SpeakConceptIfAllowed( MP_CONCEPT_TELEPORTED ); } // reset the pointers to the player now that we're done teleporting SetTeleportingPlayer( NULL ); pMatch->SetTeleportingPlayer( NULL ); SetState( TELEPORTER_STATE_RECHARGING ); m_flMyNextThink = gpGlobals->curtime + ( TELEPORTER_RECHARGE_TIME ); } break; case TELEPORTER_STATE_RECHARGING: // If we are finished recharging, go active if ( gpGlobals->curtime > m_flRechargeTime ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); } break; } }
//----------------------------------------------------------------------------- // Fire on our target //----------------------------------------------------------------------------- bool CObjectSentrygun::Fire() { //NDebugOverlay::Cross3D( m_hEnemy->WorldSpaceCenter(), 10, 255, 0, 0, false, 0.1 ); Vector vecAimDir; // Level 3 Turrets fire rockets every 3 seconds if ( m_iUpgradeLevel == 3 && m_iAmmoRockets > 0 && m_flNextRocketAttack < gpGlobals->curtime ) { Vector vecSrc; QAngle vecAng; // alternate between the 2 rocket launcher ports. if ( m_iAmmoRockets & 1 ) { GetAttachment( m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_L], vecSrc, vecAng ); } else { GetAttachment( m_iAttachments[SENTRYGUN_ATTACHMENT_ROCKET_R], vecSrc, vecAng ); } vecAimDir = m_hEnemy->WorldSpaceCenter() - vecSrc; vecAimDir.NormalizeInPlace(); // NOTE: vecAng is not actually set by GetAttachment!!! QAngle angDir; VectorAngles( vecAimDir, angDir ); EmitSound( "Building_Sentrygun.FireRocket" ); AddGesture( ACT_RANGE_ATTACK2 ); QAngle angAimDir; VectorAngles( vecAimDir, angAimDir ); CTFProjectile_SentryRocket *pProjectile = CTFProjectile_SentryRocket::Create( vecSrc, angAimDir, this, GetBuilder() ); if ( pProjectile ) { pProjectile->SetDamage( 100 ); } // Setup next rocket shot m_flNextRocketAttack = gpGlobals->curtime + 3; if ( !tf_sentrygun_ammocheat.GetBool() && !HasSpawnFlags( SF_SENTRY_INFINITE_AMMO ) ) { m_iAmmoRockets--; } if (m_iAmmoRockets == 10) ClientPrint( GetBuilder(), HUD_PRINTNOTIFY, "#Sentry_rocketslow"); if (m_iAmmoRockets == 0) ClientPrint( GetBuilder(), HUD_PRINTNOTIFY, "#Sentry_rocketsout"); } // All turrets fire shells if ( m_iAmmoShells > 0) { if ( !IsPlayingGesture( ACT_RANGE_ATTACK1 ) ) { RemoveGesture( ACT_RANGE_ATTACK1_LOW ); AddGesture( ACT_RANGE_ATTACK1 ); } Vector vecSrc; QAngle vecAng; int iAttachment; if ( m_iUpgradeLevel > 1 && (m_iAmmoShells & 1) ) { // level 2 and 3 turrets alternate muzzles each time they fizzy fizzy fire. iAttachment = m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE_ALT]; } else { iAttachment = m_iAttachments[SENTRYGUN_ATTACHMENT_MUZZLE]; } GetAttachment( iAttachment, vecSrc, vecAng ); Vector vecMidEnemy = m_hEnemy->WorldSpaceCenter(); // If we cannot see their WorldSpaceCenter ( possible, as we do our target finding based // on the eye position of the target ) then fire at the eye position trace_t tr; UTIL_TraceLine( vecSrc, vecMidEnemy, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); if ( !tr.m_pEnt || tr.m_pEnt->IsWorld() ) { // Hack it lower a little bit.. // The eye position is not always within the hitboxes for a standing TF Player vecMidEnemy = m_hEnemy->EyePosition() + Vector(0,0,-5); } vecAimDir = vecMidEnemy - vecSrc; float flDistToTarget = vecAimDir.Length(); vecAimDir.NormalizeInPlace(); //NDebugOverlay::Cross3D( vecSrc, 10, 255, 0, 0, false, 0.1 ); FireBulletsInfo_t info; info.m_vecSrc = vecSrc; info.m_vecDirShooting = vecAimDir; info.m_iTracerFreq = 1; info.m_iShots = 1; info.m_pAttacker = GetBuilder(); info.m_vecSpread = vec3_origin; info.m_flDistance = flDistToTarget + 100; info.m_iAmmoType = m_iAmmoType; info.m_flDamage = tf_sentrygun_damage.GetFloat(); FireBullets( info ); //NDebugOverlay::Line( vecSrc, vecSrc + vecAimDir * 1000, 255, 0, 0, false, 0.1 ); CEffectData data; data.m_nEntIndex = entindex(); data.m_nAttachmentIndex = iAttachment; data.m_fFlags = m_iUpgradeLevel; data.m_vOrigin = vecSrc; DispatchEffect( "TF_3rdPersonMuzzleFlash_SentryGun", data ); switch( m_iUpgradeLevel ) { case 1: default: EmitSound( "Building_Sentrygun.Fire" ); break; case 2: EmitSound( "Building_Sentrygun.Fire2" ); break; case 3: EmitSound( "Building_Sentrygun.Fire3" ); break; } if ( !tf_sentrygun_ammocheat.GetBool() && !HasSpawnFlags( SF_SENTRY_INFINITE_AMMO ) ) { m_iAmmoShells--; } } else { if ( m_iUpgradeLevel > 1 ) { if ( !IsPlayingGesture( ACT_RANGE_ATTACK1_LOW ) ) { RemoveGesture( ACT_RANGE_ATTACK1 ); AddGesture( ACT_RANGE_ATTACK1_LOW ); } } // Out of ammo, play a click EmitSound( "Building_Sentrygun.Empty" ); m_flNextAttack = gpGlobals->curtime + 0.2; } return true; }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- void CObjectTeleporter::TeleporterThink( void ) { SetContextThink( &CObjectTeleporter::TeleporterThink, gpGlobals->curtime + BUILD_TELEPORTER_NEXT_THINK, TELEPORTER_THINK_CONTEXT ); // At any point, if our match is not ready, revert to IDLE if ( IsDisabled() || IsRedeploying() || IsMatchingTeleporterReady() == false ) { ShowDirectionArrow( false ); if ( GetState() != TELEPORTER_STATE_IDLE && !IsUpgrading() ) { SetState( TELEPORTER_STATE_IDLE ); CObjectTeleporter *pMatch = GetMatchingTeleporter(); if ( !pMatch ) { // The other end has been destroyed. Revert back to L1. m_iUpgradeLevel = 1; // We need to adjust for any damage received if we downgraded float flHealthPercentage = GetHealth() / GetMaxHealthForCurrentLevel(); SetMaxHealth( GetMaxHealthForCurrentLevel() ); SetHealth( (int)( GetMaxHealthForCurrentLevel() * flHealthPercentage ) ); m_iUpgradeMetal = 0; } } return; } if ( m_flMyNextThink && m_flMyNextThink > gpGlobals->curtime ) return; // pMatch is not NULL and is not building CObjectTeleporter *pMatch = GetMatchingTeleporter(); Assert( pMatch ); Assert( pMatch->m_iState != TELEPORTER_STATE_BUILDING ); switch ( m_iState ) { // Teleporter is not yet active, do nothing case TELEPORTER_STATE_BUILDING: case TELEPORTER_STATE_UPGRADING: ShowDirectionArrow( false ); break; default: case TELEPORTER_STATE_IDLE: // Do we have a match that is active? // Make sure both ends wait through full recharge time in case they get upgraded while recharging. if ( IsMatchingTeleporterReady() && !IsUpgrading() && gpGlobals->curtime > m_flRechargeTime ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); if ( GetObjectMode() == TELEPORTER_TYPE_ENTRANCE ) { ShowDirectionArrow( true ); } } break; case TELEPORTER_STATE_READY: break; case TELEPORTER_STATE_SENDING: { pMatch->TeleporterReceive( m_hTeleportingPlayer, 1.0 ); m_flRechargeTime = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEOUT_TIME + BUILD_TELEPORTER_FADEIN_TIME + g_flTeleporterRechargeTimes[ GetUpgradeLevel() - 1] ); // change state to recharging... SetState( TELEPORTER_STATE_RECHARGING ); } break; case TELEPORTER_STATE_RECEIVING: { // get the position we'll move the player to Vector newPosition = GetAbsOrigin(); newPosition.z += TELEPORTER_MAXS.z + 1; // Telefrag anyone in the way CBaseEntity *pEnts[256]; Vector mins, maxs; Vector expand( 4, 4, 4 ); mins = newPosition + VEC_HULL_MIN - expand; maxs = newPosition + VEC_HULL_MAX + expand; CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); // move the player if ( pTeleportingPlayer ) { CUtlVector<CBaseEntity*> hPlayersToKill; bool bClear = true; // Telefrag any players in the way int numEnts = UTIL_EntitiesInBox( pEnts, 256, mins, maxs, 0 ); if ( numEnts ) { //Iterate through the list and check the results for ( int i = 0; i < numEnts && bClear; i++ ) { if ( pEnts[i] == NULL ) continue; if ( pEnts[i] == this ) continue; // kill players if ( pEnts[i]->IsPlayer() ) { if ( !pTeleportingPlayer->InSameTeam(pEnts[i]) ) { hPlayersToKill.AddToTail( pEnts[i] ); } continue; } if ( pEnts[i]->IsBaseObject() ) continue; // Solid entities will prevent a teleport if ( pEnts[i]->IsSolid() && pEnts[i]->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), MASK_ALL ) && g_pGameRules->ShouldCollide( pTeleportingPlayer->GetCollisionGroup(), pEnts[i]->GetCollisionGroup() ) ) { // We're going to teleport into something solid. Abort & destroy this exit. bClear = false; } } } if ( bClear ) { // Telefrag all enemy players we've found for ( int player = 0; player < hPlayersToKill.Count(); player++ ) { CTakeDamageInfo info( this, pTeleportingPlayer, 1000, DMG_CRUSH, TF_DMG_TELEFRAG ); hPlayersToKill[player]->TakeDamage( info ); } pTeleportingPlayer->Teleport( &newPosition, &(GetAbsAngles()), &vec3_origin ); // Unzoom if we are a sniper zoomed! if ( ( pTeleportingPlayer->GetPlayerClass()->GetClassIndex() == TF_CLASS_SNIPER ) && pTeleportingPlayer->m_Shared.InCond( TF_COND_AIMING ) ) { CTFWeaponBase *pWpn = pTeleportingPlayer->GetActiveTFWeapon(); if ( pWpn && pWpn->GetWeaponID() == TF_WEAPON_SNIPERRIFLE ) { CTFSniperRifle *pRifle = static_cast<CTFSniperRifle*>( pWpn ); pRifle->ToggleZoom(); } } pTeleportingPlayer->SetFOV( pTeleportingPlayer, 0, tf_teleporter_fov_time.GetFloat(), tf_teleporter_fov_start.GetInt() ); color32 fadeColor = {255,255,255,100}; UTIL_ScreenFade( pTeleportingPlayer, fadeColor, 0.25, 0.4, FFADE_IN ); } else { DetonateObject(); } } SetState( TELEPORTER_STATE_RECEIVING_RELEASE ); m_flMyNextThink = gpGlobals->curtime + ( BUILD_TELEPORTER_FADEIN_TIME ); } break; case TELEPORTER_STATE_RECEIVING_RELEASE: { CTFPlayer *pTeleportingPlayer = m_hTeleportingPlayer.Get(); if ( pTeleportingPlayer ) { int iTeam = GetBuilder() ? GetBuilder()->GetTeamNumber() : GetTeamNumber(); pTeleportingPlayer->m_Shared.SetTeleporterEffectColor( iTeam ); pTeleportingPlayer->TeleportEffect(); pTeleportingPlayer->m_Shared.RemoveCond( TF_COND_SELECTED_TO_TELEPORT ); if ( !m_bWasMapPlaced && GetBuilder() ) CTF_GameStats.Event_PlayerUsedTeleport( GetBuilder(), pTeleportingPlayer ); IGameEvent * event = gameeventmanager->CreateEvent( "player_teleported" ); if ( event ) { event->SetInt( "userid", pTeleportingPlayer->GetUserID() ); if ( GetBuilder() ) event->SetInt( "builderid", GetBuilder()->GetUserID() ); Vector vecOrigin = GetAbsOrigin(); Vector vecDestinationOrigin = GetMatchingTeleporter()->GetAbsOrigin(); Vector vecDifference = Vector( vecOrigin.x - vecDestinationOrigin.x, vecOrigin.y - vecDestinationOrigin.y, vecOrigin.z - vecDestinationOrigin.z ); float flDist = sqrtf( pow( vecDifference.x, 2 ) + pow( vecDifference.y, 2 ) + pow( vecDifference.z, 2 ) ); event->SetFloat( "dist", flDist ); gameeventmanager->FireEvent( event, true ); } // Don't thank ourselves. if ( pTeleportingPlayer != GetBuilder() ) pTeleportingPlayer->SpeakConceptIfAllowed( MP_CONCEPT_TELEPORTED ); } // reset the pointers to the player now that we're done teleporting SetTeleportingPlayer( NULL ); pMatch->SetTeleportingPlayer( NULL ); SetState( TELEPORTER_STATE_RECHARGING ); m_flMyNextThink = gpGlobals->curtime + ( g_flTeleporterRechargeTimes[ GetUpgradeLevel() - 1 ] ); } break; case TELEPORTER_STATE_RECHARGING: // If we are finished recharging, go active if ( gpGlobals->curtime > m_flRechargeTime ) { SetState( TELEPORTER_STATE_READY ); EmitSound( "Building_Teleporter.Ready" ); } break; } }
IAccelerationStructureBuilder &AccelerationStructureBuilderFactory::GetAccelerationStructureBuilder() { const BuilderType builderType = DetermineBestBuilder(); return GetBuilder(builderType); }
llvm::Value *CodeGen::CallFunc(llvm::Value *fn, std::initializer_list<llvm::Value *> args) { return GetBuilder().CreateCall(fn, args); }
UINT32 UDPConnectionPacketSender::GetCurTransactionID() { return GetBuilder()->GetTransactionID()->Current(); }
llvm::Value *CodeGen::ConstStringPtr(const std::string &s) const { auto &ir_builder = GetBuilder(); return ir_builder.CreateConstInBoundsGEP2_32(nullptr, ConstString(s), 0, 0); }
llvm::Value *CodeGen::CallFunc(llvm::Value *fn, const std::vector<llvm::Value *> &args) { return GetBuilder().CreateCall(fn, args); }