From: <sag...@us...> - 2012-12-12 21:07:42
|
Revision: 1458 http://sourceforge.net/p/modplug/code/1458 Author: saga-games Date: 2012-12-12 21:07:34 +0000 (Wed, 12 Dec 2012) Log Message: ----------- [Mod] Changed some things in the MOD loader regarding a problem with MOD saving after removing samples (reported by bubsy as a general problem, but no confirmation with test cases, so it's mostly guess work.) [Mod] Further changes to zip loader. Modified Paths: -------------- trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/unzip/unzip.cpp Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2012-12-12 13:36:13 UTC (rev 1457) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2012-12-12 21:07:34 UTC (rev 1458) @@ -269,7 +269,7 @@ } if (mptSmp.nLoopEnd > mptSmp.nLoopStart) { - mptSmp.uFlags |= CHN_LOOP; + mptSmp.uFlags.set(CHN_LOOP); } } } @@ -277,7 +277,7 @@ // Convert OpenMPT's internal sample header to an MOD sample header. SmpLength ConvertToMOD(const ModSample &mptSmp) { - SmpLength writeLength = mptSmp.nLength; + SmpLength writeLength = mptSmp.pSample != nullptr ? mptSmp.nLength : 0; // If the sample size is odd, we have to add a padding byte, as all sample sizes in MODs are even. if((writeLength % 2) != 0) { @@ -301,7 +301,7 @@ loopStart = 0; loopLength = 1; - if(mptSmp.uFlags & CHN_LOOP) + if(mptSmp.uFlags[CHN_LOOP]) { loopStart = static_cast<uint16>(mptSmp.nLoopStart / 2); loopLength = static_cast<uint16>(max(1, (mptSmp.nLoopEnd - mptSmp.nLoopStart) / 2)); @@ -782,7 +782,7 @@ { MODSampleHeader sampleHeader; StringFixer::WriteString<StringFixer::maybeNullTerminated>(sampleHeader.name, m_szNames[sampleSource[smp]]); - sampleLength[smp] = sampleHeader.ConvertToMOD(Samples[sampleSource[smp]]); + sampleLength[smp] = sampleHeader.ConvertToMOD(sampleSource[smp] <= GetNumSamples() ? GetSample(sampleSource[smp]) : ModSample(MOD_TYPE_MOD)); sampleHeader.ConvertEndianness(); fwrite(&sampleHeader, sizeof(sampleHeader), 1, f); } Modified: trunk/OpenMPT/unzip/unzip.cpp =================================================================== --- trunk/OpenMPT/unzip/unzip.cpp 2012-12-12 13:36:13 UTC (rev 1457) +++ trunk/OpenMPT/unzip/unzip.cpp 2012-12-12 21:07:34 UTC (rev 1458) @@ -1,7 +1,7 @@ /* * unzip.cpp * --------- - * Purpose: Implementation file for extracting modules from .zip archives + * Purpose: Implementation file for extracting modules from .zip archives, making use of MiniZip (from the zlib contrib package) * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. @@ -174,7 +174,8 @@ if(lstrcmpi(ext, "diz") && lstrcmpi(ext, "nfo") - && lstrcmpi(ext, "txt")) + && lstrcmpi(ext, "txt") + && info.uncompressed_size > 16) { // If this isn't some kind of info file, we should maybe pick it. unzGetFilePos(zipFile, &bestFile); @@ -221,8 +222,8 @@ { info.size_comment++; } - char *comment = new char[info.size_comment]; - if(unzGetGlobalComment(zipFile, comment, info.size_comment) >= 0) + char *comment = new (std::nothrow) char[info.size_comment]; + if(comment != nullptr && unzGetGlobalComment(zipFile, comment, info.size_comment) >= 0) { comment[info.size_comment - 1] = '\0'; return comment; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |