summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-12-28 00:16:39 +0100
committerHaru <haru@dotalux.com>2016-01-06 15:14:50 +0100
commitf878d5e2156dc88fb73d27473acfe01d72427bbd (patch)
tree7bcb5cd894ffd776545f4fe480276476c7688252 /src/map/npc.c
parentb3c722ecf777aeeea6317755a6adfc0216b7a2bd (diff)
downloadhercules-f878d5e2156dc88fb73d27473acfe01d72427bbd.tar.gz
hercules-f878d5e2156dc88fb73d27473acfe01d72427bbd.tar.bz2
hercules-f878d5e2156dc88fb73d27473acfe01d72427bbd.tar.xz
hercules-f878d5e2156dc88fb73d27473acfe01d72427bbd.zip
Replaced some explicit casts with BL_UCAST/BL_UCCAST
- Replaced casts in foreach callbacks. - Added assertions and nullpo checks where applicable. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index fc4abb5fa..56fc8cc8a 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -147,8 +147,13 @@ int npc_get_new_npc_id(void) {
}
}
-int npc_isnear_sub(struct block_list* bl, va_list args) {
- struct npc_data *nd = (struct npc_data*)bl;
+int npc_isnear_sub(struct block_list *bl, va_list args)
+{
+ const struct npc_data *nd = NULL;
+
+ nullpo_ret(bl);
+ Assert_ret(bl->type == BL_NPC);
+ nd = BL_UCCAST(BL_NPC, bl);
if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) )
return 0;
@@ -212,8 +217,9 @@ int npc_enable_sub(struct block_list *bl, va_list ap)
nullpo_ret(bl);
nullpo_ret(nd=va_arg(ap,struct npc_data *));
+
if (bl->type == BL_PC) {
- struct map_session_data *sd = (struct map_session_data *)bl;
+ struct map_session_data *sd = BL_UCAST(BL_PC, bl);
if (nd->option&OPTION_INVISIBLE)
return 1;
@@ -3428,10 +3434,17 @@ void npc_setcells(struct npc_data* nd) {
}
}
-int npc_unsetcells_sub(struct block_list* bl, va_list ap) {
- struct npc_data *nd = (struct npc_data*)bl;
- int id = va_arg(ap,int);
- if (nd->bl.id == id) return 0;
+int npc_unsetcells_sub(struct block_list *bl, va_list ap)
+{
+ struct npc_data *nd = NULL;
+ int id = va_arg(ap, int);
+
+ nullpo_ret(bl);
+ Assert_ret(bl->type == BL_NPC);
+ nd = BL_UCAST(BL_NPC, bl);
+
+ if (nd->bl.id == id)
+ return 0;
npc->setcells(nd);
return 1;
}