LTBOOL SOUNDFILTER::Init(CButeMgr & buteMgr, char* aTagName) { if (!aTagName) return LTFALSE; CString str = buteMgr.GetString(aTagName, SFM_NAME); if (!str.IsEmpty()) { strncpy(szName, (char*)(LPCSTR)str, ARRAY_LEN(szName)); } str = buteMgr.GetString(aTagName, SFM_FILTERNAME); if (!str.IsEmpty()) { strncpy(szFilterName, (char*)(LPCSTR)str, ARRAY_LEN(szFilterName)); } int i; for (i=0; i < SFM_MAX_VARIABLES; i++) { sprintf(s_aAttName, "%s%d", SFM_VARIABLE, i); if (buteMgr.Exist(aTagName, s_aAttName)) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szVars[i], (char*)(LPCSTR)str, ARRAY_LEN(szVars[i])); } nNumVars++; } } int nNumValues = 0; for (i=0; i < SFM_MAX_VARIABLES; i++) { sprintf(s_aAttName, "%s%d", SFM_VALUE, i); if (buteMgr.Exist(aTagName, s_aAttName)) { fValues[i] = (LTFLOAT) buteMgr.GetDouble(aTagName, s_aAttName); nNumValues++; } } if (nNumVars != nNumValues) { _ASSERT(LTFALSE); return LTFALSE; } return LTTRUE; }
LTBOOL BuildPolyDebrisFXList(PolyDebrisFXList & list, CButeMgr & buteMgr, char* pTagBase) { if (!pTagBase) return LTFALSE; int nNum = 0; sprintf(s_aTagName, "%s%d", pTagBase, nNum); // Read in the properties for each scale fx... while (buteMgr.Exist(s_aTagName)) { CPolyDebrisFX* pFX = debug_new(CPolyDebrisFX); if (pFX && pFX->Init(buteMgr, s_aTagName)) { pFX->nId = nNum; list.AddTail(pFX); } else { debug_delete(pFX); return LTFALSE; } nNum++; sprintf(s_aTagName, "%s%d", pTagBase, nNum); } return LTTRUE; }
// Add the class properties to the bute file void AddClassProperties(ClassDef *pClass, CString sTagName, BOOL &bClassAdded, CButeMgr &buteMgr) { if (!pClass) { ASSERT(FALSE); return; } // Go through each property int i; for (i=0; i < pClass->m_nProps; i++) { // Get the property PropDef *pProperty=&pClass->m_Props[i]; // Skip hidden properties if (pProperty->m_PropFlags & PF_HIDDEN) { continue; } // Get the property name char *lpszPropName=pProperty->m_PropName; // Check to see if the property help already exists if (!buteMgr.Exist(sTagName, lpszPropName)) { // Add the property buteMgr.SetString(sTagName, lpszPropName, ""); // Display that this was added if (!bClassAdded) { printf("\r\n[%s]\r\n", sTagName); bClassAdded=TRUE; } printf("%s\r\n", lpszPropName); } } }
LTBOOL SURFACE::Init(CButeMgr & buteMgr, char* aTagName) { if (!aTagName) return LTFALSE; eType = (SurfaceType) buteMgr.GetInt(aTagName, SRFMGR_SURFACE_ID); bShowsMark = (LTBOOL) buteMgr.GetInt(aTagName, SRFMGR_SURFACE_SHOWSMARK); bCanSeeThrough = (LTBOOL) buteMgr.GetInt(aTagName, SRFMGR_SURFACE_CANSEETHROUGH); bCanShootThrough = (LTBOOL) buteMgr.GetInt(aTagName, SRFMGR_SURFACE_CANSHOOTTHROUGH); bShowBreath = (LTBOOL) buteMgr.GetInt(aTagName, SRFMGR_SURFACE_SHOWBREATH); nMaxShootThroughPerturb = buteMgr.GetInt(aTagName, SRFMGR_SURFACE_MAXSHOOTTHROUGHPERTURB); nMaxShootThroughThickness= buteMgr.GetInt(aTagName, SRFMGR_SURFACE_MAXSHOOTTHROUGHTHICKNESS); fDeathNoiseModifier = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_DEATHNOISEMOD); fMovementNoiseModifier = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_MOVENOISEMOD); fImpactNoiseModifier = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_IMPACTNOISEMOD); fBodyFallSndRadius = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_BODYFALLSNDRADIUS); fBodyLedgeFallSndRadius = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_BODYLEDGEFALLSNDRADIUS); fBulletHoleMinScale = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_BULLETHOLEMINSCALE); fBulletHoleMaxScale = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_BULLETHOLEMAXSCALE); fBulletRangeDampen = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_BULLETRANGEDAMPEN); fBulletDamageDampen = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_BULLETDAMAGEDAMPEN); fActivationSndRadius = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_ACTIVATIONSNDRADIUS); fShellSndRadius = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_SHELLSNDRADIUS); fGrenadeSndRadius = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_GRENADESNDRADIUS); fHardness = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_HARDNESS); fFootPrintLifetime = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_FOOTPRINTLIFETIME); fMotoVelMult = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_MOTOVELMULTIPLIER); fSnowVelMult = (LTFLOAT) buteMgr.GetDouble(aTagName, SRFMGR_SURFACE_SNOWVELMULTIPLIER); bMagnetic = (LTBOOL) buteMgr.GetInt(aTagName, SRFMGR_SURFACE_MAGNETIC); vFootPrintScale = buteMgr.GetVector(aTagName, SRFMGR_SURFACE_FOOTPRINTSCALE); CString str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_NAME); if (!str.IsEmpty()) { strncpy(szName, (char*)(LPCSTR)str, ARRAY_LEN(szName)); } str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_BULLETHOLESPR); if (!str.IsEmpty()) { strncpy(szBulletHoleSpr, (char*)(LPCSTR)str, ARRAY_LEN(szBulletHoleSpr)); } str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_RTFOOTPRINTSPR); if (!str.IsEmpty()) { strncpy(szRtFootPrintSpr, (char*)(LPCSTR)str, ARRAY_LEN(szRtFootPrintSpr)); } str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_LTFOOTPRINTSPR); if (!str.IsEmpty()) { strncpy(szLtFootPrintSpr, (char*)(LPCSTR)str, ARRAY_LEN(szLtFootPrintSpr)); } int i; for (i=1; i <= SRF_MAX_FOOTSTEP_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_RTFOOTSND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szRtFootStepSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szRtFootStepSnds[i-1])); } } for (i=1; i <= SRF_MAX_FOOTSTEP_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_LTFOOTSND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szLtFootStepSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szLtFootStepSnds[i-1])); } } for (i=1; i <= SRF_MAX_MOTORCYCLE_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_MOTORCYCLESND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szMotorcycleSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szMotorcycleSnds[i-1])); } } for (i=1; i <= SRF_MAX_SNOWMOBILE_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_SNOWMOBILESND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szSnowmobileSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szSnowmobileSnds[i-1])); } } str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_BODYFALLSND); if (!str.IsEmpty()) { strncpy(szBodyFallSnd, (char*)(LPCSTR)str, ARRAY_LEN(szBodyFallSnd)); } str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_BODYLEDGEFALLSND); if (!str.IsEmpty()) { strncpy(szBodyLedgeFallSnd, (char*)(LPCSTR)str, ARRAY_LEN(szBodyLedgeFallSnd)); } str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_ACTIVATIONSND); if (!str.IsEmpty()) { strncpy(szActivationSnd, (char*)(LPCSTR)str, ARRAY_LEN(szActivationSnd)); } str = buteMgr.GetString(aTagName, SRFMGR_SURFACE_GRENADEIMPACTSND); if (!str.IsEmpty()) { strncpy(szGrenadeImpactSnd, (char*)(LPCSTR)str, ARRAY_LEN(szGrenadeImpactSnd)); } for (i=1; i <= SRF_MAX_IMPACT_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_BULLETIMPACTSND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szBulletImpactSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szBulletImpactSnds[i-1])); } } for (i=1; i <= SRF_MAX_IMPACT_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_PROJIMPACTSND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szProjectileImpactSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szProjectileImpactSnds[i-1])); } } for (i=1; i <= SRF_MAX_IMPACT_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_MELEEIMPACTSND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szMeleeImpactSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szMeleeImpactSnds[i-1])); } } for (i=1; i <= SRF_MAX_SHELL_SNDS; i++) { sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_SHELLIMPACTSND, i); str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { strncpy(szShellImpactSnds[i-1], (char*)(LPCSTR)str, ARRAY_LEN(szShellImpactSnds[i-1])); } } // Impact specific scale fx... // Build our impact scale fx id list... nNumImpactScaleFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_IMPACTSCALENAME, nNumImpactScaleFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumImpactScaleFX < SRF_MAX_IMPACT_SCALEFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CScaleFX* pScaleFX = g_pFXButeMgr->GetScaleFX((char*)(LPCSTR)str); if (pScaleFX) { aImpactScaleFXIds[nNumImpactScaleFX] = pScaleFX->nId; } } nNumImpactScaleFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_IMPACTSCALENAME, nNumImpactScaleFX); } // Build our impact particle shower fx id list... nNumImpactPShowerFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_IMPACTPSHOWERNAME, nNumImpactPShowerFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumImpactPShowerFX < SRF_MAX_IMPACT_PSHOWERFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CPShowerFX* pPShowerFX = g_pFXButeMgr->GetPShowerFX((char*)(LPCSTR)str); if (pPShowerFX) { aImpactPShowerFXIds[nNumImpactPShowerFX] = pPShowerFX->nId; } } nNumImpactPShowerFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_IMPACTPSHOWERNAME, nNumImpactPShowerFX); } // Build our impact poly debris fx id list... nNumImpactPolyDebrisFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_IMPACTPOLYDEBRISNAME, nNumImpactPolyDebrisFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumImpactPolyDebrisFX < SRF_MAX_IMPACT_PSHOWERFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CPolyDebrisFX* pPolyDebrisFX = g_pFXButeMgr->GetPolyDebrisFX((char*)(LPCSTR)str); if (pPolyDebrisFX) { aImpactPolyDebrisFXIds[nNumImpactPolyDebrisFX] = pPolyDebrisFX->nId; } } nNumImpactPolyDebrisFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_IMPACTPOLYDEBRISNAME, nNumImpactPolyDebrisFX); } // Build our under water impact particle shower fx id list... nNumUWImpactPShowerFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_UWIMPACTPSHOWERNAME, nNumUWImpactPShowerFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumUWImpactPShowerFX < SRF_MAX_IMPACT_PSHOWERFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CPShowerFX* pPShowerFX = g_pFXButeMgr->GetPShowerFX((char*)(LPCSTR)str); if (pPShowerFX) { aUWImpactPShowerFXIds[nNumUWImpactPShowerFX] = pPShowerFX->nId; } } nNumUWImpactPShowerFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_UWIMPACTPSHOWERNAME, nNumUWImpactPShowerFX); } // Exit specific scale fx... // Build our exit scale fx id list... nNumExitScaleFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_EXITSCALENAME, nNumExitScaleFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumExitScaleFX < SRF_MAX_IMPACT_SCALEFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CScaleFX* pScaleFX = g_pFXButeMgr->GetScaleFX((char*)(LPCSTR)str); if (pScaleFX) { aExitScaleFXIds[nNumExitScaleFX] = pScaleFX->nId; } } nNumExitScaleFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_EXITSCALENAME, nNumExitScaleFX); } // Build our exit particle shower fx id list... nNumExitPShowerFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_EXITPSHOWERNAME, nNumExitPShowerFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumExitPShowerFX < SRF_MAX_IMPACT_PSHOWERFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CPShowerFX* pPShowerFX = g_pFXButeMgr->GetPShowerFX((char*)(LPCSTR)str); if (pPShowerFX) { aExitPShowerFXIds[nNumExitPShowerFX] = pPShowerFX->nId; } } nNumExitPShowerFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_EXITPSHOWERNAME, nNumExitPShowerFX); } // Build our exit poly debris fx id list... nNumExitPolyDebrisFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_EXITPOLYDEBRISNAME, nNumExitPolyDebrisFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumExitPolyDebrisFX < SRF_MAX_IMPACT_PSHOWERFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CPolyDebrisFX* pPolyDebrisFX = g_pFXButeMgr->GetPolyDebrisFX((char*)(LPCSTR)str); if (pPolyDebrisFX) { aExitPolyDebrisFXIds[nNumExitPolyDebrisFX] = pPolyDebrisFX->nId; } } nNumExitPolyDebrisFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_EXITPOLYDEBRISNAME, nNumExitPolyDebrisFX); } // Build our under water exit particle shower fx id list... nNumUWExitPShowerFX = 0; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_UWIMPACTPSHOWERNAME, nNumUWExitPShowerFX); while (buteMgr.Exist(aTagName, s_aAttName) && nNumUWExitPShowerFX < SRF_MAX_IMPACT_PSHOWERFX) { str = buteMgr.GetString(aTagName, s_aAttName); if (!str.IsEmpty()) { CPShowerFX* pPShowerFX = g_pFXButeMgr->GetPShowerFX((char*)(LPCSTR)str); if (pPShowerFX) { aUWExitPShowerFXIds[nNumUWExitPShowerFX] = pPShowerFX->nId; } } nNumUWExitPShowerFX++; sprintf(s_aAttName, "%s%d", SRFMGR_SURFACE_UWIMPACTPSHOWERNAME, nNumUWExitPShowerFX); } return LTTRUE; }
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { if (!TdGuard::Aegis::GetSingleton().Init() || !TdGuard::Aegis::GetSingleton().DoWork()) { return 1; } int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs printf("Fatal Error: MFC initialization failed\r\n"); return 1; } if (argc < 3) { printf("Property Help Generator\r\nSyntax: PropHelpGen <object file> <output bute file>\r\n"); return 1; } // The class module and bute filename char *lpszModule=argv[1]; char *lpszButeFilename=argv[2]; // Check to see if the file exists if (_access(lpszModule, 0) != 0) { printf("Error: File %s not found\r\n", lpszModule); return 1; } // Load the object file HCLASSMODULE hModule; int nVersion; int nStatus = cb_LoadModule(lpszModule, NULL, &hModule, &nVersion); // Handle any errors switch (nStatus) { case CB_NOERROR: { break; } case CB_CANTFINDMODULE: { printf("Error: Cannot load module %s\r\n", lpszModule); return 1; } case CB_NOTCLASSMODULE: { printf("Error: Cannot get ObjectDllSetup function\r\n"); return 1; } case CB_VERSIONMISMATCH: { printf("Error: Server/Object version mismatch\r\n"); return 1; } } // If the file does not exist, then create the file if (_access(lpszButeFilename, 0) != 0) { CFile file; if (!file.Open(lpszButeFilename, CFile::modeCreate | CFile::modeNoTruncate)) { printf("Error: Unable to open the file: %s\r\n", lpszButeFilename); return 1; } file.Close(); } // Initialize ButeMgr CButeMgr buteMgr; buteMgr.Init(MessageDisplay); // Parse the file if (!buteMgr.Parse(lpszButeFilename)) { return 1; } // Indicate that properties are being added printf("Adding properties...\r\n"); // Get the classes int nClasses=cb_GetNumClassDefs(hModule); ClassDef **pClasses=cb_GetClassDefs(hModule); // Go through each class int i; for (i=0; i < nClasses; i++) { // This turns to TRUE once a property for this class has been added BOOL bClassAdded=FALSE; // Get the class name const char *lpszClassName=pClasses[i]->m_ClassName; CString sTagName; sTagName.Format("%s", lpszClassName); // Check to see if the description exists if (!buteMgr.Exist(sTagName, "ClassDescription")) { // Add the description buteMgr.SetString(sTagName, "ClassDescription", ""); // Display that this was added if (!bClassAdded) { printf("\r\n[%s]\r\n", sTagName); bClassAdded=TRUE; } printf("ClassDescription\r\n"); } // Add the properties AddClassProperties(pClasses[i], sTagName, bClassAdded, buteMgr); } // Get the tags in the bute file CStringArray tagArray; buteMgr.GetTags(GetTagsCallback, (void *)&tagArray); // This indicates if the old tag header has been printed BOOL bOldTagHeader=FALSE; // Find the classes that are in the bute file but aren't in the object.lto file for (i=0; i < tagArray.GetSize(); i++) { BOOL bFound=FALSE; // Search the classes int n; for (n=0; n < nClasses; n++) { if (tagArray[i] == pClasses[n]->m_ClassName) { bFound=TRUE; break; } } // Print out the name if it hasn't been found if (!bFound) { // Print the old tag header if needed if (!bOldTagHeader) { printf("\r\nThese classes do not exist in the object.lto file:\r\n"); bOldTagHeader=TRUE; } printf("%s\r\n", tagArray[i]); } } // Save the bute file buteMgr.Save(); printf("\r\nSuccess!\r\n"); return 0; }