diff options
author | Haru <haru@dotalux.com> | 2015-12-28 00:16:39 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-01-06 15:14:50 +0100 |
commit | f878d5e2156dc88fb73d27473acfe01d72427bbd (patch) | |
tree | 7bcb5cd894ffd776545f4fe480276476c7688252 /src/map/instance.c | |
parent | b3c722ecf777aeeea6317755a6adfc0216b7a2bd (diff) | |
download | hercules-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/instance.c')
-rw-r--r-- | src/map/instance.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/map/instance.c b/src/map/instance.c index e9ef602f7..5e8256c88 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -369,21 +369,31 @@ int instance_mapid2imapid(int16 m, int instance_id) { /*-------------------------------------- * Used on Init instance. Duplicates each script on source map *--------------------------------------*/ -int instance_map_npcsub(struct block_list* bl, va_list args) { - struct npc_data* nd = (struct npc_data*)bl; +int instance_map_npcsub(struct block_list* bl, va_list args) +{ + struct npc_data *nd = NULL; int16 m = va_arg(args, int); // Destination Map - if ( npc->duplicate4instance(nd, m) ) + nullpo_ret(bl); + Assert_ret(bl->type == BL_NPC); + nd = BL_UCAST(BL_NPC, bl); + + if (npc->duplicate4instance(nd, m)) ShowDebug("instance_map_npcsub:npc_duplicate4instance failed (%s/%d)\n",nd->name,m); return 1; } -int instance_init_npc(struct block_list* bl, va_list args) { - struct npc_data *nd = (struct npc_data*)bl; +int instance_init_npc(struct block_list* bl, va_list args) +{ + struct npc_data *nd = NULL; struct event_data *ev; char evname[EVENT_NAME_LENGTH]; + nullpo_ret(bl); + Assert_ret(bl->type == BL_NPC); + nd = BL_UCAST(BL_NPC, bl); + snprintf(evname, EVENT_NAME_LENGTH, "%s::OnInstanceInit", nd->exname); if( ( ev = strdb_get(npc->ev_db, evname) ) ) @@ -430,10 +440,10 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { switch(bl->type) { case BL_PC: - map->quit((struct map_session_data *) bl); + map->quit(BL_UCAST(BL_PC, bl)); break; case BL_NPC: - npc->unload((struct npc_data *)bl,true); + npc->unload(BL_UCAST(BL_NPC, bl), true); break; case BL_MOB: unit->free(bl,CLR_OUTSIGHT); @@ -445,7 +455,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { map->clearflooritem(bl); break; case BL_SKILL: - skill->delunit((struct skill_unit *) bl); + skill->delunit(BL_UCAST(BL_SKILL, bl)); break; } |