diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 808b1b49e..00b27cd9e 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -311,16 +311,40 @@ void LocalPlayer::SendAttack(char type) GetNetworking()->SendData(&bs); } + void LocalPlayer::updateCell(bool forceUpdate) { const ESM::Cell *_cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell(); static bool isExterior = !_cell->isExterior(); - if(isExterior != _cell->isExterior() || !Misc::StringUtils::ciEqual(_cell->mName, GetCell()->mName) || forceUpdate) + bool shouldUpdate = false; + + // Send a packet to server to update this LocalPlayer's cell if: + // 1) forceUpdate is true + // 2) The LocalPlayer's cell name does not equal the World Player's cell name + // 3) The LocalPlayer's exterior cell coordinates do not equal the World Player's + // exterior cell coordinates + if (forceUpdate) { + shouldUpdate = true; + } + else if (!Misc::StringUtils::ciEqual(_cell->mName, GetCell()->mName)) { + shouldUpdate = true; + } + else if (_cell->isExterior()) { + + if (_cell->mCellId.mIndex.mX != GetCell()->mCellId.mIndex.mX) { + shouldUpdate = true; + } + else if (_cell->mCellId.mIndex.mY != GetCell()->mCellId.mIndex.mY) { + shouldUpdate = true; + } + } + + if (shouldUpdate) { (*GetCell()) = *_cell; isExterior = _cell->isExterior(); - + RakNet::BitStream bs; GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_CELL)->Packet(&bs, this, true); GetNetworking()->SendData(&bs); diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 5b53643e8..0c0930ee0 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -242,6 +242,10 @@ namespace MWWorld // Objects with no refnum can't be handled correctly in the merging process that happens // on a save/load, so do a simple copy & delete for these objects. + + // The code below is disabled for TES3MP for as long as player objects lack refnums, + // because it will break exterior cell transitions for them + /* if (!object.getCellRef().getRefNum().hasContentFile()) { MWWorld::Ptr copied = object.getClass().copyToCell(object, *cellToMoveTo, object.getRefData().getCount()); @@ -249,6 +253,7 @@ namespace MWWorld object.getRefData().setBaseNode(NULL); return copied; } + */ MovedRefTracker::iterator found = mMovedHere.find(object.getBase()); if (found != mMovedHere.end()) diff --git a/components/openmw-mp/Packets/PacketCell.cpp b/components/openmw-mp/Packets/PacketCell.cpp index 3e40880ee..9cf8bb1f6 100644 --- a/components/openmw-mp/Packets/PacketCell.cpp +++ b/components/openmw-mp/Packets/PacketCell.cpp @@ -9,8 +9,8 @@ mwmp::PacketCell::PacketCell(RakNet::RakPeerInterface *peer) : BasePacket(peer) { packetID = ID_GAME_CELL; - priority = MEDIUM_PRIORITY; - reliability = UNRELIABLE_SEQUENCED; + priority = IMMEDIATE_PRIORITY; + reliability = RELIABLE_ORDERED; } void mwmp::PacketCell::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send)