From d792bfdd47f922b18b320444249db68255e1728a Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Tue, 17 May 2016 21:09:08 +0300
Subject: Impliment packets CMSG_PLAYER_CHANGE_DIR and CMSG_MAP_PING for all
 packet versions.

---
 src/net/eathena/gamehandler.cpp   |  95 ++++++++++++++++++++
 src/net/eathena/packetsout.inc    | 143 ++++++++++++++++++++++++++++++
 src/net/eathena/playerhandler.cpp | 180 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 414 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp
index 6327cb794..067e5ff38 100644
--- a/src/net/eathena/gamehandler.cpp
+++ b/src/net/eathena/gamehandler.cpp
@@ -40,6 +40,7 @@
 #include "debug.h"
 
 extern Net::GameHandler *gameHandler;
+extern int packetVersion;
 
 namespace EAthena
 {
@@ -116,6 +117,100 @@ void GameHandler::quit() const
 void GameHandler::ping(const int tick) const
 {
     createOutPacket(CMSG_MAP_PING);
+    if (packetVersion >= 20101124)
+    {
+        // nothing here
+    }
+    else if (packetVersion >= 20080827)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20070212)
+    {
+        outMsg.writeInt16(0, "unknown");
+    }
+    else if (packetVersion >= 20070108)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20050719)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20050718)
+    {
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20050628)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20050509)
+    {
+        outMsg.writeInt16(0, "unknown");
+    }
+    else if (packetVersion >= 20050110)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20041129)
+    {
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20041025)
+    {
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20041005)
+    {
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20040920)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20040906)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20040809)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+        outMsg.writeInt8(0, "unknown");
+    }
+    else if (packetVersion >= 20040726)
+    {
+        outMsg.writeInt16(0, "unknown");
+        outMsg.writeInt16(0, "unknown");
+    }
     outMsg.writeInt32(tick, "tick");
 }
 
diff --git a/src/net/eathena/packetsout.inc b/src/net/eathena/packetsout.inc
index a44966def..6d02d2d8d 100644
--- a/src/net/eathena/packetsout.inc
+++ b/src/net/eathena/packetsout.inc
@@ -291,16 +291,54 @@ packet(CMSG_PARTY_INVITE2,                0x0000,   0, nullptr);
 packet(CMSG_SKILL_FEEL_SAVE_OK,           0x0000,   0, nullptr);
 packet(CMSG_PLAYER_LESS_EFFECTS,          0x0000,   0, nullptr);
 #else
+// 20040713
+if (packetVersion >= 20040713)
+{
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x009b,  13, clif->pChangeDir);
+}
+
 // 20040726
 if (packetVersion >= 20040726)
 {
     packet(CMSG_CHAT_MESSAGE,             0x00f3,  -1, clif->pGlobalMessage);
+    packet(CMSG_MAP_PING,                 0x00f7,  10, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x009f,  13, clif->pChangeDir);
+}
+
+// 20040809
+if (packetVersion >= 20040809)
+{
+    packet(CMSG_MAP_PING,                 0x00f7,  13, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x009f,  12, clif->pChangeDir);
 }
 
 // 20040906
 if (packetVersion >= 20040906)
 {
     packet(CMSG_CHAT_MESSAGE,             0x009f,  -1, clif->pGlobalMessage);
+    packet(CMSG_MAP_PING,                 0x0116,  11, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x00f3,  10, clif->pChangeDir);
+}
+
+// 20040920
+if (packetVersion >= 20040920)
+{
+    packet(CMSG_MAP_PING,                 0x0116,  14, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x00f3,  18, clif->pChangeDir);
+}
+
+// 20041005
+if (packetVersion >= 20041005)
+{
+    packet(CMSG_MAP_PING,                 0x0116,  10, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x00f3,  13, clif->pChangeDir);
+}
+
+// 20041025
+if (packetVersion >= 20041025)
+{
+    packet(CMSG_MAP_PING,                 0x0116,   9, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x00f3,  15, clif->pChangeDir);
 }
 
 // 20041108
@@ -320,6 +358,8 @@ if (packetVersion >= 20041115)
 if (packetVersion >= 20041129)
 {
     packet(CMSG_CHAT_MESSAGE,             0x0085,  -1, clif->pGlobalMessage);
+    packet(CMSG_MAP_PING,                 0x0089,   7, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x00f3,   8, clif->pChangeDir);
 }
 
 // 20050110
