|
From: <sag...@us...> - 2009-11-28 18:11:56
|
Revision: 428
http://modplug.svn.sourceforge.net/modplug/?rev=428&view=rev
Author: saga-games
Date: 2009-11-28 18:11:44 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
[Fix] Revision 421 broke reading MPT instrument / songs extension for IT / MPTM files which had an empty sample slot.
Revision Links:
--------------
http://modplug.svn.sourceforge.net/modplug/?rev=421&view=rev
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2009-11-28 16:12:21 UTC (rev 427)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2009-11-28 18:11:44 UTC (rev 428)
@@ -1209,14 +1209,13 @@
// In order to properly compute the position, in file, of eventual extended settings
// such as "attack" we need to keep the "real" size of the last sample as those extra
// setting will follow this sample in the file
- UINT lastSampleSize = 0;
+ UINT lastSampleOffset = 0;
// -! NEW_FEATURE#0027
// Reading Samples
m_nSamples = CLAMP(pifh->smpnum, 1, MAX_SAMPLES - 1);
for (UINT nsmp=0; nsmp<pifh->smpnum; nsmp++) if ((smppos[nsmp]) && (smppos[nsmp] <= dwMemLength - sizeof(ITSAMPLESTRUCT)))
{
- lastSampleSize = 0; //ensure lastsamplesize = 0 if last sample is empty, else we'll skip the MPTX stuff.
ITSAMPLESTRUCT *pis = (ITSAMPLESTRUCT *)(lpStream+smppos[nsmp]);
if (pis->id == 0x53504D49)
{
@@ -1269,7 +1268,8 @@
// -> CODE#0027
// -> DESC="per-instrument volume ramping setup (refered as attack)"
// ReadSample(&Ins[nsmp+1], flags, (LPSTR)(lpStream+pis->samplepointer), dwMemLength - pis->samplepointer);
- lastSampleSize = ReadSample(&Samples[nsmp+1], flags, (LPSTR)(lpStream+pis->samplepointer), dwMemLength - pis->samplepointer);
+ if(pis->samplepointer)
+ lastSampleOffset = pis->samplepointer + ReadSample(&Samples[nsmp+1], flags, (LPSTR)(lpStream+pis->samplepointer), dwMemLength - pis->samplepointer);
// -! NEW_FEATURE#0027
}
}
@@ -1284,11 +1284,7 @@
// -> DESC="per-instrument volume ramping setup (refered as attack)"
// Compute extra instruments settings position
- if(pifh->smpnum)
- {
- ITSAMPLESTRUCT *pis = (ITSAMPLESTRUCT *)(lpStream+smppos[pifh->smpnum-1]);
- dwMemPos = pis->samplepointer + lastSampleSize;
- }
+ if(lastSampleOffset > 0) dwMemPos = lastSampleOffset;
// Load instrument and song extensions.
if(mptStartPos >= dwMemPos)
@@ -2339,10 +2335,9 @@
flags = (psmp->uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S;
}
}
- if ((psmp->pSample) && (psmp->nLength))
- itss.samplepointer = dwPos;
- else
- itss.samplepointer = itss.flags = 0;
+ itss.samplepointer = dwPos;
+ if (!(psmp->pSample) || !(psmp->nLength))
+ itss.flags = 0;
fseek(f, smppos[nsmp-1], SEEK_SET);
fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f);
fseek(f, dwPos, SEEK_SET);
@@ -2918,10 +2913,9 @@
itss.flags |= 0x02;
flags = RS_PCM16S;
}
- if ((psmp->pSample) && (psmp->nLength))
- itss.samplepointer = dwPos;
- else
- itss.samplepointer = itss.flags = 0;
+ itss.samplepointer = dwPos;
+ if (!(psmp->pSample) || !(psmp->nLength))
+ itss.flags = 0;
fseek(f, smppos[nsmp-1], SEEK_SET);
fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f);
fseek(f, dwPos, SEEK_SET);
@@ -3374,7 +3368,7 @@
void CSoundFile::SaveExtendedInstrumentProperties(MODINSTRUMENT *instruments[], UINT nInstruments, FILE* f)
//------------------------------------------------------------------------------------------------------------
-// Used only when saving IT and XM.
+// Used only when saving IT, XM and MPTM.
// ITI, ITP saves using Ericus' macros etc...
// The reason is that ITs and XMs save [code][size][ins1.Value][ins2.Value]...
// whereas ITP saves [code][size][ins1.Value][code][size][ins2.Value]...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|