diff --git a/src/core/map.cpp b/src/core/map.cpp index e3bf2012..3d839ecc 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -271,34 +271,38 @@ void Map::setNewDimensionsBlockdata(int newWidth, int newHeight) { int oldWidth = getWidth(); int oldHeight = getHeight(); - layout->blockdata.clear(); + Blockdata newBlockdata; for (int y = 0; y < newHeight; y++) for (int x = 0; x < newWidth; x++) { if (x < oldWidth && y < oldHeight) { int index = y * oldWidth + x; - layout->blockdata.append(layout->blockdata.value(index)); + newBlockdata.append(layout->blockdata.value(index)); } else { - layout->blockdata.append(0); + newBlockdata.append(0); } } + + layout->blockdata = newBlockdata; } void Map::setNewBorderDimensionsBlockdata(int newWidth, int newHeight) { int oldWidth = getBorderWidth(); int oldHeight = getBorderHeight(); - layout->border.clear(); + Blockdata newBlockdata; for (int y = 0; y < newHeight; y++) for (int x = 0; x < newWidth; x++) { if (x < oldWidth && y < oldHeight) { int index = y * oldWidth + x; - layout->border.append(layout->border.value(index)); + newBlockdata.append(layout->border.value(index)); } else { - layout->border.append(0); + newBlockdata.append(0); } } + + layout->border = newBlockdata; } void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 22df6d71..508eb085 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2619,7 +2619,7 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked() if (oldMapDimensions != newMapDimensions || oldBorderDimensions != newBorderDimensions) { editor->map->setDimensions(newMapDimensions.width(), newMapDimensions.height()); editor->map->setBorderDimensions(newBorderDimensions.width(), newBorderDimensions.height()); - editor->map->editHistory.push(new ResizeMap(map, + editor->map->editHistory.push(new ResizeMap(map, oldMapDimensions, newMapDimensions, oldMetatiles, map->layout->blockdata, oldBorderDimensions, newBorderDimensions, diff --git a/src/project.cpp b/src/project.cpp index ee041654..dc24259d 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1183,7 +1183,6 @@ bool Project::loadBlockdata(Map *map) { QString path = QString("%1/%2").arg(root).arg(map->layout->blockdata_path); map->layout->blockdata = readBlockdata(path); - map->layout->lastCommitMapBlocks.blocks.clear(); map->layout->lastCommitMapBlocks.blocks = map->layout->blockdata; map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());