From: <sag...@us...> - 2011-01-30 14:50:26
|
Revision: 792 http://modplug.svn.sourceforge.net/modplug/?rev=792&view=rev Author: saga-games Date: 2011-01-30 14:50:20 +0000 (Sun, 30 Jan 2011) Log Message: ----------- [Fix] IT Loader: Try to fix loading some IT files that were extracted with unmo3.exe/.dll [Fix] VST: Changed some stuff in the file selection code, now VOPM shouldn't crash anymore. [Ref] Some small changes [Mod] OpenMPT: Version is now 1.19.00.21 Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-01-30 13:38:50 UTC (rev 791) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-01-30 14:50:20 UTC (rev 792) @@ -187,7 +187,7 @@ DWORD CMainFrame::m_nBitsPerSample = 16; DWORD CMainFrame::m_nPreAmp = 128; DWORD CMainFrame::gbLoopSong = TRUE; -LONG CMainFrame::m_nWaveDevice = (SNDDEV_DSOUND << SNDDEV_DEVICE_SHIFT); +LONG CMainFrame::m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_DSOUND); LONG CMainFrame::m_nMidiDevice = 0; DWORD CMainFrame::m_nBufferLength = 75; LONG CMainFrame::gnLVuMeter = 0; @@ -713,10 +713,10 @@ // Check for valid sound device if (!EnumerateSoundDevices(SNDDEV_GET_TYPE(m_nWaveDevice), SNDDEV_GET_NUMBER(m_nWaveDevice), nullptr, 0)) { - m_nWaveDevice = (SNDDEV_DSOUND << SNDDEV_DEVICE_SHIFT); + m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_DSOUND); if (!EnumerateSoundDevices(SNDDEV_GET_TYPE(m_nWaveDevice), SNDDEV_GET_NUMBER(m_nWaveDevice), nullptr, 0)) { - m_nWaveDevice = (SNDDEV_WAVEOUT << SNDDEV_DEVICE_SHIFT); + m_nWaveDevice = SNDDEV_BUILD_ID(0, SNDDEV_WAVEOUT); } } // Default directory location @@ -986,7 +986,8 @@ WritePrivateProfileDWord("Display", "MsgBoxVisibilityFlags", gnMsgBoxVisiblityFlags, iniFile); CHAR s[16]; - for (int ncol=0; ncol<MAX_MODCOLORS; ncol++) { + for (int ncol=0; ncol<MAX_MODCOLORS; ncol++) + { wsprintf(s, "Color%02d", ncol); WritePrivateProfileDWord("Display", s, rgbCustomColors[ncol], iniFile); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-01-30 13:38:50 UTC (rev 791) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-01-30 14:50:20 UTC (rev 792) @@ -1050,6 +1050,8 @@ } +// Check if a given note of an instrument or sample is playing. +// If note == 0, just check if an instrument or sample is playing. BOOL CModDoc::IsNotePlaying(UINT note, UINT nsmp, UINT nins) //---------------------------------------------------------- { @@ -2299,9 +2301,7 @@ case sfx_drywet: chanSpec.Append("Plug wet/dry ratio"); break; case sfx_cc: { int nCC = MacroToMidiCC(macroText); - CString temp; - temp.Format("MidiCC %d", nCC); - chanSpec.Append(temp); + chanSpec.AppendFormat("MidiCC %d", nCC); break; } case sfx_plug: { @@ -2318,9 +2318,7 @@ } if (paramName[0] == 0) strcpy(paramName, "N/A - no plug"); - CString temp; - temp.Format("param %d (%s)", nParam, paramName); - chanSpec.Append(temp); + chanSpec.AppendFormat("param %d (%s)", nParam, paramName); break; } case sfx_custom: default: chanSpec.Append("Custom"); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-01-30 13:38:50 UTC (rev 791) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-01-30 14:50:20 UTC (rev 792) @@ -1070,6 +1070,7 @@ if(!destructor) { pFileSel->nbReturnPath = 0; + pFileSel->reserved = 0; if(pFileSel->command != kVstDirectorySelect) { @@ -1130,24 +1131,32 @@ } else { // Single path + + // VOPM doesn't initialize required information properly (it doesn't memset the struct to 0)... + if(!memcmp(&(effect->uniqueID), "MPOV", 4)) + { + pFileSel->sizeReturnPath = _MAX_PATH; + } + if(pFileSel->returnPath == nullptr || pFileSel->sizeReturnPath == 0) { // Provide some memory for the return path. - pFileSel->sizeReturnPath = files.first_file.length(); - pFileSel->returnPath = new char[pFileSel->sizeReturnPath + 1]; + pFileSel->sizeReturnPath = files.first_file.length() + 1; + pFileSel->returnPath = new char[pFileSel->sizeReturnPath]; if(pFileSel->returnPath == nullptr) { return 0; } - pFileSel->returnPath[pFileSel->sizeReturnPath] = '\0'; + pFileSel->returnPath[pFileSel->sizeReturnPath - 1] = '\0'; pFileSel->reserved = 1; } else { pFileSel->reserved = 0; } - strncpy(pFileSel->returnPath, files.first_file.c_str(), pFileSel->sizeReturnPath); + strncpy(pFileSel->returnPath, files.first_file.c_str(), pFileSel->sizeReturnPath - 1); pFileSel->nbReturnPath = 1; + pFileSel->returnMultiplePaths = nullptr; } return 1; @@ -1179,25 +1188,25 @@ // old versions of reViSiT (which still relied on the host's file selection code) seem to be dodgy. // They report a path size of 0, but when using an own buffer, they will crash. // So we'll just assume that reViSiT can handle long enough (_MAX_PATH) paths here. - pFileSel->sizeReturnPath = strlen(szBuffer); - pFileSel->returnPath[pFileSel->sizeReturnPath] = '\0'; + pFileSel->sizeReturnPath = strlen(szBuffer) + 1; + pFileSel->returnPath[pFileSel->sizeReturnPath - 1] = '\0'; } if(pFileSel->returnPath == nullptr || pFileSel->sizeReturnPath == 0) { // Provide some memory for the return path. - pFileSel->sizeReturnPath = strlen(szBuffer); - pFileSel->returnPath = new char[pFileSel->sizeReturnPath + 1]; + pFileSel->sizeReturnPath = strlen(szBuffer) + 1; + pFileSel->returnPath = new char[pFileSel->sizeReturnPath]; if(pFileSel->returnPath == nullptr) { return 0; } - pFileSel->returnPath[pFileSel->sizeReturnPath] = '\0'; + pFileSel->returnPath[pFileSel->sizeReturnPath - 1] = '\0'; pFileSel->reserved = 1; } else { pFileSel->reserved = 0; } - strncpy(pFileSel->returnPath, szBuffer, pFileSel->sizeReturnPath); + strncpy(pFileSel->returnPath, szBuffer, pFileSel->sizeReturnPath - 1); pFileSel->nbReturnPath = 1; return 1; } else @@ -2009,8 +2018,8 @@ } //rewbs.VSTcompliance: changed from BOOL to long -long CVstPlugin::GetNumParameters() -//--------------------------------- +PlugParamIndex CVstPlugin::GetNumParameters() +//------------------------------------------- { if ((m_pEffect) && (m_pEffect->numParams > 0)) { @@ -2084,7 +2093,7 @@ bool success; //Collect required data - long numParams = GetNumParameters(); + PlugParamIndex numParams = GetNumParameters(); long ID = GetUID(); long plugVersion = GetVersion(); float *params = new float[numParams]; @@ -2115,7 +2124,7 @@ } bool CVstPlugin::LoadProgram(CString fileName) -//------------------------------------ +//-------------------------------------------- { if (!(m_pEffect)) return false; Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2011-01-30 13:38:50 UTC (rev 791) +++ trunk/OpenMPT/mptrack/Vstplug.h 2011-01-30 14:50:20 UTC (rev 792) @@ -106,7 +106,7 @@ PVSTPLUGINLIB GetPluginFactory() const { return m_pFactory; } BOOL HasEditor(); long GetNumPrograms(); - long GetNumParameters(); + PlugParamIndex GetNumParameters(); long GetCurrentProgram(); long GetNumProgramCategories(); //rewbs.VSTpresets long GetProgramNameIndexed(long index, long category, char *text); //rewbs.VSTpresets @@ -198,13 +198,13 @@ void MidiPitchBend(UINT nMidiCh, short pitchBendPos); #else // case: NO_VST public: - long GetNumParameters() {return 0;} + PlugParamIndex GetNumParameters() {return 0;} VOID GetParamName(UINT, LPSTR, UINT) {} void ToggleEditor() {} BOOL HasEditor() {return FALSE;} UINT GetNumCommands() {return 0;} VOID GetPluginType(LPSTR) {} - long GetNumPrograms() {return 0;} + PlugParamIndex GetNumPrograms() {return 0;} long GetProgramNameIndexed(long, long, char*) {return 0;} VOID SetParameter(PlugParamIndex nIndex, PlugParamValue fValue) {} VOID GetParamLabel(UINT, LPSTR) {} Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-01-30 13:38:50 UTC (rev 791) +++ trunk/OpenMPT/mptrack/version.h 2011-01-30 14:50:20 UTC (rev 792) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 19 #define VER_MINOR 00 -#define VER_MINORMINOR 20 +#define VER_MINORMINOR 21 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-01-30 13:38:50 UTC (rev 791) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-01-30 14:50:20 UTC (rev 792) @@ -718,7 +718,7 @@ // the first parapointer, we assume that it's actually no history data. if (dwMemPos + 2 < dwMemLength && (pifh->special & 0x02)) { - size_t nflt = LittleEndianW(*((uint16*)(lpStream + dwMemPos))); + const size_t nflt = LittleEndianW(*((uint16*)(lpStream + dwMemPos))); dwMemPos += 2; if (nflt * 8 <= dwMemLength - dwMemPos && dwMemPos + nflt * 8 <= minptr) @@ -766,6 +766,17 @@ dwMemPos -= 2; } } + // Another non-conforming application is unmo3 < v2.4.0.1, which doesn't set the special bit + // at all, but still writes the two edit history length bytes (zeroes)... + else if(dwMemPos + 2 < dwMemLength && pifh->highlight_major == 0 && pifh->highlight_minor == 0 && pifh->cmwt == 0x0214 && pifh->cwtv == 0x0214 && pifh->reserved == 0 && (pifh->special & (0x02|0x04)) == 0) + { + const size_t nflt = LittleEndianW(*((uint16*)(lpStream + dwMemPos))); + if(nflt == 0) + { + dwMemPos += 2; + } + } + // Reading MIDI Output & Macros if (m_dwSongFlags & SONG_EMBEDMIDICFG) { @@ -866,9 +877,9 @@ continue; } - UINT ch = b & IT_bitmask_patternChanField_c; // 0x7f We have some data grab a byte keeping only 127 bits + UINT ch = b & IT_bitmask_patternChanField_c; // 0x7f We have some data grab a byte keeping only 7 bits if (ch) - ch = (ch - 1);// & IT_bitmask_patternChanMask_c; // 0x3f mask of the byte again, keeping only 64 bits + ch = (ch - 1);// & IT_bitmask_patternChanMask_c; // 0x3f mask of the byte again, keeping only 6 bits if (b & IT_bitmask_patternChanEnabled_c) // 0x80 check if the upper bit is enabled. { @@ -2776,12 +2787,12 @@ const BYTE *p = (const BYTE *)pData; UINT nPos = 0; - while (nPos+8 < nLen) // so plugin data chunks must be multiples of 8 bytes? + while (nPos+8 < nLen) // read 4 magic bytes + size { DWORD nPluginSize; UINT nPlugin; - nPluginSize = *(DWORD *)(p+nPos+4); // why +4? + nPluginSize = *(DWORD *)(p+nPos+4); if (nPluginSize > nLen-nPos-8) break;; if ((*(DWORD *)(p+nPos)) == 'XFHC') { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |