MCPcopy Create free account
hub / github.com/Kenix3/libultraship / SFileAddInternalListFile

Function SFileAddInternalListFile

extern/StormLib/src/SFileListFile.cpp:562–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560}
561
562static DWORD SFileAddInternalListFile(
563 TMPQArchive * ha,
564 HANDLE hMpq)
565{
566 TMPQHash * pFirstHash;
567 TMPQHash * pHash;
568 LCID lcSaveLocale = g_lcFileLocale;
569 DWORD dwMaxSize = MAX_LISTFILE_SIZE;
570 DWORD dwErrCode = ERROR_SUCCESS;
571
572 // If there is hash table, we need to support multiple listfiles
573 // with different locales (BrooDat.mpq)
574 if(ha->pHashTable != NULL)
575 {
576 // If the archive is a malformed map, ignore too large listfiles
577 if(ha->dwFlags & MPQ_FLAG_MALFORMED)
578 dwMaxSize = 0x40000;
579
580 pFirstHash = pHash = GetFirstHashEntry(ha, LISTFILE_NAME);
581 while(dwErrCode == ERROR_SUCCESS && pHash != NULL)
582 {
583 // Set the prefered locale to that from list file
584 SFileSetLocale(SFILE_MAKE_LCID(pHash->Locale, pHash->Platform));
585
586 // Add that listfile
587 dwErrCode = SFileAddArbitraryListFile(ha, hMpq, NULL, dwMaxSize);
588
589 // Move to the next hash
590 pHash = GetNextHashEntry(ha, pFirstHash, pHash);
591 }
592
593 // Restore the original locale
594 SFileSetLocale(lcSaveLocale);
595 }
596 else
597 {
598 // Add the single listfile
599 dwErrCode = SFileAddArbitraryListFile(ha, hMpq, NULL, dwMaxSize);
600 }
601
602 // Return the result of the operation
603 return dwErrCode;
604}
605
606static bool DoListFileSearch(TListFileCache * pCache, SFILE_FIND_DATA * lpFindFileData)
607{

Callers 1

SFileAddListFileFunction · 0.85

Calls 4

GetFirstHashEntryFunction · 0.85
SFileSetLocaleFunction · 0.85
GetNextHashEntryFunction · 0.85

Tested by

no test coverage detected