fix instrument move/del screwing up sub-songs

This commit is contained in:
tildearrow 2022-08-15 22:54:31 -05:00
parent 51cc36532e
commit 77109c3832

View file

@ -2181,11 +2181,13 @@ void DivEngine::delInstrument(int index) {
song.ins.erase(song.ins.begin()+index); song.ins.erase(song.ins.begin()+index);
song.insLen=song.ins.size(); song.insLen=song.ins.size();
for (int i=0; i<chans; i++) { for (int i=0; i<chans; i++) {
for (int j=0; j<256; j++) { for (size_t j=0; j<song.subsong.size(); j++) {
if (curPat[i].data[j]==NULL) continue; for (int k=0; k<256; k++) {
for (int k=0; k<curSubSong->patLen; k++) { if (song.subsong[j]->pat[i].data[k]==NULL) continue;
if (curPat[i].data[j]->data[k][2]>index) { for (int l=0; l<song.subsong[j]->patLen; l++) {
curPat[i].data[j]->data[k][2]--; if (song.subsong[j]->pat[i].data[k]->data[l][2]>index) {
song.subsong[j]->pat[i].data[k]->data[l][2]--;
}
} }
} }
} }
@ -2986,13 +2988,15 @@ void DivEngine::moveOrderDown() {
void DivEngine::exchangeIns(int one, int two) { void DivEngine::exchangeIns(int one, int two) {
for (int i=0; i<chans; i++) { for (int i=0; i<chans; i++) {
for (int j=0; j<256; j++) { for (size_t j=0; j<song.subsong.size(); j++) {
if (curPat[i].data[j]==NULL) continue; for (int k=0; k<256; k++) {
for (int k=0; k<curSubSong->patLen; k++) { if (song.subsong[j]->pat[i].data[k]==NULL) continue;
if (curPat[i].data[j]->data[k][2]==one) { for (int l=0; l<curSubSong->patLen; l++) {
curPat[i].data[j]->data[k][2]=two; if (song.subsong[j]->pat[i].data[k]->data[l][2]==one) {
} else if (curPat[i].data[j]->data[k][2]==two) { song.subsong[j]->pat[i].data[k]->data[l][2]=two;
curPat[i].data[j]->data[k][2]=one; } else if (song.subsong[j]->pat[i].data[k]->data[l][2]==two) {
song.subsong[j]->pat[i].data[k]->data[l][2]=one;
}
} }
} }
} }