@@ -327,6 +367,8 @@ if (packetVersion >= 20050110)
 {
     packet(CMSG_CHAT_MESSAGE,             0x00f3,  -1, clif->pGlobalMessage);
     packet(CMSG_CLOSE_STORAGE,            0x0193,   2, clif->pCloseKafra);
+    packet(CMSG_MAP_PING,                 0x0089,   9, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  23, clif->pChangeDir);
 }
 
 // 20050328
@@ -335,18 +377,73 @@ if (packetVersion >= 20050328)
     packet(CMSG_TAEKWON_RANKS,            0x0225,   2, clif->pTaekwon);
 }
 
+// 20050509
+if (packetVersion >= 20050509)
+{
+    packet(CMSG_MAP_PING,                 0x0089,   8, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  11, clif->pChangeDir);
+}
+
 // 20050530
 if (packetVersion >= 20050530)
 {
     packet(CMSG_PK_RANKS,                 0x0237,   2, clif->pRankingPk);
 }
 
+// 20050628
+if (packetVersion >= 20050628)
+{
+    packet(CMSG_MAP_PING,                 0x0089,  13, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  17, clif->pChangeDir);
+}
+
+// 20050718
+if (packetVersion >= 20050718)
+{
+    packet(CMSG_MAP_PING,                 0x0089,   7, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  11, clif->pChangeDir);
+}
+
+// 20050719
+if (packetVersion >= 20050719)
+{
+    packet(CMSG_MAP_PING,                 0x0089,  13, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  17, clif->pChangeDir);
+}
+
 // 20050817
 if (packetVersion >= 20050817)
 {
     packet(CMSG_SKILL_FEEL_SAVE_OK,       0x0254,   3, clif->pFeelSaveOk);
 }
 
+// 20060327
+if (packetVersion >= 20060327)
+{
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  12, clif->pChangeDir);
+}
+
+// 20070108
+if (packetVersion >= 20070108)
+{
+    packet(CMSG_MAP_PING,                 0x0089,  11, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  14, clif->pChangeDir);
+}
+
+// 20070212
+if (packetVersion >= 20070212)
+{
+    packet(CMSG_MAP_PING,                 0x0089,  8, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085, 11, clif->pChangeDir);
+}
+
+// 20080827
+if (packetVersion >= 20080827)
+{
+    packet(CMSG_MAP_PING,                 0x0089,  11, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0085,  10, clif->pChangeDir);
+}
+
 // 20080910
 if (packetVersion >= 20080910)
 {
@@ -385,10 +482,19 @@ if (packetVersion >= 20100608)
     packet(CMSG_SEARCHSTORE_NEXT_PAGE,    0x0838,   2, clif->pSearchStoreInfoNextPage);
 }
 
+// 20101124
+if (packetVersion >= 20101124)
+{
+    packet(CMSG_MAP_PING,                 0x0360,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0361,   5, clif->pChangeDir);
+}
+
 // 20111005
 if (packetVersion >= 20111005)
 {
     packet(CMSG_NAME_REQUEST,             0x088a,   6, clif->pGetCharNameRequest);
+    packet(CMSG_MAP_PING,                 0x0817,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0366,   5, clif->pChangeDir);
 }
 
 // 20111102
@@ -397,6 +503,7 @@ if (packetVersion >= 20111102)
     packet(CMSG_SEARCHSTORE_SEARCH,       0x08ab,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x0835,  19, clif->pWantToConnection);  // non PACKETVER_RE
     packet(CMSG_MAP_SERVER_CONNECT,       0x083c,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x0899,   6, clif->pTickSend);          // non PACKETVER_RE
 }
 
 // 20120307
@@ -407,6 +514,8 @@ if (packetVersion >= 20120307)
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0884,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x086A,  19, clif->pWantToConnection);
     packet(CMSG_CHAR_CREATE,              0x0970,   0, nullptr);
+    packet(CMSG_MAP_PING,                 0x0887,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0890,   5, clif->pChangeDir);
 }
 
 // 20120410
@@ -415,6 +524,8 @@ if (packetVersion >= 20120410)
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0819,  -1, clif->pSearchStoreInfo);
     packet(CMSG_SKILL_USE_BEING,          0x083c,  10, clif->pUseSkillToId);
     packet(CMSG_MAP_SERVER_CONNECT,       0x094b,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x0886,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0871,   5, clif->pChangeDir);
 }
 
 // 20120418
@@ -425,12 +536,16 @@ if (packetVersion >= 20120418)
     packet(CMSG_ITEM_PICKUP,              0x07e4,   6, clif->pTakeItem);
     packet(CMSG_MOVE_TO_STORAGE,          0x07ec,   8, clif->pMoveToKafra);
     packet(CMSG_MAP_SERVER_CONNECT,       0x022d,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x035f,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0202,   5, clif->pChangeDir);
 }
 
 // 20120702
 if (packetVersion >= 20120702)
 {
     packet(CMSG_MAP_SERVER_CONNECT,       0x0363,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x0364,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0960,   5, clif->pChangeDir);
 }
 
 // 20120716
@@ -438,6 +553,8 @@ if (packetVersion >= 20120716)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0811,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x022d,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x035f,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0202,   5, clif->pChangeDir);
 }
 
 // 20130320
@@ -445,6 +562,8 @@ if (packetVersion >= 20130320)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x094e,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x0888,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x0363,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0897,   5, clif->pChangeDir);
 }
 
 // 20130515
@@ -452,6 +571,8 @@ if (packetVersion >= 20130515)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0819,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x0943,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x035f,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0362,   5, clif->pChangeDir);
 }
 
 // 20130522
@@ -459,6 +580,8 @@ if (packetVersion >= 20130522)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x095b,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x08a9,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x07ec,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0925,   5, clif->pChangeDir);
 }
 
 // 20130529
@@ -466,6 +589,8 @@ if (packetVersion >= 20130529)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0918,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x0919,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x0897,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0951,   5, clif->pChangeDir);
 }
 
 // 20130605
@@ -473,12 +598,15 @@ if (packetVersion >= 20130605)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0819,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x022d,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x035f,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0202,   5, clif->pChangeDir);
 }
 
 // 20130612
 if (packetVersion >= 20130612)
 {
     packet(CMSG_MAP_SERVER_CONNECT,       0x0919,  19, clif->pWantToConnection);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x087e,   5, clif->pChangeDir);
 }
 
 // 20130618
@@ -486,6 +614,8 @@ if (packetVersion >= 20130618)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0281,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x095b,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x0930,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x08a6,   5, clif->pChangeDir);
 }
 
 // 20130626
@@ -493,12 +623,21 @@ if (packetVersion >= 20130626)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0819,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x088c,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x035f,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x094d,   5, clif->pChangeDir);
 }
 
 // 20130703
 if (packetVersion >= 20130703)
 {
     packet(CMSG_MAP_SERVER_CONNECT,       0x022d,  19, clif->pWantToConnection);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0930,   5, clif->pChangeDir);
+}
+
+// 20130807
+if (packetVersion >= 20130807)
+{
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0202,   5, clif->pChangeDir);
 }
 
 // 20130814
@@ -506,6 +645,8 @@ if (packetVersion >= 20130814)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0889,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x0368,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x088a,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x088c,   5, clif->pChangeDir);
 }
 
 // 20131218
@@ -513,6 +654,8 @@ if (packetVersion >= 20131218)
 {
     packet(CMSG_SEARCHSTORE_SEARCH,       0x0819,  -1, clif->pSearchStoreInfo);
     packet(CMSG_MAP_SERVER_CONNECT,       0x092f,  19, clif->pWantToConnection);
+    packet(CMSG_MAP_PING,                 0x035f,   6, clif->pTickSend);
+    packet(CMSG_PLAYER_CHANGE_DIR,        0x0947,   5, clif->pChangeDir);
 }
 
 // 20131223
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index 09c80e5fa..8f5e625e8 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -44,6 +44,7 @@
 #include "debug.h"
 
 extern Net::PlayerHandler *playerHandler;
+extern int packetVersion;
 extern int serverVersion;
 
 namespace EAthena
@@ -113,10 +114,181 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const
 void PlayerHandler::setDirection(const unsigned char direction) const
 {
     createOutPacket(CMSG_PLAYER_CHANGE_DIR);
-    outMsg.writeInt8(0, "head direction");
-    outMsg.writeInt8(0, "unused");
-    outMsg.writeInt8(MessageOut::toServerDirection(direction),
-        "player direction");
+    if (packetVersion >= 20101124)
+    {
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20080827)
+    {
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20070212)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20070108)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20060327)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20050719)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20050718)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20050628)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20050509)
+    {
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20050110)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20041129)
+    {
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20041025)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20041005)
+    {
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20040920)
+    {
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt32(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20040906)
+    {
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20040809)
+    {
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else if (packetVersion >= 20040713)
+    {
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt16(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
+    else
+    {
+        outMsg.writeInt8(0, "head direction");
+        outMsg.writeInt8(0, "unused");
+        outMsg.writeInt8(MessageOut::toServerDirection(direction),
+            "player direction");
+    }
 }
 
 void PlayerHandler::setDestination(const int x, const int y,
-- 
cgit v1.2.3-70-g09d2