summaryrefslogtreecommitdiff
path: root/src/map/atcommand.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/atcommand.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/atcommand.c')
-rw-r--r--src/map/atcommand.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 635a7a220..ef569afa1 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1563,8 +1563,11 @@ int atcommand_stopattack(struct block_list *bl,va_list ap)
*------------------------------------------*/
int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
{
- struct map_session_data *sd = (struct map_session_data *)bl;
+ struct map_session_data *sd = NULL;
nullpo_ret(bl);
+ Assert_ret(bl->type == BL_PC);
+ sd = BL_UCAST(BL_PC, bl);
+
clif->pvpset(sd, 0, 0, 2);
if (sd->pvp_timer != INVALID_TIMER) {
timer->delete(sd->pvp_timer, pc->calc_pvprank_timer);
@@ -1598,8 +1601,11 @@ ACMD(pvpoff)
*------------------------------------------*/
int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
{
- struct map_session_data *sd = (struct map_session_data *)bl;
+ struct map_session_data *sd = NULL;
nullpo_ret(bl);
+ Assert_ret(bl->type == BL_PC);
+ sd = BL_UCAST(BL_PC, bl);
+
if (sd->pvp_timer == INVALID_TIMER) {
sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
sd->pvp_rank = 0;
@@ -2041,10 +2047,12 @@ ACMD(monster)
*------------------------------------------*/
int atkillmonster_sub(struct block_list *bl, va_list ap)
{
- struct mob_data *md = (struct mob_data *)bl;
+ 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->guardian_data)
return 0; //Do not touch WoE mobs!
@@ -7285,7 +7293,7 @@ int atcommand_mutearea_sub(struct block_list *bl, va_list ap)
{ // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way
int time, id;
- struct map_session_data *pl_sd = (struct map_session_data *)bl;
+ struct map_session_data *pl_sd = BL_CAST(BL_PC, bl);
if (pl_sd == NULL)
return 0;