Ejemplo n.º 1
0
static cell_t smn_KvGotoNextKey(IPluginContext *pCtx, const cell_t *params)
{
	Handle_t hndl = static_cast<Handle_t>(params[1]);
	HandleError herr;
	HandleSecurity sec;
	KeyValueStack *pStk;

	sec.pOwner = NULL;
	sec.pIdentity = g_pCoreIdent;

	if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
		!= HandleError_None)
	{
		return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
	}

	KeyValues *pSubKey = pStk->pCurRoot.front();
	if (params[2])
	{
		pSubKey = pSubKey->GetNextTrueSubKey();
	} else {
		pSubKey = pSubKey->GetNextKey();
	}
	if (!pSubKey)
	{
		return 0;
	}
	pStk->pCurRoot.pop();
	pStk->pCurRoot.push(pSubKey);

	return 1;	
}
void CCompiledKeyValuesWriter::BuildKVData_R( KeyValues *kv, int parent )
{
	// Add self
	KVInfo_t info;
	info.key = m_StringTable.AddString( kv->GetName() );
	info.value = m_StringTable.AddString( kv->GetString() );

	info.SetSubTree( kv->GetFirstSubKey() != NULL ? true : false );
	info.SetParent( parent );

	int newParent = m_Data.AddToTail( info );

	// Then add children
	for ( KeyValues *sub = kv->GetFirstSubKey(); sub; sub = sub->GetNextKey() )
	{
		BuildKVData_R( sub, newParent );
	}

	// Then add peers
	if ( parent == -1 )
	{
		if ( kv->GetNextKey() )
		{
			BuildKVData_R( kv->GetNextKey(), parent );
		}
	}
}
Ejemplo n.º 3
0
void CRoomTemplate::LoadFromKeyValues( const char *pRoomName, KeyValues *pKeyValues )
{
    m_nTilesX = pKeyValues->GetInt( "TilesX", 1 );
    m_nTilesY = pKeyValues->GetInt( "TilesY", 1 );
    SetSpawnWeight( pKeyValues->GetInt( "SpawnWeight", MIN_SPAWN_WEIGHT ) );

    SetFullName( pRoomName );

    Q_strncpy( m_Description, pKeyValues->GetString( "RoomTemplateDescription", "" ), m_nMaxDescriptionLength );
    Q_strncpy( m_Soundscape, pKeyValues->GetString( "Soundscape", "" ), m_nMaxSoundscapeLength );

    SetTileType( pKeyValues->GetInt( "TileType", ASW_TILETYPE_UNKNOWN ) );

    m_Tags.RemoveAll();

    // search through all the exit subsections
    KeyValues *pkvSubSection = pKeyValues->GetFirstSubKey();
    bool bClearedExits = false;
    while ( pkvSubSection )
    {
        // mission details
        if ( Q_stricmp(pkvSubSection->GetName(), "EXIT")==0 )
        {
            if ( !bClearedExits )
            {
                // if we haven't cleared previous exits yet then do so now
                m_Exits.PurgeAndDeleteElements();
                bClearedExits = true;
            }
            CRoomTemplateExit *pExit = new CRoomTemplateExit();
            pExit->m_iXPos = pkvSubSection->GetInt("XPos");
            pExit->m_iYPos = pkvSubSection->GetInt("YPos");
            pExit->m_ExitDirection = (ExitDirection_t) pkvSubSection->GetInt("ExitDirection");
            pExit->m_iZChange = pkvSubSection->GetInt("ZChange");
            Q_strncpy( pExit->m_szExitTag, pkvSubSection->GetString( "ExitTag" ), sizeof( pExit->m_szExitTag ) );
            pExit->m_bChokepointGrowSource = !!pkvSubSection->GetInt("ChokeGrow", 0);

            // discard exits outside the room bounds
            if ( pExit->m_iXPos < 0 || pExit->m_iYPos < 0 || pExit->m_iXPos >= m_nTilesX || pExit->m_iYPos >= m_nTilesY )
            {
                delete pExit;
            }
            else
            {
                m_Exits.AddToTail(pExit);
            }
        }
        else if ( Q_stricmp(pkvSubSection->GetName(), "Tags")==0 && TagList() )
        {
            for ( KeyValues *sub = pkvSubSection->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
            {
                if ( !Q_stricmp( sub->GetName(), "tag" ) )
                {
                    AddTag( sub->GetString() );
                }
            }
        }
        pkvSubSection = pkvSubSection->GetNextKey();
    }
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseModelPanel::ParseModelResInfo( KeyValues *inResourceData )
{
	m_bForcePos = ( inResourceData->GetInt( "force_pos", 0 ) == 1 );
	m_BMPResData.m_pszModelName = ReadAndAllocStringValue( inResourceData, "modelname" );
	m_BMPResData.m_pszModelName_HWM = ReadAndAllocStringValue( inResourceData, "modelname_hwm" );
	m_BMPResData.m_pszVCD = ReadAndAllocStringValue( inResourceData, "vcd" );
	m_BMPResData.m_angModelPoseRot.Init( inResourceData->GetFloat( "angles_x", 0.0f ), inResourceData->GetFloat( "angles_y", 0.0f ), inResourceData->GetFloat( "angles_z", 0.0f ) );
	m_BMPResData.m_vecOriginOffset.Init( inResourceData->GetFloat( "origin_x", 110.0 ), inResourceData->GetFloat( "origin_y", 5.0 ), inResourceData->GetFloat( "origin_z", 5.0 ) );
	m_BMPResData.m_vecFramedOriginOffset.Init( inResourceData->GetFloat( "frame_origin_x", 110.0 ), inResourceData->GetFloat( "frame_origin_y", 5.0 ), inResourceData->GetFloat( "frame_origin_z", 5.0 ) );
	m_BMPResData.m_vecViewportOffset.Init();
	m_BMPResData.m_nSkin = inResourceData->GetInt( "skin", -1 );
	m_BMPResData.m_bUseSpotlight = ( inResourceData->GetInt( "spotlight", 0 ) == 1 );

	m_angPlayer = m_BMPResData.m_angModelPoseRot;
	m_vecPlayerPos = m_BMPResData.m_vecOriginOffset;

	for ( KeyValues *pData = inResourceData->GetFirstSubKey(); pData != NULL; pData = pData->GetNextKey() )
	{
		if ( !Q_stricmp( pData->GetName(), "animation" ) )
		{
			ParseModelAnimInfo( pData );
		}
		else if ( !Q_stricmp( pData->GetName(), "attached_model" ) )
		{
			ParseModelAttachInfo( pData );
		}
	}
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: Loads the surface properties database into the physics DLL
//-----------------------------------------------------------------------------
void LoadSurfaceProperties( void )
{
	CreateInterfaceFn physicsFactory = GetPhysicsFactory();
	if ( !physicsFactory )
		return;

	physprops = (IPhysicsSurfaceProps *)physicsFactory( VPHYSICS_SURFACEPROPS_INTERFACE_VERSION, NULL );

	const char *SURFACEPROP_MANIFEST_FILE = "scripts/surfaceproperties_manifest.txt";
	KeyValues *manifest = new KeyValues( SURFACEPROP_MANIFEST_FILE );
	if ( manifest->LoadFromFile( g_pFileSystem, SURFACEPROP_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				LoadSurfacePropFile( sub->GetString() );
				continue;
			}
		}
	}

	manifest->deleteThis();
}
Ejemplo n.º 6
0
void C_SoundscapeSystem::AddSoundScapeFile( const char *filename )
{
	KeyValues *script = new KeyValues( filename );
#ifndef _XBOX
	if ( script->LoadFromFile( filesystem, filename ) )
#else
	if ( filesystem->LoadKeyValues( *script, IFileSystem::TYPE_SOUNDSCAPE, filename, "GAME" ) )
#endif
	{
		// parse out all of the top level sections and save their names
		KeyValues *pKeys = script;
		while ( pKeys )
		{
			// save pointers to all sections in the root
			// each one is a soundscape
			if ( pKeys->GetFirstSubKey() )
			{
				m_soundscapes.AddToTail( pKeys );
			}
			pKeys = pKeys->GetNextKey();
		}

		// Keep pointer around so we can delete it at exit
		m_SoundscapeScripts.AddToTail( script );
	}
	else
	{
		script->deleteThis();
	}
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseObject::AddAndParseBuildPoint( int iAttachmentNumber, KeyValues *pkvBuildPoint )
{
	int iPoint = AddBuildPoint( iAttachmentNumber );

	
	m_BuildPoints[iPoint].m_bPutInAttachmentSpace = (pkvBuildPoint->GetInt( "PutInAttachmentSpace", 0 ) != 0);

	// Now see if we've got a set of valid objects specified
	KeyValues *pkvValidObjects = pkvBuildPoint->FindKey( "valid_objects" );
	if ( pkvValidObjects )
	{
		KeyValues *pkvObject = pkvValidObjects->GetFirstSubKey();
		while ( pkvObject )
		{
			const char *pSpecifiedObject = pkvObject->GetName();
			int iLenObjName = Q_strlen( pSpecifiedObject );

			// Find the object index for the name
			for ( int i = 0; i < OBJ_LAST; i++ )
			{
				if ( !Q_strncasecmp( GetObjectInfo( i )->m_pClassName, pSpecifiedObject, iLenObjName) )
				{
					AddValidObjectToBuildPoint( iPoint, i );
					break;
				}
			}

			pkvObject = pkvObject->GetNextKey();
		}
	}
}
Ejemplo n.º 8
0
// fills in the target list panel with buttons for each of the entries in the desired list
bool SwarmopediaTopics::SetupList(SwarmopediaPanel *pPanel, const char *szDesiredList)
{
	// look through our KeyValues for the desired list
	KeyValues *pkvList = GetSubkeyForList(szDesiredList);
	if (!pkvList)
	{
		Msg("Swarmopedia error: Couldn't find list %s\n", szDesiredList);
		return false;
	}

	// now go through every LISTENTRY in the subkey we found, adding it to the list panel
	int iPlayerUnlockLevel = 999;	// todo: have this check a convar that measures how far through the jacob campaign the player has got
	while ( pkvList )
	{
		if (Q_stricmp(pkvList->GetName(), "LISTENTRY")==0)
		{
			const char *szEntryName = pkvList->GetString("Name");
			const char *szArticleTarget = pkvList->GetString("ArticleTarget");
			const char *szListTarget = pkvList->GetString("ListTarget");
			int iEntryUnlockLevel = pkvList->GetInt("UnlockLevel");
			int iSectionHeader = pkvList->GetInt("SectionHeader");

			if (iEntryUnlockLevel == 0 || iEntryUnlockLevel < iPlayerUnlockLevel)
			{
				pPanel->AddListEntry(szEntryName, szArticleTarget, szListTarget, iSectionHeader);
			}
		}
		pkvList = pkvList->GetNextKey();
	}
	return true;
}
Ejemplo n.º 9
0
bool VMFExporter::ProcessGenericRecursive( KeyValues *pKey )
{
    const char *szKey = pKey->GetName();
    const char *szValue = pKey->GetString();

    if ( !Q_stricmp( szKey, "startposition" ) )
    {
        Vector Origin;
        int nRead = sscanf(szValue, "[%f %f %f]", &Origin[0], &Origin[1], &Origin[2]);

        if (nRead != 3)
            return false;

        // move the points to where our room is
        Origin += GetCurrentRoomOffset();

        char buffer[256];
        Q_snprintf(buffer, sizeof(buffer), "[%f %f %f]", Origin[0], Origin[1], Origin[2]);

        pKey->SetStringValue( buffer );
    }

    if ( pKey->GetFirstSubKey() )		// if this keyvalues entry has subkeys, then process them
    {
        for ( KeyValues *pKeys = pKey->GetFirstSubKey(); pKeys; pKeys = pKeys->GetNextKey() )
        {
            if ( !ProcessGenericRecursive( pKeys ) )
                return false;
        }
    }

    return true;
}
Ejemplo n.º 10
0
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
bool CNPC_Furniture::CreateVPhysics( void )
{
#ifndef HL2_DLL
	return false;
#endif

	if ( !m_BoneFollowerManager.GetNumBoneFollowers() )
	{
		KeyValues *modelKeyValues = new KeyValues("");
		if ( modelKeyValues->LoadFromBuffer( modelinfo->GetModelName( GetModel() ), modelinfo->GetModelKeyValueText( GetModel() ) ) )
		{
			// Do we have a bone follower section?
			KeyValues *pkvBoneFollowers = modelKeyValues->FindKey("bone_followers");
			if ( pkvBoneFollowers )
			{
				// Loop through the list and create the bone followers
				KeyValues *pBone = pkvBoneFollowers->GetFirstSubKey();
				while ( pBone )
				{
					// Add it to the list
					const char *pBoneName = pBone->GetString();
					m_BoneFollowerManager.AddBoneFollower( this, pBoneName );

					pBone = pBone->GetNextKey();
				}
			}
		}
		modelKeyValues->deleteThis();
	}

	return true;
}
Ejemplo n.º 11
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();
}
Ejemplo n.º 12
0
void VMFExporter::LoadUniqueKeyList()
{
    m_UniqueKeys.RemoveAll();
    m_NodeIDKeys.RemoveAll();

    // Open the manifest file, and read the particles specified inside it
    KeyValues *manifest = new KeyValues( UNIQUE_KEYS_FILE );
    if ( manifest->LoadFromFile( g_pFullFileSystem, UNIQUE_KEYS_FILE, "GAME" ) )
    {
        for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
        {
            if ( !Q_stricmp( sub->GetName(), "key" ) )
            {
                m_UniqueKeys.AddToTail( sub->GetString() );
                continue;
            }
            if ( !Q_stricmp( sub->GetName(), "NodeID" ) )
            {
                m_NodeIDKeys.AddToTail( sub->GetString() );
                continue;
            }

            Warning( "VMFExporter::LoadUniqueKeyList:  Manifest '%s' with bogus file type '%s', expecting 'key' or 'NodeID'\n", UNIQUE_KEYS_FILE, sub->GetName() );
        }
    }
    else
    {
        Warning( "VMFExporter: Unable to load manifest file '%s'\n", UNIQUE_KEYS_FILE );
    }

    manifest->deleteThis();
}
Ejemplo n.º 13
0
void CASW_Holdout_Wave::LoadFromKeyValues( int nWaveNumber, KeyValues *pKeys )
{
	m_Entries.PurgeAndDeleteElements();
	
	m_nTotalAliens = 0;
	m_nWaveNumber = nWaveNumber;
	m_iszWaveName = AllocPooledString( pKeys->GetString( "Name", "Unknown" ) );
	m_nEnvironmentModifiers = pKeys->GetInt( "EnvironmentModifiers" );	// TODO: Turn this into a string parser for the bit flag names
	m_bWaveHasResupply = pKeys->GetBool( "Resupply", false );

	for ( KeyValues *pKey = pKeys->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey() )
	{
		if ( !Q_stricmp( pKey->GetName(), "ENTRY" ) )
		{
			if ( asw_holdout_debug.GetBool() )
			{
				Msg( "    Loading a wave entry\n" );
			}
			CASW_Holdout_Wave_Entry *pEntry = new CASW_Holdout_Wave_Entry();
			pEntry->LoadFromKeyValues( pKey );
			m_Entries.AddToTail( pEntry );

			m_nTotalAliens += pEntry->GetQuantity();
		}
	}
}
Ejemplo n.º 14
0
void PhysParseSurfaceData( IPhysicsSurfaceProps *pProps, IFileSystem *pFileSystem )
{
	KeyValues *manifest = new KeyValues( SURFACEPROP_MANIFEST_FILE );
	if ( manifest->LoadFromFile( pFileSystem, SURFACEPROP_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				AddSurfacepropFile( sub->GetString(), pProps, pFileSystem );
				continue;
			}

			Warning( "surfaceprops::Init:  Manifest '%s' with bogus file type '%s', expecting 'file'\n", 
				SURFACEPROP_MANIFEST_FILE, sub->GetName() );
		}
	}
	else
	{
		Error( "Unable to load manifest file '%s'\n", SURFACEPROP_MANIFEST_FILE );
	}

	manifest->deleteThis();
}
Ejemplo n.º 15
0
//-----------------------------------------------------------------------------
// Purpose: sets up the button/command bindings
//-----------------------------------------------------------------------------
void CControllerMap::ApplySettings( KeyValues *inResourceData )
{
	BaseClass::ApplySettings( inResourceData );

	// loop through all the data adding items to the menu
	for (KeyValues *dat = inResourceData->GetFirstSubKey(); dat != NULL; dat = dat->GetNextKey())
	{
		if ( !Q_stricmp( dat->GetName(), "button" ) )
		{
			const char *buttonName = dat->GetString( "name", "" );
			int keycode = StringToButtonCode( buttonName );
			if ( keycode != -1 )
			{
				button_t b;
				b.cmd = CUtlSymbol( dat->GetString( "command", "" ) );

				// text and icon are optional - their existence means this button
				// should be displayed in the footer panel.
				const char *helpText = dat->GetString( "text", NULL );
				if ( helpText )
				{
					b.text = CUtlSymbol( helpText );
					b.icon = CUtlSymbol( dat->GetString( "icon", NULL ) );
				}

				m_buttonMap.Insert( keycode, b );
			}
		}
	}
}
Ejemplo n.º 16
0
bool VMFExporter::AddRoomTemplateSolids( const CRoomTemplate *pRoomTemplate )
{
    // open its vmf file
    char roomvmfname[MAX_PATH];
    Q_snprintf(roomvmfname, sizeof(roomvmfname), "tilegen/roomtemplates/%s/%s.vmf",
               pRoomTemplate->m_pLevelTheme->m_szName,
               pRoomTemplate->GetFullName() );
    m_pTemplateKeys = new KeyValues( "RoomTemplateVMF" );
    m_pTemplateKeys->LoadFromFile( g_pFullFileSystem, roomvmfname, "GAME" );

    // look for world key
    for ( KeyValues *pKeys = m_pTemplateKeys; pKeys; pKeys = pKeys->GetNextKey() )
    {
        if ( !Q_stricmp( pKeys->GetName(), "world" ) )		// find the world key in our room template
        {
            if ( !ProcessWorld( pKeys ) )					// fix up solid positions
            {
                Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to copy world from room %s\n", pRoomTemplate->GetFullName() );
                return false;
            }
            for ( KeyValues *pSubKey = pKeys->GetFirstSubKey(); pSubKey; pSubKey = pSubKey->GetNextKey() )		// convert each solid to a func_detail entity
            {
                if ( !Q_stricmp( pSubKey->GetName(), "solid" ) )
                {
                    if ( IsDisplacementBrush( pSubKey ) )
                    {
                        // add to world section
                        m_pExportWorldKeys->AddSubKey( pSubKey->MakeCopy() );
                    }
                    else
                    {
                        // put into entity section as a func_detail
                        KeyValues *pFuncDetail = new KeyValues( "entity" );
                        pFuncDetail->SetInt( "id", ++m_iEntityCount );
                        pFuncDetail->SetString( "classname", "func_detail" );
                        pFuncDetail->AddSubKey( pSubKey->MakeCopy() );
                        m_pExportKeys->AddSubKey( pFuncDetail );
                    }
                }
            }
        }
    }
    m_pTemplateKeys->deleteThis();
    m_pTemplateKeys = NULL;
    return true;
}
Ejemplo n.º 17
0
void BuildGroup::ProcessConditionalKeys( KeyValues *pData, KeyValues *pConditions )
{
	// for each condition, look for it in keys
	// if its a positive condition, promote all of its children, replacing values

	if ( pData )
	{
		KeyValues *pSubKey = pData->GetFirstSubKey();
		if ( !pSubKey )
		{
			// not a block
			return;
		}

		for ( ; pSubKey != nullptr; pSubKey = pSubKey->GetNextKey() )
		{
			// recursively descend each sub block
			ProcessConditionalKeys( pSubKey, pConditions );

			KeyValues *pCondition = pConditions->GetFirstSubKey();
			for ( ; pCondition != nullptr; pCondition = pCondition->GetNextKey() )
			{
				// if we match any conditions in this sub block, copy up
				KeyValues *pConditionBlock = pSubKey->FindKey( pCondition->GetName() );
				if ( pConditionBlock )
				{
					KeyValues *pOverridingKey;
					for ( pOverridingKey = pConditionBlock->GetFirstSubKey(); pOverridingKey != nullptr; pOverridingKey = pOverridingKey->GetNextKey() )
					{
						KeyValues *pExistingKey = pSubKey->FindKey( pOverridingKey->GetName() );
						if ( pExistingKey )
						{
							pExistingKey->SetStringValue( pOverridingKey->GetString() );
						}
						else
						{
							KeyValues *copy = pOverridingKey->MakeCopy();
							pSubKey->AddSubKey( copy );
						}
					}				
				}
			}			
		}		
	}
}
Ejemplo n.º 18
0
	virtual void FrameUpdatePostEntityThink( void )
	{
		// Wait until we're all spawned in
		if ( gpGlobals->curtime < 5 )
			return;

		if ( m_bIssuedNextMapCommand )
			return;

		if ( !m_bParsedMapFile )
		{
			m_bParsedMapFile = true;

			// See if we've got a camera file to import cameras from
			char szFullName[512];
			Q_snprintf(szFullName,sizeof(szFullName), "maps/%s.txt", STRING( gpGlobals->mapname ));
			KeyValues *pkvMapCameras = new KeyValues( "MapCameras" );
			if ( pkvMapCameras->LoadFromFile( filesystem, szFullName, "MOD" ) )
			{
				Warning( "Devshots: Loading point_devshot_camera positions from %s. \n", szFullName );

				// Get each camera, and add it to our list
				KeyValues *pkvCamera = pkvMapCameras->GetFirstSubKey();
				while ( pkvCamera )
				{
					// Get camera name
					const char *pCameraName = pkvCamera->GetName();

					// Make a camera, and move it to the position specified
					CPointDevShotCamera	*pCamera = (CPointDevShotCamera*)CreateEntityByName( "point_devshot_camera" );
					Assert( pCamera );
					pCamera->KeyValue( "cameraname", pCameraName );
					pCamera->KeyValue( "origin", pkvCamera->GetString( "origin", "0 0 0" ) );
					pCamera->KeyValue( "angles", pkvCamera->GetString( "angles", "0 0 0" ) );
					pCamera->KeyValue( "FOV", pkvCamera->GetString( "FOV", "75" ) );
					DispatchSpawn( pCamera );
					pCamera->Activate();

					// Move to next camera
					pkvCamera = pkvCamera->GetNextKey();
				}
			}

			if ( !g_iDevShotCameraCount )
			{
				Warning( "Devshots: No point_devshot_camera in %s. Moving to next map.\n", STRING( gpGlobals->mapname ) );

				CBasePlayer *pPlayer = UTIL_GetLocalPlayerOrListenServerHost();
				if ( pPlayer )
				{
					engine->ClientCommand( pPlayer->edict(), "devshots_nextmap" );
					m_bIssuedNextMapCommand = true;
					return;
				}
			}
		}
	}
Ejemplo n.º 19
0
void KeyValues::AddSubKey(KeyValues *pSubkey)
{
	Assert(pSubkey->m_pPeer == NULL);

	if (m_pSub == NULL)
	{
		m_pSub = pSubkey;
	}
	else
	{
		KeyValues *pTempDat = m_pSub;

		while (pTempDat->GetNextKey() != NULL)
			pTempDat = pTempDat->GetNextKey();

		pTempDat->SetNextKey(pSubkey);
	}
}
Ejemplo n.º 20
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
}
Ejemplo n.º 21
0
void KeyValues::AppendIncludedKeys(CUtlVector<KeyValues *> &includedKeys)
{
	int includeCount = includedKeys.Count();

	for (int i = 0; i < includeCount; i++)
	{
		KeyValues *kv = includedKeys[i];
		Assert(kv);

		KeyValues *insertSpot = this;

		while (insertSpot->GetNextKey())
		{
			insertSpot = insertSpot->GetNextKey();
		}

		insertSpot->SetNextKey(kv);
	}
}
Ejemplo n.º 22
0
bool VMFExporter::ProcessConnections( KeyValues *pConnections )
{
    for ( KeyValues *pKeys = pConnections->GetFirstSubKey(); pKeys; pKeys = pKeys->GetNextKey() )
    {
        if ( !ProcessConnectionsKey( pKeys ) )
            return false;
    }

    return true;
}
Ejemplo n.º 23
0
//-----------------------------------------------------------------------------
// Purpose: create the Border objects from the scheme data
//-----------------------------------------------------------------------------
void CScheme::LoadBorders()
{
	m_pkvBorders = m_pData->FindKey("Borders", true);
	{for ( KeyValues *kv = m_pkvBorders->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
	{
		if (kv->GetDataType() == KeyValues::TYPE_STRING)
		{
			// it's referencing another border, ignore for now
		}
		else
		{
			int i = m_BorderList.AddToTail();

			Border *border = new Border();
			border->SetName(kv->GetName());
			border->ApplySchemeSettings(this, kv);

			m_BorderList[i].border = border;
			m_BorderList[i].bSharedBorder = false;
			m_BorderList[i].borderSymbol = kv->GetNameSymbol();
		}
	}}

	// iterate again to get the border references
	for ( KeyValues *kv = m_pkvBorders->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
	{
		if (kv->GetDataType() == KeyValues::TYPE_STRING)
		{
			// it's referencing another border, find it
			Border *border = (Border *)GetBorder(kv->GetString());
//			const char *str = kv->GetName();
			Assert(border);

			// add an entry that just references the existing border
			int i = m_BorderList.AddToTail();
			m_BorderList[i].border = border;
			m_BorderList[i].bSharedBorder = true;
			m_BorderList[i].borderSymbol = kv->GetNameSymbol();
		}
	}
	
	m_pBaseBorder = GetBorder("BaseBorder");
}
const char* CASW_Mission_Chooser_Source_Local::GetPrettySavedCampaignName(const char *szSaveName)
{
	static char szPrettyName[256];
	szPrettyName[0] = '\0';

	char stripped[MAX_PATH];
	V_StripExtension( szSaveName, stripped, MAX_PATH );
	char tempfile[MAX_PATH];
	Q_snprintf( tempfile, sizeof( tempfile ), "save/%s.campaignsave", stripped );

	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile))
	{
		const char *szCampaignName = pSaveKeyValues->GetString("CampaignName");
		const char *szPrettyCampaignName = szCampaignName;
		if (szCampaignName && Q_strlen(szCampaignName) > 0)
		{
			szPrettyCampaignName = GetPrettyCampaignName(szCampaignName);
		}
		const char *szDate = pSaveKeyValues->GetString("DateTime");
		char namebuffer[256];
		namebuffer[0] = '\0';
		int namepos = 0;
		KeyValues *pkvSubSection = pSaveKeyValues->GetFirstSubKey();
		while ( pkvSubSection && namepos < 253)
		{
			if (Q_stricmp(pkvSubSection->GetName(), "PLAYER")==0)
			{
				const char *pName = pkvSubSection->GetString("PlayerName");
				if (pName && pName[0] != '\0')
				{
					if (namepos != 0)
					{
						namebuffer[namepos] = ' '; namepos++;
					}
					int namelength = Q_strlen(pName);
					for (int charcopy=0; charcopy<namelength && namepos<253; charcopy++)
					{
						namebuffer[namepos] = pName[charcopy];
						namepos++;
					}
					namebuffer[namepos] = '\0';
				}
			}
			pkvSubSection = pkvSubSection->GetNextKey();
		}
		Q_snprintf(szPrettyName, sizeof(szPrettyName),
			"%s (%s) (%s)",
			szPrettyCampaignName, szDate, namebuffer);
	}
	pSaveKeyValues->deleteThis();

	return szPrettyName;
}
Ejemplo n.º 25
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CTFIntroMenu::LoadCaptions( void )
{
	bool bSuccess = false;

	// clear any current captions
	m_Captions.PurgeAndDeleteElements();
	m_iCurrentCaption = 0;

	if ( m_pCaptionLabel )
	{
		KeyValues *kvCaptions = NULL;
		char strFullpath[MAX_PATH];

		Q_strncpy( strFullpath, TFGameRules()->GetVideoFileForMap( false ), MAX_PATH );	// Assume we must play out of the media directory
		Q_strncat( strFullpath, ".res", MAX_PATH );					// Assume we're a .res extension type

		if ( g_pFullFileSystem->FileExists( strFullpath ) )
		{
			kvCaptions = new KeyValues( strFullpath );

			if ( kvCaptions )
			{
				if ( kvCaptions->LoadFromFile( g_pFullFileSystem, strFullpath ) )
				{
					for ( KeyValues *pData = kvCaptions->GetFirstSubKey(); pData != NULL; pData = pData->GetNextKey() )
					{
						CVideoCaption *pCaption = new CVideoCaption;
						if ( pCaption )
						{
							pCaption->m_pszString = ReadAndAllocStringValue( pData, "string" );
							pCaption->m_flStartTime = pData->GetFloat( "start", 0.0 );
							pCaption->m_flDisplayTime = pData->GetFloat( "length", 3.0 );

							m_Captions.AddToTail( pCaption );

							// we have at least one caption to show
							bSuccess = true;
						}
					}
				}

				kvCaptions->deleteThis();
			}
		}
	}

	if ( bSuccess )
	{
		// sort the captions so we show them in the correct order (they're not necessarily in order in the .res file)
		m_Captions.Sort( CaptionsSort );
	}

	return bSuccess;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CSoundEmitterSystemBase::BaseInit()
{
	if ( m_SoundKeyValues.Count() > 0 )
	{
		BaseShutdown();
	}

	KeyValues *manifest = new KeyValues( MANIFEST_FILE );
	if ( manifest->LoadFromFile( filesystem, MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "precache_file" ) )
			{
				// Add and always precache
				AddSoundsFromFile( sub->GetString(), true );
				continue;
			}
			else if ( !Q_stricmp( sub->GetName(), "declare_file" ) )
			{
				// Add but don't precache
				AddSoundsFromFile( sub->GetString(), false );
				continue;
			}

			Warning( "CSoundEmitterSystemBase::BaseInit:  Manifest '%s' with bogus file type '%s', expecting 'declare_file' or 'precache_file'\n", 
				MANIFEST_FILE, sub->GetName() );
		}
	}
	else
	{
		Error( "Unable to load manifest file '%s'\n", MANIFEST_FILE );
	}


