forked from mirror/openmw-tes3mp
[General] Record and get player positions before their last cell change
This commit is contained in:
parent
fbec0d9443
commit
0e2038f045
5 changed files with 56 additions and 0 deletions
|
@ -45,6 +45,30 @@ double PositionFunctions::GetPosZ(unsigned short pid) noexcept
|
||||||
return player->position.pos[2];
|
return player->position.pos[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noexcept
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, 0.0f);
|
||||||
|
|
||||||
|
return player->previousCellPosition.pos[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noexcept
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, 0.0f);
|
||||||
|
|
||||||
|
return player->previousCellPosition.pos[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noexcept
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, 0.0f);
|
||||||
|
|
||||||
|
return player->previousCellPosition.pos[2];
|
||||||
|
}
|
||||||
|
|
||||||
void PositionFunctions::GetRot(unsigned short pid, float *x, float *y, float *z) noexcept
|
void PositionFunctions::GetRot(unsigned short pid, float *x, float *y, float *z) noexcept
|
||||||
{
|
{
|
||||||
*x = 0.00;
|
*x = 0.00;
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
{"GetPosY", PositionFunctions::GetPosY},\
|
{"GetPosY", PositionFunctions::GetPosY},\
|
||||||
{"GetPosZ", PositionFunctions::GetPosZ},\
|
{"GetPosZ", PositionFunctions::GetPosZ},\
|
||||||
\
|
\
|
||||||
|
{"GetPreviousCellPosX", PositionFunctions::GetPreviousCellPosX},\
|
||||||
|
{"GetPreviousCellPosY", PositionFunctions::GetPreviousCellPosY},\
|
||||||
|
{"GetPreviousCellPosZ", PositionFunctions::GetPreviousCellPosZ},\
|
||||||
|
\
|
||||||
{"GetRot", PositionFunctions::GetRot},\
|
{"GetRot", PositionFunctions::GetRot},\
|
||||||
{"GetRotX", PositionFunctions::GetRotX},\
|
{"GetRotX", PositionFunctions::GetRotX},\
|
||||||
{"GetRotZ", PositionFunctions::GetRotZ},\
|
{"GetRotZ", PositionFunctions::GetRotZ},\
|
||||||
|
@ -59,6 +63,30 @@ public:
|
||||||
*/
|
*/
|
||||||
static double GetPosZ(unsigned short pid) noexcept;
|
static double GetPosZ(unsigned short pid) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the X position of a player from before their latest cell change.
|
||||||
|
*
|
||||||
|
* \param pid The player ID.
|
||||||
|
* \return The X position.
|
||||||
|
*/
|
||||||
|
static double GetPreviousCellPosX(unsigned short pid) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the Y position of a player from before their latest cell change.
|
||||||
|
*
|
||||||
|
* \param pid The player ID.
|
||||||
|
* \return The Y position.
|
||||||
|
*/
|
||||||
|
static double GetPreviousCellPosY(unsigned short pid) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the Z position of a player from before their latest cell change.
|
||||||
|
*
|
||||||
|
* \param pid The player ID.
|
||||||
|
* \return The Z position.
|
||||||
|
*/
|
||||||
|
static double GetPreviousCellPosZ(unsigned short pid) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Assign the player's rotational coordinate values to the variables passed as
|
* \brief Assign the player's rotational coordinate values to the variables passed as
|
||||||
* parameters.
|
* parameters.
|
||||||
|
|
|
@ -375,6 +375,7 @@ void LocalPlayer::updateCell(bool forceUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
cell = *ptrCell;
|
cell = *ptrCell;
|
||||||
|
previousCellPosition = position;
|
||||||
|
|
||||||
// Make sure the position is updated before a cell packet is sent, or else
|
// Make sure the position is updated before a cell packet is sent, or else
|
||||||
// cell change events in server scripts will have the wrong player position
|
// cell change events in server scripts will have the wrong player position
|
||||||
|
|
|
@ -235,6 +235,7 @@ namespace mwmp
|
||||||
|
|
||||||
ESM::Position position;
|
ESM::Position position;
|
||||||
ESM::Position direction;
|
ESM::Position direction;
|
||||||
|
ESM::Position previousCellPosition;
|
||||||
ESM::Cell cell;
|
ESM::Cell cell;
|
||||||
ESM::NPC npc;
|
ESM::NPC npc;
|
||||||
ESM::NpcStats npcStats;
|
ESM::NpcStats npcStats;
|
||||||
|
|
|
@ -20,6 +20,8 @@ void mwmp::PacketPlayerCellChange::Packet(RakNet::BitStream *bs, bool send)
|
||||||
RW(player->cell.mData, send, 1);
|
RW(player->cell.mData, send, 1);
|
||||||
RW(player->cell.mName, send, 1);
|
RW(player->cell.mName, send, 1);
|
||||||
|
|
||||||
|
RW(player->previousCellPosition.pos, send, 1);
|
||||||
|
|
||||||
RW(player->isChangingRegion, send);
|
RW(player->isChangingRegion, send);
|
||||||
|
|
||||||
if (player->isChangingRegion)
|
if (player->isChangingRegion)
|
||||||
|
|
Loading…
Reference in a new issue