mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:15:32 +00:00
Fix transition between exterior cells for non-local players
Make the local player send a packet whenever moving from one exterior cell to another, don't require objects to have RefNums to be moved correctly between exterior cells, and increase the packet priority for cell changes.
This commit is contained in:
parent
45fab50bd8
commit
7bf08e5e5a
3 changed files with 33 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue