Browse Source

Minor cleanups
* Changed to pass by reference.
* Expanded for loop to uint16 for DAMAGELOG_SIZE.

aleos 2 years ago
parent
commit
d266c1f477
1 changed files with 8 additions and 11 deletions
  1. 8 11
      src/map/clif.cpp

+ 8 - 11
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);
 			}