/*========================================================================= * * Banks.c - Bank conversion * * Version 1.0 * Revision date * *=======================================================================*/ #include #include #include "Banks.h" #include "SCR.h" #include "conventi.h" #include "main.h" #include "print.h" #include "system.h" #include "sprobj.h" #include "ModLib.h" #include "PlgLoad.h" #include "A3dSave.h" #include "ChlSave.h" #include "ModSave.h" #include "ObjSave.h" #include "RliSave.h" #include "VseSave.h" #include "Anims.h" #include "Levels.h" #include "Families.h" #include "SaveModifLst.h" //--- Global externs -------------------------------------------------------- MLT_tdxHandleToSuperObject g_hBankRoot; //--- Global statics -------------------------------------------------------- char gs_szFilesCommon[10][5]; //-------------------------------------------------------------------- /**************************************************************************** * Description: compute all the banks found in the source directory * * Parameters: sRawData : source directory * sGameData : destination directory *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vComputeAllBanks(char *sRawData, char *sGameData) { xString sDirectory; HANDLE hHandle; WIN32_FIND_DATA stFindFileData; // change directory GetCurrentDirectory(256, sDirectory); SetCurrentDirectory(sRawData); // search all the banks files memset(&stFindFileData,0,sizeof(stFindFileData)); hHandle = FindFirstFile("World\\Graphics\\Objects\\Banks\\*.mod", &stFindFileData); if( hHandle == INVALID_HANDLE_VALUE) { SetCurrentDirectory(sDirectory); fprintf(stderr, "\nError : Can't find the Banks directory\n"); return; } do { if(strlen(stFindFileData.cFileName) == 0) break; // compute the bank MLT_vComputeOneMod(MLT_p_cGetFileNameWithoutExt(stFindFileData.cFileName), MLT_p_cGetFileNameWithoutExt(stFindFileData.cFileName), sRawData, sGameData); } while(FindNextFile(hHandle, &stFindFileData)); FindClose(hHandle); // restore directory SetCurrentDirectory(sDirectory); } /**************************************************************************** * Description: compute the specified bank * * Parameters: sBankName : bank to convert * sRawData : source directory * sGameData : destination directory *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vComputeOneBank (char *sBankName, char *sRawData, char *sGameData) { // WIN version #ifndef _WINDOWS xString sDirectory, sFileSearch; HANDLE hHandle; WIN32_FIND_DATA stFindFileData; // change directory GetCurrentDirectory(256, sDirectory); // search for the bank file if (g_bStandardConfig) { SetCurrentDirectory(sRawData); sprintf(sFileSearch, "World\\Graphics\\Objects\\Banks\\%s.mod", sBankName); } else sprintf(sFileSearch, "%s\\%s.mod", g_szBanks, sBankName); memset(&stFindFileData,0,sizeof(stFindFileData)); hHandle = FindFirstFile(sFileSearch, &stFindFileData); if( hHandle == INVALID_HANDLE_VALUE) { SetCurrentDirectory(sDirectory); fprintf(stderr, "\nError : Can't find %s bank\n", sBankName); return; } do { if(strlen(stFindFileData.cFileName) == 0) break; // compute the MOD file MLT_vComputeOneMod(MLT_p_cGetFileNameWithoutExt(stFindFileData.cFileName), MLT_p_cGetFileNameWithoutExt(stFindFileData.cFileName), sRawData, sGameData); } while(FindNextFile(hHandle, &stFindFileData)); FindClose(hHandle); // restore directory SetCurrentDirectory(sDirectory); // DOS version #else MLT_vComputeOneMod (sBankName, sBankName, sRawData, sGameData); #endif } /**************************************************************************** * Description: compute the MOD file in the specified bank * * Parameters: sBankName : bank to convert * sModName : file to convert * sRawData : source directory * sGameData : destination directory *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vComputeOneMod (char *sBankName, char *sModName, char *sRawData, char *sGameData) { SCR_tdst_Cxt_Values *p_stVal; xString sRawBank, sGameBank, sRawFamily, sRawAnims, sRead; xString sFile, sFileM, sFile1, sFileNew; xString sRoot, sFileSpo, sDir; FILE *file, *fileR, *fileF; int f, i, ii, p, jj, j = 0, k = 0, k1 = 0, l = 0; // register globals sprintf(g_sFileIn, "%s", sModName); sprintf(g_sFileMaterial, "%s", sBankName); sprintf(g_sDirectorySave, "%s\\", sBankName); // init paths if (g_bStandardConfig) { sprintf(sRawBank, "%s\\World\\Graphics\\Objects\\Banks", sRawData); sprintf(sRawAnims, "%s\\World\\Graphics\\Anims", sRawData); sprintf(sRawFamily, "%s\\World\\Families", sRawData); } else { sprintf(sRawBank, g_szBanks); sprintf(sRawAnims, g_szAnims); sprintf(sRawFamily, g_szFamilies); } sprintf(sGameBank, "%s\\World\\Graphics\\Objects\\Banks\\%s\\", sGameData, sBankName); // DISPLAY MLT_vOutput( C_ComRes_cTitleLine, "\nBank %s\\%s.mod",sBankName, sModName); // change directory CreateDirectory(sGameBank, NULL); SetCurrentDirectory(sGameBank); // notify OBJ file, CHL file and A3d file sprintf(sFile, "%s\\%s.spo", sRawBank, sBankName); fileF = fopen (sFile, "r"); //create the basic family if the .spo file exists if (g_bCreateBasicFamily && fileF) { if (g_bStandardConfig) { MLT_vExistFile (sBankName, sRawData, "\\world\\families\\", "obj", &j); MLT_vExistFile (sBankName, sRawData, "\\world\\families\\", "chl", &j); } else { MLT_vExistFileInBank (sBankName, g_szFamilies, "obj", &j); MLT_vExistFileInBank (sBankName, g_szFamilies, "chl", &j); } //the source files for a family exist in RawData directory, so convert them if (j == 2) MLT_vOutput( C_ComRes_cNormalLine, "\nA source family already exists for this bank : the Converting Tool will convert this existing family instead of creating a new one."); // find the common extensions for the family MLT_vGetCommonExt(&jj); // test if at least one common file for a family exist in the GameData directory MLT_vExistFile (sBankName, g_sGameCommon, "\\world\\levels\\_common\\families\\", gs_szFilesCommon[0], &k); if (k) { // check if all te common files exist for the family for (p=1; p