Author: sagamusix
Date: Thu Apr 11 19:57:36 2024
New Revision: 20568
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20568
Log:
[Mod] Revert backporting of r20524 and r20538. They require further changes which are more difficult to backport.
Modified:
branches/OpenMPT-1.28/ (props changed)
branches/OpenMPT-1.28/soundlib/Load_mod.cpp
Modified: branches/OpenMPT-1.28/soundlib/Load_mod.cpp
==============================================================================
--- branches/OpenMPT-1.28/soundlib/Load_mod.cpp Thu Apr 11 19:54:58 2024 (r20567)
+++ branches/OpenMPT-1.28/soundlib/Load_mod.cpp Thu Apr 11 19:57:36 2024 (r20568)
@@ -319,11 +319,6 @@
+ ((loopStart > length * 2) ? 1 : 0);
}
- bool HasDiskName() const
- {
- return (!memcmp(name, "st-", 3) || !memcmp(name, "ST-", 3)) && name[5] == ':';
- }
-
// Suggested threshold for rejecting invalid files based on cumulated score returned by GetInvalidByteScore
enum : uint32 { INVALID_BYTE_THRESHOLD = 40 };
@@ -1327,13 +1322,15 @@
// However, there are quite a few SoundTracker modules in the wild with random
// characters. To still be able to distguish them from other formats, we just reject
// files with *too* many bogus characters. Arbitrary threshold: 48 bogus characters in total
- // or more than 5 invalid characters just in the title alone
- uint32 invalidCharsInTitle = CountInvalidChars(fileHeaders.songname);
- uint32 invalidChars = invalidCharsInTitle;
+ // or more than 5 invalid characters just in the title alone.
+ uint32 invalidChars = CountInvalidChars(fileHeaders.songname);
+ if(invalidChars > 5)
+ {
+ return false;
+ }
SmpLength totalSampleLen = 0;
uint8 allVolumes = 0;
- uint8 diskNameCount = 0;
for(SAMPLEINDEX smp = 0; smp < 15; smp++)
{
@@ -1341,15 +1338,10 @@
invalidChars += CountInvalidChars(sampleHeader.name);
- // schmokk.mod has a non-zero value here but it should not be treated as finetune
- if(sampleHeader.finetune != 0)
- invalidChars += 16;
- if(sampleHeader.HasDiskName())
- diskNameCount++;
-
// Sanity checks - invalid character count adjusted for ata.mod (MD5 937b79b54026fa73a1a4d3597c26eace, SHA1 3322ca62258adb9e0ae8e9afe6e0c29d39add874)
if(invalidChars > 48
|| sampleHeader.volume > 64
+ || sampleHeader.finetune != 0
|| sampleHeader.length > 32768)
{
return false;
@@ -1359,12 +1351,6 @@
allVolumes |= sampleHeader.volume;
}
- // scramble_2.mod has a lot of garbage in the song title, but it has lots of sample names starting with st-01, so we consider those to be more important than the garbage bytes.
- if(invalidCharsInTitle > 5 && diskNameCount < 4)
- {
- return false;
- }
-
// Reject any files with no (or only silent) samples at all, as this might just be a random binary file (e.g. ID3 tags with tons of padding)
if(totalSampleLen == 0 || allVolumes == 0)
{
@@ -1491,14 +1477,12 @@
file.Seek(20);
for(SAMPLEINDEX smp = 1; smp <= 15; smp++)
{
- ModSample &mptSmp = Samples[smp];
MODSampleHeader sampleHeader;
ReadSample(file, sampleHeader, Samples[smp], m_szNames[smp], true);
- mptSmp.nFineTune = 0;
- totalSampleLen += mptSmp.nLength;
+ totalSampleLen += Samples[smp].nLength;
- if(m_szNames[smp][0] && sampleHeader.HasDiskName())
+ if(m_szNames[smp][0] && ((memcmp(m_szNames[smp], "st-", 3) && memcmp(m_szNames[smp], "ST-", 3)) || m_szNames[smp][5] != ':'))
{
// Ultimate Soundtracker 1.8 and D.O.C. SoundTracker IX always have sample names containing disk names.
hasDiskNames = false;
@@ -1507,9 +1491,9 @@
// Loop start is always in bytes, not words, so don't trust the auto-fix magic in the sample header conversion (fixes loop of "st-01:asia" in mod.drag 10)
if(sampleHeader.loopLength > 1)
{
- mptSmp.nLoopStart = sampleHeader.loopStart;
- mptSmp.nLoopEnd = sampleHeader.loopStart + sampleHeader.loopLength * 2;
- mptSmp.SanitizeLoops();
+ Samples[smp].nLoopStart = sampleHeader.loopStart;
+ Samples[smp].nLoopEnd = sampleHeader.loopStart + sampleHeader.loopLength * 2;
+ Samples[smp].SanitizeLoops();
}
// UST only handles samples up to 9999 bytes. Master Soundtracker 1.0 and SoundTracker 2.0 introduce 32KB samples.
|