From a2c81f1ca9f067c3ac557b5fab079e62f07f3fb0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 12 Sep 2014 20:59:23 +0200 Subject: [PATCH] -fixed the file validity checks in MapData::GetChecksum. They need to be done per lump, because MapData::Seek can alter the FileReader being used for a specific lump. Even worse, the FileReader will be NULL when the function as it was is called for a map inside a Zip-file. --- src/p_setup.cpp | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index a6dbca868..6b5d9403f 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -537,34 +537,31 @@ void MapData::GetChecksum(BYTE cksum[16]) { MD5Context md5; - if (file != NULL) + if (isText) { - if (isText) + Seek(ML_TEXTMAP); + if (file != NULL) md5.Update(file, Size(ML_TEXTMAP)); + } + else + { + if (Size(ML_LABEL) != 0) { - Seek(ML_TEXTMAP); - md5.Update(file, Size(ML_TEXTMAP)); - } - else - { - if (Size(ML_LABEL) != 0) - { - Seek(ML_LABEL); - md5.Update(file, Size(ML_LABEL)); - } - Seek(ML_THINGS); - md5.Update(file, Size(ML_THINGS)); - Seek(ML_LINEDEFS); - md5.Update(file, Size(ML_LINEDEFS)); - Seek(ML_SIDEDEFS); - md5.Update(file, Size(ML_SIDEDEFS)); - Seek(ML_SECTORS); - md5.Update(file, Size(ML_SECTORS)); - } - if (HasBehavior) - { - Seek(ML_BEHAVIOR); - md5.Update(file, Size(ML_BEHAVIOR)); + Seek(ML_LABEL); + if (file != NULL) md5.Update(file, Size(ML_LABEL)); } + Seek(ML_THINGS); + if (file != NULL) md5.Update(file, Size(ML_THINGS)); + Seek(ML_LINEDEFS); + if (file != NULL) md5.Update(file, Size(ML_LINEDEFS)); + Seek(ML_SIDEDEFS); + if (file != NULL) md5.Update(file, Size(ML_SIDEDEFS)); + Seek(ML_SECTORS); + if (file != NULL) md5.Update(file, Size(ML_SECTORS)); + } + if (HasBehavior) + { + Seek(ML_BEHAVIOR); + if (file != NULL) md5.Update(file, Size(ML_BEHAVIOR)); } md5.Final(cksum); }