Merge new archive manager with zip file support

This commit is contained in:
2025-04-12 08:26:17 +03:00
62 changed files with 924 additions and 4600 deletions

View File

@ -203,18 +203,31 @@ const char* ApplicationStringTable_GetStringz(DWORD dwID)
int Setup(LPSTR lpCmdLine); // Internal function forward
bool PackInitialize(const char * c_pszFolder)
bool PackInitialize(const std::string& packFolder)
{
NANOBEGIN
if (_access(c_pszFolder, 0) != 0)
if (_access(packFolder.c_str(), 0) != 0)
return true;
std::string stFolder(c_pszFolder);
stFolder += "/";
// Initialize variables
bool bPackFirst = true;
std::string stFolder = packFolder + "/";
std::string stFileName;
std::string stFileName(stFolder);
stFileName += "Index";
#ifdef _DISTRIBUTE
Tracef("Info: Pack search mode set to archive-first.\n");
// Set Index file name to production value
stFileName = stFolder + "Index";
#else
bPackFirst = false;
Tracef("Info: Pack search mode set to file-first.\n");
// Set Index file name to development value
stFileName = stFolder + "Index.dev";
#endif
// Set up file reader
CMappedFile file;
LPCVOID pvData;
@ -228,56 +241,43 @@ bool PackInitialize(const char * c_pszFolder)
CMemoryTextFileLoader TextLoader;
TextLoader.Bind(file.Size(), pvData);
bool bPackFirst = TRUE;
const std::string& strPackType = TextLoader.GetLineString(0);
if (strPackType.compare("FILE") && strPackType.compare("PACK"))
{
TraceError("Pack/Index has invalid syntax. First line must be 'PACK' or 'FILE'");
return false;
}
#ifdef _DISTRIBUTE
Tracef("You are in pack mode.\n");
//if (0 == strPackType.compare("FILE"))
//{
// bPackFirst = FALSE;
// Tracef("You are in file mode.\n");
//}
//else
//{
// Tracef("You are in pack mode.\n");
//}
#else
bPackFirst = FALSE;
Tracef("You are in file mode.\n");
#endif
// Set up archive manager
CTextFileLoader::SetCacheMode();
#if defined(USE_RELATIVE_PATH)
CEterPackManager::Instance().SetRelativePathMode();
#endif
CEterPackManager::Instance().SetCacheMode();
CEterPackManager::Instance().SetSearchMode(bPackFirst);
CSoundData::SetPackMode(); // Miles 파일 콜백을 셋팅
// Read lines and parse tokens
std::string strPackName, strTexCachePackName;
for (DWORD i = 1; i < TextLoader.GetLineCount() - 1; i += 2)
CTokenVector tokens = CTokenVector();
for (DWORD i = 0; i < TextLoader.GetLineCount() - 1; i++)
{
const std::string & c_rstFolder = TextLoader.GetLineString(i);
const std::string & c_rstName = TextLoader.GetLineString(i + 1);
// Split line into tokens
TextLoader.SplitLineByTab(i, &tokens);
// Check if the read number of tokens is valid
if (tokens.size() != 2)
{
TraceError("Invalid number of tokens on line %d: expected %d, got %d!", i, 2, tokens.size());
return false;
}
// Assign tokens into variables
const std::string& c_rstName = tokens[0];
const std::string& c_rstContainer = tokens[1];
// Load pack
strPackName = stFolder + c_rstName;
strTexCachePackName = strPackName + "_texcache";
CEterPackManager::Instance().RegisterPack(strPackName, c_rstContainer);
CEterPackManager::Instance().RegisterPack(strPackName.c_str(), c_rstFolder.c_str());
CEterPackManager::Instance().RegisterPack(strTexCachePackName.c_str(), c_rstFolder.c_str());
// Try to load texture cache pack if it exists
strTexCachePackName = strPackName + "_texcache";
if (CEterPackManager::Instance().PackExists(strTexCachePackName, c_rstContainer)) {
CEterPackManager::Instance().RegisterPack(strTexCachePackName, c_rstContainer);
}
}
CEterPackManager::Instance().RegisterRootPack((stFolder + std::string("root")).c_str());
NANOEND
return true;
}