コード例 #1
0
void C_SoundscapeSystem::Shutdown()
{
	for ( int i = m_loopingSounds.Count() - 1; i >= 0; --i )
	{
		loopingsound_t &sound = m_loopingSounds[i];

		// sound is done, remove from list.
		StopLoopingSound( sound );
	}
	
	// These are only necessary so we can use shutdown/init calls
	// to flush soundscape data
	m_loopingSounds.RemoveAll();
	m_randomSounds.RemoveAll();
	m_soundscapes.RemoveAll();
	m_params.ent.Set( NULL );
	m_params.soundscapeIndex = -1;

	while ( m_SoundscapeScripts.Count() > 0 )
	{
		KeyValues *kv = m_SoundscapeScripts[ 0 ];
		m_SoundscapeScripts.Remove( 0 );
		kv->deleteThis();
	}
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: Check to see if any of our constrained players have broken the constraint
//-----------------------------------------------------------------------------
void CPointPlayerMoveConstraint::ConstraintThink( void )
{
	int iCount = m_hConstrainedPlayers.Count();

	// Count backwards, because we might drop them if they've broken the constraint
	for ( int i = (iCount-1); i >= 0; i-- )
	{
		CBasePlayer *pPlayer = ToBasePlayer( m_hConstrainedPlayers[i] );
		if ( pPlayer )
		{
			float flDistanceSqr = (pPlayer->GetAbsOrigin() - GetAbsOrigin()).LengthSqr();
			if ( flDistanceSqr > m_flRadiusSquared )
			{
				// Break the constraint to this player
				pPlayer->DeactivateMovementConstraint();
				m_hConstrainedPlayers.Remove(i);

				// Fire the broken output
				m_OnConstraintBroken.FireOutput( this, pPlayer );
			}
		}
	}

	// Only keep thinking if we any left
	if ( m_hConstrainedPlayers.Count() )
	{
		SetNextThink( gpGlobals->curtime + 0.1f );
	}
}
コード例 #3
0
void CParticleSystemQuery::PostSimulate( ) 
{
#if defined( CLIENT_DLL )
	TProjectedTextureInfo *pInfo;

	while( m_ProjectedInfoAdds.PopItem( &pInfo ) == true )
	{
		m_ActiveProjectedInfos.AddToTail( pInfo );
	}

	for( int i = 0; i < m_ActiveProjectedInfos.Count(); i++ )
	{
		if ( m_ActiveProjectedInfos[ i ]->m_bUsedThisFrame == false )
		{
			delete m_ActiveProjectedInfos[ i ]->m_pEntity;
			m_ActiveProjectedInfos.Remove( i );
			i--;
			continue;
		}
		if ( m_ActiveProjectedInfos[ i ]->m_pEntity == NULL )
		{
			m_ActiveProjectedInfos[ i ]->m_pEntity = C_EnvProjectedTexture::Create();
		}

		m_ActiveProjectedInfos[ i ]->m_pEntity->SetAbsOrigin( m_ActiveProjectedInfos[ i ]->m_vOrigin );
		m_ActiveProjectedInfos[ i ]->m_pEntity->SetMaterial( m_ActiveProjectedInfos[ i ]->m_pMaterial );
		m_ActiveProjectedInfos[ i ]->m_pEntity->SetLightColor( m_ActiveProjectedInfos[ i ]->m_r * 255, m_ActiveProjectedInfos[ i ]->m_g * 255, m_ActiveProjectedInfos[ i ]->m_b * 255, m_ActiveProjectedInfos[ i ]->m_a * 255 );
		m_ActiveProjectedInfos[ i ]->m_pEntity->SetSize( m_ActiveProjectedInfos[ i ]->m_flSize );
		m_ActiveProjectedInfos[ i ]->m_pEntity->SetRotation( m_ActiveProjectedInfos[ i ]->m_flRotation );
	}
#endif // #if defined( CLIENT_DLL )
}
コード例 #4
0
ファイル: cmd.cpp プロジェクト: Axitonium/SourceEngine2007
static int CreateExecutionMarker()
{
	if ( g_ExecutionMarkers.Count() > 2048 )
		g_ExecutionMarkers.Remove( 0 );

	int i = g_ExecutionMarkers.AddToTail( RandomInt( 0, 1<<30 ) );
	return g_ExecutionMarkers[i];
}
コード例 #5
0
ファイル: cmd.cpp プロジェクト: Axitonium/SourceEngine2007
static bool FindAndRemoveExecutionMarker( int iCode )
{
	int i = g_ExecutionMarkers.Find( iCode );
	if ( i == g_ExecutionMarkers.InvalidIndex() )
		return false;
	
	g_ExecutionMarkers.Remove( i );
	return true;
}
コード例 #6
0
ファイル: hl2_triggers.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Purpose: Dissolve all weapons within our volume
//-----------------------------------------------------------------------------
void CTriggerWeaponDissolve::DissolveThink( void )
{
	int	numWeapons = m_pWeapons.Count();

	// Dissolve all the items within the volume
	for ( int i = 0; i < numWeapons; i++ )
	{
		CBaseCombatWeapon *pWeapon = m_pWeapons[i];
		Vector vecConduit = GetConduitPoint( pWeapon );
		
		// The physcannon upgrades when this happens
		if ( FClassnameIs( pWeapon, "weapon_physcannon" ) )
		{
			// This must be the last weapon for us to care
			if ( numWeapons > 1 )
				continue;

			//FIXME: Make them do this on a stagger!

			// All conduits send power to the weapon
			for ( int i = 0; i < m_pConduitPoints.Count(); i++ )
			{
				CreateBeam( m_pConduitPoints[i]->GetAbsOrigin(), pWeapon, 4.0f );
			}

			PhysCannonBeginUpgrade( pWeapon );
			m_OnChargingPhyscannon.FireOutput( this, this );

			EmitSound( "WeaponDissolve.Beam" );

			// We're done
			m_pWeapons.Purge();
			m_pConduitPoints.Purge();
			SetContextThink( NULL, 0, s_pDissolveThinkContext );
			return;
		}

		// Randomly dissolve them all
		float flLifetime = random->RandomFloat( 2.5f, 4.0f );
		CreateBeam( vecConduit, pWeapon, flLifetime );
		pWeapon->Dissolve( NULL, gpGlobals->curtime + ( 3.0f - flLifetime ), false );

		m_OnDissolveWeapon.FireOutput( this, this );

		CPASAttenuationFilter filter( pWeapon );
		EmitSound( filter, pWeapon->entindex(), "WeaponDissolve.Dissolve" );
		
		// Beam looping sound
		EmitSound( "WeaponDissolve.Beam" );

		m_pWeapons.Remove( i );
		SetContextThink( &CTriggerWeaponDissolve::DissolveThink, gpGlobals->curtime + random->RandomFloat( 0.5f, 1.5f ), s_pDissolveThinkContext );
		return;
	}

	SetContextThink( &CTriggerWeaponDissolve::DissolveThink, gpGlobals->curtime + 0.1f, s_pDissolveThinkContext );
}
コード例 #7
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDarknessLightSourcesSystem::RemoveLightSource( CInfoDarknessLightSource *pEntity )
{
	for ( int i = m_LightSources.Count() - 1; i >= 0; i-- )
	{
		if ( m_LightSources[i].hEntity == pEntity )
		{
			m_LightSources.Remove(i);
		}
	}
}
コード例 #8
0
void Templates_RemoveByHammerID( int nHammerID )
{
	for ( int i=g_Templates.Count()-1; i >= 0; i-- )
	{
		if ( g_Templates[i]->m_nHammerID == nHammerID )
		{
			Templates_FreeTemplate( g_Templates[i] );
			g_Templates.Remove( i );
		}
	}
}
コード例 #9
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CNPC_EnemyFinderCombineCannon::UpdateOnRemove() 
{
	BaseClass::UpdateOnRemove();

	// See if I'm in the list of Combine enemyfinders
	int index = s_ListEnemyfinders.Find(this);
	if( index != -1 )
	{
		s_ListEnemyfinders.Remove(index);
	}
}
コード例 #10
0
void CPhysicsMotionController::RemoveCore( IVP_Core *pCore )
{
	int index = m_coreList.Find(pCore);
	if ( !m_coreList.IsValidIndex(index) )
	{
#if DEBUG
		Msg("removed invalid core !!!\n");
#endif
		return;
	}
	m_coreList.Remove( index );
	pCore->rem_core_controller( static_cast<IVP_Controller_Independent *>(this) );
}
コード例 #11
0
void UpdateServicesBrowserIPs()
{
	double curTime = Plat_FloatTime();
	for ( int i=0; i < g_ServicesBrowsers.Count(); i++ )
	{
		if ( (curTime - g_ServicesBrowsers[i].m_flLastPingTime) >= SERVICES_BROWSER_TIMEOUT )
		{
			g_ServicesBrowsers.Remove( i );
			--i;
			break;
		}
	}
}
コード例 #12
0
ファイル: hl2_triggers.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Purpose: Called when an entity stops touching us.
// Input  : pOther - The entity that was touching us.
//-----------------------------------------------------------------------------
void CTriggerWateryDeath::EndTouch( CBaseEntity *pOther )
{
	if ( IsTouching( pOther ) )
	{
		EHANDLE hOther;
		hOther = pOther;

		// Remove the time from our list
		int iIndex = m_hTouchingEntities.Find( hOther );
		if ( iIndex != m_hTouchingEntities.InvalidIndex() )
		{
			m_flEntityKillTimes.Remove( iIndex );
		}
	}

#ifdef HL2_DLL
	if ( pOther->IsPlayer() )
	{
		for (int i = 0; i < m_hLeeches.Count(); i++ )
		{
			CWateryDeathLeech *pLeech = dynamic_cast<CWateryDeathLeech*>( m_hLeeches[i].Get() );

			if ( pLeech )
			{
				pLeech->m_iFadeState = -1;
			}
		}

		if ( m_hLeeches.Count() > 0 )
			 m_hLeeches.Purge();

		CHL2_Player *pHL2Player = dynamic_cast<CHL2_Player*>( pOther );

		if ( pHL2Player )
		{
			//Adrian: Hi, you might be wondering why I'm doing this, yes?
			//        Well, EndTouch is called not only when the player leaves
			//		  the trigger, but also on level shutdown. We can't let the
			//		  soundpatch fade the sound out since we'll hit a nasty assert
			//        cause it'll try to fade out a sound using an entity that might
			//        be gone since we're shutting down the server.
			if ( !(pHL2Player->GetFlags() & FL_DONTTOUCH ) )
				  pHL2Player->StopWaterDeathSounds();
		}
	}
#endif

	BaseClass::EndTouch( pOther );
}
コード例 #13
0
//-----------------------------------------------------------------------------
// Purpose: The blob has too many elements. Locate good candidates and remove
// this many elements.
//-----------------------------------------------------------------------------
void CNPC_Blob::RemoveExcessElements( int iNumElements )
{
	// For now we're not assessing candidates, just blindly removing.
	int i;
	for( i = 0 ; i < iNumElements ; i++ )
	{
		int iLastElement = m_iNumElements - 1;
		
		// Nuke the associated entity
		m_Elements[ iLastElement ]->SUB_Remove();

		m_Elements.Remove( iLastElement );
		m_iNumElements--;
	}
}
コード例 #14
0
// This is a hack to make point_message stuff appear in developer 0 release builds
//  for now
void DrawMessageEntities()
{
	int c = g_MessageEntities.Count();
	for ( int i = c - 1; i >= 0; i-- )
	{
		CMessageEntity *me = g_MessageEntities[ i ];
		if ( !me )
		{
			g_MessageEntities.Remove( i );
			continue;
		}

		me->DrawOverlays();
	}
}
コード例 #15
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CVGui::RemoveTickSignal( VPANEL panel )
{
	// remove from tick signal dar
	int count = m_TickSignalVec.Count();

	for (int i = 0; i < count; i++ )
	{
		Tick_t *tick = m_TickSignalVec[i];
		if ( tick->panel == panel )
		{
			m_TickSignalVec.Remove( i );
			delete tick;
			return;
		}
	}
}
コード例 #16
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CObjectTunnelTrigger::TunnelThink()
{
	// Make sure it's not already in the list
	int c = m_Tunneling.Count();
	for ( int i = c - 1; i >= 0; i-- )
	{
		TunnelPlayer *tp = &m_Tunneling[ i ];

		if ( !KeepTunneling( tp ) )
		{
			m_Tunneling.Remove( i );
		}
	}

	SetNextThink( gpGlobals->curtime + TUNNEL_THINK_INTERVAL );
}
コード例 #17
0
//---------------------------------------------------------
//---------------------------------------------------------
void CVisibilityMonitor::RemoveEntity( CBaseEntity *pEntity )
{
	Assert( pEntity != NULL );

	for( int i = 0 ; i < m_Entities.Count() ; i++ )
	{
		if( m_Entities[i].entity == pEntity )
		{
			m_Entities.Remove( i );

			if( debug_visibility_monitor.GetBool() )
			{
				Msg("VisMon: Removed Entity: %s (%s)\n", pEntity->GetClassname(), pEntity->GetDebugName() );
			}

			return;
		}
	}
}
コード例 #18
0
//-----------------------------------------------------------------------------
// Purpose: Run through all the Bots in the game and let them think.
//-----------------------------------------------------------------------------
void Bot_RunAll( void )
{
	if ( !botmanager )
		return;

	for ( int i = 0; i < s_Bots.Count(); i++ )
	{
		CPluginBot & bot = s_Bots[i];
		if ( bot.m_BotEdict->IsFree() || !bot.m_BotEdict->GetUnknown()|| !bot.m_PlayerInfo->IsConnected() )
		{
			s_Bots.Remove(i);
			--i;
		}
		else
		{
			Bot_Think( &bot );
		}
	}
}
コード例 #19
0
void EatTextModeKeyPresses()
{
	if ( !g_bTextMode )
		return;
	
	static bool bFirstRun = true;
	if ( bFirstRun )
	{
		bFirstRun = false;
		MoveConsoleWindowToFront();
	}

	char ch;
	while ( (ch = NextGetch()) != -1 )
	{
		if ( ch == 8 )
		{
			// Backspace..
			if ( g_TextModeLine.Count() )
			{
				g_TextModeLine.Remove( g_TextModeLine.Count() - 1 );
			}
		}
		else if ( ch == '\r' )
		{
			// Finish the line.
			if ( g_TextModeLine.Count() )
			{
				g_TextModeLine.AddMultipleToTail( 2, "\n" );
				Cbuf_AddText( g_TextModeLine.Base() );
				g_TextModeLine.Purge();
			}
			printf( "\n" );
		}
		else
		{
			g_TextModeLine.AddToTail( ch );
		}

		printf( "%c", ch );
	}	
}
コード例 #20
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTriggerPortal::DisabledThink( void )
{
	// If we've got no disabled entities left, we're done
	if ( !m_hDisabledForEntities.Count() )
	{
		SetContextThink( NULL, gpGlobals->curtime, TRIGGER_DISABLED_THINK );
		return;
	}

	for ( int i = m_hDisabledForEntities.Count()-1; i >= 0; i-- )
	{
		CBaseEntity *pEntity = m_hDisabledForEntities[i];
		if ( !pEntity || !IsTouchingPortal(pEntity) )
		{
			m_hDisabledForEntities.Remove(i);
		}
	}

	SetContextThink( &CTriggerPortal::DisabledThink, gpGlobals->curtime + 0.1, TRIGGER_DISABLED_THINK );
}
コード例 #21
0
static void RemoveDuplicateEntries( CUtlVector< QuickJoinPanel::QuickInfo > &arr )
{
	//
	// Assumes list sorted by name "stricmp"
	//
	const char *szLastName = "";

	for ( int k = 0; k < arr.Count(); ++ k )
	{
		QuickJoinPanel::QuickInfo &fi = arr[k];
		if ( !stricmp( fi.m_szName, szLastName ) )
		{
			// Same name entry, must be removed
			arr.Remove( k -- );
		}
		else
		{
			// Next name, remember for next item
			szLastName = fi.m_szName;
		}
	}
}
コード例 #22
0
// picks a number of spawners randomly from this spawngroup
void CASW_Spawn_Group::PickSpawnersRandomly( int nNumSpawners, bool bIncludeRecentlySpawned, CUtlVector< CASW_Base_Spawner* > *pSpawners )
{
	pSpawners->RemoveAll();
	CUtlVector< CASW_Base_Spawner* > candidates;

	for ( int i = 0; i < m_hSpawners.Count(); i++ )
	{
		if ( !m_hSpawners[i].Get() || !m_hSpawners[i]->IsEnabled() )
			continue;

		if ( !bIncludeRecentlySpawned && m_hSpawners[i]->HasRecentlySpawned() )
			continue;

		candidates.AddToTail( m_hSpawners[i].Get() );
	}
	for ( int i = 0; ( (i < nNumSpawners) && (candidates.Count() > 0) ); i++ )
	{
		int nChosen = RandomInt( 0, candidates.Count() - 1 );
		pSpawners->AddToTail( candidates[ nChosen ] );
		candidates.Remove( nChosen );
	}
}
コード例 #23
0
//-----------------------------------------------------------------------------
// Purpose: Draws a colored, filled rectangle
// Input  : *rect - 
//			*color - 
//			alpha - 
//-----------------------------------------------------------------------------
void CNetGraphPanel::DrawLine2( vrect_t *rect, unsigned char *color, unsigned char *color2, unsigned char alpha, unsigned char alpha2 )
{
	VPROF( "CNetGraphPanel::DrawLine2" );

	int idx = m_Rects.AddToTail();
	CLineSegment *seg = &m_Rects[ idx ];

	seg->color[0] = color[0];
	seg->color[1] = color[1];
	seg->color[2] = color[2];
	seg->color[3] = alpha;
	seg->color2[0] = color2[0];
	seg->color2[1] = color2[1];
	seg->color2[2] = color2[2];
	seg->color2[3] = alpha2;

	if ( rect->width == 1 )
	{
		seg->x1 = rect->x;
		seg->y1 = rect->y;
		seg->x2 = rect->x;
		seg->y2 = rect->y + rect->height;
	}
	else if ( rect->height == 1 )
	{
		seg->x1 = rect->x;
		seg->y1 = rect->y;
		seg->x2 = rect->x + rect->width;
		seg->y2 = rect->y;
	}
	else
	{
		Assert( 0 );
		m_Rects.Remove( idx );
	}
}
コード例 #24
0
int CNetworkStringTable::WriteUpdate( CBaseClient *client, bf_write &buf, int tick_ack )
{
	CUtlVector< StringHistoryEntry > history;

	int entriesUpdated = 0;
	int lastEntry = -1;

	int count = m_pItems->Count();

	for ( int i = 0; i < count; i++ )
	{
		CNetworkStringTableItem *p = &m_pItems->Element( i );

		// Client is up to date
		if ( p->GetTickChanged() <= tick_ack )
			continue;

		int nStartBit = buf.GetNumBitsWritten();

		// Write Entry index
		if ( (lastEntry+1) == i )
		{
			buf.WriteOneBit( 1 );
		}
		else
		{
			buf.WriteOneBit( 0 );
			buf.WriteUBitLong( i, m_nEntryBits );
		}

		// check if string can use older string as base eg "models/weapons/gun1" & "models/weapons/gun2"
		char const *pEntry = m_pItems->String( i );

		if ( p->GetTickCreated() > tick_ack )
		{
			// this item has just been created, send string itself
			buf.WriteOneBit( 1 );
			
			int substringsize = 0;
			int bestprevious = GetBestPreviousString( history, pEntry, substringsize );
			if ( bestprevious != -1 )
			{
				buf.WriteOneBit( 1 );
				buf.WriteUBitLong( bestprevious, 5 );	// history never has more than 32 entries
				buf.WriteUBitLong( substringsize, SUBSTRING_BITS );
				buf.WriteString( pEntry + substringsize );
			}
			else
			{
				buf.WriteOneBit( 0 );
				buf.WriteString( pEntry  );
			}
		}
		else
		{
			buf.WriteOneBit( 0 );
		}

		// Write the item's user data.
		int len;
		const void *pUserData = GetStringUserData( i, &len );
		if ( pUserData && len > 0 )
		{
			buf.WriteOneBit( 1 );

			if ( IsUserDataFixedSize() )
			{
				// Don't have to send length, it was sent as part of the table definition
				buf.WriteBits( pUserData, GetUserDataSizeBits() );
			}
			else
			{
				buf.WriteUBitLong( len, CNetworkStringTableItem::MAX_USERDATA_BITS );
				buf.WriteBits( pUserData, len*8 );
			}
		}
		else
		{
			buf.WriteOneBit( 0 );
		}

		// limit string history to 32 entries
		if ( history.Count() > 31 )
		{
			history.Remove( 0 );
		}

		// add string to string history
		StringHistoryEntry she;
		Q_strncpy( she.string, pEntry, sizeof( she.string ) );
		history.AddToTail( she );

		entriesUpdated++;
		lastEntry = i;

		if ( client && client->IsTracing() )
		{
			int nBits = buf.GetNumBitsWritten() - nStartBit;
			client->TraceNetworkMsg( nBits, " [%s] %d:%s ", GetTableName(), i, GetString( i ) );
		}
	}

	return entriesUpdated;
}
コード例 #25
0
//-----------------------------------------------------------------------------
// Purpose: Runs a single vgui frame, pumping all message to panels
//-----------------------------------------------------------------------------
void CVGui::RunFrame() 
{
	// NOTE: This can happen when running in Maya waiting for modal dialogs
	bool bIsReentrant = m_InDispatcher;
	if ( bIsReentrant )
	{
		++m_nReentrancyCount;
	}

#ifdef DEBUG
//  memory allocation debug helper
//	DPrintf( "Delete Count:%i,%i\n", m_iDeleteCount, m_iDeletePanelCount );
//	m_iDeleteCount = 	m_iDeletePanelCount = 0;
#endif

	// this will generate all key and mouse events as well as make a real repaint
	{
		VPROF( "surface()->RunFrame()" );
		g_pSurface->RunFrame();
	}

	// give the system a chance to process
	{
		VPROF( "system()->RunFrame()" );
		g_pSystem->RunFrame();
	}

	// update cursor positions
	if ( IsPC() && !IsReentrant() )
	{
		VPROF( "update cursor positions" );
		int cursorX, cursorY;
		g_pInput->GetCursorPosition(cursorX, cursorY);

		// this does the actual work given a x,y and a surface
		g_pInput->UpdateMouseFocus(cursorX, cursorY);

	}

	if ( !bIsReentrant )
	{
		VPROF( "input()->RunFrame()" );
		g_pInput->RunFrame();
	}

	// messenging
	if ( !bIsReentrant )
	{
		VPROF( "messenging" );
		// send all the messages waiting in the queue
		DispatchMessages();

		int time = g_pSystem->GetTimeMillis();

		// directly invoke tick all who asked to be ticked
		int count = m_TickSignalVec.Count();
		for (int i = count - 1; i >= 0; i-- )
		{
			Tick_t *t = m_TickSignalVec[i];
			
			VPANEL tickTarget = t->panel;
			if ( !tickTarget )
			{
				m_TickSignalVec.Remove( i );
				delete t;
				continue;
			}

			if ( t->interval != 0 )
			{
				if ( time < t->nexttick )
					continue;

				t->nexttick = time + t->interval;
			}

			PostMessage(tickTarget, new KeyValues("Tick"), NULL);
		}
	}

	{
		VPROF( "SolveTraverse" );
		// make sure the hierarchy is up to date
		g_pSurface->SolveTraverse(g_pSurface->GetEmbeddedPanel());
		g_pSurface->ApplyChanges();
		Assert( IsX360() || ( IsPC() && _heapchk() == _HEAPOK ) );
	}

	if ( bIsReentrant )
	{
		--m_nReentrancyCount;
	}
}
コード例 #26
0
void CHudCloseCaption::DrawStream( wrect_t &rcText, const CCloseCaptionPhrase *phrase )
{
    vgui::surface()->DrawSetColor( GetBgColor() );
    vgui::surface()->DrawFilledRect( rcText.left, rcText.top, rcText.right, rcText.bottom );

    int c = phrase->CountTokens();
    int i;

    int fontheight = vgui::surface()->GetFontTall( fontSet[ FONT_NORMAL ] );
    int x = 0;
    int y = 0;

    int available_width = rcText.right - rcText.left;

    color32 clr;
    clr.r = 255;
    clr.b = 255;
    clr.g = 255;
    clr.a = 255;

    CUtlVector< color32 > colorStack;
    colorStack.AddToTail( clr );

    int italic = 0;
    int bold = 0;

    for ( i = 0; i < c; i++ )
    {
        const wchar_t *token = phrase->GetToken( i );
        if ( !token )
            continue;

        wchar_t cmd[ 256 ];
        wchar_t args[ 256 ];

        if ( phrase->SplitCommand( token, cmd, args ) )
        {
            if ( !wcscmp( cmd, L"cr" ) )
            {
                x = 0;
                y += ( fontheight + 1 );
            }

            if ( !wcscmp( cmd, L"clr" ) )
            {
                if ( args[0] == 0 && colorStack.Count()>= 2)
                {
                    colorStack.Remove( colorStack.Count() - 1 );
                }
                else
                {
                    int r, g, b;
                    color32 newcolor;
                    if ( 3 == swscanf( args, L"%i,%i,%i", &r, &g, &b ) )
                    {
                        newcolor.r = r;
                        newcolor.g = g;
                        newcolor.b = b;
                        newcolor.a = 255;
                        colorStack.AddToTail( newcolor );
                    }
                }
            }

            if ( !wcscmp( cmd, L"I" ) )
            {
                italic = !italic;
            }

            if ( !wcscmp( cmd, L"B" ) )
            {
                bold = !bold;
            }

            continue;
        }

        int w, h;

        if ( italic )
        {
            italic = FONT_ITALIC;
        }

        if ( bold )
        {
            bold = FONT_BOLD;
        }
        vgui::HFont useF = FindFont( bold | italic );

        wchar_t sz[ 1024 ];
        swprintf( sz, L"%s ", token );

        vgui::surface()->GetTextSize( useF, sz, w, h );

        if ( x + w > available_width )
        {
            x = 0;
            y += ( h + 1 );
        }

        wrect_t rcOut;
        rcOut.left = rcText.left + x + 5;
        rcOut.right = rcOut.left + w;
        rcOut.top = rcText.top + y;
        rcOut.bottom = rcOut.top + fontheight + 1;

        color32 useColor = colorStack[ colorStack.Count() - 1 ];

        vgui::surface()->DrawSetTextFont( useF );
        vgui::surface()->DrawSetTextPos( rcOut.left, rcOut.top );
        vgui::surface()->DrawSetTextColor( Color( useColor.r, useColor.g, useColor.b, useColor.a ) );
        vgui::surface()->DrawPrintText( sz, wcslen( sz ) );

        x += w;
    }
}
コード例 #27
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFHudFlagObjectives::OnTick()
{
	// iterate through the flags to set their position in our HUD
	for ( int i = 0; i < g_Flags.Count(); i++ )
	{
		CCaptureFlag *pFlag = dynamic_cast< CCaptureFlag* >( ClientEntityList().GetEnt( g_Flags[i] ) );

		if ( pFlag )
		{
			if (!pFlag->IsDisabled())
			{
				if (m_pRedFlag && pFlag->GetTeamNumber() == TF_TEAM_RED)
				{
					m_pRedFlag->SetEntity(pFlag);
				}
				else if (m_pBlueFlag && pFlag->GetTeamNumber() == TF_TEAM_BLUE)
				{
					m_pBlueFlag->SetEntity(pFlag);
				}
				else if (m_pGreenFlag && pFlag->GetTeamNumber() == TF_TEAM_GREEN)
				{
					m_pGreenFlag->SetEntity(pFlag);
				}
				else if (m_pYellowFlag && pFlag->GetTeamNumber() == TF_TEAM_YELLOW)
				{
					m_pYellowFlag->SetEntity(pFlag);
				}
			}
		}
		else
		{
			// this isn't a valid index for a flag
			g_Flags.Remove( i );
		}
	}

	// are we playing captures for rounds?
	if ( tf_flag_caps_per_round.GetInt() > 0 )
	{
		C_TFTeam *pTeam = GetGlobalTFTeam( TF_TEAM_BLUE );
		if ( pTeam )
		{
			SetDialogVariable( "bluescore", pTeam->GetFlagCaptures() );
		}

		pTeam = GetGlobalTFTeam( TF_TEAM_RED );
		if ( pTeam )
		{
			SetDialogVariable( "redscore", pTeam->GetFlagCaptures() );
		}

		SetPlayingToLabelVisible( true );
		SetDialogVariable( "rounds", tf_flag_caps_per_round.GetInt() );
	}
	else // we're just playing straight score
	{
		C_TFTeam *pTeam = GetGlobalTFTeam( TF_TEAM_BLUE );
		if ( pTeam )
		{
			SetDialogVariable( "bluescore", pTeam->Get_Score() );
		}

		pTeam = GetGlobalTFTeam( TF_TEAM_RED );
		if ( pTeam )
		{
			SetDialogVariable( "redscore", pTeam->Get_Score() );
		}

		SetPlayingToLabelVisible( false );
	}

	// check the local player to see if they're spectating, OBS_MODE_IN_EYE, and the target entity is carrying the flag
	bool bSpecCarriedImage = false;
	C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();
	if ( pPlayer && ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) )
	{
		// does our target have the flag?
		C_BaseEntity *pEnt = pPlayer->GetObserverTarget();
		if ( pEnt && pEnt->IsPlayer() )
		{
			C_TFPlayer *pTarget = static_cast< C_TFPlayer* >( pEnt );
			if ( pTarget->HasTheFlag() )
			{
				bSpecCarriedImage = true;

				CCaptureFlag *pPlayerFlag = dynamic_cast<CCaptureFlag*>(pTarget->GetItem());

				if (m_pSpecCarriedImage)
				{
					switch (pPlayerFlag->GetTeamNumber())
					{
						case TF_TEAM_RED:
							m_pSpecCarriedImage->SetImage(("%s_red", STRING(pPlayerFlag->m_szHudIcon)));
							break;
						case TF_TEAM_BLUE:
							m_pSpecCarriedImage->SetImage(("%s_blue", STRING(pPlayerFlag->m_szHudIcon)));
							break;
						case TF_TEAM_GREEN:
							m_pSpecCarriedImage->SetImage(("%s_green", STRING(pPlayerFlag->m_szHudIcon)));
							break;
						case TF_TEAM_YELLOW:
							m_pSpecCarriedImage->SetImage(("%s_yellow", STRING(pPlayerFlag->m_szHudIcon)));
							break;
					}
				}
			}
		}
	}

	if ( bSpecCarriedImage )
	{
		if ( m_pSpecCarriedImage && !m_pSpecCarriedImage->IsVisible() )
		{
			m_pSpecCarriedImage->SetVisible( true );
		}
	}
	else
	{
		if ( m_pSpecCarriedImage && m_pSpecCarriedImage->IsVisible() )
		{
			m_pSpecCarriedImage->SetVisible( false );
		}
	}
}
コード例 #28
0
int CFileLoaderThread::DoThreadWork()
{
	int i;
	// Check for shutdown event
	if ( WAIT_OBJECT_0 == WaitForSingleObject( GetShutdownHandle(), 0 ) )
	{
		return 0;
	}

	// No changes to list right now
	Lock();
	// Move new items to work list
	int newItems = m_FileList.Count();
	for ( i = 0; i < newItems; i++ )
	{
		// Move to pending and issue async i/o calls
		m_Pending.AddToTail( m_FileList[ i ] );

		m_nTotalPending++;
	}
	m_FileList.RemoveAll();
	// Done adding new work items
	Unlock();

	int remaining = m_Pending.Count();
	if ( !remaining )
		return 1;

	int workitems = remaining; // min( remaining, 1000 );

	CUtlVector< SentenceRequest * > transfer;

	for ( i = 0; i < workitems; i++ )
	{
		SentenceRequest *r = m_Pending[ 0 ];
		m_Pending.Remove( 0 );

		transfer.AddToTail( r );
		// Do the work
		
		m_nTotalProcessed++;

		r->valid = SceneManager_LoadSentenceFromWavFileUsingIO( r->filename, r->sentence, m_ThreadIO );
	}

	// Now move to completed list
	Lock();
	for ( i = 0; i < workitems; i++ )
	{
		SentenceRequest *r = transfer[ i ];
		if ( r->valid )
		{
			m_nTotalCompleted++;

			m_Completed.AddToTail( r );
		}
		else
		{
			delete r;
		}
	}
	Unlock();
	return 1;
}
コード例 #29
0
void CloseCaptionTool::ComputeStreamWork( CChoreoWidgetDrawHelper &helper, int available_width, CCloseCaptionItem *item )
{
	// Start with a clean param block
	WorkUnitParams params;

	const wchar_t *curpos = item->GetStream();
	
	CUtlVector< COLORREF > colorStack;

	for ( ; curpos && *curpos != L'\0'; ++curpos )
	{
		wchar_t cmd[ 256 ];
		wchar_t args[ 256 ];

		if ( SplitCommand( &curpos, cmd, args ) )
		{
			if ( !wcscmp( cmd, L"cr" ) )
			{
				params.newline = true;
				AddWorkUnit( item, params);
			}
			else if ( !wcscmp( cmd, L"clr" ) )
			{
				AddWorkUnit( item, params );

				if ( args[0] == 0 && colorStack.Count()>= 2)
				{
					colorStack.Remove( colorStack.Count() - 1 );
					params.clr = colorStack[ colorStack.Count() - 1 ];
				}
				else
				{
					int r, g, b;
					COLORREF newcolor;
					if ( 3 == swscanf( args, L"%i,%i,%i", &r, &g, &b ) )
					{
						newcolor = RGB( r, g, b );
						colorStack.AddToTail( newcolor );
						params.clr = colorStack[ colorStack.Count() - 1 ];
					}
				}
			}
			else if ( !wcscmp( cmd, L"playerclr" ) )
			{
				AddWorkUnit( item, params );

				if ( args[0] == 0 && colorStack.Count()>= 2)
				{
					colorStack.Remove( colorStack.Count() - 1 );
					params.clr = colorStack[ colorStack.Count() - 1 ];
				}
				else
				{
					// player and npc color selector
					// e.g.,. 255,255,255:200,200,200
					int pr, pg, pb, nr, ng, nb;
					COLORREF newcolor;
					if ( 6 == swscanf( args, L"%i,%i,%i:%i,%i,%i", &pr, &pg, &pb, &nr, &ng, &nb ) )
					{
						// FIXME:  nothing in .vcds is ever from the player...
						newcolor = /*item->IsFromPlayer()*/ false ? RGB( pr, pg, pb ) : RGB( nr, ng, nb );
						colorStack.AddToTail( newcolor );
						params.clr = colorStack[ colorStack.Count() - 1 ];
					}
				}
			}
			else if ( !wcscmp( cmd, L"I" ) )
			{
				AddWorkUnit( item, params );
				params.italic = !params.italic;
			}
			else if ( !wcscmp( cmd, L"B" ) )
			{
				AddWorkUnit( item, params );
				params.bold = !params.bold;
			}

			continue;
		}

		HFONT useF = m_hFonts[ params.GetFontNumber() ];
		
		int w = helper.CalcTextWidthW( useF, L"%c", *curpos ); 

		if ( ( params.x + params.width ) + w > available_width )
		{
			params.newline = true;
			AddWorkUnit( item, params );
		}
		*params.out++ = *curpos;
		params.width += w;
	}

	// Add the final unit.
	params.newline = true;
	AddWorkUnit( item, params );

	item->SetSizeComputed( true );

	// DumpWork( item );
}
コード例 #30
0
//-----------------------------------------------------------------------------
// Purpose: Parse string update
//-----------------------------------------------------------------------------
void CNetworkStringTable::ParseUpdate( bf_read &buf, int entries )
{
	int lastEntry = -1;

	CUtlVector< StringHistoryEntry > history;

	for (int i=0; i<entries; i++)
	{
		int entryIndex = lastEntry + 1;

		if ( !buf.ReadOneBit() )
		{
			entryIndex = buf.ReadUBitLong( GetEntryBits() );
		}

		lastEntry = entryIndex;
		
		if ( entryIndex < 0 || entryIndex >= GetMaxStrings() )
		{
			Host_Error( "Server sent bogus string index %i for table %s\n", entryIndex, GetTableName() );
		}

		const char *pEntry = NULL;
		char entry[ 1024 ]; 
		char substr[ 1024 ];

		if ( buf.ReadOneBit() )
		{
			bool substringcheck = buf.ReadOneBit() ? true : false;

			if ( substringcheck )
			{
				int index = buf.ReadUBitLong( 5 );
				int bytestocopy = buf.ReadUBitLong( SUBSTRING_BITS );
				Q_strncpy( entry, history[ index ].string, bytestocopy + 1 );
				buf.ReadString( substr, sizeof(substr) );
				Q_strncat( entry, substr, sizeof(entry), COPY_ALL_CHARACTERS );
			}
			else
			{
				buf.ReadString( entry, sizeof( entry ) );
			}

			pEntry = entry;
		}
		
		// Read in the user data.
		unsigned char tempbuf[ CNetworkStringTableItem::MAX_USERDATA_SIZE ];
		memset( tempbuf, 0, sizeof( tempbuf ) );
		const void *pUserData = NULL;
		int nBytes = 0;

		if ( buf.ReadOneBit() )
		{
			if ( IsUserDataFixedSize() )
			{
				// Don't need to read length, it's fixed length and the length was networked down already.
				nBytes = GetUserDataSize();
				Assert( nBytes > 0 );
				tempbuf[nBytes-1] = 0; // be safe, clear last byte
				buf.ReadBits( tempbuf, GetUserDataSizeBits() );
			}
			else
			{
				nBytes = buf.ReadUBitLong( CNetworkStringTableItem::MAX_USERDATA_BITS );
				ErrorIfNot( nBytes <= sizeof( tempbuf ),
					("CNetworkStringTableClient::ParseUpdate: message too large (%d bytes).", nBytes)
				);

				buf.ReadBytes( tempbuf, nBytes );
			}

			pUserData = tempbuf;
		}

		// Check if we are updating an old entry or adding a new one
		if ( entryIndex < GetNumStrings() )
		{
			SetStringUserData( entryIndex, nBytes, pUserData );
#ifdef _DEBUG
			if ( pEntry )
			{
				Assert( !Q_strcmp( pEntry, GetString( entryIndex ) ) ); // make sure string didn't change
			}
#endif
			pEntry = GetString( entryIndex ); // string didn't change
		}
		else
		{
			// Grow the table (entryindex must be the next empty slot)
			Assert( (entryIndex == GetNumStrings()) && (pEntry != NULL) );
				
			if ( pEntry == NULL )
			{
				Msg("CNetworkStringTable::ParseUpdate: NULL pEntry, table %s, index %i\n", GetTableName(), entryIndex );
				pEntry = "";// avoid crash because of NULL strings
			}

			AddString( true, pEntry, nBytes, pUserData );
		}

		if ( history.Count() > 31 )
		{
			history.Remove( 0 );
		}

		StringHistoryEntry she;
		Q_strncpy( she.string, pEntry, sizeof( she.string ) );
		history.AddToTail( she );
	}
}