|
From: <sag...@us...> - 2010-05-13 19:12:36
|
Revision: 592
http://modplug.svn.sourceforge.net/modplug/?rev=592&view=rev
Author: saga-games
Date: 2010-05-13 19:12:29 +0000 (Thu, 13 May 2010)
Log Message:
-----------
[Imp] Mod Loaders: Instead of creating messageboxes in various places, errors are now written to the log.
[Imp] Binary files are now less often falsely recognized as early MOD files (15 samples without header): If the orderlist contains orderlist items > 128, loading is cancelled.
[Ref] Bits of refactoring here and there.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_gdm.cpp
trunk/OpenMPT/soundlib/Load_imf.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mo3.cpp
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Load_psm.cpp
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/load_j2b.cpp
Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -14,6 +14,9 @@
#include "stdafx.h"
#include "sndfile.h"
+#ifdef MODPLUG_TRACKER
+#include "../mptrack/moddoc.h"
+#endif // MODPLUG_TRACKER
#pragma pack(1)
@@ -255,9 +258,11 @@
if(Patterns.Insert(iPat, 64))
{
+#ifdef MODPLUG_TRACKER
CString s;
s.Format(TEXT("Allocating patterns failed starting from pattern %u"), iPat);
- MessageBox(NULL, s, TEXT("OpenMPT GDM import"), MB_ICONERROR);
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
+#endif // MODPLUG_TRACKER
break;
}
Modified: trunk/OpenMPT/soundlib/Load_imf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_imf.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/Load_imf.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -8,6 +8,9 @@
#include "stdafx.h"
#include "sndfile.h"
+#ifdef MODPLUG_TRACKER
+#include "../mptrack/moddoc.h"
+#endif // MODPLUG_TRACKER
#pragma pack(1)
@@ -365,9 +368,11 @@
if(Patterns.Insert(nPat, nrows))
{
+#ifdef MODPLUG_TRACKER
CString s;
s.Format(TEXT("Allocating patterns failed starting from pattern %u"), nPat);
- MessageBox(NULL, s, TEXT("OpenMPT IMF import"), MB_ICONERROR);
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
+#endif // MODPLUG_TRACKER
break;
}
row_data = Patterns[nPat];
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -1354,9 +1354,11 @@
{
if(Patterns.Insert(npat, 64))
{
+#ifdef MODPLUG_TRACKER
CString s;
- s.Format("Allocating patterns failed starting from pattern %u", npat);
- MessageBox(NULL, s, "", MB_ICONERROR);
+ s.Format(TEXT("Allocating patterns failed starting from pattern %u"), npat);
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
+#endif
break;
}
continue;
Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mo3.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -8,9 +8,10 @@
#include "stdafx.h"
#include "sndfile.h"
+#ifdef MODPLUG_TRACKER
+#include "../mptrack/moddoc.h"
+#endif // MODPLUG_TRACKER
-
-
// decode a MO3 file (returns the same "exit codes" as UNMO3.EXE, eg. 0=success)
// IN: data/len = MO3 data/len
// OUT: data/len = decoded data/len (if successful)
@@ -29,11 +30,14 @@
#ifdef NO_MO3_SUPPORT
/* As of August 2009, the format revision is 5; Versions > 31 are unlikely to exist in the next few years,
so we will just ignore those if there's no UNMO3 library to tell us if the file is valid or not
- (avoid messagebox with .MOD files that have a song name starting with "MO3" */
+ (avoid log entry with .MOD files that have a song name starting with "MO3" */
if(lpStream[3] > 31) return false;
- AfxMessageBox(GetStrI18N(__TEXT("The file appears to be a MO3 file, but this OpenMPT build does not support loading MO3 files.")));
+#ifdef MODPLUG_TRACKER
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(GetStrI18N(__TEXT("The file appears to be a MO3 file, but this OpenMPT build does not support loading MO3 files.")));
+#endif // MODPLUG_TRACKER
return false;
+
#else
bool b_result = false; // result of trying to load the module, false == fail.
@@ -44,7 +48,9 @@
HMODULE unmo3 = LoadLibrary(_TEXT("unmo3.dll"));
if(unmo3 == NULL) // Didn't succeed.
{
- AfxMessageBox(GetStrI18N(_TEXT("Loading MO3 file failed because unmo3.dll could not be loaded.")), MB_ICONINFORMATION);
+#ifdef MODPLUG_TRACKER
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(GetStrI18N(_TEXT("Loading MO3 file failed because unmo3.dll could not be loaded.")));
+#endif // MODPLUG_TRACKER
}
else //case: dll loaded succesfully.
{
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -326,6 +326,10 @@
m_nChannels = 4;
bFLT8 = false;
}
+
+ // chances are very high that we're dealing with a non-MOD file here.
+ if(m_nSamples == 15 && i >= 0x80)
+ return false;
}
if(bFLT8)
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -20,6 +20,9 @@
#include "stdafx.h"
#include "sndfile.h"
+#ifdef MODPLUG_TRACKER
+#include "../mptrack/moddoc.h"
+#endif // MODPLUG_TRACKER
#pragma pack(1)
@@ -32,67 +35,68 @@
struct PSMNEWHEADER
{
- DWORD formatID; // "PSM " (new format)
- DWORD fileSize; // Filesize - 12
- DWORD fileInfoID; // "FILE" Start of file info
+ uint32 formatID; // "PSM " (new format)
+ uint32 fileSize; // Filesize - 12
+ uint32 fileInfoID; // "FILE" Start of file info
};
struct PSMSONGHEADER
{
- CHAR songType[9]; // Mostly "MAINSONG " (But not in Extreme Pinball!)
- BYTE compression; // 1 - uncompressed
- BYTE numChannels; // Number of channels, usually 4
+ char songType[9]; // Mostly "MAINSONG " (But not in Extreme Pinball!)
+ uint8 compression; // 1 - uncompressed
+ uint8 numChannels; // Number of channels, usually 4
};
struct PSMOLDSAMPLEHEADER // Regular sample header
{
- BYTE flags;
- CHAR fileName[8]; // Filename of the original module (without extension)
- DWORD sampleID; // INS0...INS9 (only last digit of sample ID, i.e. sample 1 and sample 11 are equal)
- CHAR sampleName[33];
- CHAR unknown1[6]; // 00 00 00 00 00 FF
- WORD sampleNumber;
- DWORD sampleLength;
- DWORD loopStart;
- DWORD loopEnd; // FF FF FF FF = end of sample
- BYTE unknown3;
- BYTE defaulPan; // unused?
- BYTE defaultVolume;
- DWORD unknown4;
- WORD C5Freq;
- CHAR unknown5[21]; // 00 ... 00
+ uint8 flags;
+ char fileName[8]; // Filename of the original module (without extension)
+ uint32 sampleID; // INS0...INS9 (only last digit of sample ID, i.e. sample 1 and sample 11 are equal)
+ char sampleName[33];
+ uint8 unknown1[6]; // 00 00 00 00 00 FF
+ uint16 sampleNumber;
+ uint32 sampleLength;
+ uint32 loopStart;
+ uint32 loopEnd; // FF FF FF FF = end of sample
+ uint8 unknown3;
+ uint8 defaulPan; // unused?
+ uint8 defaultVolume;
+ uint32 unknown4;
+ uint16 C5Freq;
+ uint8 unknown5[21]; // 00 ... 00
};
struct PSMNEWSAMPLEHEADER // Sinaria sample header (and possibly other games)
{
- BYTE flags;
- CHAR fileName[8]; // Filename of the original module (without extension)
- CHAR sampleID[8]; // INS0...INS99999
- CHAR sampleName[33];
- CHAR unknown1[6]; // 00 00 00 00 00 FF
- WORD sampleNumber;
- DWORD sampleLength;
- DWORD loopStart;
- DWORD loopEnd;
- WORD unknown3;
- BYTE defaultPan; // unused?
- BYTE defaultVolume;
- DWORD unknown4;
- WORD C5Freq;
- CHAR unknown5[16]; // 00 ... 00
+ uint8 flags;
+ char fileName[8]; // Filename of the original module (without extension)
+ char sampleID[8]; // INS0...INS99999
+ char sampleName[33];
+ uint8 unknown1[6]; // 00 00 00 00 00 FF
+ uint16 sampleNumber;
+ uint32 sampleLength;
+ uint32 loopStart;
+ uint32 loopEnd;
+ uint16 unknown3;
+ uint8 defaultPan; // unused?
+ uint8 defaultVolume;
+ uint32 unknown4;
+ uint16 C5Freq;
+ char unknown5[16]; // 00 ... 00
};
#pragma pack()
struct PSMSUBSONG // For internal use (pattern conversion)
{
- BYTE channelPanning[MAX_BASECHANNELS], channelVolume[MAX_BASECHANNELS];
- bool channelSurround[MAX_BASECHANNELS];
- BYTE defaultTempo, defaultSpeed;
- CHAR songName[10];
+ uint8 channelPanning[MAX_BASECHANNELS], channelVolume[MAX_BASECHANNELS];
+ bool channelSurround[MAX_BASECHANNELS];
+ uint8 defaultTempo, defaultSpeed;
+ char songName[10];
ORDERINDEX startOrder, endOrder, restartPos;
- PSMSUBSONG() {
+ PSMSUBSONG()
+ {
memset(channelPanning, 128, sizeof(channelPanning));
memset(channelVolume, 64, sizeof(channelVolume));
memset(channelSurround, false, sizeof(channelSurround));
@@ -144,9 +148,9 @@
// pattern offset and identifier
PATTERNINDEX numPatterns = 0; // used for setting up the orderlist - final pattern count
- vector<DWORD> patternOffsets; // pattern offsets (sorted as they occour in the file)
- vector<DWORD> patternIDs; // pattern IDs (sorted as they occour in the file)
- vector<DWORD> orderOffsets; // combine the upper two vectors to get the offsets for each order item
+ vector<uint32> patternOffsets; // pattern offsets (sorted as they occour in the file)
+ vector<uint32> patternIDs; // pattern IDs (sorted as they occour in the file)
+ vector<uint32> orderOffsets; // combine the upper two vectors to get the offsets for each order item
patternOffsets.clear();
patternIDs.clear();
orderOffsets.clear();
@@ -159,8 +163,8 @@
{
// Skip through the chunks
ASSERT_CAN_READ(8);
- DWORD chunkID = LittleEndian(*(DWORD *)(lpStream + dwMemPos));
- DWORD chunkSize = LittleEndian(*(DWORD *)(lpStream + dwMemPos + 4));
+ uint32 chunkID = LittleEndian(*(uint32 *)(lpStream + dwMemPos));
+ uint32 chunkSize = LittleEndian(*(uint32 *)(lpStream + dwMemPos + 4));
dwMemPos += 8;
ASSERT_CAN_READ(chunkSize);
@@ -177,7 +181,7 @@
break;
case 0x444F4250: // "PBOD" - Pattern data of a single pattern
- if(chunkSize < 8 || chunkSize != LittleEndian(*(DWORD *)(lpStream + dwMemPos))) return false; // same value twice
+ if(chunkSize < 8 || chunkSize != LittleEndian(*(uint32 *)(lpStream + dwMemPos))) return false; // same value twice
// Pattern ID (something like "P0 " or "P13 ", or "PATT0 " in Sinaria) follows
if(memcmp(lpStream + dwMemPos + 4, "P", 1)) return false;
@@ -210,8 +214,8 @@
// "Sub sub chunks"
while(dwChunkPos + 8 < dwMemPos + chunkSize)
{
- DWORD subChunkID = LittleEndian(*(DWORD *)(lpStream + dwChunkPos));
- DWORD subChunkSize = LittleEndian(*(DWORD *)(lpStream + dwChunkPos + 4));
+ uint32 subChunkID = LittleEndian(*(uint32 *)(lpStream + dwChunkPos));
+ uint32 subChunkSize = LittleEndian(*(uint32 *)(lpStream + dwChunkPos + 4));
dwChunkPos += 8;
switch(subChunkID)
@@ -220,7 +224,7 @@
if(subChunkSize != 6) break;
{
- CHAR cversion[7];
+ char cversion[7];
memcpy(cversion, lpStream + dwChunkPos, 6);
cversion[6] = 0;
int version = atoi(cversion);
@@ -239,7 +243,7 @@
// Now, the interesting part begins!
DWORD dwSettingsOffset = dwChunkPos + 2;
- WORD nChunkCount = 0, nFirstOrderChunk = (WORD)-1;
+ uint16 nChunkCount = 0, nFirstOrderChunk = uint16_max;
// "Sub sub sub chunks" (grrrr, silly format)
while(dwSettingsOffset - dwChunkPos + 1 < subChunkSize)
@@ -257,7 +261,7 @@
char patternID[4]; // temporary
memcpy(patternID, lpStream + dwSettingsOffset + 2 + (bNewFormat ? 3 : 0), 3);
patternID[3] = 0;
- DWORD nPattern = atoi(patternID);
+ uint32 nPattern = atoi(patternID);
// seek which pattern has this ID
for(uint32 i = 0; i < patternIDs.size(); i++)
@@ -278,13 +282,13 @@
}
}
// decide whether this is the first order chunk or not (for finding out the correct restart position)
- if(nFirstOrderChunk == (WORD)-1) nFirstOrderChunk = nChunkCount;
+ if(nFirstOrderChunk == uint16_max) nFirstOrderChunk = nChunkCount;
dwSettingsOffset += 5 + (bNewFormat ? 4 : 0);
break;
case 0x04: // Restart position
{
- WORD nRestartChunk = LittleEndian(*(WORD *)(lpStream + dwSettingsOffset + 1));
+ uint16 nRestartChunk = LittleEndian(*(uint16 *)(lpStream + dwSettingsOffset + 1));
ORDERINDEX nRestartPosition = 0;
if(nRestartChunk >= nFirstOrderChunk) nRestartPosition = (ORDERINDEX)(nRestartChunk - nFirstOrderChunk);
subsong.restartPos += nRestartPosition;
@@ -359,9 +363,11 @@
break;
default: // How the hell should this happen? I've listened through almost all existing (original) PSM files. :)
+#ifdef MODPLUG_TRACKER
CString s;
s.Format("Report to the OpenMPT team: Unknown chunk %d found at position %d (in the OPLH chunk of this PSM file)", lpStream[dwSettingsOffset], dwSettingsOffset);
- MessageBox(NULL, s, TEXT("OpenMPT PSM import"), MB_ICONERROR);
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
+#endif // MODPLUG_TRACKER
// anyway, in such cases, we have to quit as we don't know how big the chunk really is.
return false;
break;
@@ -377,7 +383,7 @@
case 0x4E415050: // PPAN - Channel panning table (used in Sinaria)
if(subChunkSize & 1) return false;
- for(DWORD i = 0; i < subChunkSize; i += 2)
+ for(uint32 i = 0; i < subChunkSize; i += 2)
{
CHANNELINDEX nChn = (CHANNELINDEX)(i >> 1);
if(nChn >= m_nChannels) break;
@@ -507,16 +513,18 @@
for(ORDERINDEX nOrd = 0; nOrd < Order.size(); nOrd++)
{
if(orderOffsets[nOrd] == nullptr) continue;
- DWORD dwPatternOffset = orderOffsets[nOrd];
+ uint32 dwPatternOffset = orderOffsets[nOrd];
if(dwPatternOffset + 2 > dwMemLength) return false;
- WORD patternSize = LittleEndianW(*(WORD *)(lpStream + dwPatternOffset));
+ uint16 patternSize = LittleEndianW(*(uint16 *)(lpStream + dwPatternOffset));
dwPatternOffset += 2;
if(Patterns.Insert(nPat, patternSize))
{
+#ifdef MODPLUG_TRACKER
CString s;
s.Format(TEXT("Allocating patterns failed starting from pattern %u"), nPat);
- MessageBox(NULL, s, TEXT("OpenMPT PSM import"), MB_ICONERROR);
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
+#endif // MODPLUG_TRACKER
break;
}
@@ -527,9 +535,9 @@
for(int nRow = 0; nRow < patternSize; nRow++)
{
if(dwPatternOffset + 2 > dwMemLength) return false;
- WORD rowSize = LittleEndianW(*(WORD *)(lpStream + dwPatternOffset));
+ uint16 rowSize = LittleEndianW(*(uint16 *)(lpStream + dwPatternOffset));
- DWORD dwRowOffset = dwPatternOffset + 2;
+ uint32 dwRowOffset = dwPatternOffset + 2;
while(dwRowOffset < dwPatternOffset + rowSize)
{
@@ -579,7 +587,7 @@
{
// Effect present - convert
if(dwRowOffset + 2 > dwMemLength) return false;
- BYTE command = lpStream[dwRowOffset], param = lpStream[dwRowOffset + 1];
+ uint8 command = lpStream[dwRowOffset], param = lpStream[dwRowOffset + 1];
switch(command)
{
@@ -812,51 +820,51 @@
struct PSM16HEADER
{
- DWORD formatID; // "PSM\xFE" (PSM16)
- CHAR songName[59]; // Song title, padded with nulls
- BYTE lineEnd; // $1A
- BYTE songType; // Song Type bitfield
- BYTE formatVersion; // $10
- BYTE patternVersion; // 0 or 1
- BYTE songSpeed; //
- BYTE songTempo; // 32 ... 255
- BYTE masterVolume; // 0 ... 255
- WORD songLength; // 0 ... 255 (number of patterns to play in the song)
- WORD songOrders; // 0 ... 255 (same as previous value as no subsongs are present)
- WORD numPatterns; // 1 ... 255
- WORD numSamples; // 1 ... 255
- WORD numChannelsPlay; // 0 ... 32 (max. number of channels to play)
- WORD numChannelsReal; // 0 ... 32 (max. number of channels to process)
- DWORD orderOffset;
- DWORD panOffset;
- DWORD patOffset;
- DWORD smpOffset;
- DWORD commentsOffset;
- DWORD patSize; // Size of all patterns
- CHAR filler[40];
+ uint32 formatID; // "PSM\xFE" (PSM16)
+ char songName[59]; // Song title, padded with nulls
+ uint8 lineEnd; // $1A
+ uint8 songType; // Song Type bitfield
+ uint8 formatVersion; // $10
+ uint8 patternVersion; // 0 or 1
+ uint8 songSpeed; //
+ uint8 songTempo; // 32 ... 255
+ uint8 masterVolume; // 0 ... 255
+ uint16 songLength; // 0 ... 255 (number of patterns to play in the song)
+ uint16 songOrders; // 0 ... 255 (same as previous value as no subsongs are present)
+ uint16 numPatterns; // 1 ... 255
+ uint16 numSamples; // 1 ... 255
+ uint16 numChannelsPlay; // 0 ... 32 (max. number of channels to play)
+ uint16 numChannelsReal; // 0 ... 32 (max. number of channels to process)
+ uint32 orderOffset;
+ uint32 panOffset;
+ uint32 patOffset;
+ uint32 smpOffset;
+ uint32 commentsOffset;
+ uint32 patSize; // Size of all patterns
+ uint8 filler[40];
};
struct PSM16SMPHEADER
{
- CHAR filename[13]; // null-terminated
- CHAR name[24]; // dito
- DWORD offset; // in file
- DWORD memoffset; // not used
- WORD sampleNumber; // 1 ... 255
- BYTE flags; // sample flag bitfield
- DWORD length; // in bytes
- DWORD loopStart; // in samples?
- DWORD loopEnd; // in samples?
- CHAR finetune; // 0 ... 15 (useless? also, why is this almost always 70?)
- BYTE volume; // default volume
- WORD c2freq;
+ uint8 filename[13]; // null-terminated
+ uint8 name[24]; // dito
+ uint32 offset; // in file
+ uint32 memoffset; // not used
+ uint16 sampleNumber;// 1 ... 255
+ uint8 flags; // sample flag bitfield
+ uint32 length; // in bytes
+ uint32 loopStart; // in samples?
+ uint32 loopEnd; // in samples?
+ int8 finetune; // 0 ... 15 (useless? also, why is this almost always 70?)
+ uint8 volume; // default volume
+ uint16 c2freq;
};
struct PSM16PATHEADER
{
- WORD size; // includes header bytes
- BYTE numRows; // 1 ... 64
- BYTE numChans; // 1 ... 31
+ uint16 size; // includes header bytes
+ uint8 numRows; // 1 ... 64
+ uint8 numChans; // 1 ... 31
};
#pragma pack()
@@ -898,7 +906,7 @@
// Read orders
dwMemPos = LittleEndian(shdr->orderOffset);
ASSERT_CAN_READ((DWORD)LittleEndianW(shdr->songOrders) + 2);
- if(LittleEndian(shdr->orderOffset) > 4 && LittleEndian(*(DWORD *)(lpStream + dwMemPos - 4)) == 0x44524f50) // PORD
+ if(LittleEndian(shdr->orderOffset) > 4 && LittleEndian(*(uint32 *)(lpStream + dwMemPos - 4)) == 0x44524f50) // PORD
{
Order.ReadAsByte(lpStream + dwMemPos, LittleEndianW(shdr->songOrders), dwMemLength - dwMemPos);
}
@@ -906,7 +914,7 @@
// Read pan positions
dwMemPos = LittleEndian(shdr->panOffset);
ASSERT_CAN_READ(32);
- if(LittleEndian(shdr->panOffset) > 4 && LittleEndian(*(DWORD *)(lpStream + dwMemPos - 4)) == 0x4E415050) // PPAN
+ if(LittleEndian(shdr->panOffset) > 4 && LittleEndian(*(uint32 *)(lpStream + dwMemPos - 4)) == 0x4E415050) // PPAN
{
for(CHANNELINDEX i = 0; i < 32; i++)
{
@@ -919,7 +927,7 @@
// Read samples
dwMemPos = LittleEndian(shdr->smpOffset);
ASSERT_CAN_READ(0);
- if(LittleEndian(shdr->smpOffset) > 4 && LittleEndian(*(DWORD *)(lpStream + dwMemPos - 4)) == 0x48415350) // PSAH
+ if(LittleEndian(shdr->smpOffset) > 4 && LittleEndian(*(uint32 *)(lpStream + dwMemPos - 4)) == 0x48415350) // PSAH
{
SAMPLEINDEX iSmpCount = 0;
m_nSamples = LittleEndianW(shdr->numSamples);
@@ -1000,9 +1008,11 @@
if(Patterns.Insert(nPat, phdr->numRows))
{
+#ifdef MODPLUG_TRACKER
CString s;
s.Format(TEXT("Allocating patterns failed starting from pattern %u"), nPat);
- MessageBox(NULL, s, TEXT("OpenMPT PSM16 import"), MB_ICONERROR);
+ if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
+#endif // MODPLUG_TRACKER
break;
}
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -10,9 +10,11 @@
#include "stdafx.h"
#include "sndfile.h"
-#include "../mptrack/moddoc.h"
#include "../mptrack/misc_util.h"
#include "../mptrack/version.h"
+#ifdef MODPLUG_TRACKER
+#include "../mptrack/moddoc.h"
+#endif // MODPLUG_TRACKER
#pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data"
@@ -218,9 +220,9 @@
bool CSoundFile::ReadS3M(const BYTE *lpStream, DWORD dwMemLength)
//---------------------------------------------------------------
{
- if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER)+64)) return false;
+ if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER) + 64)) return false;
- UINT insnum,patnum,nins,npat;
+ UINT insnum, patnum, nins, npat;
DWORD insfile[128];
WORD ptr[256];
BYTE s[1024];
@@ -512,11 +514,11 @@
if (psfh.flags & 0x10) m_dwSongFlags |= SONG_AMIGALIMITS;
#ifdef MODPLUG_TRACKER
- if(bHasAdlibPatches)
+ if(bHasAdlibPatches && m_pModDoc != nullptr)
{
- ::MessageBox(0, "This track uses Adlib instruments, which are not supported by OpenMPT.", "OpenMPT S3M Import", MB_OK|MB_ICONEXCLAMATION);
+ m_pModDoc->AddToLog("This track uses Adlib instruments, which are not supported by OpenMPT.");
}
-#endif
+#endif // MODPLUG_TRACKER
return true;
}
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2010-05-09 22:04:33 UTC (rev 591)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2010-05-13 19:12:29 UTC (rev 592)
@@ -9,7 +9,9 @@
#include "stdafx.h"
#include "sndfile.h"
+#ifndef ZLIB_WINAPI
#define ZLIB_WINAPI
+#endif // ZLIB_WINAPI
#include "../zlib/zlib.h"
#pragma pack(1)
@@ -18,7 +20,7 @@
struct J2BHEADER
{
uint32 signature; // MUSE
- uint32 deadbeaf; // 0xDEADBEAF (AM) or 0xDEADBABE (AMFF)
+ uint32 deadbeaf; // 0xDEADBEAF (AM) or 0xDEADBABE (AMFF)
uint32 j2blength; // complete filesize
uint32 crc32; // checksum of the compressed data block
uint32 packed_length; // length of the compressed data block
@@ -80,7 +82,7 @@
{
uint32 signature; // "SAMP"
uint32 chunksize; // header + sample size
- uint32 headsize; // header size
+ uint32 headsize; // header size
char name[32];
uint16 pan;
uint16 volume;
@@ -485,6 +487,8 @@
// header is valid, now unpack the RIFF AM file using inflate
DWORD destSize = LittleEndian(header->unpacked_length);
Bytef *bOutput = new Bytef[destSize];
+ if(bOutput == nullptr)
+ return false;
int nRetVal = uncompress(bOutput, &destSize, &lpStream[dwMemPos], LittleEndian(header->packed_length));
bool bResult = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|