From d266c1f477b1bb07ab5b1a096d57b26be9ebe1d7 Mon Sep 17 00:00:00 2001 From: aleos Date: Wed, 7 Sep 2022 10:04:36 -0400 Subject: [PATCH] Minor cleanups * Changed to pass by reference. * Expanded for loop to uint16 for DAMAGELOG_SIZE. --- src/map/clif.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 57526b2b68..0d7c1edac7 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -1043,21 +1043,18 @@ static int clif_setlevel(struct block_list* bl) { * @param tbl: Mob to check * @return True if the HP bar should be displayed or false otherwise */ -static bool clif_mob_damaged_hpbar(block_list *bl, block_list *tbl) { - if (bl == nullptr || tbl == nullptr) - return false; - - mob_data *md = BL_CAST(BL_MOB, tbl); +static bool clif_mob_damaged_hpbar(block_list &bl, block_list &tbl) { + mob_data *md = BL_CAST(BL_MOB, &tbl); if (md == nullptr) return false; - map_session_data *sd = BL_CAST(BL_PC, bl); + map_session_data *sd = BL_CAST(BL_PC, &bl); if (sd == nullptr) return false; - for (uint8 i = 0; i < DAMAGELOG_SIZE; i++) { // Must show hp bar to all char who already hit the mob. + for (uint16 i = 0; i < DAMAGELOG_SIZE; i++) { // Must show hp bar to all char who already hit the mob. if (md->dmglog[i].id == sd->status.char_id) return true; } @@ -1193,7 +1190,7 @@ static void clif_set_unit_idle( struct block_list* bl, bool walking, send_target #endif #if PACKETVER >= 20120221 if( battle_config.monster_hp_bars_info && bl->type == BL_MOB && tbl->type == BL_PC && !map_getmapflag( bl->m, MF_HIDEMOBHPBAR ) && ( status_get_hp( bl ) < status_get_max_hp( bl ) ) ){ - if (clif_mob_damaged_hpbar(tbl, bl)) { // Must show hp bar to all char who already hit the mob. + if (clif_mob_damaged_hpbar(*tbl, *bl)) { // Must show hp bar to all char who already hit the mob. p.maxHP = status_get_max_hp(bl); p.HP = status_get_hp(bl); } else { // Player didn't attack the mob. @@ -1339,7 +1336,7 @@ static void clif_spawn_unit( struct block_list *bl, enum send_target target ){ #endif #if PACKETVER >= 20120221 if( battle_config.monster_hp_bars_info && bl->type == BL_MOB && !map_getmapflag( bl->m, MF_HIDEMOBHPBAR ) && ( status_get_hp( bl ) < status_get_max_hp( bl ) ) ){ - if (clif_mob_damaged_hpbar(bl, bl)) { // Must show hp bar to all char who already hit the mob. + if (clif_mob_damaged_hpbar(*bl, *bl)) { // Must show hp bar to all char who already hit the mob. p.maxHP = status_get_max_hp(bl); p.HP = status_get_hp(bl); } else { // Player didn't attack the mob. @@ -1452,7 +1449,7 @@ static void clif_set_unit_walking( struct block_list *bl, struct map_session_dat #endif #if PACKETVER >= 20120221 if( battle_config.monster_hp_bars_info && bl->type == BL_MOB && tsd != nullptr && !map_getmapflag(bl->m, MF_HIDEMOBHPBAR) && (status_get_hp(bl) < status_get_max_hp( bl ) ) ){ - if (clif_mob_damaged_hpbar(&tsd->bl, bl)) { // Must show hp bar to all char who already hit the mob. + if (clif_mob_damaged_hpbar(tsd->bl, *bl)) { // Must show hp bar to all char who already hit the mob. p.maxHP = status_get_max_hp(bl); p.HP = status_get_hp(bl); } else { // Player didn't attack the mob. @@ -4846,7 +4843,7 @@ void clif_getareachar_unit( struct map_session_data* sd,struct block_list *bl ){ clif_specialeffect_single(bl,EF_BABYBODY2,sd->fd); #if PACKETVER >= 20120404 if (battle_config.monster_hp_bars_info && !map_getmapflag(bl->m, MF_HIDEMOBHPBAR)) { - for (uint8 i = 0; i < DAMAGELOG_SIZE; i++) // Must show hp bar to all char who already hit the mob. + for (uint16 i = 0; i < DAMAGELOG_SIZE; i++) // Must show hp bar to all char who already hit the mob. if( md->dmglog[i].id == sd->status.char_id ) clif_monster_hp_bar(md, sd->fd); }