From a62da201e5516ba677ade73214bb3b161ddd4a05 Mon Sep 17 00:00:00 2001 From: Sam Hellawell Date: Sat, 16 Mar 2024 09:02:47 +0000 Subject: [PATCH] check for land index not -1, fix warning Signed-off-by: Sam Hellawell --- apps/opencs/model/world/regionmap.cpp | 4 +++- apps/opencs/view/world/regionmap.cpp | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/regionmap.cpp b/apps/opencs/model/world/regionmap.cpp index c27846a890..f555f0ea32 100644 --- a/apps/opencs/model/world/regionmap.cpp +++ b/apps/opencs/model/world/regionmap.cpp @@ -29,9 +29,11 @@ namespace CSMWorld { const IdCollection& lands = data.getLand(); int landIndex = lands.searchId(cell.mId); - const Land& land = lands.getRecord(landIndex).get(); + if (landIndex == -1) + return 0.0f; // If any part of land is above water, returns > 0 - otherwise returns < 0 + const Land& land = lands.getRecord(landIndex).get(); if (land.getLandData()) return land.getLandData()->mMaxHeight - cell.mWater; diff --git a/apps/opencs/view/world/regionmap.cpp b/apps/opencs/view/world/regionmap.cpp index 5c3aa11c8e..17d0016afc 100644 --- a/apps/opencs/view/world/regionmap.cpp +++ b/apps/opencs/view/world/regionmap.cpp @@ -364,7 +364,6 @@ std::vector CSVWorld::RegionMap::getDraggedRecords() cons void CSVWorld::RegionMap::dragMoveEvent(QDragMoveEvent* event) { - QModelIndex index = indexAt(event->pos()); const CSMWorld::TableMimeData* mime = dynamic_cast(event->mimeData()); if (mime != nullptr && (mime->holdsType(CSMWorld::UniversalId::Type_Region))) {