Browse Source

[Bugfix] Update players directions on joining (#8462)

master
Yuri Pourre 7 days ago committed by GitHub
parent
commit
5a08031caf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      Source/msg.h
  2. 15
      Source/multi.cpp
  3. 3
      Source/pack.cpp
  4. 1
      Source/pack.h

1
Source/msg.h

@ -703,6 +703,7 @@ struct TPktHdr {
uint8_t bstr;
uint8_t bmag;
uint8_t bdex;
uint8_t pdir;
uint16_t wCheck;
uint16_t wLen;
};

15
Source/multi.cpp

@ -180,6 +180,7 @@ void NetReceivePlayerData(TPkt *pkt)
pkt->hdr.bstr = myPlayer._pBaseStr;
pkt->hdr.bmag = myPlayer._pBaseMag;
pkt->hdr.bdex = myPlayer._pBaseDex;
pkt->hdr.pdir = static_cast<uint8_t>(myPlayer._pdir);
}
bool IsNetPlayerValid(const Player &player)
@ -724,6 +725,16 @@ void ProcessGameMessagePackets()
player._pBaseStr = pkt->bstr;
player._pBaseMag = pkt->bmag;
player._pBaseDex = pkt->bdex;
const uint8_t rawDir = pkt->pdir;
if (rawDir <= static_cast<uint8_t>(Direction::SouthEast)) {
const Direction newDir = static_cast<Direction>(rawDir);
if (player._pdir != newDir && player._pmode == PM_STAND) {
player._pdir = newDir;
StartStand(player, newDir);
}
}
if (!cond && player.plractive && !player.hasNoLife()) {
if (player.isOnActiveLevel() && !player._pLvlChanging) {
if (player.position.tile.WalkingDistance(syncPosition) > 3 && PosOkPlayer(player, syncPosition)) {
@ -949,13 +960,13 @@ void recv_plrinfo(Player &player, const TCmdPlrInfoHdr &header, bool recv)
}
if (!player.hasNoLife()) {
StartStand(player, Direction::South);
StartStand(player, player._pdir);
return;
}
player._pgfxnum &= ~0xFU;
player._pmode = PM_DEATH;
NewPlrAnim(player, player_graphic::Death, Direction::South);
NewPlrAnim(player, player_graphic::Death, player._pdir);
player.AnimInfo.currentFrame = player.AnimInfo.numberOfFrames - 2;
dFlags[player.position.tile.x][player.position.tile.y] |= DungeonFlag::DeadPlayer;
}

3
Source/pack.cpp

@ -221,6 +221,7 @@ void PackNetPlayer(PlayerNetPack &packed, const Player &player)
packed.plrlevel = player.plrlevel;
packed.px = player.position.tile.x;
packed.py = player.position.tile.y;
packed.pdir = static_cast<uint8_t>(player._pdir);
CopyUtf8(packed.pName, player._pName, sizeof(packed.pName));
packed.pClass = static_cast<uint8_t>(player._pClass);
packed.pBaseStr = player._pBaseStr;
@ -489,9 +490,11 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player)
ValidateField(packed._pNumInv, packed._pNumInv <= InventoryGridCells);
ValidateField(packed.pdir, packed.pdir <= static_cast<uint8_t>(Direction::SouthEast));
player.setCharacterLevel(packed.pLevel);
player.position.tile = position;
player.position.future = position;
player._pdir = static_cast<Direction>(packed.pdir);
player.plrlevel = packed.plrlevel;
player.plrIsOnSetLevel = packed.isOnSetLevel != 0;
player._pMaxHPBase = baseHpMax;

1
Source/pack.h

@ -91,6 +91,7 @@ struct PlayerNetPack {
uint8_t plrlevel;
uint8_t px;
uint8_t py;
uint8_t pdir;
char pName[PlayerNameLength];
uint8_t pClass;
uint8_t pBaseStr;

Loading…
Cancel
Save