From: <sv...@op...> - 2024-07-13 17:29:29
|
Author: sagamusix Date: Sat Jul 13 19:29:22 2024 New Revision: 21152 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21152 Log: Merged revision(s) 21145, 21148 from trunk/OpenMPT: [Imp] XM: For files made with registered MadTracker 2 versions, replace the encoded user ID with a "(registered)" string to avoid binary garbage in the string. ........ [Fix] XM: Don't fingerprint truncated files as "Unknown", caused by trying to read the instrument header size and failing, then jumping back 4 bytes and reading it again (and thus fingerprinting the instrument header size based on the previous sample or pattern data) ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_xm.cpp Modified: branches/OpenMPT-1.31/soundlib/Load_xm.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_xm.cpp Sat Jul 13 15:31:12 2024 (r21151) +++ branches/OpenMPT-1.31/soundlib/Load_xm.cpp Sat Jul 13 19:29:22 2024 (r21152) @@ -670,6 +670,10 @@ // Fix arpeggios in kragle_-_happy_day.xm m_playBehaviour.reset(kFT2Arpeggio); isMadTracker = true; + if(memcmp(fileHeader.trackerName + 15, "\0\0\0\0", 4)) + madeWithTracker = UL_("MadTracker 2 (registered)"); + else + madeWithTracker = UL_("MadTracker 2"); } else if(!memcmp(fileHeader.trackerName, "Skale Tracker\0", 14) || !memcmp(fileHeader.trackerName, "Sk@le Tracker\0", 14)) { m_playBehaviour.reset(kFT2ST3OffsetOutOfRange); @@ -727,6 +731,11 @@ // Reading instruments for(INSTRUMENTINDEX instr = 1; instr <= m_nInstruments; instr++) { + if(!AllocateInstrument(instr)) + return false; + if(!file.CanRead(4)) + continue; + // First, try to read instrument header length... uint32 headerSize = file.ReadUint32LE(); if(headerSize == 0) @@ -789,11 +798,6 @@ } } - if(AllocateInstrument(instr) == nullptr) - { - continue; - } - instrHeader.ConvertToMPT(*Instruments[instr]); if(lastInstrType == -1) |