diff options
author | hemagx <hemagx2@gmail.com> | 2016-06-23 11:58:01 +0200 |
---|---|---|
committer | hemagx <hemagx2@gmail.com> | 2016-06-23 23:50:17 +0200 |
commit | a3e0827422d1745c619f5bee4a225874e727e188 (patch) | |
tree | 7c3a9f0e0b5ba9b2249d8a8ba68a202287d98f11 | |
parent | fdc5307d320ae0e3eef2e2a8f1d939e91a552d10 (diff) | |
download | hercules-a3e0827422d1745c619f5bee4a225874e727e188.tar.gz hercules-a3e0827422d1745c619f5bee4a225874e727e188.tar.bz2 hercules-a3e0827422d1745c619f5bee4a225874e727e188.tar.xz hercules-a3e0827422d1745c619f5bee4a225874e727e188.zip |
Fix Possible Crash on clif_bl_type now it checks if vd is null
-rw-r--r-- | src/map/clif.c | 42 | ||||
-rw-r--r-- | src/map/clif.h | 25 |
2 files changed, 51 insertions, 16 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 259bc7253..41f7c1515 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -267,19 +267,37 @@ uint32 clif_refresh_ip(void) #if PACKETVER >= 20071106 static inline unsigned char clif_bl_type(struct block_list *bl) { - nullpo_retr(0x1, bl); + struct view_data *vd; + nullpo_retr(CLUT_NPC, bl); + switch (bl->type) { - case BL_PC: return (disguised(bl) && !pc->db_checkid(status->get_viewdata(bl)->class_))? 0x1:0x0; //PC_TYPE - case BL_ITEM: return 0x2; //ITEM_TYPE - case BL_SKILL: return 0x3; //SKILL_TYPE - case BL_CHAT: return 0x4; //UNKNOWN_TYPE - case BL_MOB: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE - case BL_NPC: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x6; //NPC_EVT_TYPE - case BL_PET: return pc->db_checkid(status->get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE - case BL_HOM: return 0x8; //NPC_HOM_TYPE - case BL_MER: return 0x9; //NPC_MERSOL_TYPE - case BL_ELEM: return 0xa; //NPC_ELEMENTAL_TYPE - default: return 0x1; //NPC_TYPE + case BL_PC: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + + if (disguised(bl) && !pc->db_checkid(vd->class_)) + return CLUT_NPC; + else + return CLUT_PC; + case BL_ITEM: return CLUT_ITEM; + case BL_SKILL: return CLUT_SKILL; + case BL_CHAT: return CLUT_UNKNOW; + case BL_MOB: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + return pc->db_checkid(vd->class_)? CLUT_PC:CLUT_MOB; + case BL_NPC: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + return pc->db_checkid(vd->class_)? CLUT_PC:CLUT_EVENT; + case BL_PET: + vd = status->get_viewdata(bl); + nullpo_retr(CLUT_NPC, vd); + return pc->db_checkid(vd->class_)? CLUT_PC:CLUT_PET; + case BL_HOM: return CLUT_HOMNUCLUS; + case BL_MER: return CLUT_MERCNARY; + case BL_ELEM: return CLUT_ELEMENTAL; + default: return CLUT_NPC; } } #endif diff --git a/src/map/clif.h b/src/map/clif.h index 4d22fd4af..bf61aee20 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -520,7 +520,7 @@ enum CLOSE_ROULETTE_ACK { /** * Reason for item deletion (clif->delitem) - */ + **/ enum delitem_reason { DELITEM_NORMAL = 0, /// Normal DELITEM_SKILLUSE = 1, /// Item used for a skill @@ -532,9 +532,9 @@ enum delitem_reason { DELITEM_ANALYSIS = 7, /// Consumed by Four Spirit Analysis (SO_EL_ANALYSIS) skill }; -/* -* Merge items reasons -*/ +/** + * Merge items reasons + **/ enum mergeitem_reason { MERGEITEM_SUCCESS = 0x0, @@ -543,6 +543,23 @@ enum mergeitem_reason { }; /** + * Clif Unit Type + **/ +enum clif_unittype { + CLUT_PC = 0x0, + CLUT_NPC = 0x1, + CLUT_ITEM = 0x2, + CLUT_SKILL = 0x3, + CLUT_UNKNOW = 0x4, + CLUT_MOB = 0x5, + CLUT_EVENT = 0x6, + CLUT_PET = 0x7, + CLUT_HOMNUCLUS = 0x8, + CLUT_MERCNARY = 0x9, + CLUT_ELEMENTAL = 0xa, +}; + +/** * Structures **/ typedef void (*pFunc)(int, struct map_session_data *); //cant help but put it first |