From 6bb39422881d683946746f14a1e54951476db667 Mon Sep 17 00:00:00 2001 From: greye Date: Sun, 7 Jul 2013 13:47:40 +0400 Subject: [PATCH] use Land height data for position in coc --- apps/openmw/mwscript/cellextensions.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index e1acfadb2d..dfd8967782 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -87,10 +87,21 @@ namespace MWScript static bool findExteriorPosition(const std::string &name, ESM::Position &pos) { + pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; MWBase::World *world = MWBase::Environment::get().getWorld(); if (const ESM::Cell *ext = world->getExterior(name)) { - world->indexToPosition(ext->mData.mX, ext->mData.mY, pos.pos[0], pos.pos[1], true); + int x = ext->getGridX(); + int y = ext->getGridY(); + world->indexToPosition(x, y, pos.pos[0], pos.pos[1], true); + + ESM::Land* land = + world->getStore().get().search(x, y); + assert(land && "Correctly found exteriors must have land data"); + if (!land->isDataLoaded(ESM::Land::DATA_VHGT)) { + land->loadData(ESM::Land::DATA_VHGT); + } + pos.pos[2] = land->mLandData->mHeights[ESM::Land::LAND_NUM_VERTS / 2 + 1]; return true; }