summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-12-28 15:41:36 +0100
committerHaru <haru@dotalux.com>2016-01-06 15:18:39 +0100
commite3eac134b1607cfe78331e298aaa20b260662571 (patch)
tree135f15dadc1c7964b3078fd8223771f94d1ed0e6 /src/map/npc.c
parent0e05c1ed742707e0eb5923b562b2f6b8c6c5a3be (diff)
downloadhercules-e3eac134b1607cfe78331e298aaa20b260662571.tar.gz
hercules-e3eac134b1607cfe78331e298aaa20b260662571.tar.bz2
hercules-e3eac134b1607cfe78331e298aaa20b260662571.tar.xz
hercules-e3eac134b1607cfe78331e298aaa20b260662571.zip
Replaced the remaining explicit casts with BL_CAST/BL_UCAST
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 6d495e531..411e52c29 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -277,9 +277,9 @@ int npc_enable(const char* name, int flag)
/*==========================================
* NPC lookup (get npc_data through npcname)
*------------------------------------------*/
-struct npc_data* npc_name2id(const char* name)
+struct npc_data *npc_name2id(const char *name)
{
- return (struct npc_data *) strdb_get(npc->name_db, name);
+ return strdb_get(npc->name_db, name);
}
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
@@ -1170,13 +1170,13 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) {
*------------------------------------------*/
struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl)
{
- struct npc_data *nd;
+ struct npc_data *nd = BL_CAST(BL_NPC, bl);
int distance = AREA_SIZE + 1;
nullpo_retr(NULL, sd);
- if (bl == NULL) return NULL;
- if (bl->type != BL_NPC) return NULL;
- nd = (struct npc_data *)bl;
+
+ if (nd == NULL)
+ return NULL;
if (sd->npc_id == bl->id)
return nd;
@@ -2288,10 +2288,11 @@ int npc_unload(struct npc_data* nd, bool single)
if( single && nd->bl.m != -1 )
map->remove_questinfo(nd->bl.m,nd);
- if( nd->src_id == 0 && ( nd->subtype == SHOP || nd->subtype == CASHSHOP ) ) //src check for duplicate shops [Orcao]
+ if (nd->src_id == 0 && ( nd->subtype == SHOP || nd->subtype == CASHSHOP)) {
+ //src check for duplicate shops [Orcao]
aFree(nd->u.shop.shop_item);
- else if( nd->subtype == SCRIPT ) {
- struct s_mapiterator* iter;
+ } else if (nd->subtype == SCRIPT) {
+ struct s_mapiterator *iter;
struct map_session_data *sd = NULL;
if( single ) {
@@ -2301,7 +2302,7 @@ int npc_unload(struct npc_data* nd, bool single)
iter = mapit_geteachpc();
for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) {
- if( sd && sd->npc_timer_id != INVALID_TIMER ) {
+ if (sd->npc_timer_id != INVALID_TIMER ) {
const struct TimerData *td = timer->get(sd->npc_timer_id);
if( td && td->id != nd->bl.id )
@@ -4889,7 +4890,7 @@ int do_init_npc(bool minimal) {
}
// Init dummy NPC
- npc->fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data));
+ CREATE(npc->fake_nd, struct npc_data, 1);
npc->fake_nd->bl.m = -1;
npc->fake_nd->bl.id = npc->get_new_npc_id();
npc->fake_nd->class_ = FAKE_NPC;