harden .fur file saver
This commit is contained in:
parent
6f8f8d21f3
commit
ffe582236c
|
|
@ -2535,13 +2535,40 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
||||||
|
|
||||||
SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
||||||
saveLock.lock();
|
saveLock.lock();
|
||||||
int insPtr[256];
|
std::vector<int> insPtr;
|
||||||
int wavePtr[256];
|
std::vector<int> wavePtr;
|
||||||
int samplePtr[256];
|
std::vector<int> samplePtr;
|
||||||
std::vector<int> patPtr;
|
std::vector<int> patPtr;
|
||||||
size_t ptrSeek;
|
size_t ptrSeek;
|
||||||
warnings="";
|
warnings="";
|
||||||
|
|
||||||
|
// fail if values are out of range
|
||||||
|
if (song.ordersLen>256) {
|
||||||
|
logE("maximum song length is 256!");
|
||||||
|
lastError="maximum song length is 256";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (song.patLen>256) {
|
||||||
|
logE("maximum pattern length is 256!");
|
||||||
|
lastError="maximum pattern length is 256";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (song.ins.size()>256) {
|
||||||
|
logE("maximum number of instruments is 256!");
|
||||||
|
lastError="maximum number of instruments is 256";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (song.wave.size()>256) {
|
||||||
|
logE("maximum number of wavetables is 256!");
|
||||||
|
lastError="maximum number of wavetables is 256";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (song.sample.size()>256) {
|
||||||
|
logE("maximum number of samples is 256!");
|
||||||
|
lastError="maximum number of samples is 256";
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!notPrimary) {
|
if (!notPrimary) {
|
||||||
song.isDMF=false;
|
song.isDMF=false;
|
||||||
song.version=DIV_ENGINE_VERSION;
|
song.version=DIV_ENGINE_VERSION;
|
||||||
|
|
@ -2719,21 +2746,21 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
||||||
/// INSTRUMENT
|
/// INSTRUMENT
|
||||||
for (int i=0; i<song.insLen; i++) {
|
for (int i=0; i<song.insLen; i++) {
|
||||||
DivInstrument* ins=song.ins[i];
|
DivInstrument* ins=song.ins[i];
|
||||||
insPtr[i]=w->tell();
|
insPtr.push_back(w->tell());
|
||||||
ins->putInsData(w);
|
ins->putInsData(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WAVETABLE
|
/// WAVETABLE
|
||||||
for (int i=0; i<song.waveLen; i++) {
|
for (int i=0; i<song.waveLen; i++) {
|
||||||
DivWavetable* wave=song.wave[i];
|
DivWavetable* wave=song.wave[i];
|
||||||
wavePtr[i]=w->tell();
|
wavePtr.push_back(w->tell());
|
||||||
wave->putWaveData(w);
|
wave->putWaveData(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SAMPLE
|
/// SAMPLE
|
||||||
for (int i=0; i<song.sampleLen; i++) {
|
for (int i=0; i<song.sampleLen; i++) {
|
||||||
DivSample* sample=song.sample[i];
|
DivSample* sample=song.sample[i];
|
||||||
samplePtr[i]=w->tell();
|
samplePtr.push_back(w->tell());
|
||||||
w->write("SMPL",4);
|
w->write("SMPL",4);
|
||||||
w->writeI(0);
|
w->writeI(0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue