//----------------------------------------------------------------------------- // 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 ); } } }
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey ) { if ( m_WeaponInfoDatabase.Count() ) return; KeyValues *manifest = new KeyValues( "weaponscripts" ); manifest->UsesEscapeSequences( true ); 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(); }
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(); } }
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(); }
bool VMFExporter::AddLevelContainer() { KeyValues *pLevelContainerKeys = new KeyValues( "LevelContainer" ); if ( !pLevelContainerKeys->LoadFromFile( g_pFullFileSystem, "tilegen/roomtemplates/levelcontainer.vmf.no_func_detail", "GAME" ) ) return false; m_bWritingLevelContainer = true; // set the extents of the map m_pMapLayout->GetExtents(m_iMapExtents_XMin, m_iMapExtents_XMax, m_iMapExtents_YMin, m_iMapExtents_YMax); Msg( "Layout extents: Topleft: %f %f - Lower right: %f %f\n", m_iMapExtents_XMin, m_iMapExtents_YMin, m_iMapExtents_XMax, m_iMapExtents_YMax ); // adjust to be relative to the centre of the map int half_map_size = MAP_LAYOUT_TILES_WIDE * 0.5f; m_iMapExtents_XMin -= half_map_size; m_iMapExtents_XMax -= half_map_size; m_iMapExtents_YMin -= half_map_size; m_iMapExtents_YMax -= half_map_size; // pad them by 2 blocks, so the player doesn't move his camera into the wall when at an edge block m_iMapExtents_XMin -= 2; m_iMapExtents_XMax += 2; m_iMapExtents_YMin -= 2; m_iMapExtents_YMax += 2; Msg( " Adjusted to: Topleft: %d %d - Lower right: %d %d\n", m_iMapExtents_XMin, m_iMapExtents_YMin, m_iMapExtents_XMax, m_iMapExtents_YMax ); // find world keys KeyValues *pWorldKeys = NULL; for ( KeyValues *pKeys = pLevelContainerKeys; pKeys; pKeys = pKeys->GetNextKey() ) { const char *szName = pKeys->GetName(); if ( !Q_stricmp( szName, "world" ) ) { pWorldKeys = pKeys; break; } } if ( !pWorldKeys || !ProcessWorld( pWorldKeys ) ) { Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to copy level container\n" ); return false; } m_bWritingLevelContainer = false; for ( KeyValues *pKeys = pWorldKeys->GetFirstSubKey(); pKeys; pKeys = pKeys->GetNextKey() ) { const char *szName = pKeys->GetName(); if ( !Q_stricmp( szName, "solid" ) ) { m_pExportWorldKeys->AddSubKey( pKeys->MakeCopy() ); } } pLevelContainerKeys->deleteThis(); m_pTemplateKeys->deleteThis(); m_pTemplateKeys = NULL; return true; }
bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show) { KeyValues *SubKey = NULL; int count = 0; cell_t players[] = {client}; #if SOURCE_ENGINE == SE_CSGO CCSUsrMsg_VGUIMenu *pMsg; if ((pMsg = (CCSUsrMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL) { return false; } #else bf_write *pBitBuf = NULL; if ((pBitBuf = g_UserMsgs.StartBitBufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL) { return false; } #endif if (data) { SubKey = data->GetFirstSubKey(); while (SubKey) { count++; SubKey = SubKey->GetNextKey(); } SubKey = data->GetFirstSubKey(); } #if SOURCE_ENGINE == SE_CSGO pMsg->set_name(name); pMsg->set_show(show); while (SubKey) { CCSUsrMsg_VGUIMenu_Subkey *key = pMsg->add_subkeys(); key->set_name(SubKey->GetName()); key->set_str(SubKey->GetString()); SubKey = SubKey->GetNextKey(); } #else pBitBuf->WriteString(name); pBitBuf->WriteByte((show) ? 1 : 0); pBitBuf->WriteByte(count); while (SubKey) { pBitBuf->WriteString(SubKey->GetName()); pBitBuf->WriteString(SubKey->GetString()); SubKey = SubKey->GetNextKey(); } #endif g_UserMsgs.EndMessage(); return true; }
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 }
//----------------------------------------------------------------------------- // 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 ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CMaterialSubRect::ParseMaterialVars( KeyValues &keyValues ) { KeyValues *pKeyValues = &keyValues; // I'm not quite sure how this can happen, but we'll see... const char *pShaderName = pKeyValues->GetName(); if ( !pShaderName ) { DevWarning( 1, "CMaterialSubRect::InitializeShader: Shader not specified in material %s.\n", GetName() ); Assert( 0 ); pShaderName = IsPC() ? "Wireframe_DX6" : "Wireframe_DX9"; } // Verify we have the correct "shader." There is only one type. if ( !Q_strcmp( pShaderName, "Subrect" ) ) { KeyValues *pVar = pKeyValues->GetFirstSubKey(); while ( pVar ) { if ( !Q_strcmp( pVar->GetName(), "$Pos" ) ) { sscanf( pVar->GetString(), "%f %f", &m_vecOffset.x, &m_vecOffset.y ); } if ( !Q_strcmp( pVar->GetName(), "$Size" ) ) { sscanf( pVar->GetString(), "%f %f", &m_vecSize.x, &m_vecSize.y ); } if ( !Q_strcmp( pVar->GetName(), "$Material" ) ) { m_pMaterialPage = static_cast<IMaterialInternal*>( MaterialSystem()->FindMaterial( pVar->GetString(), TEXTURE_GROUP_DECAL ) ); m_pMaterialPage = m_pMaterialPage->GetRealTimeVersion(); //always work with the realtime material internally } // if ( !Q_strcmp( pVar->GetName(), "$decalscale" ) ) // { // m_flDecalScale = pVar->GetFloat(); // } // Add var to list. IMaterialVar *pNewVar = CreateMaterialVarFromKeyValue( this, pVar ); if ( pNewVar ) { m_aMaterialVars.AddToTail( pNewVar ); } // Continue getting the keys until they are all found. pVar = pVar->GetNextKey(); } } }
bool CMapAdd::HandleRemoveEnitity( KeyValues *mapaddValue) { if(AllocPooledString(mapaddValue->GetName()) == AllocPooledString("remove:sphere")) { Vector RemoveVector = Vector(0,0,0); CBaseEntity *ppEnts[256]; // CBaseEntity *ppCandidates[256]; RemoveVector.x = mapaddValue->GetFloat("x", RemoveVector.x); RemoveVector.y = mapaddValue->GetFloat("y", RemoveVector.y); RemoveVector.z = mapaddValue->GetFloat("z", RemoveVector.z); int nEntCount = UTIL_EntitiesInSphere( ppEnts, 256, RemoveVector, mapaddValue->GetFloat("radius", 0), 0 ); //Look through the entities it found KeyValues *pEntKeyValues = mapaddValue->FindKey("entities"); if(pEntKeyValues) { KeyValues *pEntKeyValuesRemove = pEntKeyValues->GetFirstValue(); while(pEntKeyValuesRemove) { int i; for ( i = 0; i < nEntCount; i++ ) { if ( ppEnts[i] == NULL ) continue; if(AllocPooledString(pEntKeyValuesRemove->GetName()) == AllocPooledString("classname")) // || ( AllocPooledString(pEntKeyValuesRemove->GetName()) == ppEnts[i]->GetEntityName()) { if(AllocPooledString(pEntKeyValuesRemove->GetString()) == AllocPooledString(ppEnts[i]->GetClassname())) { UTIL_Remove(ppEnts[i]); continue; } } if(AllocPooledString(pEntKeyValuesRemove->GetName()) == AllocPooledString("targetname")) // || ( AllocPooledString(pEntKeyValuesRemove->GetName()) == ppEnts[i]->GetEntityName()) { if(AllocPooledString(pEntKeyValuesRemove->GetString()) == ppEnts[i]->GetEntityName()) { UTIL_Remove(ppEnts[i]); continue; } } } pEntKeyValuesRemove = pEntKeyValuesRemove->GetNextValue(); } } return true; } return false; }
void OverrideDefaultsForModel( const char *keyname, simplifyparams_t ¶ms ) { KeyValues *pKeys = g_pModelConfig; while ( pKeys ) { if ( !Q_stricmp( pKeys->GetName(), keyname ) ) { for ( KeyValues *pData = pKeys->GetFirstSubKey(); pData; pData = pData->GetNextKey() ) { if ( !Q_stricmp( pData->GetName(), "tolerance" ) ) { params.tolerance = pData->GetFloat(); if (!g_bQuiet) { Msg("%s: tolerance set to %.2f\n", keyname, params.tolerance ); } } else if ( !Q_stricmp( pData->GetName(), "addAABB" ) ) { params.addAABBToSimplifiedHull = pData->GetInt() ? true : false; if (!g_bQuiet) { Msg("%s: AABB %s\n", keyname, params.addAABBToSimplifiedHull ? "on" : "off" ); } } else if ( !Q_stricmp( pData->GetName(), "singleconvex" ) ) { params.forceSingleConvex = pData->GetInt() ? true : false; if (!g_bQuiet) { Msg("%s: Forced to single convex\n", keyname ); } } else if ( !Q_stricmp( pData->GetName(), "mergeconvex" ) ) { params.mergeConvexTolerance = pData->GetFloat(); params.mergeConvexElements = params.mergeConvexTolerance > 0 ? true : false; if (!g_bQuiet) { Msg("%s: Merge convex %.2f\n", keyname, params.mergeConvexTolerance ); } } } return; } pKeys = pKeys->GetNextKey(); } }
void BuildCheckdirList() { vprint( 0, "Checking for dirlist\n" ); // Search for unusedcontent.cfg file if ( g_pFileSystem->FileExists( UNUSEDCONTENT_CFG, "GAME") ) { KeyValues *kv = new KeyValues( UNUSEDCONTENT_CFG ); if ( kv ) { if ( kv->LoadFromFile( g_pFileSystem, UNUSEDCONTENT_CFG, "GAME" ) ) { for ( KeyValues *sub = kv->GetFirstSubKey(); sub; sub = sub->GetNextKey() ) { if ( !Q_stricmp( sub->GetName(), "dir" ) ) { AddCheckdir( sub->GetString() ); } else if ( !Q_stricmp( sub->GetName(), "ignore" ) ) { AddIgnoredir( sub->GetString() ); } else { vprint( 1, "Unknown subkey '%s' in %s\n", sub->GetName(), UNUSEDCONTENT_CFG ); } } } kv->deleteThis(); } } else { int c = ARRAYSIZE( directories_to_check ); int i; for ( i = 0; i < c; ++i ) { AddCheckdir( directories_to_check[ i ] ); } // add the list of dirs to ignore from the others lists c = ARRAYSIZE( directories_to_ignore ); for ( i = 0; i < c; ++i ) { AddIgnoredir( directories_to_ignore[ i ] ); } } }
// 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; }
// sets priority of objective entities based on the order the rooms were listed in the mission/objective txt void VMFExporter::ReorderObjectives( const CRoomTemplate *pTemplate, KeyValues *pTemplateKeys ) { KeyValues *pKeys = m_pTemplateKeys; while ( pKeys ) { if ( !Q_stricmp( pKeys->GetName(), "entity" ) && !Q_strnicmp( pKeys->GetString( "classname" ), "asw_objective", 13 ) ) { if ( pKeys->GetFloat( "Priority" ) != 0 ) // if level designer has already set priority, then don't override it { pKeys = pKeys->GetNextKey(); continue; } int iPriority = 100; // We no longer have a requested rooms array, so this code is not valid. Need to replace it with something else to ensure priorities are set correctly. // for ( int i = 0; i < m_pMapLayout->m_pRequestedRooms.Count(); i++ ) // { // if ( m_pMapLayout->m_pRequestedRooms[i]->m_pRoomTemplate == pTemplate ) // { // iPriority = m_pMapLayout->m_pRequestedRooms[i]->m_iMissionTextOrder; // } // } pKeys->SetFloat( "Priority", iPriority ); } pKeys = pKeys->GetNextKey(); } }
int CASW_Mission_Chooser_Source_Local::GetNumMissionsInCampaign( int iCampaignIndex ) { if (!m_bBuiltMapList) BuildMapList(); ASW_Mission_Chooser_Mission* pCampaign = GetCampaign( iCampaignIndex ); if ( !pCampaign ) return 0; KeyValues *pCampaignDetails = GetCampaignDetails( pCampaign->m_szMissionName ); if ( !pCampaignDetails ) return 0; CUtlVector<KeyValues*> aMissionKeys; bool bSkippedFirst = false; for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() ) { if ( !Q_stricmp( pMission->GetName(), "MISSION" ) ) { if ( !bSkippedFirst ) { bSkippedFirst = true; } else { aMissionKeys.AddToTail( pMission ); } } } return aMissionKeys.Count(); }
//----------------------------------------------------------------------------- // Main entry point for the unserialization //----------------------------------------------------------------------------- CDmElement* CImportActBusy::UnserializeFromKeyValues( KeyValues *pKeyValues ) { // Create the main element CDmElement *pElement = CreateDmElement( "DmElement", "ActBusyList", NULL ); if ( !pElement ) return NULL; // Each act busy list needs to have an editortype associated with it so it displays nicely in editors pElement->SetValue( "editorType", "actBusyList" ); // All actbusy keys are elements of a single element array attribute 'children' CDmAttribute *pChildren = pElement->AddAttribute( "children", AT_ELEMENT_ARRAY ); if ( !pChildren ) return NULL; // Under the root are all the actbusy keys for ( KeyValues *pActBusyKey = pKeyValues->GetFirstTrueSubKey(); pActBusyKey != NULL; pActBusyKey = pActBusyKey->GetNextTrueSubKey() ) { if ( !UnserializeActBusyKey( pChildren, pActBusyKey ) ) { Warning( "Error importing actbusy element %s\n", pActBusyKey->GetName() ); return NULL; } } // Resolve all element references recursively RecursivelyResolveElement( pElement ); return pElement; }
//----------------------------------------------------------------------------- // Parses the key-value pairs in the detail.vbsp file //----------------------------------------------------------------------------- static void ParseDetailObjectFile( KeyValues& keyValues ) { // Iterate over all detail object groups... KeyValues* pIter; for( pIter = keyValues.GetFirstSubKey(); pIter; pIter = pIter->GetNextKey() ) { if (!pIter->GetFirstSubKey()) continue; int i = s_DetailObjectDict.AddToTail( ); s_DetailObjectDict[i].m_Name = pIter->GetName() ; s_DetailObjectDict[i].m_Density = pIter->GetFloat( "density", 0.0f ); // Iterate over all detail object groups... KeyValues* pIterGroups = pIter->GetFirstSubKey(); while( pIterGroups ) { if (pIterGroups->GetFirstSubKey()) { ParseDetailGroup( i, pIterGroups ); } pIterGroups = pIterGroups->GetNextKey(); } } }
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(); } } }
//----------------------------------------------------------------------------- // Purpose: Load in the model portion of the panel's resource file. //----------------------------------------------------------------------------- void CBaseModelPanel::ApplySettings( KeyValues *inResourceData ) { BaseClass::ApplySettings( inResourceData ); // Set whether we render to texture m_bRenderToTexture = inResourceData->GetBool( "render_texture", true ); m_bUseParticle = inResourceData->GetBool( "use_particle", false ); // Grab and set the camera FOV. float flFOV = GetCameraFOV(); m_BMPResData.m_flFOV = inResourceData->GetInt( "fov", flFOV ); SetCameraFOV( m_BMPResData.m_flFOV ); // Do we allow rotation on these panels. m_bAllowRotation = inResourceData->GetBool( "allow_rot", false ); m_bAllowPitch = inResourceData->GetBool( "allow_pitch", false ); // Do we allow full manipulation on these panels. m_bAllowFullManipulation = inResourceData->GetBool( "allow_manip", false ); // Parse our resource file and apply all necessary updates to the MDL. for ( KeyValues *pData = inResourceData->GetFirstSubKey() ; pData != NULL ; pData = pData->GetNextKey() ) { if ( !Q_stricmp( pData->GetName(), "model" ) ) { ParseModelResInfo( pData ); } } SetMouseInputEnabled( m_bAllowFullManipulation || m_bAllowRotation || m_bAllowPitch ); }
//----------------------------------------------------------------------------- // 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(); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CModelPanel::OnAddAnimation( KeyValues *pData ) { if ( !pData ) return; CModelPanelModelAnimation *pAnimation = new CModelPanelModelAnimation; if ( pAnimation ) { pAnimation->m_pszName = ReadAndAllocStringValue( pData, "name" ); pAnimation->m_pszSequence = ReadAndAllocStringValue( pData, "sequence" ); pAnimation->m_pszActivity = ReadAndAllocStringValue( pData, "activity" ); pAnimation->m_bDefault = ( pData->GetInt( "default", 0 ) == 1 ); for ( KeyValues *pAnimData = pData->GetFirstSubKey(); pAnimData != NULL; pAnimData = pAnimData->GetNextKey() ) { if ( !Q_stricmp( pAnimData->GetName(), "pose_parameters" ) ) { pAnimation->m_pPoseParameters = pAnimData->MakeCopy(); } } m_pModelInfo->m_Animations.AddToTail( pAnimation ); if ( pAnimation->m_bDefault ) { m_iDefaultAnimation = m_pModelInfo->m_Animations.Find( pAnimation ); } } }
//----------------------------------------------------------------------------- // 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 ); } } } }
static cell_t smn_KvGetSectionName(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 *pSection = pStk->pCurRoot.front(); const char *name = pSection->GetName(); if (!name) { return 0; } pCtx->StringToLocalUTF8(params[2], params[3], name, NULL); return 1; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_TFHintManager::ResetDisplayStats( void ) { if ( !m_pkvHintDisplayStats ) { Assert( 0 ); return; } KeyValues *kv = m_pkvHintDisplayStats->GetFirstSubKey(); while ( kv ) { KeyValues *subKey = kv->GetFirstSubKey(); if ( subKey && stricmp( subKey->GetName(), "times_shown") ) { while ( subKey ) { subKey->SetString( "times_shown", "0" ); subKey = subKey->GetNextKey(); } } else { kv->SetString( "times_shown", "0" ); } kv = kv->GetNextKey(); } }
//----------------------------------------------------------------------------- // 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(); }
bool CASW_Location_Grid::LoadLocationGrid() { m_Groups.PurgeAndDeleteElements(); // open our mission grid file KeyValues *pGridKeys = new KeyValues( "MissionGrid" ); if ( !pGridKeys->LoadFromFile( g_pFullFileSystem, "resource/mission_grid.txt", "GAME" ) ) { Msg( "Failed to load resource/mission_grid.txt\n" ); pGridKeys->deleteThis(); return false; } KeyValues *pKeys = pGridKeys; while ( pKeys ) { if ( !Q_stricmp( pKeys->GetName(), "Group" ) ) { CASW_Location_Group *pGroup = new CASW_Location_Group( this ); pGroup->LoadFromKeyValues( pKeys ); m_Groups.AddToTail( pGroup ); } pKeys = pKeys->GetNextKey(); } return true; }
//----------------------------------------------------------------------------- // Purpose: adds all the font specifications to the surface //----------------------------------------------------------------------------- void CScheme::LoadFonts() { // add our custom fonts for (KeyValues *kv = m_pData->FindKey("CustomFontFiles", true)->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey()) { const char *fontFile = kv->GetString(); if (fontFile && *fontFile) { g_pSurface->AddCustomFontFile( fontFile ); } } // add bitmap fonts for (KeyValues *kv = m_pData->FindKey("BitmapFontFiles", true)->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey()) { const char *fontFile = kv->GetString(); if (fontFile && *fontFile) { bool bSuccess = g_pSurface->AddBitmapFontFile( fontFile ); if ( bSuccess ) { // refer to the font by a user specified symbol g_pSurface->SetBitmapFontName( kv->GetName(), fontFile ); } } } // create the fonts for (KeyValues *kv = m_pData->FindKey("Fonts", true)->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey()) { for ( int i = 0; i < 2; i++ ) { // create the base font bool proportionalFont = static_cast<bool>( i ); const char *fontName = GetMungedFontName( kv->GetName(), tag, proportionalFont ); // first time it adds a normal font, and then a proportional one HFont font = g_pSurface->CreateFont(); int j = m_FontAliases.AddToTail(); m_FontAliases[j]._fontName = fontName; m_FontAliases[j]._trueFontName = kv->GetName(); m_FontAliases[j]._font = font; m_FontAliases[j].m_bProportional = proportionalFont; } } // load in the font glyphs ReloadFontGlyphs(); }
//----------------------------------------------------------------------------- // Parse the metaclass list //----------------------------------------------------------------------------- bool CPanelMetaClassMgrImp::ParseMetaClassList( const char* pFileName, KeyValues* pKeyValues, int keyValueIdx ) { // Iterate over all metaclasses... KeyValues* pIter = pKeyValues->GetFirstSubKey(); while( pIter ) { if (!ParseSingleMetaClass( pFileName, pIter->GetName(), pIter, keyValueIdx )) { // return false; Warning( "MetaClass missing for %s\n", pIter->GetName() ); } pIter = pIter->GetNextKey(); } return true; }
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; }