summaryrefslogtreecommitdiff
path: root/src/map/pc.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/pc.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/pc.c')
-rw-r--r--src/map/pc.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 7fc67d668..cf7bc6dcb 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -286,14 +286,17 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type)
}
return 0;
}
-int pc_check_banding( struct block_list *bl, va_list ap ) {
+int pc_check_banding(struct block_list *bl, va_list ap)
+{
int *c, *b_sd;
struct block_list *src;
- struct map_session_data *tsd;
+ const struct map_session_data *tsd;
struct status_change *sc;
nullpo_ret(bl);
- nullpo_ret(tsd = (struct map_session_data*)bl);
+ Assert_ret(bl->type == BL_PC);
+ tsd = BL_UCCAST(BL_PC, bl);
+
nullpo_ret(src = va_arg(ap,struct block_list *));
c = va_arg(ap,int *);
b_sd = va_arg(ap, int *);
@@ -5224,7 +5227,7 @@ void pc_bound_clear(struct map_session_data *sd, enum e_item_bound_type type) {
*------------------------------------------*/
int pc_show_steal(struct block_list *bl,va_list ap)
{
- struct map_session_data *sd;
+ struct map_session_data *sd = NULL, *tsd = NULL;
int itemid;
struct item_data *item=NULL;
@@ -5233,11 +5236,16 @@ int pc_show_steal(struct block_list *bl,va_list ap)
sd=va_arg(ap,struct map_session_data *);
itemid=va_arg(ap,int);
+ nullpo_ret(bl);
+ Assert_ret(bl->type == BL_PC);
+ tsd = BL_UCAST(BL_PC, bl);
+ nullpo_ret(sd);
+
if((item=itemdb->exists(itemid))==NULL)
sprintf(output,"%s stole an Unknown Item (id: %i).",sd->status.name, itemid);
else
sprintf(output,"%s stole %s.",sd->status.name,item->jname);
- clif->message( ((struct map_session_data *)bl)->fd, output);
+ clif->message(tsd->fd, output);
return 0;
}
@@ -8323,11 +8331,12 @@ int pc_percentheal(struct map_session_data *sd,int hp,int sp)
int jobchange_killclone(struct block_list *bl, va_list ap)
{
- struct mob_data *md;
- int flag;
- md = (struct mob_data *)bl;
- nullpo_ret(md);
- flag = va_arg(ap, int);
+ struct mob_data *md = NULL;
+ int flag = va_arg(ap, int);
+
+ nullpo_ret(bl);
+ Assert_ret(bl->type == BL_MOB);
+ md = BL_UCAST(BL_MOB, bl);
if (md->master_id && md->special_state.clone && md->master_id == flag)
status_kill(&md->bl);
@@ -9999,12 +10008,15 @@ int pc_checkitem(struct map_session_data *sd)
/*==========================================
* Update PVP rank for sd1 in cmp to sd2
*------------------------------------------*/
-int pc_calc_pvprank_sub(struct block_list *bl,va_list ap)
+int pc_calc_pvprank_sub(struct block_list *bl, va_list ap)
{
- struct map_session_data *sd1,*sd2;
+ struct map_session_data *sd1 = NULL;
+ struct map_session_data *sd2 = va_arg(ap,struct map_session_data *);
- sd1=(struct map_session_data *)bl;
- sd2=va_arg(ap,struct map_session_data *);
+ nullpo_ret(bl);
+ Assert_ret(bl->type == BL_PC);
+ sd1 = BL_UCAST(BL_PC, bl);
+ nullpo_ret(sd2);
if (pc_isinvisible(sd1) ||pc_isinvisible(sd2)) {
// cannot register pvp rank for hidden GMs