diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index bccd14acb..2f80aaca1 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -365,19 +365,19 @@ void DivInstrument::writeFeatureFM(SafeWriter* w, bool fui) { } void MemPatch::clear() { - data = NULL; - offset=0; - size=0; + data = nullptr; + offset = 0; + size = 0; } bool MemPatch::calcDiff(const void* pre, const void* post, size_t inputSize) { - bool diffValid=false; - size_t firstDiff=0; - size_t lastDiff=0; - const unsigned char* preBytes=(const unsigned char*)pre; - const unsigned char* postBytes=(const unsigned char*)post; + bool diffValid = false; + size_t firstDiff = 0; + size_t lastDiff = 0; + const uint8_t* preBytes = (const uint8_t*)pre; + const uint8_t* postBytes = (const uint8_t*)post; - for (size_t ii=0; iidata and its segment on target - for (size_t ii=0; iiname!=post->name != 0) { - nameValid=true; - name=pre->name; + if (pre->name.compare(post->name) != 0) { + nameValid = true; + name = pre->name; } return nameValid || podPatch.isValid(); @@ -443,7 +443,7 @@ void DivInstrument::recordUndoStepIfChanged(size_t processTime, const DivInstrum if (step.makeUndoPatch(processTime, old, this)) { // make room - if (undoHist.size()>=undoHist.capacity()) { + if (undoHist.size() >= undoHist.capacity()) { DivInstrumentUndoStep* step = undoHist.front(); delete step; undoHist.pop_front(); @@ -455,8 +455,8 @@ void DivInstrument::recordUndoStepIfChanged(size_t processTime, const DivInstrum redoHist.pop_back(); } - DivInstrumentUndoStep* stepPtr=new DivInstrumentUndoStep; - *stepPtr=step; + DivInstrumentUndoStep* stepPtr = new DivInstrumentUndoStep; + *stepPtr = step; step.clear(); // don't let it delete the data ptr that's been copied! undoHist.push_back(stepPtr); @@ -465,16 +465,16 @@ void DivInstrument::recordUndoStepIfChanged(size_t processTime, const DivInstrum } int DivInstrument::undo() { - if (undoHist.empty()) return 0; + if (undoHist.empty()) { return 0; } - DivInstrumentUndoStep* step=undoHist.back(); + DivInstrumentUndoStep* step = undoHist.back(); undoHist.pop_back(); logI("DivInstrument::undo (%u off, %u size)", step->podPatch.offset, step->podPatch.size); step->applyAndReverse(this); // make room - if (redoHist.size()>=redoHist.capacity()) { - DivInstrumentUndoStep* step=redoHist.front(); + if (redoHist.size() >= redoHist.capacity()) { + DivInstrumentUndoStep* step = redoHist.front(); delete step; redoHist.pop_front(); } @@ -484,7 +484,7 @@ int DivInstrument::undo() { } int DivInstrument::redo() { - if (redoHist.empty()) return 0; + if (redoHist.empty()) { return 0; } DivInstrumentUndoStep* step = redoHist.back(); redoHist.pop_back(); @@ -492,8 +492,8 @@ int DivInstrument::redo() { step->applyAndReverse(this); // make room - if (undoHist.size()>=undoHist.capacity()) { - DivInstrumentUndoStep* step=undoHist.front(); + if (undoHist.size() >= undoHist.capacity()) { + DivInstrumentUndoStep* step = undoHist.front(); delete step; undoHist.pop_front(); } diff --git a/src/engine/instrument.h b/src/engine/instrument.h index 473cf777e..c4fd743cd 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -888,7 +888,7 @@ struct DivInstrumentPOD { struct MemPatch { MemPatch() : - data(NULL) + data(nullptr) , offset(0) , size(0) { } @@ -902,9 +902,9 @@ struct MemPatch { void clear(); bool calcDiff(const void* pre, const void* post, size_t size); void applyAndReverse(void* target, size_t inputSize); - bool isValid() const { return size>0; } + bool isValid() const { return size > 0; } - unsigned char* data; + uint8_t* data; size_t offset; size_t size; }; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 9a0c920b1..8fb588a98 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -5250,7 +5250,7 @@ void FurnaceGUI::drawInsEdit() { ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(canvasW,canvasH)); } if (ImGui::Begin("Instrument Editor",&insEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking),_("Instrument Editor"))) { - DivInstrument* ins=NULL; + DivInstrument* ins=nullptr; if (curIns==-2) { ImGui::SetCursorPosY(ImGui::GetCursorPosY()+(ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)*0.5f); CENTER_TEXT(_("waiting...")); @@ -7742,8 +7742,8 @@ void FurnaceGUI::drawInsEdit() { } if (ins) { - bool insChanged=ins!=cachedCurInsPtr; - bool delayDiff=ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseDown(ImGuiMouseButton_Right) || ImGui::GetIO().WantCaptureKeyboard; + bool insChanged = ins != cachedCurInsPtr; + bool delayDiff = ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseDown(ImGuiMouseButton_Right) || ImGui::GetIO().WantCaptureKeyboard; // check against the last cached to see if diff -- note that modifications to instruments happen outside // drawInsEdit (e.g. cursor inputs are processed and can directly modify macro data) @@ -7752,12 +7752,12 @@ void FurnaceGUI::drawInsEdit() { } if (insChanged || !delayDiff) { - cachedCurIns=*ins; + cachedCurIns = *ins; } - cachedCurInsPtr=ins; + cachedCurInsPtr = ins; } else { - cachedCurInsPtr=NULL; + cachedCurInsPtr = nullptr; } }