// Only print total once, on server
#if !defined( CLIENT_DLL )
	int missing = CheckForMissingWavFiles( false );

	if ( missing > 0 )
	{
		DevMsg( 1, "CSoundEmitterSystem:  Registered %i sounds ( %i missing .wav files referenced )\n",
			m_Sounds.Count(), missing );
	}
	else
	{
		DevMsg( 1, "CSoundEmitterSystem:  Registered %i sounds\n",
			m_Sounds.Count() );
	}
#endif

	return true;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *filename - 
//-----------------------------------------------------------------------------
void CSoundEmitterSystemBase::AddSoundsFromFile( const char *filename, bool precachealways )
{
	CSoundScriptFile sf;
	Assert( Q_strlen( filename ) < sizeof( sf.filename ) );
	Q_strncpy( sf.filename, filename, sizeof( sf.filename ) );
	sf.dirty = false;
	sf.precachealways = precachealways;

	int scriptindex = m_SoundKeyValues.AddToTail( sf );

	// Open the soundscape data file, and abort if we can't
	KeyValues *kv = new KeyValues( filename );

	if ( kv->LoadFromFile( filesystem, filename, "GAME" ) )
	{
		// parse out all of the top level sections and save their names
		KeyValues *pKeys = kv;
		while ( pKeys )
		{
			if ( pKeys->GetFirstSubKey() )
			{
				CSoundEntry entry;
				entry.m_bRemoved			= false;
				entry.m_nScriptFileIndex	= scriptindex;
				entry.m_bPrecacheAlways		= precachealways;

				int lookup = m_Sounds.Find( pKeys->GetName() );
				if ( lookup != m_Sounds.InvalidIndex() )
				{
					DevMsg( "CSoundEmitterSystem::AddSoundsFromFile(%s):  Entry %s duplicated, skipping\n", filename, pKeys->GetName() );
				}
				else
				{
					InitSoundInternalParameters( pKeys->GetName(), pKeys, entry.m_SoundParams );
					m_Sounds.Insert( pKeys->GetName(), entry );
				}
			}
			pKeys = pKeys->GetNextKey();
		}
	}
	else
	{
		Msg( "CSoundEmitterSystem::AddSoundsFromFile:  No such file %s\n", filename );

		// Discard
		m_SoundKeyValues.Remove( scriptindex );

		kv->deleteThis();
		return;
	}

	Assert( scriptindex >= 0 );
}
void CGECharacterDataParser::Parse( KeyValues *pKeyValuesData, const char *szFileWithoutEXT )
{
	CGECharData *pChar = g_GECharacters.Add( szFileWithoutEXT );

	Q_strncpy( pChar->szPrintName,	pKeyValuesData->GetString("printname",		"#GE_UNNAMED"),	MAX_CHAR_IDENT );
	Q_strncpy( pChar->szShortName,	pKeyValuesData->GetString("shortname",		"#GE_UNNAMED"),	MAX_CHAR_NAME  );
	Q_strncpy( pChar->szBio,		pKeyValuesData->GetString("bio",			""			 ),	MAX_CHAR_BIO   );

	// Load our weight
	pChar->iWeight = pKeyValuesData->GetInt( "weight" );

	// Affiliate them with a team
	const char *team = pKeyValuesData->GetString( "team", "unassigned" );
	if ( !Q_stricmp(team, "mi6") )
		pChar->iTeam = TEAM_MI6;
	else if ( !Q_stricmp(team, "janus") )
		pChar->iTeam = TEAM_JANUS;
	else
		pChar->iTeam = TEAM_UNASSIGNED;

	const char *gender = pKeyValuesData->GetString( "gender", "m" );
	if ( gender[0] == 'f' )
		pChar->iGender = CHAR_GENDER_FEMALE;
	else
		pChar->iGender = CHAR_GENDER_MALE;

	// Load our skins in
	KeyValues *pSkinValues = pKeyValuesData->FindKey( "skins" );
	if ( pSkinValues )
	{
		KeyValues *pSkinData = pSkinValues->GetFirstSubKey();
		for( int i=0; i < MAX_CHAR_SKINS; i++ )
		{
			if( pSkinData == NULL )
				break;

			GECharSkin *skin = new GECharSkin;

			Q_strncpy( skin->szIdent,		pSkinData->GetName(),								MAX_CHAR_IDENT );
			Q_strncpy( skin->szPreviewImg,	pSkinData->GetString("previewimg", "unknown"	 ),	MAX_CHAR_NAME  );
			Q_strncpy( skin->szModel,		pSkinData->GetString("model",	   ""			 ),	MAX_MODEL_PATH );
			Q_strncpy( skin->szHatModel,	pSkinData->GetString("hatmodel",   ""			 ),	MAX_MODEL_PATH );
			
			skin->iViewSkin	 = pSkinData->GetInt( "viewmodelskin",  0 );
			skin->iWorldSkin = pSkinData->GetInt( "worldmodelskin", 0 );

			// TODO: We need to error check this input....
			pChar->m_pSkins.AddToTail( skin );

			pSkinData = pSkinData->GetNextKey();
		}
	}
}
Ejemplo n.º 29
0
bool VMFExporter::IsDisplacementBrush( KeyValues *pSolidKeys )
{
    // go through each side
    for ( KeyValues *pKeys = pSolidKeys->GetFirstSubKey(); pKeys; pKeys = pKeys->GetNextKey() )
    {
        if ( !Q_stricmp( pKeys->GetName(), "side" ) && pKeys->FindKey( "dispinfo" ) )
        {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 30
0
//-----------------------------------------------------------------------------
// Clear out the stats + their history
//-----------------------------------------------------------------------------
void CPropData::ParsePropDataFile( void )
{
	m_pKVPropData = new KeyValues( "PropDatafile" );
	if ( !m_pKVPropData->LoadFromFile( filesystem, "scripts/propdata.txt" ) )
	{
		m_pKVPropData->deleteThis();
		m_pKVPropData = NULL;
		return;
	}

	m_bPropDataLoaded = true;

	// Now try and parse out the breakable section
	KeyValues *pBreakableSection = m_pKVPropData->FindKey( "BreakableModels" );
	if ( pBreakableSection )
	{
		KeyValues *pChunkSection = pBreakableSection->GetFirstSubKey();
		while ( pChunkSection )
		{
			// Create a new chunk section and add it to our list
			int index = m_BreakableChunks.AddToTail();
			propdata_breakablechunk_t *pBreakableChunk = &m_BreakableChunks[index];
			pBreakableChunk->iszChunkType = AllocPooledString( pChunkSection->GetName() );

			// Read in all the model names
			KeyValues *pModelName = pChunkSection->GetFirstSubKey();
			while ( pModelName )
			{
				const char *pModel = pModelName->GetName();
				string_t pooledName = AllocPooledString( pModel );
				pBreakableChunk->iszChunkModels.AddToTail( pooledName );
				CBaseEntity::PrecacheModel( STRING( pooledName ) );

				pModelName = pModelName->GetNextKey();
			}

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