1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-05 19:19:44 +00:00

[General] Fix jump synchronization for players

This had been broken by fr3dz10's physics rewrites from the earlier part of the year that made it so dedicated players were always regarded by the movement solver as being on the ground.
This commit is contained in:
David Cernat 2021-10-09 18:11:57 +02:00
parent b67af8d99c
commit 3e81371e53
8 changed files with 56 additions and 1 deletions

View file

@ -443,6 +443,17 @@ namespace MWBase
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to set whether a Ptr is on the ground or not, needed for proper
synchronization in multiplayer
*/
virtual void setOnGround(const MWWorld::Ptr& ptr, bool onGround) = 0;
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition

View file

@ -64,6 +64,9 @@ DedicatedPlayer::DedicatedPlayer(RakNet::RakNetGUID guid) : BasePlayer(guid)
hasReceivedInitialEquipment = false;
hasFinishedInitialTeleportation = false;
isJumping = false;
wasJumping = false;
}
DedicatedPlayer::~DedicatedPlayer()
@ -209,6 +212,17 @@ void DedicatedPlayer::setAnimFlags()
isLevitationPurged = false;
}
if (isJumping && !wasJumping)
{
world->setOnGround(ptr, false);
wasJumping = true;
}
else if (wasJumping && !isJumping)
{
world->setOnGround(ptr, true);
wasJumping = false;
}
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
ptrCreatureStats->setDrawState(static_cast<MWMechanics::DrawState_>(drawState));

View file

@ -85,6 +85,8 @@ namespace mwmp
bool hasReceivedInitialEquipment;
bool hasFinishedInitialTeleportation;
bool isLevitationPurged;
bool wasJumping;
};
}
#endif //OPENMW_DEDICATEDPLAYER_HPP

View file

@ -612,7 +612,7 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
isFlying = world->isFlying(ptrPlayer);
bool isJumping = !world->isOnGround(ptrPlayer) && !isFlying;
isJumping = !world->isOnGround(ptrPlayer) && !isFlying;
// We need to send a new packet at the end of jumping, flying and TCL-ing too,
// so keep track of what we were doing last frame

View file

@ -1722,6 +1722,21 @@ namespace MWWorld
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to set whether a Ptr is on the ground or not, needed for proper
synchronization in multiplayer
*/
void World::setOnGround(const Ptr& ptr, bool onGround)
{
MWPhysics::Actor* actor = mPhysics->getActor(ptr);
actor->setOnGround(onGround);
}
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition

View file

@ -517,6 +517,17 @@ namespace MWWorld
End of tes3mp addition
*/
/*
Start of tes3mp addition
Make it possible to set whether a Ptr is on the ground or not, needed for proper
synchronization in multiplayer
*/
void setOnGround(const Ptr& ptr, bool onGround);
/*
End of tes3mp addition
*/
/*
Start of tes3mp addition

View file

@ -232,6 +232,7 @@ namespace mwmp
unsigned int movementFlags = 0;
char drawState;
bool isJumping = false;
bool isFlying = false;
bool hasTcl = false;

View file

@ -12,6 +12,7 @@ void mwmp::PacketPlayerAnimFlags::Packet(RakNet::BitStream *newBitstream, bool s
RW(player->movementFlags, send);
RW(player->drawState, send);
RW(player->isJumping, send);
RW(player->isFlying, send);
RW(player->hasTcl, send);
}