From: <sag...@us...> - 2013-12-16 17:04:40
|
Revision: 3481 http://sourceforge.net/p/modplug/code/3481 Author: saga-games Date: 2013-12-16 17:04:30 +0000 (Mon, 16 Dec 2013) Log Message: ----------- [Ref] Small oneliner changes here and there. [Mod] mpt::strnlen uses built-in ::strnlen when compiling with MSVC now. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/Load_mo3.cpp trunk/OpenMPT/soundlib/Tables.cpp trunk/OpenMPT/soundlib/modcommand.h Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/common/mptString.h 2013-12-16 17:04:30 UTC (rev 3481) @@ -45,6 +45,7 @@ // Remove whitespace at start of string static inline std::string LTrim(std::string str, const std::string &whitespace = " \n\r\t") +//----------------------------------------------------------------------------------------- { std::string::size_type pos = str.find_first_not_of(whitespace); if(pos != std::string::npos) @@ -72,6 +73,7 @@ // Remove whitespace at end of string static inline std::string RTrim(std::string str, const std::string &whitespace = " \n\r\t") +//----------------------------------------------------------------------------------------- { std::string::size_type pos = str.find_last_not_of(whitespace); if(pos != std::string::npos) @@ -99,6 +101,7 @@ // Remove whitespace at start and end of string static inline std::string Trim(std::string str, const std::string &whitespace = " \n\r\t") +//---------------------------------------------------------------------------------------- { return RTrim(LTrim(str, whitespace), whitespace); } @@ -109,6 +112,7 @@ static inline std::string Replace(std::string str, const std::string &oldStr, const std::string &newStr) +//------------------------------------------------------------------------------------------------------ { std::size_t pos = 0; while((pos = str.find(oldStr, pos)) != std::string::npos) @@ -138,6 +142,9 @@ static inline std::size_t strnlen(const char *str, std::size_t n) //--------------------------------------------------------------- { +#if MPT_COMPILER_MSVC + return ::strnlen(str, n); +#else if(n >= SIZE_MAX) { return std::strlen(str); @@ -150,10 +157,12 @@ } } return n; +#endif } static inline int strnicmp(const char *a, const char *b, size_t count) +//-------------------------------------------------------------------- { #if MPT_COMPILER_MSVC return _strnicmp(a, b, count); Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-12-16 17:04:30 UTC (rev 3481) @@ -311,17 +311,13 @@ HANDLE hFindFile = FindFirstFileW(searchPattern.AsNative().c_str(), &findData); if(hFindFile != INVALID_HANDLE_VALUE) { - while(true) + do { if(!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { foundfiles.push_back(path + mpt::PathString::FromNative(findData.cFileName)); } - if(FindNextFileW(hFindFile, &findData) == FALSE) - { - break; - } - } + } while(FindNextFileW(hFindFile, &findData)); FindClose(hFindFile); hFindFile = INVALID_HANDLE_VALUE; } Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-12-16 17:04:30 UTC (rev 3481) @@ -53,7 +53,8 @@ baseRescuePath += timestampDir; if(!PathIsDirectoryW(baseRescuePath.AsNative().c_str()) && !CreateDirectoryW(baseRescuePath.AsNative().c_str(), nullptr)) { - errorMessage.AppendFormat("\n\nCould not create the following directory for saving debug information and modified files to:\n%s", mpt::ToCString(baseRescuePath.ToWide())); + errorMessage += "\n\nCould not create the following directory for saving debug information and modified files to:\n" + + mpt::ToCString(baseRescuePath.ToWide()); } } @@ -90,7 +91,8 @@ pExceptionInfo ? &ExInfo : NULL, NULL, NULL); ::CloseHandle(hFile); - errorMessage.AppendFormat("\n\nDebug information has been saved to\n%s", mpt::ToCString(baseRescuePath.ToWide())); + errorMessage += "\n\nDebug information has been saved to\n" + + mpt::ToCString(baseRescuePath.ToWide()); } } ::FreeLibrary(hDll); @@ -149,7 +151,7 @@ } -// Try to close the audio device and rescue unsaved work if an unhandled exception occours... +// Try to close the audio device and rescue unsaved work if an unhandled exception occurrs... LONG ExceptionHandler::UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo) //---------------------------------------------------------------------------------- { @@ -174,7 +176,7 @@ } CString errorMessage; - errorMessage.Format("Unhandled exception 0x%X at address %p occoured.", pExceptionInfo->ExceptionRecord->ExceptionCode, pExceptionInfo->ExceptionRecord->ExceptionAddress); + errorMessage.Format("Unhandled exception 0x%X at address %p occurred.", pExceptionInfo->ExceptionRecord->ExceptionCode, pExceptionInfo->ExceptionRecord->ExceptionAddress); GenerateDump(errorMessage, pExceptionInfo); Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-12-16 17:04:30 UTC (rev 3481) @@ -25,10 +25,10 @@ static const struct ColorDescriptions { - char *name; + const char *name; int previewImage; uint32 colorIndex1, colorIndex2, colorIndex3; - char *descText1, *descText2, *descText3; + const char *descText1, *descText2, *descText3; } colorDefs[] = { {"Pattern Editor", 0, MODCOLOR_BACKNORMAL, MODCOLOR_TEXTNORMAL, MODCOLOR_BACKHILIGHT, "Background:", "Foreground:", "Highlighted:"}, @@ -550,7 +550,7 @@ static const struct GeneralOptionsDescriptions { uint32 flag; - char *name, *description; + const char *name, *description; } generalOptionsList[] = { {PATTERN_PLAYNEWNOTE, "Play new notes while recording", "When this option is enabled, notes entered in the pattern editor will always be played (If not checked, notes won't be played in record mode)."}, Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-16 17:04:30 UTC (rev 3481) @@ -333,7 +333,6 @@ BOOL CTrackApp::ImportMidiConfig(SettingsContainer &file, bool forgetSettings) //---------------------------------------------------------------------------- { - TCHAR s[_MAX_PATH]; mpt::PathString UltraSndPath; UltraSndPath = file.Read<mpt::PathString>("Ultrasound", "PatchDir", mpt::PathString()); @@ -348,21 +347,22 @@ for (UINT iMidi=0; iMidi<256; iMidi++) { mpt::PathString filename; - wsprintf(s, (iMidi < 128) ? _T("Midi%d") : _T("Perc%d"), iMidi & 0x7f); - filename = file.Read<mpt::PathString>("Midi Library", s, mpt::PathString()); - if(forgetSettings) file.Forget("Midi Library", s); + char section[32]; + sprintf(section, (iMidi < 128) ? _T("Midi%d") : _T("Perc%d"), iMidi & 0x7f); + filename = file.Read<mpt::PathString>("Midi Library", section, mpt::PathString()); + if(forgetSettings) file.Forget("Midi Library", section); // Check for ULTRASND.INI if(filename.empty()) { LPCSTR pszSection = (iMidi < 128) ? _T("Melodic Patches") : _T("Drum Patches"); - wsprintf(s, _T("%d"), iMidi & 0x7f); - filename = file.Read<mpt::PathString>(pszSection, s, mpt::PathString()); - if(forgetSettings) file.Forget(pszSection, s); + sprintf(section, _T("%d"), iMidi & 0x7f); + filename = file.Read<mpt::PathString>(pszSection, section, mpt::PathString()); + if(forgetSettings) file.Forget(pszSection, section); if(filename.empty()) { pszSection = (iMidi < 128) ? _T("Melodic Bank 0") : _T("Drum Bank 0"); - filename = file.Read<mpt::PathString>(pszSection, s, mpt::PathString()); - if(forgetSettings) file.Forget(pszSection, s); + filename = file.Read<mpt::PathString>(pszSection, section, mpt::PathString()); + if(forgetSettings) file.Forget(pszSection, section); } if(!filename.empty()) { @@ -401,21 +401,21 @@ BOOL CTrackApp::ExportMidiConfig(SettingsContainer &file) //------------------------------------------------------- { - CHAR s[128]; - for(size_t iMidi = 0; iMidi < 256; iMidi++) if (!midiLibrary.MidiMap[iMidi].empty()) { - if (iMidi < 128) - wsprintf(s, _T("Midi%d"), iMidi); - else - wsprintf(s, _T("Perc%d"), iMidi & 0x7F); - mpt::PathString szFileName = midiLibrary.MidiMap[iMidi]; if(!szFileName.empty()) { if(theApp.IsPortableMode()) szFileName = theApp.AbsolutePathToRelative(szFileName); + + char s[16]; + if (iMidi < 128) + sprintf(s, _T("Midi%d"), iMidi); + else + sprintf(s, _T("Perc%d"), iMidi & 0x7F); + file.Write<mpt::PathString>("Midi Library", s, szFileName); } } @@ -438,7 +438,7 @@ for(size_t i = 0; i < numBanks; i++) { char s[16]; - wsprintf(s, _T("Bank%d"), i + 1); + sprintf(s, _T("Bank%d"), i + 1); mpt::PathString path = theApp.GetSettings().Read<mpt::PathString>("DLS Banks", s, mpt::PathString()); path = theApp.RelativePathToAbsolute(path); AddDLSBank(path); @@ -483,7 +483,6 @@ BOOL CTrackApp::SaveDefaultDLSBanks() //----------------------------------- { - TCHAR s[64]; DWORD nBanks = 0; for(size_t i = 0; i < gpDLSBanks.size(); i++) { @@ -497,7 +496,8 @@ path = theApp.AbsolutePathToRelative(path); } - wsprintf(s, _T("Bank%d"), nBanks+1); + char s[16]; + sprintf(s, _T("Bank%d"), nBanks + 1); theApp.GetSettings().Write<mpt::PathString>("DLS Banks", s, path); nBanks++; @@ -776,8 +776,6 @@ AfxOleInit(); // Standard initialization - // Change the registry key under which our settings are stored. - //SetRegistryKey(_T("Olivier Lapicque")); // Start loading BeginWaitCursor(); @@ -827,7 +825,7 @@ ImportMidiConfig(theApp.GetSettings(), true); // create main MDI Frame window - CMainFrame* pMainFrame = new CMainFrame(/*cmdInfo.m_csExtension*/); + CMainFrame* pMainFrame = new CMainFrame(); if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; @@ -960,12 +958,8 @@ CModDoc *pModDoc = CMainFrame::GetMainFrame()->GetActiveDoc(); if(pModDoc != nullptr) { - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if(pSndFile != nullptr) - { - nNewType = pSndFile->GetBestSaveFormat(); - bIsProject = pSndFile->m_SongFlags[SONG_ITPROJECT]; - } + nNewType = pModDoc->GetrSoundFile().GetBestSaveFormat(); + bIsProject = pModDoc->GetrSoundFile().m_SongFlags[SONG_ITPROJECT]; } switch(nNewType) @@ -1932,7 +1926,7 @@ for(size_t plug = 0; plug < numPlugins; plug++) { char tmp[32]; - wsprintf(tmp, "Plugin%d", plug); + sprintf(tmp, "Plugin%d", plug); mpt::PathString plugPath = theApp.GetSettings().Read<mpt::PathString>("VST Plugins", tmp, MPT_PATHSTRING("")); if(!plugPath.empty()) { @@ -1970,7 +1964,7 @@ if((**pPlug).pluginId1 != kDmoMagic) { char tmp[32]; - wsprintf(tmp, "Plugin%d", plug); + sprintf(tmp, "Plugin%d", plug); mpt::PathString plugPath = (**pPlug).dllPath; if(theApp.IsPortableMode()) { Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-12-16 17:04:30 UTC (rev 3481) @@ -433,7 +433,7 @@ // (called from writeChunk) void* in <ptr> (char[2048], or sizeof(FSSpec)) - DEPRECATED in VST 2.4 case audioMasterGetChunkFile: #ifdef MODPLUG_TRACKER - if(pVstPlugin) + if(pVstPlugin && pVstPlugin->GetModDoc()) { strcpy(ptr, pVstPlugin->GetModDoc()->GetPathNameMpt().ToLocale().c_str()); return 1; Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-12-16 17:04:30 UTC (rev 3481) @@ -89,19 +89,17 @@ const void *stream = file.GetRawData(); uint32 length = mpt::saturate_cast<uint32>(file.GetLength()); + int32 unmo3result; #ifdef _WIN32 - int32 unmo3result; if(UNMO3_GetVersion == nullptr) { // Old API version: No "flags" parameter. unmo3result = static_cast<UNMO3_DECODE_OLD>(UNMO3_Decode)(&stream, &length); } else +#endif // _WIN32 { unmo3result = static_cast<UNMO3_DECODE>(UNMO3_Decode)(&stream, &length, (loadFlags & loadSampleData) ? 0 : 1); } -#else - int32 unmo3result = UNMO3_Decode(&stream, &length, (loadFlags & loadSampleData) ? 0 : 1); -#endif // _WIN32 if(unmo3result == 0) { Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/soundlib/Tables.cpp 2013-12-16 17:04:30 UTC (rev 3481) @@ -639,7 +639,10 @@ }; -const uint32 LinearSlideUpTable[256] = +// floor(65536 * 2**(n/192)) +// 192 = 16 finetune steps for 12 notes +// Table content is in 16.16 format +const uint32 LinearSlideUpTable[256] = { 65536, 65773, 66010, 66249, 66489, 66729, 66971, 67213, 67456, 67700, 67945, 68190, 68437, 68685, 68933, 69182, @@ -676,8 +679,10 @@ }; - -const uint32 LinearSlideDownTable[256] = +// floor(65536 * 2**(-n/192)) +// 192 = 16 finetune steps for 12 notes +// Table content is in 16.16 format +const uint32 LinearSlideDownTable[256] = { 65536, 65299, 65064, 64830, 64596, 64363, 64131, 63900, 63670, 63440, 63212, 62984, 62757, 62531, 62305, 62081, @@ -824,8 +829,6 @@ - - ///////////////////////////////////////////////////////////////////////////////////////////// @@ -872,7 +875,6 @@ } } - #if 0 // this code is currently unused Modified: trunk/OpenMPT/soundlib/modcommand.h =================================================================== --- trunk/OpenMPT/soundlib/modcommand.h 2013-12-16 14:50:15 UTC (rev 3480) +++ trunk/OpenMPT/soundlib/modcommand.h 2013-12-16 17:04:30 UTC (rev 3481) @@ -88,13 +88,13 @@ CMD_PANNINGSLIDE = 29, CMD_SETENVPOSITION = 30, CMD_MIDI = 31, - CMD_SMOOTHMIDI = 32, //rewbs.smoothVST + CMD_SMOOTHMIDI = 32, CMD_DELAYCUT = 33, CMD_XPARAM = 34, // -> CODE#0010 -> DESC="add extended parameter mechanism to pattern effects" -! NEW_FEATURE#0010 - CMD_NOTESLIDEUP = 35, // IMF Gxy / PTM Jxy (Slide y notes up every ticks) - CMD_NOTESLIDEDOWN = 36, // IMF Hxy / PTM Kxy (Slide y notes down every ticks) - CMD_NOTESLIDEUPRETRIG = 37, // PTM Lxy (Slide y notes up every ticks + retrigger note) - CMD_NOTESLIDEDOWNRETRIG = 38, // PTM Mxy (Slide y notes down every ticks + retrigger note) + CMD_NOTESLIDEUP = 35, // IMF Gxy / PTM Jxy (Slide y notes up every x ticks) + CMD_NOTESLIDEDOWN = 36, // IMF Hxy / PTM Kxy (Slide y notes down every x ticks) + CMD_NOTESLIDEUPRETRIG = 37, // PTM Lxy (Slide y notes up every x ticks + retrigger note) + CMD_NOTESLIDEDOWNRETRIG = 38, // PTM Mxy (Slide y notes down every x ticks + retrigger note) CMD_REVERSEOFFSET = 39, // PTM Nxx Revert sample + offset MAX_EFFECTS = 40 }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |