If you have an issue with any of our projects. feel free to register.

Commit ee0782ef authored by Christopher Snowhill's avatar Christopher Snowhill

Updated libopenmpt to version 0.5.3

parent 4eb7a3ee
MPT_SVNVERSION=13555
MPT_SVNURL=https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.5.2
MPT_SVNDATE=2020-08-30T13:42:32.941871Z
MPT_SVNVERSION=13775
MPT_SVNURL=https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.5.3
MPT_SVNDATE=2020-10-25T14:02:16.624929Z
#pragma once
#define OPENMPT_VERSION_SVNVERSION "13555"
#define OPENMPT_VERSION_REVISION 13555
#define OPENMPT_VERSION_SVNVERSION "13775"
#define OPENMPT_VERSION_REVISION 13775
#define OPENMPT_VERSION_DIRTY 0
#define OPENMPT_VERSION_MIXEDREVISIONS 0
#define OPENMPT_VERSION_URL "https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.5.2"
#define OPENMPT_VERSION_DATE "2020-08-30T13:42:32.941871Z"
#define OPENMPT_VERSION_URL "https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.5.3"
#define OPENMPT_VERSION_DATE "2020-10-25T14:02:16.624929Z"
#define OPENMPT_VERSION_IS_PACKAGE 1
......@@ -563,10 +563,7 @@ namespace FileReader
static_assert(mpt::is_binary_safe<T>::value);
if(f.CanRead(sizeof(destArray)))
{
for(auto &element : destArray)
{
Read(f, element);
}
f.ReadRaw(mpt::as_raw_memory(destArray));
return true;
} else
{
......@@ -584,10 +581,7 @@ namespace FileReader
static_assert(mpt::is_binary_safe<T>::value);
if(f.CanRead(sizeof(destArray)))
{
for(auto &element : destArray)
{
Read(f, element);
}
f.ReadRaw(mpt::as_raw_memory(destArray));
return true;
} else
{
......@@ -606,10 +600,7 @@ namespace FileReader
destVector.resize(destSize);
if(f.CanRead(sizeof(T) * destSize))
{
for(auto &element : destVector)
{
Read(f, element);
}
f.ReadRaw(mpt::as_raw_memory(destVector));
return true;
} else
{
......@@ -679,18 +670,9 @@ namespace FileReader
typename TFileCursor::off_t avail = f.GetRaw(bytes, sizeof(bytes));
typename TFileCursor::off_t readPos = 1;
size_t writtenBits = 0;
uint8 b = mpt::byte_cast<uint8>(bytes[0]);
target = (b & 0x7F);
// Count actual bits used in most significant byte (i.e. this one)
for(size_t bit = 0; bit < 7; bit++)
{
if((b & (1u << bit)) != 0)
{
writtenBits = bit + 1;
}
}
size_t writtenBits = static_cast<size_t>(mpt::bit_width(target)); // Bits used in the most significant byte
while(readPos < avail && (b & 0x80) != 0)
{
......
......@@ -388,8 +388,11 @@ void SsbWrite::OnWroteItem(const ID &id, const Postype& posBeforeWrite)
{
const Offtype nRawEntrySize = oStrm.tellp() - posBeforeWrite;
if (nRawEntrySize < 0 || static_cast<uint64>(nRawEntrySize) > std::numeric_limits<DataSize>::max())
{ AddWriteNote(SNW_INSUFFICIENT_DATASIZETYPE); return; }
MPT_MAYBE_CONSTANT_IF(nRawEntrySize < 0 || static_cast<uint64>(nRawEntrySize) > std::numeric_limits<DataSize>::max())
{
AddWriteNote(SNW_INSUFFICIENT_DATASIZETYPE);
return;
}
if(GetFlag(RwfRMapHasSize) && (nRawEntrySize < 0 || static_cast<uint64>(nRawEntrySize) > (std::numeric_limits<DataSize>::max() >> 2)))
{ AddWriteNote(SNW_DATASIZETYPE_OVERFLOW); return; }
......@@ -557,8 +560,11 @@ void SsbRead::BeginRead(const ID &id, const uint64& nVersion)
const Offtype rawEndOfHdrData = iStrm.tellg() - m_posStart;
if (rawEndOfHdrData < 0 || static_cast<uint64>(rawEndOfHdrData) > std::numeric_limits<RposType>::max())
{ AddReadNote(SNR_INSUFFICIENT_RPOSTYPE); return; }
MPT_MAYBE_CONSTANT_IF(rawEndOfHdrData < 0 || static_cast<uint64>(rawEndOfHdrData) > std::numeric_limits<RposType>::max())
{
AddReadNote(SNR_INSUFFICIENT_RPOSTYPE);
return;
}
m_rposEndofHdrData = static_cast<RposType>(rawEndOfHdrData);
m_rposMapBegin = (GetFlag(RwfRwHasMap)) ? static_cast<RposType>(tempU64) : m_rposEndofHdrData;
......
......@@ -17,7 +17,7 @@ OPENMPT_NAMESPACE_BEGIN
// Version definitions. The only thing that needs to be changed when changing version number.
#define VER_MAJORMAJOR 1
#define VER_MAJOR 29
#define VER_MINOR 03
#define VER_MINOR 05
#define VER_MINORMINOR 00
OPENMPT_NAMESPACE_END
#!/usr/bin/env bash
cd "${0%/*}"
AFL_VERSION="$(wget --quiet -O - "https://api.github.com/repos/vanhauser-thc/AFLplusplus/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')"
AFL_VERSION="$(wget --quiet -O - "https://api.github.com/repos/AFLplusplus/AFLplusplus/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')"
AFL_FILENAME="$AFL_VERSION.tar.gz"
AFL_URL="https://github.com/vanhauser-thc/AFLplusplus/archive/$AFL_FILENAME"
AFL_URL="https://github.com/AFLplusplus/AFLplusplus/archive/$AFL_FILENAME"
rm $AFL_FILENAME
wget $AFL_URL || exit
......
......@@ -5,6 +5,31 @@ Changelog {#changelog}
For fully detailed change log, please see the source repository directly. This
is just a high-level summary.
### libopenmpt 0.5.3 (2020-10-25)
* [**Sec**] Possible hang if a MED file claimed to contain 256 songs. (r13704)
* [**Bug**] libopenmpt: `openmpt::is_extension_supported2()` exported symbol
was missing (C++).
* [**Bug**] `openmpt::module::set_position_seconds` sometimes behaved as if
the song end was reached when seeking into a pattern loop and in some other
corner cases.
* Increase threshold for ignoring panning commands from 820 to 830.
* Subsong names now fall back to the first pattern's name if empty.
* MO3: Avoid certain ModPlug hacks from being fixed up twice, which could lead
to e.g. very narrow pan swing range for old OpenMPT IT files saved with a
recent MO3 encoder version.
* MO3: Some files with corrupted envelope data could be rejected completely
(normally libopenmpt should fix up the envelope data).
* MO3: Song metadata didn't correctly identify MPTM as source format (it
appeared as IT instead).
* STM: Change tempo computation to behave like Scream Tracker 2.3 instead of
Scream Tracker 2.2, as the playback frequencies we use for sample playback
are closer to those of Scream Tracker 2.3.
* PLM: Percentage offset (Mxx) was slightly off.
* WOW: Fix loading of several files and harden WOW detection.
### libopenmpt 0.5.2 (2020-08-30)
* [**Change**] `Makefile` `CONFIG=emscripten` now supports
......
......@@ -1567,7 +1567,7 @@ static int get_pattern_row_channel_effect_type( openmpt_module_ext * mod_ext, in
int set_current_speed( openmpt_module_ext * mod_ext, int32_t speed ) {
static int set_current_speed( openmpt_module_ext * mod_ext, int32_t speed ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_current_speed( speed );
......@@ -1577,7 +1577,7 @@ int set_current_speed( openmpt_module_ext * mod_ext, int32_t speed ) {
}
return 0;
}
int set_current_tempo( openmpt_module_ext * mod_ext, int32_t tempo ) {
static int set_current_tempo( openmpt_module_ext * mod_ext, int32_t tempo ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_current_tempo( tempo );
......@@ -1587,7 +1587,7 @@ int set_current_tempo( openmpt_module_ext * mod_ext, int32_t tempo ) {
}
return 0;
}
int set_tempo_factor( openmpt_module_ext * mod_ext, double factor ) {
static int set_tempo_factor( openmpt_module_ext * mod_ext, double factor ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_tempo_factor( factor );
......@@ -1597,7 +1597,7 @@ int set_tempo_factor( openmpt_module_ext * mod_ext, double factor ) {
}
return 0;
}
double get_tempo_factor( openmpt_module_ext * mod_ext ) {
static double get_tempo_factor( openmpt_module_ext * mod_ext ) {
try {
openmpt::interface::check_soundfile( mod_ext );
return mod_ext->impl->get_tempo_factor();
......@@ -1606,7 +1606,7 @@ double get_tempo_factor( openmpt_module_ext * mod_ext ) {
}
return 0.0;
}
int set_pitch_factor( openmpt_module_ext * mod_ext, double factor ) {
static int set_pitch_factor( openmpt_module_ext * mod_ext, double factor ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_pitch_factor( factor );
......@@ -1616,7 +1616,7 @@ int set_pitch_factor( openmpt_module_ext * mod_ext, double factor ) {
}
return 0;
}
double get_pitch_factor( openmpt_module_ext * mod_ext ) {
static double get_pitch_factor( openmpt_module_ext * mod_ext ) {
try {
openmpt::interface::check_soundfile( mod_ext );
return mod_ext->impl->get_pitch_factor();
......@@ -1625,7 +1625,7 @@ double get_pitch_factor( openmpt_module_ext * mod_ext ) {
}
return 0.0;
}
int set_global_volume( openmpt_module_ext * mod_ext, double volume ) {
static int set_global_volume( openmpt_module_ext * mod_ext, double volume ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_global_volume( volume );
......@@ -1635,7 +1635,7 @@ int set_global_volume( openmpt_module_ext * mod_ext, double volume ) {
}
return 0;
}
double get_global_volume( openmpt_module_ext * mod_ext ) {
static double get_global_volume( openmpt_module_ext * mod_ext ) {
try {
openmpt::interface::check_soundfile( mod_ext );
return mod_ext->impl->get_global_volume();
......@@ -1644,7 +1644,7 @@ double get_global_volume( openmpt_module_ext * mod_ext ) {
}
return 0.0;
}
int set_channel_volume( openmpt_module_ext * mod_ext, int32_t channel, double volume ) {
static int set_channel_volume( openmpt_module_ext * mod_ext, int32_t channel, double volume ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_channel_volume( channel, volume );
......@@ -1654,7 +1654,7 @@ int set_channel_volume( openmpt_module_ext * mod_ext, int32_t channel, double vo
}
return 0;
}
double get_channel_volume( openmpt_module_ext * mod_ext, int32_t channel ) {
static double get_channel_volume( openmpt_module_ext * mod_ext, int32_t channel ) {
try {
openmpt::interface::check_soundfile( mod_ext );
return mod_ext->impl->get_channel_volume( channel );
......@@ -1663,7 +1663,7 @@ double get_channel_volume( openmpt_module_ext * mod_ext, int32_t channel ) {
}
return 0.0;
}
int set_channel_mute_status( openmpt_module_ext * mod_ext, int32_t channel, int mute ) {
static int set_channel_mute_status( openmpt_module_ext * mod_ext, int32_t channel, int mute ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_channel_mute_status( channel, mute ? true : false );
......@@ -1673,7 +1673,7 @@ int set_channel_mute_status( openmpt_module_ext * mod_ext, int32_t channel, int
}
return 0;
}
int get_channel_mute_status( openmpt_module_ext * mod_ext, int32_t channel ) {
static int get_channel_mute_status( openmpt_module_ext * mod_ext, int32_t channel ) {
try {
openmpt::interface::check_soundfile( mod_ext );
return mod_ext->impl->get_channel_mute_status( channel ) ? 1 : 0;
......@@ -1682,7 +1682,7 @@ int get_channel_mute_status( openmpt_module_ext * mod_ext, int32_t channel ) {
}
return -1;
}
int set_instrument_mute_status( openmpt_module_ext * mod_ext, int32_t instrument, int mute ) {
static int set_instrument_mute_status( openmpt_module_ext * mod_ext, int32_t instrument, int mute ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->set_instrument_mute_status( instrument, mute ? true : false );
......@@ -1692,7 +1692,7 @@ int set_instrument_mute_status( openmpt_module_ext * mod_ext, int32_t instrument
}
return 0;
}
int get_instrument_mute_status( openmpt_module_ext * mod_ext, int32_t instrument ) {
static int get_instrument_mute_status( openmpt_module_ext * mod_ext, int32_t instrument ) {
try {
openmpt::interface::check_soundfile( mod_ext );
return mod_ext->impl->get_instrument_mute_status( instrument ) ? 1 : 0;
......@@ -1701,7 +1701,7 @@ int get_instrument_mute_status( openmpt_module_ext * mod_ext, int32_t instrument
}
return -1;
}
int32_t play_note( openmpt_module_ext * mod_ext, int32_t instrument, int32_t note, double volume, double panning ) {
static int32_t play_note( openmpt_module_ext * mod_ext, int32_t instrument, int32_t note, double volume, double panning ) {
try {
openmpt::interface::check_soundfile( mod_ext );
return mod_ext->impl->play_note( instrument, note, volume, panning );
......@@ -1710,7 +1710,7 @@ int32_t play_note( openmpt_module_ext * mod_ext, int32_t instrument, int32_t not
}
return -1;
}
int stop_note( openmpt_module_ext * mod_ext, int32_t channel ) {
static int stop_note( openmpt_module_ext * mod_ext, int32_t channel ) {
try {
openmpt::interface::check_soundfile( mod_ext );
mod_ext->impl->stop_note( channel );
......
......@@ -126,7 +126,7 @@ std::vector<std::string> get_supported_extensions() {
bool is_extension_supported( const std::string & extension ) {
return openmpt::module_impl::is_extension_supported( extension );
}
bool is_extension_supported( std::string_view extension ) {
bool is_extension_supported2( std::string_view extension ) {
return openmpt::module_impl::is_extension_supported( extension );
}
......
......@@ -1106,11 +1106,11 @@ double module_impl::set_position_seconds( double seconds ) {
} else {
subsong = &subsongs[m_current_subsong];
}
GetLengthType t = m_sndFile->GetLength( eNoAdjust, GetLengthTarget( seconds ).StartPos( static_cast<SEQUENCEINDEX>( subsong->sequence ), static_cast<ORDERINDEX>( subsong->start_order ), static_cast<ROWINDEX>( subsong->start_row ) ) ).back();
GetLengthType t = m_sndFile->GetLength( m_ctl_seek_sync_samples ? eAdjustSamplePositions : eAdjust, GetLengthTarget( seconds ).StartPos( static_cast<SEQUENCEINDEX>( subsong->sequence ), static_cast<ORDERINDEX>( subsong->start_order ), static_cast<ROWINDEX>( subsong->start_row ) ) ).back();
m_sndFile->m_PlayState.m_nCurrentOrder = t.lastOrder;
m_sndFile->SetCurrentOrder( t.lastOrder );
m_sndFile->m_PlayState.m_nNextRow = t.lastRow;
m_currentPositionSeconds = base_seconds + m_sndFile->GetLength( m_ctl_seek_sync_samples ? eAdjustSamplePositions : eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ).StartPos( static_cast<SEQUENCEINDEX>( subsong->sequence ), static_cast<ORDERINDEX>( subsong->start_order ), static_cast<ROWINDEX>( subsong->start_row ) ) ).back().duration;
m_currentPositionSeconds = base_seconds + t.duration;
return m_currentPositionSeconds;
}
double module_impl::set_position_order_row( std::int32_t order, std::int32_t row ) {
......@@ -1367,8 +1367,15 @@ std::vector<std::string> module_impl::get_subsong_names() const {
std::vector<std::string> retval;
std::unique_ptr<subsongs_type> subsongs_temp = has_subsongs_inited() ? std::unique_ptr<subsongs_type>() : std::make_unique<subsongs_type>( get_subsongs() );
const subsongs_type & subsongs = has_subsongs_inited() ? m_subsongs : *subsongs_temp;
retval.reserve( subsongs.size() );
for ( const auto & subsong : subsongs ) {
retval.push_back( mpt::ToCharset( mpt::Charset::UTF8, m_sndFile->Order( static_cast<SEQUENCEINDEX>( subsong.sequence ) ).GetName() ) );
const auto & order = m_sndFile->Order( static_cast<SEQUENCEINDEX>( subsong.sequence ) );
retval.push_back( mpt::ToCharset( mpt::Charset::UTF8, order.GetName() ) );
if ( retval.back().empty() ) {
// use first pattern name instead
if ( order.IsValidPat( static_cast<SEQUENCEINDEX>( subsong.start_order ) ) )
retval.back() = mpt::ToCharset( mpt::Charset::UTF8, m_sndFile->GetCharsetInternal(), m_sndFile->Patterns[ order[ subsong.start_order ] ].GetName() );
}
}
return retval;
}
......
......@@ -19,7 +19,7 @@
/*! \brief libopenmpt minor version number */
#define OPENMPT_API_VERSION_MINOR 5
/*! \brief libopenmpt patch version number */
#define OPENMPT_API_VERSION_PATCH 2
#define OPENMPT_API_VERSION_PATCH 3
/*! \brief libopenmpt pre-release tag */
#define OPENMPT_API_VERSION_PREREL ""
/*! \brief libopenmpt pre-release flag */
......
LIBOPENMPT_VERSION_MAJOR=0
LIBOPENMPT_VERSION_MINOR=5
LIBOPENMPT_VERSION_PATCH=2
LIBOPENMPT_VERSION_PATCH=3
LIBOPENMPT_VERSION_PREREL=
LIBOPENMPT_LTVER_CURRENT=2
LIBOPENMPT_LTVER_REVISION=2
LIBOPENMPT_LTVER_REVISION=3
LIBOPENMPT_LTVER_AGE=2
......@@ -190,7 +190,7 @@ bool CSoundFile::Read669(FileReader &file, ModLoadingFlags loadFlags)
continue;
}
const ModCommand::COMMAND effTrans[] =
static constexpr ModCommand::COMMAND effTrans[] =
{
CMD_PORTAMENTOUP, // Slide up (param * 80) Hz on every tick
CMD_PORTAMENTODOWN, // Slide down (param * 80) Hz on every tick
......
......@@ -313,7 +313,7 @@ bool CSoundFile::ReadDSM(FileReader &file, ModLoadingFlags loadFlags)
}
}
patNum++;
} else if(!memcmp(chunkHeader.magic, "INST", 4) && GetNumSamples() < SAMPLEINDEX(MAX_SAMPLES - 1))
} else if(!memcmp(chunkHeader.magic, "INST", 4) && CanAddMoreSamples())
{
// Read sample
m_nSamples++;
......
......@@ -118,16 +118,12 @@ struct MMDSong
MMD0Song GetMMD0Song() const
{
static_assert(sizeof(MMD0Song) == sizeof(song));
MMD0Song result;
std::memcpy(&result, song, sizeof(result));
return result;
return mpt::bit_cast<MMD0Song>(song);
}
MMD2Song GetMMD2Song() const
{
static_assert(sizeof(MMD2Song) == sizeof(song));
MMD2Song result;
std::memcpy(&result, song, sizeof(result));
return result;
return mpt::bit_cast<MMD2Song>(song);
}
uint16be defaultTempo;
int8be playTranspose; // The global play transpose value for current song
......@@ -575,24 +571,24 @@ static void MEDReadNextSong(FileReader &file, MMD0FileHeader &fileHeader, MMD0Ex
}
static CHANNELINDEX MEDScanNumChannels(FileReader &file, const uint8 version)
static std::pair<CHANNELINDEX, SEQUENCEINDEX> MEDScanNumChannels(FileReader &file, const uint8 version)
{
MMD0FileHeader fileHeader;
MMD0Exp expData;
MMDSong songHeader;
file.Rewind();
uint32 songOffset = 0;
MEDReadNextSong(file, fileHeader, expData, songHeader);
auto numSongs = fileHeader.expDataOffset ? fileHeader.extraSongs + 1 : 1;
SEQUENCEINDEX numSongs = std::min(MAX_SEQUENCES, mpt::saturate_cast<SEQUENCEINDEX>(fileHeader.expDataOffset ? fileHeader.extraSongs + 1 : 1));
CHANNELINDEX numChannels = 4;
// Scan patterns for max number of channels
for(SEQUENCEINDEX song = 0; song < numSongs; song++)
{
const PATTERNINDEX numPatterns = songHeader.numBlocks;
if(songHeader.numSamples > 63 || numPatterns > 0x7FFF)
return 0;
return {};
for(PATTERNINDEX pat = 0; pat < numPatterns; pat++)
{
......@@ -604,11 +600,16 @@ static CHANNELINDEX MEDScanNumChannels(FileReader &file, const uint8 version)
numChannels = std::max(numChannels, static_cast<CHANNELINDEX>(version < 1 ? file.ReadUint8() : file.ReadUint16BE()));
}
if(!expData.nextModOffset || !file.Seek(expData.nextModOffset))
// If song offsets are going backwards, reject the file
if(expData.nextModOffset <= songOffset || !file.Seek(expData.nextModOffset))
{
numSongs = song + 1;
break;
}
songOffset = expData.nextModOffset;
MEDReadNextSong(file, fileHeader, expData, songHeader);
}
return numChannels;
return {numChannels, numSongs};
}
......@@ -680,9 +681,10 @@ bool CSoundFile::ReadMED(FileReader &file, ModLoadingFlags loadFlags)
file.ReadStruct(expData);
}
m_nChannels = MEDScanNumChannels(file, version);
if(m_nChannels < 1 || m_nChannels > MAX_BASECHANNELS)
const auto [numChannels, numSongs] = MEDScanNumChannels(file, version);
if(numChannels < 1 || numChannels > MAX_BASECHANNELS)
return false;
m_nChannels = numChannels;
// Start with the instruments, as those are shared between songs
......@@ -993,8 +995,6 @@ bool CSoundFile::ReadMED(FileReader &file, ModLoadingFlags loadFlags)
}
}
const auto numSongs = std::min<SEQUENCEINDEX>(MAX_SEQUENCES, fileHeader.expDataOffset ? fileHeader.extraSongs + 1 : 1);
file.Rewind();
PATTERNINDEX basePattern = 0;
for(SEQUENCEINDEX song = 0; song < numSongs; song++)
......
......@@ -292,8 +292,9 @@ uint32 CSoundFile::MapMidiInstrument(uint8 program, uint16 bank, uint8 midiChann
if (program + 1 == p->nMidiProgram && bank + 1 == p->wMidiBank && p->nMidiDrumKey == 0) return i;
}
}
if ((m_nInstruments + 1 >= MAX_INSTRUMENTS) || (m_nSamples + 1 >= MAX_SAMPLES)) return 0;
if(!CanAddMoreInstruments() || !CanAddMoreSamples())
return 0;
pIns = AllocateInstrument(m_nInstruments + 1);
if(pIns == nullptr)
{
......@@ -347,7 +348,7 @@ struct MThd
uint16be division; // Delta timing value: positive = units/beat; negative = smpte compatible units
};
MPT_BINARY_STRUCT(MThd, 10);
MPT_BINARY_STRUCT(MThd, 10)
using tick_t = uint32;
......
......@@ -838,34 +838,16 @@ bool CSoundFile::ReadMO3(FileReader &file, ModLoadingFlags loadFlags)
m_nDefaultSpeed = fileHeader.defaultSpeed ? fileHeader.defaultSpeed : 6;
m_nDefaultTempo.Set(fileHeader.defaultTempo ? fileHeader.defaultTempo : 125, 0);
mpt::ustring originalFormatType;
mpt::ustring originalFormatName;
if(fileHeader.flags & MO3FileHeader::isIT)
{
SetType(MOD_TYPE_IT);
originalFormatType = U_("it");
originalFormatName = U_("Impulse Tracker");
} else if(fileHeader.flags & MO3FileHeader::isS3M)
{
else if(fileHeader.flags & MO3FileHeader::isS3M)
SetType(MOD_TYPE_S3M);
originalFormatType = U_("s3m");
originalFormatName = U_("ScreamTracker 3");
} else if(fileHeader.flags & MO3FileHeader::isMOD)
{
else if(fileHeader.flags & MO3FileHeader::isMOD)
SetType(MOD_TYPE_MOD);
originalFormatType = U_("mod");
originalFormatName = U_("Generic MOD");
} else if(fileHeader.flags & MO3FileHeader::isMTM)
{
else if(fileHeader.flags & MO3FileHeader::isMTM)
SetType(MOD_TYPE_MTM);
originalFormatType = U_("mtm");
originalFormatName = U_("MultiTracker");
} else
{
else
SetType(MOD_TYPE_XM);
originalFormatType = U_("xm");
originalFormatName = U_("FastTracker 2");
}
if(fileHeader.flags & MO3FileHeader::linearSlides)
m_SongFlags.set(SONG_LINEARSLIDES);
......@@ -1828,7 +1810,6 @@ bool CSoundFile::ReadMO3(FileReader &file, ModLoadingFlags loadFlags)
mpt::ustring madeWithTracker;
uint16 cwtv = 0;
uint16 cmwt = 0;
MPT_UNUSED_VARIABLE(cmwt);
while(musicChunk.CanRead(8))
{
uint32 id = musicChunk.ReadUint32LE();
......@@ -1926,16 +1907,18 @@ bool CSoundFile::ReadMO3(FileReader &file, ModLoadingFlags loadFlags)
if(fileHeader.flags & MO3FileHeader::modplugMode)
{
// Apply some old ModPlug (mis-)behaviour
for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++)
if(!m_dwLastSavedWithVersion)
{
if(ModInstrument *ins = Instruments[i])
// These fixes are only applied when the OpenMPT version number is not known, as otherwise the song upgrade feature will take care of it.
for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++)
{
// Fix pitch / filter envelope being shortened by one tick
if(m_dwLastSavedWithVersion < MPT_V("1.20.00.00"))
if(ModInstrument *ins = Instruments[i])
{
// Fix pitch / filter envelope being shortened by one tick (for files before v1.20)
ins->GetEnvelope(ENV_PITCH).Convert(MOD_TYPE_XM, GetType());
// Fix excessive pan swing range
if(m_dwLastSavedWithVersion < MPT_V("1.26.00.00"))
// Fix excessive pan swing range (for files before v1.26)
ins->nPanSwing = (ins->nPanSwing + 3) / 4u;
}
}
}
if(m_dwLastSavedWithVersion < MPT_V("1.18.00.00"))
......@@ -1956,8 +1939,39 @@ bool CSoundFile::ReadMO3(FileReader &file, ModLoadingFlags loadFlags)
m_modFormat.formatName = mpt::format(U_("Un4seen MO3 v%1"))(version);
m_modFormat.type = U_("mo3");
m_modFormat.originalType = std::move(originalFormatType);
m_modFormat.originalFormatName = std::move(originalFormatName);
switch(GetType())
{
case MOD_TYPE_MTM:
m_modFormat.originalType = U_("mtm");
m_modFormat.originalFormatName = U_("MultiTracker");
break;
case MOD_TYPE_MOD:
m_modFormat.originalType = U_("mod");
m_modFormat.originalFormatName = U_("Generic MOD");
break;
case MOD_TYPE_XM:
m_modFormat.originalType = U_("xm");
m_modFormat.originalFormatName = U_("FastTracker 2");
break;
case MOD_TYPE_S3M:
m_modFormat.originalType = U_("s3m");
m_modFormat.originalFormatName = U_("ScreamTracker 3");
break;
case MOD_TYPE_IT:
m_modFormat.originalType = U_("it");
if(cmwt)
m_modFormat.originalFormatName = mpt::format(U_("Impulse Tracker %1.%2"))(cmwt >> 8, mpt::ufmt::hex0<2>(cmwt & 0xFF));
else
m_modFormat.originalFormatName = U_("Impulse Tracker");
break;
case MOD_TYPE_MPT:
m_modFormat.originalType = U_("mptm");
m_modFormat.originalFormatName = U_("OpenMPT MPTM");
break;
default:
MPT_ASSERT_NOTREACHED();
}
m_modFormat.madeWithTracker = std::move(madeWithTracker);
if(m_dwLastSavedWithVersion)
m_modFormat.charset = mpt::Charset::Windows1252;
......