From d8187e40b253a80c6bf2c010645485c94e39de7a Mon Sep 17 00:00:00 2001 From: Dave Corley <smokydave@icloud.com> Date: Sun, 10 Dec 2023 11:16:59 -0600 Subject: [PATCH] Feat(CS): Create LAND record using the undo stack --- apps/opencs/view/render/cell.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index a67923ecf4..f67c2ec466 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -25,6 +25,7 @@ #include "cellwater.hpp" #include "instancedragmodes.hpp" #include "mask.hpp" +#include "model/world/commands.hpp" #include "object.hpp" #include "pathgrid.hpp" #include "terrainstorage.hpp" @@ -131,11 +132,17 @@ void CSVRender::Cell::updateLand() return; } - // Setup land if available - const CSMWorld::IdCollection<CSMWorld::Land>& land = mData.getLand(); + CSMWorld::IdCollection<CSMWorld::Land>& land = mData.getLand(); int landIndex = land.searchId(mId); - if (landIndex == -1 || land.getRecord(mId).isDeleted()) + if (landIndex == -1) + { + CSMWorld::IdTable& landTable + = dynamic_cast<CSMWorld::IdTable&>(*mData.getTableModel(CSMWorld::UniversalId::Type_Land)); + mUndoStack.push(new CSMWorld::CreateCommand(landTable, mId.getRefIdString())); + } + + if (land.getRecord(mId).isDeleted()) return; const ESM::Land& esmLand = land.getRecord(mId).get();