From: <sag...@us...> - 2010-03-30 19:13:18
|
Revision: 564 http://modplug.svn.sourceforge.net/modplug/?rev=564&view=rev Author: saga-games Date: 2010-03-30 19:13:11 +0000 (Tue, 30 Mar 2010) Log Message: ----------- [Fix] Pattern Editor: When using MIDI record or split keyboard settings, volume data was writting into the volume column in MOD format. [Ref] Improved TCHAR handling of the previous patch (does not really matter at the moment, but let's better fix this right now) Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_pat.cpp Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2010-03-29 20:00:06 UTC (rev 563) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2010-03-30 19:13:11 UTC (rev 564) @@ -135,7 +135,7 @@ CHAR s[_MAX_PATH], *pszCmd, *pszData; int len; - lstrcpyn(s, lpszCommand, sizeof(s)); + lstrcpyn(s, lpszCommand, CountOf(s)); len = strlen(s) - 1; while ((len > 0) && (strchr("(){}[]\'\" ", s[len]))) s[len--] = 0; pszCmd = s; @@ -356,24 +356,24 @@ } return TRUE; } - GetPrivateProfileString(_T("Ultrasound"), _T("PatchDir"), _T(""), szUltraSndPath, sizeof(szUltraSndPath), lpszConfigFile); + GetPrivateProfileString(_T("Ultrasound"), _T("PatchDir"), _T(""), szUltraSndPath, CountOf(szUltraSndPath), lpszConfigFile); if (!strcmp(szUltraSndPath, _T(".\\"))) szUltraSndPath[0] = 0; - if (!szUltraSndPath[0]) GetCurrentDirectory(sizeof(szUltraSndPath), szUltraSndPath); + if (!szUltraSndPath[0]) GetCurrentDirectory(CountOf(szUltraSndPath), szUltraSndPath); for (UINT iMidi=0; iMidi<256; iMidi++) { szFileName[0] = 0; wsprintf(s, (iMidi < 128) ? _T("Midi%d") : _T("Perc%d"), iMidi & 0x7f); - GetPrivateProfileString(_T("Midi Library"), s, _T(""), szFileName, sizeof(szFileName), lpszConfigFile); + GetPrivateProfileString(_T("Midi Library"), s, _T(""), szFileName, CountOf(szFileName), lpszConfigFile); // Check for ULTRASND.INI if (!szFileName[0]) { LPCSTR pszSection = (iMidi < 128) ? _T("Melodic Patches") : _T("Drum Patches"); wsprintf(s, _T("%d"), iMidi & 0x7f); - GetPrivateProfileString(pszSection, s, _T(""), szFileName, sizeof(szFileName), lpszConfigFile); + GetPrivateProfileString(pszSection, s, _T(""), szFileName, CountOf(szFileName), lpszConfigFile); if (!szFileName[0]) { pszSection = (iMidi < 128) ? _T("Melodic Bank 0") : _T("Drum Bank 0"); - GetPrivateProfileString(pszSection, s, "", szFileName, sizeof(szFileName), lpszConfigFile); + GetPrivateProfileString(pszSection, s, "", szFileName, CountOf(szFileName), lpszConfigFile); } if (szFileName[0]) { @@ -384,9 +384,9 @@ int len = strlen(s)-1; if ((len) && (s[len-1] != '\\')) strcat(s, _T("\\")); } - strncat(s, szFileName, sizeof(s)); - strncat(s, ".pat", sizeof(s)); - strcpy(szFileName, s); + _tcsncat(s, szFileName, CountOf(s)); + _tcsncat(s, ".pat", CountOf(s)); + _tcscpy(szFileName, s); } } if (szFileName[0]) @@ -396,7 +396,7 @@ if ((glpMidiLibrary->MidiMap[iMidi] = new TCHAR[_MAX_PATH]) == nullptr) return FALSE; } CMainFrame::RelativePathToAbsolute(szFileName); - strcpy(glpMidiLibrary->MidiMap[iMidi], szFileName); + _tcscpy(glpMidiLibrary->MidiMap[iMidi], szFileName); } } return FALSE; @@ -409,7 +409,7 @@ TCHAR szFileName[_MAX_PATH], s[128]; if ((!glpMidiLibrary) || (!lpszConfigFile) || (!lpszConfigFile[0])) return FALSE; - for (UINT iMidi=0; iMidi<256; iMidi++) if (glpMidiLibrary->MidiMap[iMidi]) + for(size_t iMidi = 0; iMidi < 256; iMidi++) if (glpMidiLibrary->MidiMap[iMidi]) { if (iMidi < 128) wsprintf(s, _T("Midi%d"), iMidi); @@ -418,7 +418,7 @@ strcpy(szFileName, glpMidiLibrary->MidiMap[iMidi]); - if (szFileName[0]) + if(szFileName[0]) { if(IsPortableMode()) CMainFrame::AbsolutePathToRelative(szFileName); @@ -449,8 +449,9 @@ { CHAR s[MAX_PATH]; UINT numBanks = CMainFrame::GetPrivateProfileLong("DLS Banks", "NumBanks", 0, theApp.GetConfigFileName()); - for (UINT i=0; i<numBanks; i++) { - wsprintf(s, _T("Bank%d"), i+1); + for(size_t i = 0; i < numBanks; i++) + { + wsprintf(s, _T("Bank%d"), i + 1); TCHAR szPath[_MAX_PATH]; GetPrivateProfileString("DLS Banks", s, "", szPath, INIBUFFERSIZE, theApp.GetConfigFileName()); CMainFrame::RelativePathToAbsolute(szPath); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2010-03-29 20:00:06 UTC (rev 563) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2010-03-30 19:13:11 UTC (rev 564) @@ -4226,22 +4226,36 @@ }*/ // -- write vol data + int volWrite = -1; if (vol >= 0 && vol <= 64 && !(isSplit && pModDoc->GetSplitKeyboardSettings()->splitVolume)) //write valid volume, as long as there's no split volume override. { - p->volcmd=VOLCMD_VOLUME; - p->vol = vol; + volWrite = vol; } else if (isSplit && pModDoc->GetSplitKeyboardSettings()->splitVolume) //cater for split volume override. { if (pModDoc->GetSplitKeyboardSettings()->splitVolume > 0 && pModDoc->GetSplitKeyboardSettings()->splitVolume <= 64) { - p->volcmd=VOLCMD_VOLUME; - p->vol = pModDoc->GetSplitKeyboardSettings()->splitVolume; + volWrite = pModDoc->GetSplitKeyboardSettings()->splitVolume; } } + if(volWrite != -1) + { + if(pSndFile->GetType() == MOD_TYPE_MOD) + { + p->command = CMD_VOLUME; + p->param = (MODCOMMAND::PARAM)volWrite; + } else + { + p->volcmd = VOLCMD_VOLUME; + p->vol = (MODCOMMAND::VOL)volWrite; + } + } + // -- write sdx if playing live - if (usePlaybackPosition && nTick) { // avoid SD0 which will be mis-interpreted - if (p->command == 0) { //make sure we don't overwrite any existing commands. + if (usePlaybackPosition && nTick) // avoid SD0 which will be mis-interpreted + { + if (p->command == 0) //make sure we don't overwrite any existing commands. + { p->command = (pSndFile->TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; UINT maxSpeed = 0x0F; if(pSndFile->m_nMusicSpeed > 0) maxSpeed = min(0x0F, pSndFile->m_nMusicSpeed - 1); @@ -4275,14 +4289,17 @@ } //Move cursor down only if not recording live. - if ( bIsLiveRecord == false ) + if(bIsLiveRecord == false) { - if ((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) { + if((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) + { - if (nRow + m_nSpacing < pSndFile->PatternSize[nPat] || (CMainFrame::m_dwPatternSetup & PATTERN_CONTSCROLL)) { + if(nRow + m_nSpacing < pSndFile->PatternSize[nPat] || (CMainFrame::m_dwPatternSetup & PATTERN_CONTSCROLL)) + { SetCurrentRow(nRow + m_nSpacing, (CMainFrame::m_dwPatternSetup & PATTERN_CONTSCROLL) ? true: false); m_bLastNoteEntryBlocked=false; - } else { + } else + { m_bLastNoteEntryBlocked=true; // if the cursor is block by the end of the pattern here, } // we must remember to not step back should the next note form a chord. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |