char const *CMapEntities::GetName( int number )
{
	if ( number < 0 || number >= (int)m_Entities.Count() )
		return NULL;

	return m_Entities.GetElementName( number );
}
Beispiel #2
0
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey )
{
	if ( m_WeaponInfoDatabase.Count() )
		return;

	KeyValues *manifest = new KeyValues( "weaponscripts" );
	if ( manifest->LoadFromFile( filesystem, "scripts/weapon_manifest.txt", "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL ; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				char fileBase[512];
				Q_FileBase( sub->GetString(), fileBase, sizeof(fileBase) );
				WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
				if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
				{
					gWR.LoadWeaponSprites( tmp );
				}
#else
				ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
			}
			else
			{
				Error( "Expecting 'file', got %s\n", sub->GetName() );
			}
		}
	}
	manifest->deleteThis();
}
	virtual void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave )
	{
		CUtlDict< ConceptHistory_t, int > *ch = ((CUtlDict< ConceptHistory_t, int > *)fieldInfo.pField);
		int count = ch->Count();
		pSave->WriteInt( &count );
		for ( int i = 0 ; i < count; i++ )
		{
			ConceptHistory_t *pHistory = &(*ch)[ i ];

			pSave->StartBlock();
			{

				// Write element name
				pSave->WriteString( ch->GetElementName( i ) );

				// Write data
				pSave->WriteAll( pHistory );
				// Write response blob
				bool hasresponse = pHistory->response != NULL ? true : false;
				pSave->WriteBool( &hasresponse );
				if ( hasresponse )
				{
					pSave->WriteAll( pHistory->response );
				}
				// TODO: Could blat out pHistory->criteria pointer here, if it's needed
			}
			pSave->EndBlock();
		}
	}
Beispiel #4
0
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey )
{
	if ( m_WeaponInfoDatabase.Count() )
		return;

#if !defined( _XBOX )
	FileFindHandle_t findHandle;
	const char *pFilename = filesystem->FindFirstEx( "scripts/weapon_*.txt", IsXbox() ? "XGAME" : "GAME", &findHandle );
	while ( pFilename != NULL )
	{
		char fileBase[512];
		Q_FileBase( pFilename, fileBase, sizeof(fileBase) );
		WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
		if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
		{
			gWR.LoadWeaponSprites( tmp );
		}
#else
		ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
		pFilename = filesystem->FindNext( findHandle );
	}
	filesystem->FindClose( findHandle );
#else
#define WEAPON_SCRIPT_MANIFEST_FILE		"scripts/_weapon_manifest.txt"

	// Use a manifest file on the xbox
	KeyValues *manifest = new KeyValues( "weaponscripts" );
	if ( manifest->LoadFromFile( filesystem, WEAPON_SCRIPT_MANIFEST_FILE, "XGAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL ; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				char fileBase[512];
				Q_FileBase( sub->GetString(), fileBase, sizeof(fileBase) );
				WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
				if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
				{
					gWR.LoadWeaponSprites( tmp );
				}
#else
				ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
			}
			else
			{
				Error( "Expecting 'file', got %s\n", sub->GetName() );
			}
		}
	}
	manifest->deleteThis();
