Skip to content

Commit

Permalink
Merge branch 'mapshenanigans' into 'master'
Browse files Browse the repository at this point in the history
Fix local map issues

Closes #8004

See merge request OpenMW/openmw!4174
  • Loading branch information
psi29a committed Jun 15, 2024
2 parents 9523aab + 5a54cd9 commit 218e19d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
3 changes: 3 additions & 0 deletions apps/openmw/mwgui/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@ namespace MWGui
mWeapBox->setUserData(MyGUI::Any::Null);
mSpellBox->clearUserStrings();
mSpellBox->setUserData(MyGUI::Any::Null);

mActiveCell = nullptr;
mHasALastActiveCell = false;
}

void HUD::customMarkerCreated(MyGUI::Widget* marker)
Expand Down
23 changes: 8 additions & 15 deletions apps/openmw/mwgui/mapwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace

MyGUI::IntRect createRect(const MyGUI::IntPoint& center, int radius)
{
return { center.left - radius, center.top + radius, center.left + radius, center.top - radius };
return { center.left - radius, center.top - radius, center.left + radius, center.top + radius };
}

int getLocalViewingDistance()
Expand Down Expand Up @@ -387,16 +387,6 @@ namespace MWGui

if (cell.isExterior())
{
int curX = 0;
int curY = 0;
if (mActiveCell)
{
curX = mActiveCell->getGridX();
curY = mActiveCell->getGridY();
}
const MyGUI::IntRect intersection = { std::max(x, curX) - mCellDistance, std::max(y, curY) - mCellDistance,
std::min(x, curX) + mCellDistance, std::min(y, curY) + mCellDistance };

const MyGUI::IntRect activeGrid = createRect({ x, y }, Constants::CellGridRadius);
const MyGUI::IntRect currentView = createRect({ x, y }, mCellDistance);

Expand All @@ -416,10 +406,13 @@ namespace MWGui
for (auto& widget : mDoorMarkersToRecycle)
widget->setVisible(false);

for (auto const& entry : mMaps)
if (mHasALastActiveCell)
{
if (mHasALastActiveCell && !intersection.inside({ entry.mCellX, entry.mCellY }))
mLocalMapRender->removeExteriorCell(entry.mCellX, entry.mCellY);
for (const auto& entry : mMaps)
{
if (!currentView.inside({ entry.mCellX, entry.mCellY }))
mLocalMapRender->removeExteriorCell(entry.mCellX, entry.mCellY);
}
}
}

Expand Down Expand Up @@ -513,7 +506,7 @@ namespace MWGui
if (markers.empty())
return;

std::string markerTexture;
std::string_view markerTexture;
if (type == MWBase::World::Detect_Creature)
{
markerTexture = "textures\\detect_animal_icon.dds";
Expand Down

0 comments on commit 218e19d

Please sign in to comment.