Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 11-02-2009, 10:43 AM
cybernine186
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default

I meant to explain the changes but forgot.

The Client::SetMana() was calling Mob:SetMana() and in the function Mob::SetMana() it was recalculating the max mana using CalcMaxMana(). Well CalcMaxMana() was being calculated for Mobs and not Clients so the wrong max mana was being set.

I noticed on the VZTZ source this was causing things like Manastones & Cannibalize spells to only reach up to 60% mana before it would quit giving you mana.

The Client::SetMana() was already setting the cur_mana and then trying to set cur_mana again in the Mob::SetMana().

There was no need to call the Mob::SetMana() because it was 1. calculating the wrong maximum mana and 2. The cur_mana was already set in Client::SetMana().


The client_process.cpp file in function Client:oManaRegen() was calling the functions SetMana() and SendManaUpdatePacket(). The SetMana() functions already calls the SendManaUpdatePacket() at the end of the SetMana() function. So the SendManaUpdatePacket() was being sent to the client twice.

I hope I explained it well enough for everyone to understand.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:17 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3