Browse Source

Clean up mpqapi.cpp

pull/133/head
Anders Jenbo 7 years ago
parent
commit
a55d2a811f
  1. 29
      Source/mpqapi.cpp

29
Source/mpqapi.cpp

@ -4,7 +4,7 @@
DWORD sgdwMpqOffset; DWORD sgdwMpqOffset;
char mpq_buf[4096]; char mpq_buf[4096];
_HASHENTRY *sgpHashTbl; _HASHENTRY *sgpHashTbl;
BOOL save_archive_modified; // weak BOOL save_archive_modified;
_BLOCKENTRY *sgpBlockTbl; _BLOCKENTRY *sgpBlockTbl;
BOOLEAN save_archive_open; // weak BOOLEAN save_archive_open; // weak
@ -457,7 +457,7 @@ BOOL OpenMPQ(const char *pszArchive, BOOL hidden, DWORD dwChar)
if (sghArchive == INVALID_HANDLE_VALUE) if (sghArchive == INVALID_HANDLE_VALUE)
return 0; return 0;
save_archive_open = 1; save_archive_open = 1;
save_archive_modified = 1; save_archive_modified = TRUE;
} }
if (!sgpBlockTbl || !sgpHashTbl) { if (!sgpBlockTbl || !sgpHashTbl) {
memset(&fhdr, 0, sizeof(fhdr)); memset(&fhdr, 0, sizeof(fhdr));
@ -489,7 +489,6 @@ BOOL OpenMPQ(const char *pszArchive, BOOL hidden, DWORD dwChar)
} }
return 1; return 1;
} }
// 65AB0C: using guessed type int save_archive_modified;
// 65AB14: using guessed type char save_archive_open; // 65AB14: using guessed type char save_archive_open;
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
@ -526,7 +525,7 @@ BOOL ParseMPQHeader(_FILEHEADER *pHdr, DWORD *pdwNextFileStart)
pHdr->sectorsizeid = 3; pHdr->sectorsizeid = 3;
pHdr->version = 0; pHdr->version = 0;
*pdwNextFileStart = 0x10068; *pdwNextFileStart = 0x10068;
save_archive_modified = 1; save_archive_modified = TRUE;
save_archive_open = 1; save_archive_open = 1;
} }
@ -564,7 +563,7 @@ void mpqapi_store_modified_time(const char *pszArchive, DWORD dwChar)
handle = FindFirstFile(pszArchive, &FindFileData); handle = FindFirstFile(pszArchive, &FindFileData);
if (handle != INVALID_HANDLE_VALUE) { if (handle != INVALID_HANDLE_VALUE) {
FindClose(handle); FindClose(handle);
*((FILETIME*) (dst) + dwChar * 2 + 1) = FindFileData.ftLastWriteTime; *((FILETIME *)(dst) + dwChar * 2 + 1) = FindFileData.ftLastWriteTime;
mpqapi_reg_store_modification_time(dst, 160); mpqapi_reg_store_modification_time(dst, 160);
} }
} }
@ -572,22 +571,22 @@ void mpqapi_store_modified_time(const char *pszArchive, DWORD dwChar)
BOOL mpqapi_flush_and_close(const char *pszArchive, BOOL bFree, DWORD dwChar) BOOL mpqapi_flush_and_close(const char *pszArchive, BOOL bFree, DWORD dwChar)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
if (sghArchive == INVALID_HANDLE_VALUE) if (sghArchive == INVALID_HANDLE_VALUE)
ret = TRUE; ret = TRUE;
else { else {
ret = FALSE; ret = FALSE;
if (!save_archive_modified) if (!save_archive_modified)
ret = TRUE; ret = TRUE;
else if (mpqapi_can_seek() && WriteMPQHeader() && mpqapi_write_block_table()) { else if (mpqapi_can_seek() && WriteMPQHeader() && mpqapi_write_block_table()) {
if (mpqapi_write_hash_table()) if (mpqapi_write_hash_table())
ret = TRUE; ret = TRUE;
else else
ret = FALSE; ret = FALSE;
} }
} }
CloseMPQ(pszArchive, bFree, dwChar); CloseMPQ(pszArchive, bFree, dwChar);
return ret; return ret;
} }
BOOL WriteMPQHeader() BOOL WriteMPQHeader()

Loading…
Cancel
Save