//-----------------------------------------------------------------------------
// Purpose: Read data on weapon from script file
// Output:  true  - if data2 successfully read
//			false - if data load fails
//-----------------------------------------------------------------------------
bool ReadPlayerClassDataFromFileForSlot( IFileSystem* filesystem, const char *szPlayerClassName, PLAYERCLASS_FILE_INFO_HANDLE *phandle, const unsigned char *pICEKey )
{
	if ( !phandle )
	{
		Assert( 0 );
		return false;
	}

	*phandle = FindPlayerClassInfoSlot( szPlayerClassName );
	FilePlayerClassInfo_t *pFileInfo = GetFilePlayerClassInfoFromHandle( *phandle );
	Assert( pFileInfo );

	if ( pFileInfo->m_bParsedScript )
		return true;

	char sz[128];
	Q_snprintf( sz, sizeof( sz ), "scripts/playerclass_%s", szPlayerClassName );
	KeyValues *pKV = ReadEncryptedKVFile( filesystem, sz, pICEKey );
	if ( !pKV )
		return false;

	pFileInfo->Parse( pKV, szPlayerClassName );

	pKV->deleteThis();

	return true;
}
Ejemplo n.º 2
0
bool ReadWeaponDataFromFileForSlot( IFileSystem* filesystem, const char *szWeaponName, WEAPON_FILE_INFO_HANDLE *phandle, const unsigned char *pICEKey )
{
	if ( !phandle )
	{
		Assert( 0 );
		return false;
	}
	
	*phandle = FindWeaponInfoSlot( szWeaponName );
	FileWeaponInfo_t *pFileInfo = GetFileWeaponInfoFromHandle( *phandle );
	Assert( pFileInfo );

	if ( pFileInfo->bParsedScript )
		return true;

	char sz[128];
	Q_snprintf( sz, sizeof( sz ), "scripts/%s", szWeaponName );

	KeyValues *pKV = ReadEncryptedKVFile( filesystem, sz, pICEKey,
#if defined( DOD_DLL )
		true			// Only read .ctx files!
#else
		false
#endif
		);

	if ( !pKV )
		return false;

	pFileInfo->Parse( pKV, szWeaponName );

	pKV->deleteThis();

	return true;
}
Ejemplo n.º 3
0
bool ReadItemDataFromFile( IFileSystem* filesystem, const char *szItemName, ITEM_FILE_INFO_HANDLE *phandle, const unsigned char *pICEKey )
{
	if ( !phandle )
	{
		Assert( 0 );
		return false;
	}
	
	*phandle = FindItemInfo( szItemName );
	FileItemInfo_t *pFileInfo = GetFileItemInfoFromHandle( *phandle );
	Assert( pFileInfo );

	if ( pFileInfo->bParsedScript )
		return true;

	char sz[128];
	Q_snprintf( sz, sizeof( sz ), "scripts/items/%s", szItemName );

	KeyValues *pKV = ReadEncryptedKVFile( filesystem, sz, pICEKey, false );

	if ( !pKV )
		return false;

	pFileInfo->Parse( pKV, szItemName );

	pKV->deleteThis();

	return true;
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: Parses the weapon txt files to get the sprites needed.
//-----------------------------------------------------------------------------
void LoadHudTextures( CUtlDict< CHudTexture *, int >& list, char *szFilenameWithoutExtension, const unsigned char *pICEKey )
{
	KeyValues *pTemp, *pTextureSection;

	KeyValues *pKeyValuesData = ReadEncryptedKVFile( filesystem, szFilenameWithoutExtension, pICEKey );
	if ( pKeyValuesData )
	{
		pTextureSection = pKeyValuesData->FindKey( "TextureData" );
		if ( pTextureSection  )
		{
			// Read the sprite data
			pTemp = pTextureSection->GetFirstSubKey();
			while ( pTemp )
			{
				CHudTexture *tex = new CHudTexture();
				// Key Name is the sprite name
				Q_strncpy( tex->szShortName, pTemp->GetName(), sizeof( tex->szShortName ) );

				if ( pTemp->GetString( "font", NULL ) )
				{
					// it's a font-based icon
					tex->bRenderUsingFont = true;
					tex->cCharacterInFont = *(pTemp->GetString("character", ""));
					Q_strncpy( tex->szTextureFile, pTemp->GetString( "font" ), sizeof( tex->szTextureFile ) );
				}
				else
				{
					tex->bRenderUsingFont = false;
					Q_strncpy( tex->szTextureFile, pTemp->GetString( "file" ), sizeof( tex->szTextureFile ) );
					tex->rc.left	= pTemp->GetInt( "x", 0 );
					tex->rc.top		= pTemp->GetInt( "y", 0 );
					tex->rc.right	= pTemp->GetInt( "width", 0 )	+ tex->rc.left;
					tex->rc.bottom	= pTemp->GetInt( "height", 0 )	+ tex->rc.top;
				}

				list.Insert( tex->szShortName, tex );

				pTemp = pTemp->GetNextKey();
			}
		}
	}

	// Failed for some reason. Delete the Key data and abort.
	pKeyValuesData->deleteThis();
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void TFPlayerClassData_t::Parse( const char *szName )
{
	// Have we parsed this file already?
	if ( m_bParsed )
		return;

	// No filesystem at this point????  Hmmmm......

	// Parse class file.

	const unsigned char *pKey = NULL;

	if ( g_pGameRules )
	{
		pKey = g_pGameRules->GetEncryptionKey();
	}

	KeyValues *pKV = ReadEncryptedKVFile( filesystem, szName, pKey );
	if ( pKV )
	{
		ParseData( pKV );
		pKV->deleteThis();
	}
}
Ejemplo n.º 6
0
Archivo: hud.cpp Proyecto: Yosam02/game
void LoadHudTextures(CUtlDict< CHudTexture *, int >& list, const char *szFilenameWithoutExtension, const unsigned char *pICEKey)
{
    KeyValues *pTemp, *pTextureSection;

    KeyValues *pKeyValuesData = ReadEncryptedKVFile(filesystem, szFilenameWithoutExtension, pICEKey);
    if (pKeyValuesData)
    {
        CUtlVector<HudTextureFileRef> hudTextureFileRefs;

        // By default, add a default entry mapping "file" to no prefix. This will allow earlier-version files
        // to work with no modification.
        hudTextureFileRefs.AddToTail(HudTextureFileRef("file", ""));

        // Read "*file"-to-prefix mapping.
        KeyValues *pTextureFileRefs = pKeyValuesData->FindKey("TextureFileRefs");
        if (pTextureFileRefs)
        {
            pTemp = pTextureFileRefs->GetFirstSubKey();
            while (pTemp)
            {
                hudTextureFileRefs.AddToTail(HudTextureFileRef(pTemp->GetName(), pTemp->GetString("prefix", "")));
                pTemp = pTemp->GetNextKey();
            }
        }

        // Read our individual HUD texture data blocks.
        pTextureSection = pKeyValuesData->FindKey("TextureData");
        if (pTextureSection)
        {
            // Read the sprite data
            pTemp = pTextureSection->GetFirstSubKey();
            while (pTemp)
            {
                if (pTemp->GetString("font", NULL))
                {
                    CHudTexture *tex = new CHudTexture();

                    // Key Name is the sprite name
                    Q_strncpy(tex->szShortName, pTemp->GetName(), sizeof(tex->szShortName));

                    // it's a font-based icon
                    tex->bRenderUsingFont = true;
                    tex->cCharacterInFont = *(pTemp->GetString("character", ""));
                    Q_strncpy(tex->szTextureFile, pTemp->GetString("font"), sizeof(tex->szTextureFile));

                    list.Insert(tex->szShortName, tex);
                }
                else
                {
                    int iTexLeft = pTemp->GetInt("x", 0),
                        iTexTop = pTemp->GetInt("y", 0),
                        iTexRight = pTemp->GetInt("width", 0) + iTexLeft,
                        iTexBottom = pTemp->GetInt("height", 0) + iTexTop;

                    for (int i = 0; i < hudTextureFileRefs.Size(); i++)
                    {
                        const char *cszFilename = pTemp->GetString(hudTextureFileRefs[i].m_fileKeySymbol, NULL);
                        if (cszFilename)
                        {
                            CHudTexture *tex = new CHudTexture();

                            tex->bRenderUsingFont = false;
                            tex->rc.left = iTexLeft;
                            tex->rc.top = iTexTop;
                            tex->rc.right = iTexRight;
                            tex->rc.bottom = iTexBottom;

                            Q_strncpy(tex->szShortName, hudTextureFileRefs[i].m_cszHudTexturePrefix, sizeof(tex->szShortName));
                            Q_strncpy(tex->szShortName + hudTextureFileRefs[i].m_uiPrefixLength, pTemp->GetName(), sizeof(tex->szShortName) - hudTextureFileRefs[i].m_uiPrefixLength);
                            Q_strncpy(tex->szTextureFile, cszFilename, sizeof(tex->szTextureFile));

                            list.Insert(tex->szShortName, tex);
                        }
                    }
                }

                pTemp = pTemp->GetNextKey();
            }
        }
    }

    // Failed for some reason. Delete the Key data and abort.
    pKeyValuesData->deleteThis();
}