mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 15:06:43 +00:00
[Server] Send level packets in Player's update() at the appropriate time
Previously, trying to send a level packet after base info and character class packets in a script actually led to the level packet being sent first and then being overridden by the others, with the player ending up at level 1 on their client.
This commit is contained in:
parent
494b10b97e
commit
57a0415ba3
3 changed files with 13 additions and 7 deletions
|
@ -19,11 +19,12 @@ NetActor::NetActor() : inventory(this), cellAPI(this)
|
||||||
|
|
||||||
void NetActor::resetUpdateFlags()
|
void NetActor::resetUpdateFlags()
|
||||||
{
|
{
|
||||||
|
baseInfoChanged = false;
|
||||||
|
levelChanged = false;
|
||||||
statsChanged = false;
|
statsChanged = false;
|
||||||
|
positionChanged = false;
|
||||||
skillsChanged = false;
|
skillsChanged = false;
|
||||||
attributesChanged = false;
|
attributesChanged = false;
|
||||||
baseInfoChanged = false;
|
|
||||||
positionChanged = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<float, float, float> NetActor::getPosition() const
|
std::tuple<float, float, float> NetActor::getPosition() const
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
|
|
||||||
mwmp::BaseNetCreature *getNetCreature() { return netCreature; }
|
mwmp::BaseNetCreature *getNetCreature() { return netCreature; }
|
||||||
protected:
|
protected:
|
||||||
bool statsChanged, attributesChanged, skillsChanged, baseInfoChanged, positionChanged;
|
bool baseInfoChanged, levelChanged, statsChanged, positionChanged, attributesChanged, skillsChanged;
|
||||||
mwmp::BasePlayer *basePlayer;
|
mwmp::BasePlayer *basePlayer;
|
||||||
mwmp::BaseNetCreature *netCreature;
|
mwmp::BaseNetCreature *netCreature;
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,14 @@ void Player::update()
|
||||||
// The character class can override values from below on the client, so send it first
|
// The character class can override values from below on the client, so send it first
|
||||||
cClass.update();
|
cClass.update();
|
||||||
|
|
||||||
|
if (levelChanged)
|
||||||
|
{
|
||||||
|
auto packet = plPCtrl->GetPacket(ID_PLAYER_LEVEL);
|
||||||
|
packet->setPlayer(basePlayer);
|
||||||
|
packet->Send(false);
|
||||||
|
packet->Send(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (statsChanged)
|
if (statsChanged)
|
||||||
{
|
{
|
||||||
auto packet = plPCtrl->GetPacket(ID_PLAYER_STATS_DYNAMIC);
|
auto packet = plPCtrl->GetPacket(ID_PLAYER_STATS_DYNAMIC);
|
||||||
|
@ -356,10 +364,7 @@ void Player::setIsMale(bool male)
|
||||||
void Player::setLevel(int level)
|
void Player::setLevel(int level)
|
||||||
{
|
{
|
||||||
creatureStats.mLevel = level;
|
creatureStats.mLevel = level;
|
||||||
auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_LEVEL);
|
levelChanged = true;
|
||||||
packet->setPlayer(this);
|
|
||||||
packet->Send(false);
|
|
||||||
packet->Send(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::getLevel() const
|
int Player::getLevel() const
|
||||||
|
|
Loading…
Reference in a new issue