#endif
}
Beispiel #5
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : * - 
//			list - 
//-----------------------------------------------------------------------------
void FreeHudTextureList(CUtlDict< CHudTexture *, int >& list)
{
    int c = list.Count();
    for (int i = 0; i < c; i++)
    {
        CHudTexture *tex = list[i];
        delete tex;
    }
    list.RemoveAll();
}
//-----------------------------------------------------------------------------
// Purpose: 
// Sets the name of the bitmap from decals.wad to be used in a specific slot #
// called from cl_parse.cpp twice
// This sets the name of a decal prototype texture
// Input  : decal - 
//			*name - 
//-----------------------------------------------------------------------------
// called from gl_rsurf.cpp
IMaterial *Draw_DecalMaterial( int index )
{
	if ( index < 0 || index >= g_DecalLookup.Count() )
		return NULL;

	int slot = g_DecalLookup[ index ];
	if ( slot < 0 || slot >= (int)g_DecalDictionary.Count() )
		return NULL;

	return g_DecalDictionary[ slot ].material;
}
void ResetFileWeaponInfoDatabase( void )
{
	int c = m_WeaponInfoDatabase.Count(); 
	for ( int i = 0; i < c; ++i )
	{
		delete m_WeaponInfoDatabase[ i ];
	}
	m_WeaponInfoDatabase.RemoveAll();

#ifdef _DEBUG
	memset(g_bUsedWeaponSlots, 0, sizeof(g_bUsedWeaponSlots));
#endif
}
void CorrelateWavsAndVCDs( CUtlVector< CUtlSymbol >& vcdfiles, CUtlVector< CUtlSymbol >& wavfiles )
{
    CUtlDict< VCDList, int >	database;

    int i;
    int c = vcdfiles.Count();
    for ( i = 0; i < c; i++ )
    {
        CUtlSymbol& vcdname = vcdfiles[ i ];

        // Load the .vcd and update the database
        ProcessVCD( database, vcdname );
    }

    if ( vcdonly )
        return;

    vprint( 0, "Found %i wav files in %i vcds\n",
            database.Count(), vcdfiles.Count() );

    // Now look for any wavfiles that weren't in the database
    int ecount = 0;

    c = wavfiles.Count();
    for ( i = 0; i < c; i++ )
    {
        CUtlSymbol& wavename = wavfiles[ i ];

        int idx = database.Find( g_Analysis.symbols.String( wavename ) );
        if ( idx != database.InvalidIndex() )
        {
            VCDList *listentry = &database[ idx ];
            int vcdcount = listentry->vcds.Count();
            if ( vcdcount >= 2 && verbose )
            {
                vprint( 0, " wave '%s' used by multiple .vcds:\n", g_Analysis.symbols.String( wavename ) );
                int j;
                for ( j = 0; j < vcdcount; j++ )
                {
                    vprint( 1, "%i -- '%s'\n", j+1, g_Analysis.symbols.String( listentry->vcds[ j ] ) );
                }
            }
            continue;
        }

        vprint( 0, "%i -- '%s' not referenced by .vcd\n",
                ++ecount, g_Analysis.symbols.String( wavename ) );
    }

    vprint( 0, "\nSummary:  found %i/%i (%.2f percent) .wav errors\n", ecount, c, 100.0 * ecount / max( c, 1 ) );
}
Beispiel #9
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : handle - 
// Output : FileItemInfo_t
//-----------------------------------------------------------------------------
FileItemInfo_t *GetFileItemInfoFromHandle( ITEM_FILE_INFO_HANDLE handle )
{
	if ( handle < 0 || handle >= m_ItemInfoDatabase.Count() )
	{
		return &gNullItemInfo;
	}

	if ( handle == m_ItemInfoDatabase.InvalidIndex() )
	{
		return &gNullItemInfo;
	}

	return m_ItemInfoDatabase[ handle ];
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : handle - 
// Output : FilePlayerClassInfo_t
//-----------------------------------------------------------------------------
FilePlayerClassInfo_t *GetFilePlayerClassInfoFromHandle( PLAYERCLASS_FILE_INFO_HANDLE handle )
{
	if ( handle < 0 || handle >= m_PlayerClassInfoDatabase.Count() )
	{
		return &gNullPlayerClassInfo;
	}

	if ( handle == m_PlayerClassInfoDatabase.InvalidIndex() )
	{
		return &gNullPlayerClassInfo;
	}

	return m_PlayerClassInfoDatabase[ handle ];
}
int CTextureManager::FindNext( int iIndex, ITextureInternal **pTexInternal )
{
	if ( iIndex == -1 && m_TextureList.Count() )
	{
		iIndex = m_TextureList.First();
	}
	else if ( !m_TextureList.Count() || !m_TextureList.IsValidIndex( iIndex ) )
	{
		*pTexInternal = NULL;
		return -1;
	}

	*pTexInternal = m_TextureList[iIndex];

	iIndex = m_TextureList.Next( iIndex );
	if ( iIndex == m_TextureList.InvalidIndex() )
	{
		// end of list
		iIndex = -1;
	}

	return iIndex;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : handle - 
// Output : FileWeaponInfo_t
//-----------------------------------------------------------------------------
FileWeaponInfo_t *GetFileWeaponInfoFromHandle( WEAPON_FILE_INFO_HANDLE handle )
{
	if ( handle < 0 || handle >= m_WeaponInfoDatabase.Count() )
	{
		return &gNullWeaponInfo;
	}

	if ( handle == m_WeaponInfoDatabase.InvalidIndex() )
	{
		return &gNullWeaponInfo;
	}

	return m_WeaponInfoDatabase[ handle ];
}
void CClassMap::RemoveAllScripted( void )
{
	int c = m_ClassDict.Count();
	int i;

	for ( i = 0; i < c; i++ )
	{
		classentry_t *lookup = &m_ClassDict[ i ];
		if ( !lookup )
			continue;

		if ( lookup->scripted )
		{
			m_ClassDict.RemoveAt( i );
		}
	}
}
Beispiel #14
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void Decal_Shutdown( void )
{
	g_DecalLookup.Purge();

	int c = g_DecalDictionary.Count();

	int decal;
	for ( decal = 0; decal < c; decal++ )
	{
		IMaterial *mat = g_DecalDictionary[ decal ].material;
		if ( mat )
		{
			GL_UnloadMaterial( mat );
		}
	}

	g_DecalDictionary.Purge();
}
Beispiel #15
0
C_BaseEntity *CClassMap::CreateEntity( const char *mapname )
{
	int c = m_ClassDict.Count();
	int i;

	for ( i = 0; i < c; i++ )
	{
		classentry_t *lookup = &m_ClassDict[ i ];
		if ( !lookup )
			continue;

		if ( Q_stricmp( lookup->GetMapName(), mapname ) )
			continue;

#ifdef DISABLE_PYTHON
		if ( !lookup->factory )
		{
#if defined( _DEBUG )
			Msg( "No factory for %s/%s\n", lookup->GetMapName(), m_ClassDict.GetElementName( i ) );
#endif
			continue;
		}

		return ( *lookup->factory )();
#else
		if( lookup->factory )
		{
			return ( *lookup->factory )();
		}
		else if( lookup->pyfactory )
		{
			return lookup->pyfactory->Create();
		}
		else
		{
#if defined( _DEBUG )
			Msg( "No factory for %s/%s\n", lookup->GetMapName(), m_ClassDict.GetElementName( i ) );
#endif
		}
#endif // 0
	}

	return NULL;
}
int CClassMap::GetClassSize( const char *classname )
{
	int c = m_ClassDict.Count();
	int i;

	for ( i = 0; i < c; i++ )
	{
		classentry_t *lookup = &m_ClassDict[ i ];
		if ( !lookup )
			continue;

		if ( Q_strcmp( lookup->GetMapName(), classname ) )
			continue;

		return lookup->size;
	}

	return -1;
}
const char *CClassMap::Lookup( const char *classname )
{
	int c = m_ClassDict.Count();
	int i;

	for ( i = 0; i < c; i++ )
	{
		classentry_t *lookup = &m_ClassDict[ i ];
		if ( !lookup )
			continue;

		if ( Q_stricmp( lookup->GetClassName(), classname ) )
			continue;

		return lookup->GetMapName();
	}

	return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPanelAnimationDictionary::PanelAnimationDumpVars( char const *className )
{
	if ( className == NULL )
	{
		for ( int i = 0; i < (int)m_AnimationMaps.Count(); i++ )
		{
			PanelAnimationDumpMap( m_AnimationMaps[ i ].map, false );
		}
	}
	else
	{
		PanelAnimationMap *map = FindPanelAnimationMap( className );
		if ( map )
		{
			PanelAnimationDumpMap( map, true );
		}
		else
		{
			Msg( "No such Panel Animation class %s\n", className );
		}
	}
}
Beispiel #19
0
void CHudIcons::Init()
{
	if (m_bHudTexturesLoaded)
		return;

	m_bHudTexturesLoaded = true;
	CUtlDict< CHudTexture *, int >	textureList;

	// check to see if we have sprites for this res; if not, step down
	LoadHudTextures(textureList, "scripts/hud_textures", NULL);
	LoadHudTextures(textureList, "scripts/mod_textures", NULL);

	LoadHudTextures(textureList, "scripts/instructor_textures", NULL);
	LoadHudTextures(textureList, "scripts/instructor_modtextures", NULL);

	int c = textureList.Count();
	for (int index = 0; index < c; index++)
	{
		CHudTexture* tex = textureList[index];
		AddSearchableHudIconToList(*tex);
	}

	FreeHudTextureList(textureList);
}
int CMapEntities::Count( void )
{
	return m_Entities.Count();
}
Beispiel #21
0
//-----------------------------------------------------------------------------
// Purpose: This is called every time the DLL is loaded
//-----------------------------------------------------------------------------
void CHud::Init(void)
{
    HOOK_HUD_MESSAGE(gHUD, ResetHUD);

#ifdef CSTRIKE_DLL
    HOOK_HUD_MESSAGE( gHUD, SendAudio );
#endif

    InitFonts();

    // Create all the Hud elements
    CHudElementHelper::CreateAllElements();

    gLCD.Init();

    // Initialize all created elements
    for (int i = 0; i < m_HudList.Size(); i++)
    {
        m_HudList[i]->Init();
    }

    m_bHudTexturesLoaded = false;

    KeyValues *kv = new KeyValues("layout");
    if (kv)
    {
        if (kv->LoadFromFile(filesystem, "scripts/HudLayout.res"))
        {
            int numelements = m_HudList.Size();

            for (int i = 0; i < numelements; i++)
            {
                CHudElement *element = m_HudList[i];

                vgui::Panel *pPanel = dynamic_cast<vgui::Panel*>(element);
                if (!pPanel)
                {
                    Msg("Non-vgui hud element %s\n", m_HudList[i]->GetName());
                    continue;
                }

                KeyValues *key = kv->FindKey(pPanel->GetName(), false);
                if (!key)
                {
                    Msg("Hud element '%s' doesn't have an entry '%s' in scripts/HudLayout.res\n", m_HudList[i]->GetName(), pPanel->GetName());
                }

                // Note:  When a panel is parented to the module root, it's "parent" is returned as NULL.
                if (!element->IsParentedToClientDLLRootPanel() &&
                    !pPanel->GetParent())
                {
                    DevMsg("Hud element '%s'/'%s' doesn't have a parent\n", m_HudList[i]->GetName(), pPanel->GetName());
                }
            }
        }

        kv->deleteThis();
    }

    if (m_bHudTexturesLoaded)
        return;

    m_bHudTexturesLoaded = true;
    CUtlDict< CHudTexture *, int >	textureList;

    // check to see if we have sprites for this res; if not, step down
    LoadHudTextures(textureList, "scripts/hud_textures", NULL);
    LoadHudTextures(textureList, "scripts/mod_textures", NULL);

    int c = textureList.Count();
    for (int index = 0; index < c; index++)
    {
        CHudTexture* tex = textureList[index];
        AddSearchableHudIconToList(*tex);
    }

    FreeHudTextureList(textureList);
}
	virtual bool IsEmpty( const SaveRestoreFieldInfo_t &fieldInfo )
	{
		CUtlDict< ConceptHistory_t, int > *ch = ((CUtlDict< ConceptHistory_t, int > *)fieldInfo.pField);
		return ch->Count() == 0 ? true : false;
	}
Beispiel #23
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHud::RefreshHudTextures()
{
    if (!m_bHudTexturesLoaded)
    {
        Assert(0);
        return;
    }

    CUtlDict< CHudTexture *, int >	textureList;

    // check to see if we have sprites for this res; if not, step down
    LoadHudTextures(textureList, "scripts/hud_textures", NULL);
    LoadHudTextures(textureList, "scripts/mod_textures", NULL);

    // fix up all the texture icons first
    int c = textureList.Count();
    for (int index = 0; index < c; index++)
    {
        CHudTexture *tex = textureList[index];
        Assert(tex);

        CHudTexture *icon = GetIcon(tex->szShortName);
        if (!icon)
            continue;

        // Update file
        Q_strncpy(icon->szTextureFile, tex->szTextureFile, sizeof(icon->szTextureFile));

        if (!icon->bRenderUsingFont)
        {
            // Update subrect
            icon->rc = tex->rc;

            // Keep existing texture id, but now update texture file and texture coordinates
            vgui::surface()->DrawSetTextureFile(icon->textureId, icon->szTextureFile, false, false);

            // Get new texture dimensions in case it changed
            int wide, tall;
            vgui::surface()->DrawGetTextureSize(icon->textureId, wide, tall);

            // Assign coords
            icon->texCoords[0] = (float) (icon->rc.left + 0.5f) / (float) wide;
            icon->texCoords[1] = (float) (icon->rc.top + 0.5f) / (float) tall;
            icon->texCoords[2] = (float) (icon->rc.right - 0.5f) / (float) wide;
            icon->texCoords[3] = (float) (icon->rc.bottom - 0.5f) / (float) tall;
        }
    }

    FreeHudTextureList(textureList);

    // fixup all the font icons
    vgui::HScheme scheme = vgui::scheme()->GetScheme("ClientScheme");
    for (int i = m_Icons.First(); m_Icons.IsValidIndex(i); i = m_Icons.Next(i))
    {
        CHudTexture *icon = m_Icons[i];
        if (!icon)
            continue;

        // Update file
        if (icon->bRenderUsingFont)
        {
            icon->hFont = vgui::scheme()->GetIScheme(scheme)->GetFont(icon->szTextureFile, true);
            icon->rc.top = 0;
            icon->rc.left = 0;
            icon->rc.right = vgui::surface()->GetCharacterWidth(icon->hFont, icon->cCharacterInFont);
            icon->rc.bottom = vgui::surface()->GetFontTall(icon->hFont);
        }
    }
}
// Compute master/slave, count, endtime info for close captioning data
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CChoreoChannel::ReconcileCloseCaption()
{
	// Create a dictionary based on the combined token name
	CUtlDict< EventGroup, int > validSpeakEventsGroupedByName;

	int i;
	// Sort items
	int c = GetNumEvents();
	for ( i = 0; i < c; i++ )
	{
		CChoreoEvent *e = GetEvent( i );
		Assert( e );
		if ( e->GetType() != CChoreoEvent::SPEAK )
			continue;

		CChoreoEvent::CLOSECAPTION type;

		type = e->GetCloseCaptionType();
		if ( type == CChoreoEvent::CC_DISABLED )
		{
			e->SetUsingCombinedFile( false );
			e->SetRequiredCombinedChecksum( 0 );
			e->SetNumSlaves( 0 );
			e->SetLastSlaveEndTime( 0.0f );
			continue;
		}

		char const *name = e->GetCloseCaptionToken();
		if ( !name || !name[0] )
		{
			// Fixup invalid slave tag
			if ( type == CChoreoEvent::CC_SLAVE )
			{
				e->SetCloseCaptionType( CChoreoEvent::CC_MASTER );
				e->SetUsingCombinedFile( false );
				e->SetRequiredCombinedChecksum( 0 );
				e->SetNumSlaves( 0 );
				e->SetLastSlaveEndTime( 0.0f );
			}
			continue;
		}
	
		int idx = validSpeakEventsGroupedByName.Find( name );
		if ( idx == validSpeakEventsGroupedByName.InvalidIndex() )
		{
			EventGroup eg;
			eg.timeSortedEvents.Insert( e );
			validSpeakEventsGroupedByName.Insert( name, eg );
		}
		else
		{
			EventGroup & eg = validSpeakEventsGroupedByName[ idx ];
			eg.timeSortedEvents.Insert( e );
		}
	}

	c = validSpeakEventsGroupedByName.Count();
	// Now walk list of events by group
	if ( !c )
	{
		return;
	}

	for ( i = 0; i < c; ++i )
	{
		EventGroup & eg = validSpeakEventsGroupedByName[ i ];
		int sortedEventInGroup = eg.timeSortedEvents.Count();
		// If there's only one, just mark it valid
		if ( sortedEventInGroup <= 1 )
		{
			CChoreoEvent *e = eg.timeSortedEvents[ 0 ];
			Assert( e );
			// Make sure it's the master
			e->SetCloseCaptionType( CChoreoEvent::CC_MASTER );
			// Since it's by itself, can't be using "combined" file
			e->SetUsingCombinedFile( false );
			e->SetRequiredCombinedChecksum( 0 );
			e->SetNumSlaves( 0 );
			e->SetLastSlaveEndTime( 0.0f );
			continue;
		}

		// Okay, read them back in of start time
		int j = eg.timeSortedEvents.FirstInorder();
		CChoreoEvent *master = NULL;
		while ( j != eg.timeSortedEvents.InvalidIndex() )
		{
			CChoreoEvent *e = eg.timeSortedEvents[ j ];
			if ( !master )
			{
				master = e;
				e->SetCloseCaptionType( CChoreoEvent::CC_MASTER );
				//e->SetUsingCombinedFile( true );
				e->SetRequiredCombinedChecksum( 0 );
				e->SetNumSlaves( sortedEventInGroup - 1 );
				e->SetLastSlaveEndTime( e->GetEndTime() );
			}
			else
			{
				// Keep bumping out the end time
				master->SetLastSlaveEndTime( e->GetEndTime() );
				e->SetCloseCaptionType( CChoreoEvent::CC_SLAVE );
				e->SetUsingCombinedFile( master->IsUsingCombinedFile() );
				e->SetRequiredCombinedChecksum( 0 );
				e->SetLastSlaveEndTime( 0.0f );
			}

			j = eg.timeSortedEvents.NextInorder( j );
		}
	}
}