From: <sag...@us...> - 2010-08-02 21:40:19
|
Revision: 668 http://modplug.svn.sourceforge.net/modplug/?rev=668&view=rev Author: saga-games Date: 2010-08-02 21:40:13 +0000 (Mon, 02 Aug 2010) Log Message: ----------- [Imp] Removed warning when converting from MPTM to another format (the possibility of losing data is always there, and there's a log for that anyway). Instrument tunings are now also removed properly when converting from MPTM. [Fix] Channel names in AMS files (Extreme's Tracker) are now loaded properly. [Ref] Some changes here and there. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Modedit.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Message.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-08-01 22:20:31 UTC (rev 667) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-08-02 21:40:13 UTC (rev 668) @@ -460,7 +460,7 @@ if(m_SndFile.instrumentModified[i]) { unsavedInstrument = true; break; } } - if(unsavedInstrument && ::MessageBox(NULL,"Do you want to save modified instruments ?",NULL,MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES){ + if(unsavedInstrument && ::MessageBox(NULL,"Do you want to save modified instruments?",NULL,MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL) == IDYES){ for(INSTRUMENTINDEX i = 0 ; i < m_SndFile.m_nInstruments ; i++){ if(m_SndFile.m_szInstrumentPath[i][0] != '\0'){ @@ -2042,7 +2042,8 @@ double bpm = CMainFrame::GetMainFrame()->GetApproxBPM(); - switch(m_SndFile.m_nTempoMode) { + switch(m_SndFile.m_nTempoMode) + { case tempo_mode_alternative: Message.Format("Using alternative tempo interpretation.\n\nAssuming:\n. %d ticks per second\n. %d ticks per row\n. %d rows per beat\nthe tempo is approximately: %.20g BPM", m_SndFile.m_nMusicTempo, m_SndFile.m_nMusicSpeed, m_SndFile.m_nRowsPerBeat, bpm); Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2010-08-01 22:20:31 UTC (rev 667) +++ trunk/OpenMPT/mptrack/Moddoc.h 2010-08-02 21:40:13 UTC (rev 668) @@ -218,8 +218,8 @@ // operations public: - BOOL ChangeModType(MODTYPE wType); - BOOL ChangeNumChannels(UINT nNewChannels, const bool showCancelInRemoveDlg = true); + bool ChangeModType(MODTYPE wType); + bool ChangeNumChannels(UINT nNewChannels, const bool showCancelInRemoveDlg = true); BOOL ConvertInstrumentsToSamples(); UINT RemovePlugs(const bool (&keepMask)[MAX_MIXPLUGINS]); Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2010-08-01 22:20:31 UTC (rev 667) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2010-08-02 21:40:13 UTC (rev 668) @@ -19,8 +19,6 @@ static char THIS_FILE[] = __FILE__; #endif -#define str_mptm_conversion_warning GetStrI18N(_TEXT("Conversion from mptm to any other moduletype may makes certain features unavailable and is not guaranteed to work properly. Do the conversion anyway?")) - const size_t Pow10Table[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}; // Return D'th digit(character) of given value. @@ -37,7 +35,7 @@ ////////////////////////////////////////////////////////////////////// // Module type conversion -BOOL CModDoc::ChangeModType(MODTYPE nNewType) +bool CModDoc::ChangeModType(MODTYPE nNewType) //------------------------------------------- { CHAR s[256]; @@ -50,10 +48,11 @@ // This is because ITP is a HACK and doesn't genuinely change m_nType, // but uses flages instead. ChangeFileExtension(nNewType); - return TRUE; + return true; } - if(nNewType == nOldType) return TRUE; + if(nNewType == nOldType) + return true; const bool oldTypeIsMOD = (nOldType == MOD_TYPE_MOD), oldTypeIsXM = (nOldType == MOD_TYPE_XM), oldTypeIsS3M = (nOldType == MOD_TYPE_S3M), oldTypeIsIT = (nOldType == MOD_TYPE_IT), @@ -70,40 +69,38 @@ const CModSpecifications& specs = m_SndFile.GetModSpecifications(nNewType); - if(oldTypeIsMPT) - { - if(::MessageBox(NULL, str_mptm_conversion_warning, 0, MB_YESNO) != IDYES) - return FALSE; + /* + Incomplete list of MPTm-only features and extensions in the old formats: - /* - Incomplete list of MPTm-only features and extensions in the old formats: + Features only available for MPTm: + -User definable tunings. + -Extended pattern range + -Extended sequence + -Multiple sequences ("songs") + -Pattern-specific time signatures + -Pattern effects :xy, S7D, S7E + -Long instrument envelopes + -Envelope release node (this was previously also usable in the IT format, but is deprecated in that format) - Features only available for MPTm: - -User definable tunings. - -Extended pattern range - -Extended sequence - -Multiple sequences + Extended features in IT/XM/S3M/MOD(not all listed below are available in all of those formats): + -plugs + -Extended ranges for + -sample count + -instrument count + -pattern count + -sequence size + -Row count + -channel count + -tempo limits + -Extended sample/instrument properties. + -MIDI mapping directives + -Versioninfo + -channel names + -pattern names + -Alternative tempomodes + -For more info, see e.g. SaveExtendedSongProperties(), SaveExtendedInstrumentProperties() + */ - Extended features in IT/XM/S3M/MOD(not all listed below are available in all of those formats): - -plugs - -Extended ranges for - -sample count - -instrument count - -pattern count - -sequence size - -Row count - -channel count - -tempo limits - -Extended sample/instrument properties. - -MIDI mapping directives - -Versioninfo - -channel names - -pattern names - -Alternative tempomodes - -For more info, see e.g. SaveExtendedSongProperties(), SaveExtendedInstrumentProperties() - */ - } - // Check if conversion to 64 rows is necessary for (UINT ipat=0; ipat<m_SndFile.Patterns.Size(); ipat++) { @@ -114,7 +111,7 @@ if (::MessageBox(NULL, "This operation will convert all instruments to samples,\n" "and resize all patterns to 64 rows.\n" - "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return FALSE; + "Do you want to continue?", "Warning", MB_YESNO | MB_ICONQUESTION) != IDYES) return false; BeginWaitCursor(); BEGIN_CRITICAL(); // Converting instruments to samples @@ -278,7 +275,7 @@ if (oldTypeIsIT_MPT && newTypeIsXM) { bool bBrokenNoteMap = false, bBrokenSustainLoop = false; - for(INSTRUMENTINDEX nIns = 1; nIns <= m_SndFile.m_nInstruments; nIns++) + for(INSTRUMENTINDEX nIns = 1; nIns <= m_SndFile.GetNumInstruments(); nIns++) { MODINSTRUMENT *pIns = m_SndFile.Instruments[nIns]; if (pIns) @@ -314,6 +311,24 @@ if (bBrokenSustainLoop) AddToLog("WARNING: Sustain loops were converted to sustain points.\n"); } + // Instrument tunings + if(oldTypeIsMPT) + { + bool bFirstWarn = true; + for(INSTRUMENTINDEX nIns = 1; nIns <= m_SndFile.GetNumInstruments(); nIns++) + { + if(m_SndFile.Instruments[nIns] != nullptr && m_SndFile.Instruments[nIns]->pTuning != nullptr) + { + m_SndFile.Instruments[nIns]->SetTuning(nullptr); + if(bFirstWarn) + { + AddToLog("WARNING: Instrument tunings will be lost!\n"); + bFirstWarn = false; + } + } + } + } + if(newTypeIsMOD) { // Not supported in MOD format @@ -396,7 +411,7 @@ GetSampleUndo()->ClearUndo(); UpdateAllViews(NULL, HINT_MODTYPE | HINT_MODGENERAL); EndWaitCursor(); - return TRUE; + return true; } // Trim envelopes and remove release nodes. @@ -437,7 +452,7 @@ // Change the number of channels -BOOL CModDoc::ChangeNumChannels(UINT nNewChannels, const bool showCancelInRemoveDlg) +bool CModDoc::ChangeNumChannels(UINT nNewChannels, const bool showCancelInRemoveDlg) //---------------------------------------------------------------------------------- { const CHANNELINDEX maxChans = m_SndFile.GetModSpecifications().channelsMax; @@ -446,10 +461,10 @@ CString error; error.Format("Error: Max number of channels for this file type is %d", maxChans); ::AfxMessageBox(error, MB_OK|MB_ICONEXCLAMATION); - return FALSE; + return false; } - if (nNewChannels == m_SndFile.m_nChannels) return FALSE; + if (nNewChannels == m_SndFile.m_nChannels) return false; if (nNewChannels < m_SndFile.m_nChannels) { UINT nChnToRemove = 0; @@ -466,7 +481,7 @@ CRemoveChannelsDlg rem(&m_SndFile, nChnToRemove, showCancelInRemoveDlg); CheckUnusedChannels(rem.m_bChnMask, nFound); - if (rem.DoModal() != IDOK) return FALSE; + if (rem.DoModal() != IDOK) return false; // Removing selected channels RemoveChannels(rem.m_bChnMask); @@ -483,7 +498,7 @@ { END_CRITICAL(); AddToLog("ERROR: Not enough memory to create new channels!\nPattern Data is corrupted!\n"); - return FALSE; + return false; } for (UINT j=0; j<m_SndFile.Patterns[i].GetNumRows(); j++) { @@ -507,7 +522,7 @@ SetModified(); GetPatternUndo()->ClearUndo(); UpdateAllViews(NULL, HINT_MODTYPE); - return TRUE; + return true; } Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2010-08-01 22:20:31 UTC (rev 667) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2010-08-02 21:40:13 UTC (rev 668) @@ -139,7 +139,7 @@ BYTE chnnamlen = lpStream[dwMemPos++]; if ((chnnamlen) && (chnnamlen < MAX_CHANNELNAME)) { - memcpy(ChnSettings[cNam].szName, lpStream + dwMemPos + 1, chnnamlen); + memcpy(ChnSettings[cNam].szName, lpStream + dwMemPos, chnnamlen); SpaceToNullStringFixed(ChnSettings[cNam].szName, chnnamlen); } dwMemPos += chnnamlen; Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-08-01 22:20:31 UTC (rev 667) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-08-02 21:40:13 UTC (rev 668) @@ -380,7 +380,7 @@ insfile[iSmp] = ((DWORD)LittleEndianW(*((LPWORD)(s+0x0E)))) << 4; insfile[iSmp] += ((DWORD)(BYTE)s[0x0D]) << 20; - if (insfile[iSmp] > dwMemLength) insfile[iSmp] &= 0xFFFF; + if (insfile[iSmp] > dwMemLength) insfile[iSmp] &= 0xFFFF; // wtf? whose idea was this? if(Samples[iSmp].nLoopEnd < 2) Samples[iSmp].nLoopStart = Samples[iSmp].nLoopEnd = 0; Modified: trunk/OpenMPT/soundlib/Message.cpp =================================================================== --- trunk/OpenMPT/soundlib/Message.cpp 2010-08-01 22:20:31 UTC (rev 667) +++ trunk/OpenMPT/soundlib/Message.cpp 2010-08-02 21:40:13 UTC (rev 668) @@ -151,7 +151,7 @@ // [in] data: pointer to the data in memory that is going to be read // [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended). // [in] lineLength: The fixed length of a line. -// [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line) +// [in] lineEndingLength: The padding space between two fixed lines. (there could for example be a null char after every line) // [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise). // [out] returns true on success. bool CSoundFile::ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength, void (*pTextConverter)(char &)) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2010-08-01 22:20:31 UTC (rev 667) +++ trunk/OpenMPT/soundlib/Sndfile.h 2010-08-02 21:40:13 UTC (rev 668) @@ -972,7 +972,7 @@ // [in] data: pointer to the data in memory that is going to be read // [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended). // [in] lineLength: The fixed length of a line. - // [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line) + // [in] lineEndingLength: The padding space between two fixed lines. (there could for example be a null char after every line) // [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise). // [out] returns true on success. bool ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength, void (*pTextConverter)(char &) = nullptr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |