From 3e49b4ca2f6de3c1ccc7503489cdbea5614ed673 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Sat, 2 Apr 2016 01:17:49 +0300
Subject: Sort more packets. Add version checks inside packets.

---
 src/net/eathena/beingrecv.cpp | 20 +++++---------------
 src/net/eathena/beingrecv.h   |  1 -
 src/net/eathena/packetsin.inc | 33 ++++++++++++++++++++++++---------
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index be49cd625..e037f444d 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -1199,7 +1199,11 @@ void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
 
     const uint32_t opt1 = msg.readInt16("opt1");
     const uint32_t opt2 = msg.readInt16("opt2");
-    const uint32_t option = msg.readInt32("option");
+    uint32_t option;
+    if (msg.getVersion() >= 7)
+        option = msg.readInt32("option");
+    else
+        option = msg.readInt16("option");
     dstBeing->setKarma(msg.readUInt8("karma"));
 
     dstBeing->setStatusEffectOpitons(option,
@@ -1226,20 +1230,6 @@ void BeingRecv::processPlayerStatusChange2(Net::MessageIn &msg)
     dstBeing->setStatusEffectOpiton0(option);
 }
 
-void BeingRecv::processPlayerStatusChangeNoTick(Net::MessageIn &msg)
-{
-    const uint16_t status = msg.readInt16("index");
-    const BeingId id = msg.readBeingId("account id");
-    const Enable flag = fromBool(msg.readUInt8("state")
-        ? true : false, Enable);
-
-    Being *const dstBeing = actorManager->findBeing(id);
-    if (!dstBeing)
-        return;
-
-    dstBeing->setStatusEffect(status, flag);
-}
-
 void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
 {
     BLOCK_START("BeingRecv::processBeingResurrect")
diff --git a/src/net/eathena/beingrecv.h b/src/net/eathena/beingrecv.h
index 004ca22b0..4932232ba 100644
--- a/src/net/eathena/beingrecv.h
+++ b/src/net/eathena/beingrecv.h
@@ -78,7 +78,6 @@ namespace EAthena
         void processSkillGroundNoDamage(Net::MessageIn &msg);
         void processSkillEntry(Net::MessageIn &msg);
         void processPlayerStatusChange(Net::MessageIn &msg);
-        void processPlayerStatusChangeNoTick(Net::MessageIn &msg);
         void processBeingResurrect(Net::MessageIn &msg);
         void processPlayerGuilPartyInfo(Net::MessageIn &msg);
         void processBeingRemoveSkill(Net::MessageIn &msg);
diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc
index 3156c8a29..bd52ca6c5 100644
--- a/src/net/eathena/packetsin.inc
+++ b/src/net/eathena/packetsin.inc
@@ -23,6 +23,8 @@
 // very outdated packets
 packet(SMSG_BEING_CHANGE_LOOKS_OUTDATED,   0x00c3,   8, nullptr,                                        0);
 packet(SMSG_BEING_FAKE_NAME,               0x0078,  54, &BeingRecv::processBeingFakeName,               0);
+packet(SMSG_BEING_STATUS_CHANGE,           0x0196,   9, &BeingRecv::processBeingStatusChange,           1);
+packet(SMSG_PLAYER_STATUS_CHANGE,          0x0119,  13, &BeingRecv::processPlayerStatusChange,          1);
 
 // 3
 packet(SMSG_PLAYER_INVENTORY_USE,          0x01c8,  13, &Ea::InventoryRecv::processPlayerInventoryUse,  3);
@@ -37,6 +39,9 @@ packet(SMSG_PLAYER_CART_ADD,               0x01c5,  22, &InventoryRecv::processP
 // 20040816
 packet(SMSG_ADMIN_ACCOUNT_STATS,           0x0214,  42, &AdminRecv::processAccountStats,                20040816);
 
+// 20041101
+packet(SMSG_PLAYER_SKILL_MESSAGE,          0x0215,   6, &PlayerRecv::processPlayerSkillMessage,         20041101);
+
 // 20041108
 packet(SMSG_FAMILY_ASK_FOR_CHILD_REPLY,    0x0216,   6, &FamilyRecv::processAskForChildReply,           20041108);
 packet(SMSG_BLACKSMITH_RANKS_LIST,         0x0219, 282, &BeingRecv::processBlacksmithRanksList,         20041108);
@@ -50,6 +55,12 @@ packet(SMSG_PLAYER_REFINE_LIST,            0x0221,  -1, &InventoryRecv::processP
 // 20050328
 packet(SMSG_PLAYER_FAME_TAEKWON,           0x0224,  10, &PlayerRecv::processPlayerFameTaekwon,          20050328);
 
+// 20050411
+if (packetVersion >= 20050411)
+{
+    packet(SMSG_PLAYER_STATUS_CHANGE,      0x0229,  15, &BeingRecv::processPlayerStatusChange,          20050411);
+}
+
 // 20050523
 packet(SMSG_HOMUNCULUS_DATA,               0x0230,  12, &HomunculusRecv::processHomunculusData,         20050523);
 
@@ -105,6 +116,7 @@ if (packetVersion >= 20060424)
     packet(SMSG_BEING_SPECIAL_EFFECT_NUM,  0x0284,  14, &BeingRecv::processBeingSpecialEffectNum,       20060424);
     packet(SMSG_NPC_CASH_SHOP_OPEN,        0x0287,  -1, &CashShopRecv::processCashShopOpen,             20060424);
     packet(SMSG_NPC_CASH_BUY_ACK,          0x0289,   8, &CashShopRecv::processCashShopBuyAck,           20060424);
+    packet(SMSG_PLAYER_STATUS_CHANGE2,     0x028a,  18, &BeingRecv::processPlayerStatusChange2,         20060424);
     packet(SMSG_FORMAT_MESSAGE,            0x0291,   4, &ChatRecv::processFormatMessage,                20060424);
     packet(SMSG_BOSS_MAP_INFO,             0x0293,  70, &BeingRecv::processBossMapInfo,                 20060424);
     packet(SMSG_PLAYER_READ_BOOK,          0x0294,  10, &PlayerRecv::processPlayerReadBook,             20060424);
@@ -172,6 +184,12 @@ packet(SMSG_NPC_PROGRESS_BAR_ABORT,        0x02f2,   2, &NpcRecv::processProgres
 // 20081112
 packet(SMSG_PLAYER_SKILL_COOLDOWN,         0x043d,   8, &SkillRecv::processSkillCoolDown,               20081112);
 
+// 20081113
+if (packetVersion >= 20081113)
+{
+    packet(SMSG_PLAYER_SKILL_COOLDOWN_LIST, 0x043e,  -1, &SkillRecv::processSkillCoolDownList,          20081113);
+}
+
 // 20081126
 packet(SMSG_PET_STATUS,                    0x01a2,  37, &PetRecv::processPetStatus,                     20081126);
 
@@ -257,7 +275,10 @@ if (packetVersion >= 20120618)
 }
 
 // 20120604
-packet(SMSG_PLAYER_SKILL_COOLDOWN_LIST,    0x0985,  -1, &SkillRecv::processSkillCoolDownList,           20120604);
+if (packetVersion >= 20120604)
+{
+    packet(SMSG_PLAYER_SKILL_COOLDOWN_LIST, 0x0985,  -1, &SkillRecv::processSkillCoolDownList,           20120604);
+}
 
 // 20120925
 if (packetVersion >= 20120925)
@@ -476,17 +497,11 @@ packet(SMSG_PLAYER_REPAIR_EFFECT,          0x01fe,   5, &InventoryRecv::processP
 packet(SMSG_PLAYER_REPAIR_LIST,            0x01fc,  -1, &InventoryRecv::processPlayerRepairList,        0);
 packet(SMSG_PLAYER_SKILLS,                 0x010f,  -1, &SkillRecv::processPlayerSkills,                0);
 packet(SMSG_PLAYER_SKILL_AUTO_SPELLS,      0x01cd,  29, &SkillRecv::processSkillAutoSpells,             0);
-
-// 20150000 or near
-packet(SMSG_PLAYER_SKILL_COOLDOWN_LIST_OUTDATED, 0x043e, 0, nullptr,                                    0);
-packet(SMSG_PLAYER_SKILL_MESSAGE,          0x0215,   6, &PlayerRecv::processPlayerSkillMessage,         0);
 packet(SMSG_PLAYER_SKILL_PRODUCE_EFFECT,   0x018f,   6, &SkillRecv::processSkillProduceEffect,          0);
 packet(SMSG_PLAYER_SKILL_PRODUCE_MIX_LIST, 0x018d,  -1, &SkillRecv::processSkillProduceMixList,         0);
 packet(SMSG_PLAYER_SKILL_UP,               0x010e,  11, &Ea::SkillRecv::processPlayerSkillUp,           0);
-packet(SMSG_PLAYER_STATUS_CHANGE,          0x0229,  15, &BeingRecv::processPlayerStatusChange,          0);
-packet(SMSG_PLAYER_STATUS_CHANGE2,         0x028a,  18, &BeingRecv::processPlayerStatusChange2,         0);
-packet(SMSG_PLAYER_STATUS_CHANGE_NO_TICK,  0x0196,   9, &BeingRecv::processPlayerStatusChangeNoTick,    0);
-packet(SMSG_PLAYER_STATUS_CHANGE_OUTDATED, 0x0119,  13, nullptr,                                        0);
+
+// 20150000 or near
 packet(SMSG_PLAYER_STAT_UPDATE_1,          0x00b0,   8, &Ea::PlayerRecv::processPlayerStatUpdate1,      0);
 packet(SMSG_PLAYER_STAT_UPDATE_2,          0x00b1,   8, &Ea::PlayerRecv::processPlayerStatUpdate2,      0);
 packet(SMSG_PLAYER_STAT_UPDATE_3,          0x0141,  14, &Ea::PlayerRecv::processPlayerStatUpdate3,      0);
-- 
cgit v1.2.3-70-g09d2