Browse Source

Restrict health pct update for pets only if the pet is got max_hp set to avoid divide by 0

Emagi 1 year ago
parent
commit
8bf5ec84b7
1 changed files with 2 additions and 2 deletions
  1. 2 2
      EQ2/source/WorldServer/Spawn.cpp

+ 2 - 2
EQ2/source/WorldServer/Spawn.cpp

@@ -1448,13 +1448,13 @@ void Spawn::SetTotalHP(sint32 new_val){
 
 	if (IsNPC() && ((NPC*)this)->IsPet() && ((NPC*)this)->GetOwner()->IsPlayer()) {
 		Player* player = (Player*)((NPC*)this)->GetOwner();
-		if (player->GetPet() && player->GetCharmedPet()) {
+		if (basic_info.max_hp && player->GetPet() && player->GetCharmedPet()) {
 			if (this == player->GetPet()) {
 				player->GetInfoStruct()->set_pet_health_pct((float)basic_info.cur_hp / (float)basic_info.max_hp);
 				player->SetCharSheetChanged(true);
 			}
 		}
-		else {
+		else if(basic_info.max_hp) {
 			player->GetInfoStruct()->set_pet_health_pct((float)basic_info.cur_hp / (float)basic_info.max_hp);
 			player->SetCharSheetChanged(true);
 		}