static LPCSTR Skins_Parse(string strThisSkinFileName, CGPGroup *pFileGroup, CGPGroup *pParseGroup_Prefs) { LPCSTR psError = NULL; // read any optional surface on/off blocks... // for (int iSurfaceOnOffType = 0; iSurfaceOnOffType<3; iSurfaceOnOffType++) { CGPGroup *pSurfaceParseGroup = NULL; switch (iSurfaceOnOffType) { case 0: pSurfaceParseGroup = pParseGroup_Prefs->FindSubGroup(sSKINKEYWORD_SURFACES_ON); break; case 1: pSurfaceParseGroup = pParseGroup_Prefs->FindSubGroup(sSKINKEYWORD_SURFACES_OFF); break; case 2: pSurfaceParseGroup = pParseGroup_Prefs->FindSubGroup(sSKINKEYWORD_SURFACES_OFFNOCHILDREN); break; default: assert(0); break; } if (pSurfaceParseGroup) { CGPValue *pValue = pSurfaceParseGroup->GetPairs(); while (pValue) { // string str1 = (*it).first; // junk, eg "name1" string str2 = pValue->GetTopValue(); switch (iSurfaceOnOffType) { case 0: CurrentSkinsSurfacePrefs[strThisSkinFileName].vSurfacesOn.push_back(str2); break; case 1: CurrentSkinsSurfacePrefs[strThisSkinFileName].vSurfacesOff.push_back(str2); break; case 2: CurrentSkinsSurfacePrefs[strThisSkinFileName].vSurfacesOffNoChildren.push_back(str2); break; default: assert(0); break; } pValue = pValue->GetNext(); } } } // find all the materials and add them to the skin set... // int iMaterialDeclarationIndex = 0; for (CGPGroup *pMaterialGroup = pFileGroup->GetSubGroups(); pMaterialGroup; pMaterialGroup = pMaterialGroup->GetNext(), iMaterialDeclarationIndex++) { string strKeyWord = pMaterialGroup->GetName(); if (strKeyWord == sSKINKEYWORD_MATERIAL) { string strMaterialName(pMaterialGroup->FindPairValue(sSKINKEYWORD_NAME,"")); if (strMaterialName == "") { psError = va("%s[%d] had no \"%s\" field!\n",sSKINKEYWORD_MATERIAL, iMaterialDeclarationIndex, sSKINKEYWORD_NAME); return psError; } // now iterate through the ethnic group variants of this material... // int iEthnicGroupIndex = 0; for (CGPGroup *pEthnicGroup = pMaterialGroup->GetSubGroups(); pEthnicGroup; pEthnicGroup = pEthnicGroup->GetNext(), iEthnicGroupIndex++) { strKeyWord = pEthnicGroup->GetName(); if (strKeyWord == sSKINKEYWORD_GROUP) { string strEthnicGroupName(pEthnicGroup->FindPairValue(sSKINKEYWORD_NAME,"")); if (strEthnicGroupName == "") { psError = va("%s[%d] %s[%d] had no \"%s\" field!\n",sSKINKEYWORD_MATERIAL, iMaterialDeclarationIndex, sSKINKEYWORD_GROUP, iEthnicGroupIndex, sSKINKEYWORD_NAME); return psError; } // now iterate through the shader variants for this ethnic version of this material... (is anyone reading this...?) // int iAlternateShaderIndex = 0; for (CGPValue *pValue = pEthnicGroup->GetPairs(); pValue; pValue = pValue->GetNext()) { string strField(pValue->GetName()); if (strField != sSKINKEYWORD_NAME) { // ... then it should be a shader... // string strShader(pValue->GetTopValue()); CurrentSkins[strThisSkinFileName][strEthnicGroupName][strMaterialName].push_back(strShader); } } } } } } return psError; }
/************************************************************************************************ * CRMInstanceFile::CreateInstance * Creates an instance (to be freed by caller) using the given instance name. * * inputs: * name: Name of the instance to read from the instance file * * return: * NULL: instance could not be read from the instance file * NON-NULL: instance created and returned for further use * ************************************************************************************************/ CRMInstance* CRMInstanceFile::CreateInstance ( const char* name ) { static int instanceID = 0; CGPGroup* group; CRMInstance* instance; // Make sure we were loaded assert ( mInstances ); // Search through the instances for the one with the given name for ( group = mInstances; group; group = group->GetNext ( ) ) { // Skip it if the name doesnt match if ( stricmp ( name, group->FindPairValue ( "name", "" ) ) ) { continue; } // Handle the various forms of instance types if ( !stricmp ( group->GetName ( ), "bsp" ) ) { instance = new CRMBSPInstance ( group, *this ); } else if ( !stricmp ( group->GetName ( ), "npc" ) ) { // instance = new CRMNPCInstance ( group, *this ); continue; } else if ( !stricmp ( group->GetName ( ), "group" ) ) { instance = new CRMGroupInstance ( group, *this ); } else if ( !stricmp ( group->GetName ( ), "random" ) ) { instance = new CRMRandomInstance ( group, *this ); } else if ( !stricmp ( group->GetName ( ), "void" ) ) { instance = new CRMVoidInstance ( group, *this ); } else { continue; } // If the instance isnt valid after being created then delete it if ( !instance->IsValid ( ) ) { delete instance; return NULL; } // The instance was successfully created so return it return instance; } #ifndef FINAL_BUILD // The instance wasnt found in the file so report it Com_Printf(va("WARNING: Instance '%s' was not found in the active instance file\n", name )); #endif return NULL; }