Преглед изворни кода

Player hp/power details properly persist cross zone

Emagi пре 1 година
родитељ
комит
7870d9f25d

+ 5 - 3
EQ2/source/WorldServer/Player.cpp

@@ -6733,7 +6733,7 @@ void Player::MentorTarget()
 	}
 }
 
-void Player::SetMentorStats(int32 effective_level, int32 target_char_id)
+void Player::SetMentorStats(int32 effective_level, int32 target_char_id, bool update_stats)
 {
 	RemoveSpells();
 	if(client->GetPlayer()->GetGroupMemberInfo())
@@ -6743,8 +6743,10 @@ void Player::SetMentorStats(int32 effective_level, int32 target_char_id)
 	client->GetPlayer()->SetTotalHPBase(effective_level * effective_level * 2 + 40);
 	client->GetPlayer()->SetTotalPowerBase((sint32)(effective_level * effective_level * 2.1 + 45));
 	client->GetPlayer()->CalculateBonuses();
-	client->GetPlayer()->SetHP(GetTotalHP());
-	client->GetPlayer()->SetPower(GetTotalPower());
+	if(update_stats) {
+		client->GetPlayer()->SetHP(GetTotalHP());
+		client->GetPlayer()->SetPower(GetTotalPower());
+	}
 	/*info->set_agi_base(effective_level * 2 + 15);
 	info->set_intel_base(effective_level * 2 + 15);
 	info->set_wis_base(effective_level * 2 + 15);

+ 1 - 1
EQ2/source/WorldServer/Player.h

@@ -1023,7 +1023,7 @@ public:
 	bool StopSaveSpellEffects() { return stop_save_spell_effects; }
 
 	void MentorTarget();
-	void SetMentorStats(int32 effective_level, int32 target_char_id = 0);
+	void SetMentorStats(int32 effective_level, int32 target_char_id = 0, bool update_stats = true);
 
 	bool ResetMentorship() { 
 		bool mentorship_status = reset_mentorship;

+ 7 - 4
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -1619,6 +1619,13 @@ bool WorldDatabase::LoadCharacterStats(int32 id, int32 account_id, Client* clien
 		{
 			InfoStruct* info = client->GetPlayer()->GetInfoStruct();
 
+			// must have totals up top before we set the current 'hp' / 'power'
+			client->GetPlayer()->SetTotalHP(result.GetSInt32Str("max_hp"));
+			client->GetPlayer()->SetTotalPower(result.GetSInt32Str("max_power"));
+			
+			client->GetPlayer()->SetTotalHPBase(client->GetPlayer()->GetTotalHP());
+			client->GetPlayer()->SetTotalPowerBase(client->GetPlayer()->GetTotalPower());
+			
 			client->GetPlayer()->SetHP(result.GetSInt32Str("hp"));
 			client->GetPlayer()->SetPower(result.GetSInt32Str("power"));
 			info->set_max_concentration(result.GetInt8Str("max_concentration"));
@@ -1663,8 +1670,6 @@ bool WorldDatabase::LoadCharacterStats(int32 id, int32 account_id, Client* clien
 			client->GetPlayer()->GetPlayerInfo()->SetBindZ(result.GetFloatStr("bind_z"));
 			client->GetPlayer()->GetPlayerInfo()->SetBindHeading(result.GetFloatStr("bind_heading"));
 			client->GetPlayer()->GetPlayerInfo()->SetHouseZone(result.GetInt32Str("house_zone_id"));
-			client->GetPlayer()->SetTotalHP(result.GetSInt32Str("max_hp"));
-			client->GetPlayer()->SetTotalPower(result.GetSInt32Str("max_power"));
 			client->GetPlayer()->SetAssignedAA(result.GetInt16Str("assigned_aa"));
 			client->GetPlayer()->SetUnassignedAA(result.GetInt16Str("unassigned_aa"));
 			client->GetPlayer()->SetTradeskillAA(result.GetInt16Str("tradeskill_aa"));
@@ -1689,8 +1694,6 @@ bool WorldDatabase::LoadCharacterStats(int32 id, int32 account_id, Client* clien
 				client->GetPlayer()->SetNeededTSXP();
 
 			info->set_tradeskill_xp_vitality(result.GetFloatStr("tradeskill_xp_vitality"));
-			client->GetPlayer()->SetTotalHPBase(client->GetPlayer()->GetTotalHP());
-			client->GetPlayer()->SetTotalPowerBase(client->GetPlayer()->GetTotalPower());
 			info->set_bank_coin_copper(result.GetInt32Str("bank_copper"));
 			info->set_bank_coin_silver(result.GetInt32Str("bank_silver"));
 			info->set_bank_coin_gold(result.GetInt32Str("bank_gold"));

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

@@ -894,13 +894,13 @@ void Client::SendCharInfo() {
 		Entity* ent = world.GetGroupManager()->IsPlayerInGroup(rejoin_group_id, GetPlayer()->GetGroupMemberInfo()->mentor_target_char_id);
 		if(ent && ent->IsPlayer())
 		{
-			GetPlayer()->SetMentorStats(ent->GetLevel(), ent->GetID());
+			GetPlayer()->SetMentorStats(ent->GetLevel(), ent->GetID(), false);
 			groupMentor = true;
 		}
 	}
 
 	if(!groupMentor)
-		GetPlayer()->SetMentorStats(GetPlayer()->GetLevel(), 0);
+		GetPlayer()->SetMentorStats(GetPlayer()->GetLevel(), 0, false);
 
 	database.LoadCharacterSpellEffects(GetCharacterID(), this, DB_TYPE_MAINTAINEDEFFECTS);
 	database.LoadCharacterSpellEffects(GetCharacterID(), this, DB_TYPE_SPELLEFFECTS);