From b0bd10f219854d4baff79958e2ddc7e69a2f1842 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 3 Aug 2016 22:07:49 +0300 Subject: [PATCH] Allow script-based teleportation from interior to exterior cell 0,0 --- .../Script/Functions/Translocations.cpp | 5 +-- apps/openmw/mwmp/LocalPlayer.cpp | 40 +++++++++---------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Translocations.cpp b/apps/openmw-mp/Script/Functions/Translocations.cpp index dfe1be340..d0224acd6 100644 --- a/apps/openmw-mp/Script/Functions/Translocations.cpp +++ b/apps/openmw-mp/Script/Functions/Translocations.cpp @@ -104,10 +104,7 @@ void ScriptFunctions::SetExterior(unsigned short pid, int x, int y) noexcept cout << "exterior: " << player->GetCell()->mCellId.mIndex.mX << ", " << player->GetCell()->mCellId.mIndex.mY; cout << " in to exterior cell \"" << x << ", " << y << "\"" << endl; - /*cout << "TEST1 : " << player->GetCell()->mData.mFlags << endl; - player->GetCell()->mData.mFlags &= ~1; - cout << "TEST2 : " << player->GetCell()->mData.mFlags << endl;*/ - + player->GetCell()->mName = ""; player->GetCell()->mCellId.mIndex.mX = x; player->GetCell()->mCellId.mIndex.mY = y; diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 6fc5fb0ed..ca5d4fc30 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -139,29 +139,27 @@ void LocalPlayer::setCell() int x = GetCell()->mCellId.mIndex.mX; int y = GetCell()->mCellId.mIndex.mY; ESM::CellId curCell = player.mCell->getCell()->mCellId; - if(x != curCell.mIndex.mX || y != curCell.mIndex.mY) - { - cout << "Exterior location: " << x << ", " << y << endl; - world->indexToPosition (x, y, pos.pos[0], pos.pos[1], true); - pos.pos[2] = 0; - pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; + if (GetCell()->mName.empty()) + { + world->indexToPosition(x, y, pos.pos[0], pos.pos[1], true); + pos.pos[2] = 0; - world->changeToExteriorCell (pos, true); - world->fixPosition(player); - } - else if (world->findExteriorPosition(GetCell()->mName, pos)) - { - cout << "Exterior location: " << GetCell()->mName << endl; - world->changeToExteriorCell(pos, true); - world->fixPosition(player); - } - else - { - cout << "Interior location: " << GetCell()->mName << endl; - world->findInteriorPosition(GetCell()->mName, pos); - world->changeToInteriorCell(GetCell()->mName, pos, true); - } + pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; + + world->changeToExteriorCell(pos, true); + world->fixPosition(player); + } + else if (world->findExteriorPosition(GetCell()->mName, pos)) + { + world->changeToExteriorCell(pos, true); + world->fixPosition(player); + } + else { + + world->findInteriorPosition(GetCell()->mName, pos); + world->changeToInteriorCell(GetCell()->mName, pos, true); + } updateCell(true); }