diff --git a/Source/msg.h b/Source/msg.h index d0b51ad81..10b6131b6 100644 --- a/Source/msg.h +++ b/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; }; diff --git a/Source/multi.cpp b/Source/multi.cpp index 84a6e7fda..85afa1539 100644 --- a/Source/multi.cpp +++ b/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(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(Direction::SouthEast)) { + const Direction newDir = static_cast(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; } diff --git a/Source/pack.cpp b/Source/pack.cpp index fc29573b9..73d40d481 100644 --- a/Source/pack.cpp +++ b/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(player._pdir); CopyUtf8(packed.pName, player._pName, sizeof(packed.pName)); packed.pClass = static_cast(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(Direction::SouthEast)); player.setCharacterLevel(packed.pLevel); player.position.tile = position; player.position.future = position; + player._pdir = static_cast(packed.pdir); player.plrlevel = packed.plrlevel; player.plrIsOnSetLevel = packed.isOnSetLevel != 0; player._pMaxHPBase = baseHpMax; diff --git a/Source/pack.h b/Source/pack.h index a83fa1c84..6f0028be3 100644 --- a/Source/pack.h +++ b/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;