diff options
| author | Ladislav Zezula <ladislav.zezula@avast.com> | 2021-05-17 10:04:06 +0200 | 
|---|---|---|
| committer | Ladislav Zezula <ladislav.zezula@avast.com> | 2021-05-17 10:04:06 +0200 | 
| commit | a3332c7c9bc36f13aace6543ebc719f833882dfc (patch) | |
| tree | 6f785736f3b5a61bcf162b15181c5fab92ccf24d /src/SFileOpenArchive.cpp | |
| parent | a7ebfbccb7eb16f4852a7fd3bd6a738ecb7db423 (diff) | |
nError -> dwErrCode
Diffstat (limited to 'src/SFileOpenArchive.cpp')
| -rw-r--r-- | src/SFileOpenArchive.cpp | 98 | 
1 files changed, 49 insertions, 49 deletions
diff --git a/src/SFileOpenArchive.cpp b/src/SFileOpenArchive.cpp index cda8140..ea29850 100644 --- a/src/SFileOpenArchive.cpp +++ b/src/SFileOpenArchive.cpp @@ -96,7 +96,7 @@ static TMPQUserData * IsValidMpqUserData(ULONGLONG ByteOffset, ULONGLONG FileSiz  }  // This function gets the right positions of the hash table and the block table. -static int VerifyMpqTablePositions(TMPQArchive * ha, ULONGLONG FileSize) +static DWORD VerifyMpqTablePositions(TMPQArchive * ha, ULONGLONG FileSize)  {      TMPQHeader * pHeader = ha->pHeader;      ULONGLONG ByteOffset; @@ -216,7 +216,7 @@ bool WINAPI SFileOpenArchive(      LPBYTE pbHeaderBuffer = NULL;       // Buffer for searching MPQ header      DWORD dwStreamFlags = (dwFlags & STREAM_FLAGS_MASK);      MTYPE MapType = MapTypeNotChecked; -    int nError = ERROR_SUCCESS; +    DWORD dwErrCode = ERROR_SUCCESS;      // Verify the parameters      if(szMpqName == NULL || *szMpqName == 0 || phMpq == NULL) @@ -238,30 +238,30 @@ bool WINAPI SFileOpenArchive(          return false;      // Check the file size. There must be at least 0x20 bytes -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      {          FileStream_GetSize(pStream, &FileSize);          if(FileSize < MPQ_HEADER_SIZE_V1) -            nError = ERROR_BAD_FORMAT; +            dwErrCode = ERROR_BAD_FORMAT;      }      // Allocate the MPQhandle -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      {          if((ha = STORM_ALLOC(TMPQArchive, 1)) == NULL) -            nError = ERROR_NOT_ENOUGH_MEMORY; +            dwErrCode = ERROR_NOT_ENOUGH_MEMORY;      }      // Allocate buffer for searching MPQ header -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      {          pbHeaderBuffer = STORM_ALLOC(BYTE, HEADER_SEARCH_BUFFER_SIZE);          if(pbHeaderBuffer == NULL) -            nError = ERROR_NOT_ENOUGH_MEMORY; +            dwErrCode = ERROR_NOT_ENOUGH_MEMORY;      }      // Find the position of MPQ header -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      {          ULONGLONG ByteOffset = 0;          ULONGLONG EndOfSearch = FileSize; @@ -303,7 +303,7 @@ bool WINAPI SFileOpenArchive(              // Read the eventual MPQ header              if(!FileStream_Read(ha->pStream, &ByteOffset, pbHeaderBuffer, dwBytesAvailable))              { -                nError = GetLastError(); +                dwErrCode = GetLastError();                  break;              } @@ -313,7 +313,7 @@ bool WINAPI SFileOpenArchive(                  // Do nothing if the file is an AVI file                  if((MapType = CheckMapType(szMpqName, pbHeaderBuffer, dwBytesAvailable)) == MapTypeAviFile)                  { -                    nError = ERROR_AVI_FILE; +                    dwErrCode = ERROR_AVI_FILE;                      break;                  }              } @@ -355,8 +355,8 @@ bool WINAPI SFileOpenArchive(                  if(dwHeaderID == g_dwMpqSignature && dwHeaderSize >= MPQ_HEADER_SIZE_V1)                  {                      // Now convert the header to version 4 -                    nError = ConvertMpqHeaderToFormat4(ha, ByteOffset, FileSize, dwFlags, MapType); -                    if(nError != ERROR_FAKE_MPQ_HEADER) +                    dwErrCode = ConvertMpqHeaderToFormat4(ha, ByteOffset, FileSize, dwFlags, MapType); +                    if(dwErrCode != ERROR_FAKE_MPQ_HEADER)                      {                          bSearchComplete = true;                          break; @@ -367,7 +367,7 @@ bool WINAPI SFileOpenArchive(                  if(MapType == MapTypeNotRecognized && dwHeaderID == ID_MPK)                  {                      // Now convert the MPK header to MPQ Header version 4 -                    nError = ConvertMpkHeaderToFormat4(ha, FileSize, dwFlags); +                    dwErrCode = ConvertMpkHeaderToFormat4(ha, FileSize, dwFlags);                      bSearchComplete = true;                      break;                  } @@ -375,7 +375,7 @@ bool WINAPI SFileOpenArchive(                  // If searching for the MPQ header is disabled, return an error                  if(dwFlags & MPQ_OPEN_NO_HEADER_SEARCH)                  { -                    nError = ERROR_NOT_SUPPORTED; +                    dwErrCode = ERROR_NOT_SUPPORTED;                      bSearchComplete = true;                      break;                  } @@ -386,7 +386,7 @@ bool WINAPI SFileOpenArchive(          }          // Did we identify one of the supported headers? -        if(nError == ERROR_SUCCESS) +        if(dwErrCode == ERROR_SUCCESS)          {              // Set the user data position to the MPQ header, if none              if(ha->pUserData == NULL) @@ -399,12 +399,12 @@ bool WINAPI SFileOpenArchive(              // Sector size must be nonzero.              if(ByteOffset >= FileSize || ha->pHeader->wSectorSize == 0) -                nError = ERROR_BAD_FORMAT; +                dwErrCode = ERROR_BAD_FORMAT;          }      }      // Fix table positions according to format -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      {          // Dump the header  //      DumpMpqHeader(ha->pHeader); @@ -444,25 +444,25 @@ bool WINAPI SFileOpenArchive(          ha->dwSectorSize = (0x200 << ha->pHeader->wSectorSize);          // Verify if any of the tables doesn't start beyond the end of the file -        nError = VerifyMpqTablePositions(ha, FileSize); +        dwErrCode = VerifyMpqTablePositions(ha, FileSize);      }      // Read the hash table. Ignore the result, as hash table is no longer required      // Read HET table. Ignore the result, as HET table is no longer required -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      { -        nError = LoadAnyHashTable(ha); +        dwErrCode = LoadAnyHashTable(ha);      }      // Now, build the file table. It will be built by combining      // the block table, BET table, hi-block table, (attributes) and (listfile). -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      { -        nError = BuildFileTable(ha); +        dwErrCode = BuildFileTable(ha);      }      // Load the internal listfile and include it to the file table -    if(nError == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_LISTFILE) == 0) +    if(dwErrCode == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_LISTFILE) == 0)      {          // Quick check for (listfile)          pFileEntry = GetFileEntryLocale(ha, LISTFILE_NAME, LANG_NEUTRAL); @@ -475,7 +475,7 @@ bool WINAPI SFileOpenArchive(      }      // Load the "(attributes)" file and merge it to the file table -    if(nError == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_ATTRIBUTES) == 0 && (ha->dwFlags & MPQ_FLAG_BLOCK_TABLE_CUT) == 0) +    if(dwErrCode == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_ATTRIBUTES) == 0 && (ha->dwFlags & MPQ_FLAG_BLOCK_TABLE_CUT) == 0)      {          // Quick check for (attributes)          pFileEntry = GetFileEntryLocale(ha, ATTRIBUTES_NAME, LANG_NEUTRAL); @@ -488,7 +488,7 @@ bool WINAPI SFileOpenArchive(      }      // Remember whether the archive has weak signature. Only for MPQs format 1.0. -    if(nError == ERROR_SUCCESS) +    if(dwErrCode == ERROR_SUCCESS)      {          // Quick check for (signature)          pFileEntry = GetFileEntryLocale(ha, SIGNATURE_NAME, LANG_NEUTRAL); @@ -504,11 +504,11 @@ bool WINAPI SFileOpenArchive(      }      // Cleanup and exit -    if(nError != ERROR_SUCCESS) +    if(dwErrCode != ERROR_SUCCESS)      {          FileStream_Close(pStream);          FreeArchiveHandle(ha); -        SetLastError(nError); +        SetLastError(dwErrCode);          ha = NULL;      } @@ -517,7 +517,7 @@ bool WINAPI SFileOpenArchive(          STORM_FREE(pbHeaderBuffer);      if(phMpq != NULL)          *phMpq = ha; -    return (nError == ERROR_SUCCESS); +    return (dwErrCode == ERROR_SUCCESS);  }  //----------------------------------------------------------------------------- @@ -552,8 +552,8 @@ bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK Downlo  bool WINAPI SFileFlushArchive(HANDLE hMpq)  {      TMPQArchive * ha; -    int nResultError = ERROR_SUCCESS; -    int nError; +    DWORD dwResultError = ERROR_SUCCESS; +    DWORD dwErrCode;      // Do nothing if 'hMpq' is bad parameter      if((ha = IsValidMpqHandle(hMpq)) == NULL) @@ -578,23 +578,23 @@ bool WINAPI SFileFlushArchive(HANDLE hMpq)          if(ha->dwFlags & MPQ_FLAG_SIGNATURE_NEW)          { -            nError = SSignFileCreate(ha); -            if(nError != ERROR_SUCCESS) -                nResultError = nError; +            dwErrCode = SSignFileCreate(ha); +            if(dwErrCode != ERROR_SUCCESS) +                dwResultError = dwErrCode;          }          if(ha->dwFlags & (MPQ_FLAG_LISTFILE_NEW | MPQ_FLAG_LISTFILE_FORCE))          { -            nError = SListFileSaveToMpq(ha); -            if(nError != ERROR_SUCCESS) -                nResultError = nError; +            dwErrCode = SListFileSaveToMpq(ha); +            if(dwErrCode != ERROR_SUCCESS) +                dwResultError = dwErrCode;          }          if(ha->dwFlags & MPQ_FLAG_ATTRIBUTES_NEW)          { -            nError = SAttrFileSaveToMpq(ha); -            if(nError != ERROR_SUCCESS) -                nResultError = nError; +            dwErrCode = SAttrFileSaveToMpq(ha); +            if(dwErrCode != ERROR_SUCCESS) +                dwResultError = dwErrCode;          }          // Save HET table, BET table, hash table, block table, hi-block table @@ -605,16 +605,16 @@ bool WINAPI SFileFlushArchive(HANDLE hMpq)                  RebuildHetTable(ha);              // Save all MPQ tables first -            nError = SaveMPQTables(ha); -            if(nError != ERROR_SUCCESS) -                nResultError = nError; +            dwErrCode = SaveMPQTables(ha); +            if(dwErrCode != ERROR_SUCCESS) +                dwResultError = dwErrCode;              // If the archive has weak signature, we need to finish it              if(ha->dwFileFlags3 != 0)              { -                nError = SSignFileFinish(ha); -                if(nError != ERROR_SUCCESS) -                    nResultError = nError; +                dwErrCode = SSignFileFinish(ha); +                if(dwErrCode != ERROR_SUCCESS) +                    dwResultError = dwErrCode;              }          } @@ -623,9 +623,9 @@ bool WINAPI SFileFlushArchive(HANDLE hMpq)      }      // Return the error -    if(nResultError != ERROR_SUCCESS) -        SetLastError(nResultError); -    return (nResultError == ERROR_SUCCESS); +    if(dwResultError != ERROR_SUCCESS) +        SetLastError(dwResultError); +    return (dwResultError == ERROR_SUCCESS);  }  //-----------------------------------------------------------------------------  | 
