View Single Post
  #1  
Old 10-30-2009, 05:13 PM
cybernine186
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default Client::SetMana corrections

I have found some flaws in the Client::SetMana causing items like Manastone and Cannibalize to not work properly. Also Client::DoManaRegen() does a unnecessary call of the SendManaUpdatePacket(); twice.

Here is a diff of the latest version of PEQ. Please let me know how it works for you.

Code:
Index: zone/client.cpp
===================================================================
--- zone/client.cpp	(revision 1046)
+++ zone/client.cpp	(working copy)
@@ -1621,17 +1621,22 @@
 }
 
 const sint32& Client::SetMana(sint32 amount) {
-	bool update = false;
-	if (amount < 0)
+
+	// No negative amount
+	if (amount < 0) {
 		amount = 0;
-	if (amount > GetMaxMana())
+	}
+	
+	// Do not set above the maximum amount
+	if (amount > GetMaxMana()) {
 		amount = GetMaxMana();
-	if (amount != cur_mana)
-		update = true;
-	cur_mana = amount;
-	if (update)
-		Mob::SetMana(amount);
-	SendManaUpdatePacket();
+	}
+	
+	// Update mana and sent to client
+	if (amount != cur_mana) {
+		cur_mana = amount;
+		SendManaUpdatePacket();
+	}
 	return cur_mana;
 }
 
Index: zone/client_process.cpp
===================================================================
--- zone/client_process.cpp	(revision 1046)
+++ zone/client_process.cpp	(working copy)
@@ -1761,7 +1761,6 @@
 	regen = (regen * RuleI(Character, ManaRegenMultiplier)) / 100;
 	
 	SetMana(GetMana() + regen + RestRegenMana);
-	SendManaUpdatePacket();
 }
Reply With Quote