Go Back   EQEmulator Home > EQEmulator Forums > Development > Development: Custom Code

Development: Custom Code This is for code thatdoes not emulate live and wont be added to the official code.

Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-2012, 10:14 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default Alternate TakeMoneyFromPP()

This is basically a polished version of the existing TakeMoneyFromPP() method that is referenced here: http://www.eqemulator.org/forums/showthread.php?t=35883

I integrated Lerxst's rework for AddMoneyToPP() into this in an attempt to speed up this procedure. (http://www.eqemulator.org/forums/sho...0&postcount=18)


There may be a minor increase of speed in certain operations, but the overall is still negligible and doesn't warrant the work and effort of testing and implementing it.

It's posted here for reference, so feel free to do whatever with it. I'll answer any questions as to why I did things a certain way.


BETA-LEVEL PROCEDURE

Code:
bool Client::TakeMoneyFromPP(uint64 copper, bool updateclient) {
	
	if (!HasMoney(copper)) { return false; }

	sint64 cur_copper = static_cast<sint64>(m_pp.copper) - copper;
	if (cur_copper < 0) {
		sint64 cur_silver = (static_cast<sint64>(m_pp.silver) * 10) + cur_copper;
		if (cur_silver < 0) {
			sint64 cur_gold = (static_cast<sint64>(m_pp.gold) * 100 ) + cur_silver;	
			if (cur_gold < 0) {
				sint64 cur_platinum = (static_cast<sint64>(m_pp.platinum) * 1000) + cur_gold;	
				if (cur_platinum < 0) {
#if (EQDEBUG>=5)
					LogFile->write(EQEMuLog::Debug, "Client::TakeMoneyFromPP() %s's transaction resulted in a deficit of %i copper",
						GetName(), (~cur_platinum + 1));
#endif
					m_pp.platinum = 0;
					m_pp.gold = 0;
					m_pp.silver = 0;
					m_pp.copper = 0;
				}
				else {
					m_pp.platinum = cur_platinum / 1000;
					m_pp.gold = (cur_platinum / 100) % 10;
					m_pp.silver = (cur_platinum / 10) % 10;
					m_pp.copper = cur_platinum % 10;
				}
			}
			else {
				m_pp.gold = cur_gold / 100;
				m_pp.silver = (cur_gold / 10) % 10;
				m_pp.copper = cur_gold % 10;
			}
 		}
		else {
			m_pp.silver = cur_silver / 10;
			m_pp.copper = cur_silver % 10;
 		}
	}
	else {
		m_pp.copper = cur_copper;
	}
 
	if (updateclient) { SendMoneyUpdate(); }
	
	RecalcWeight();
	Save();
	return true;
}
__________________
Uleat of Bertoxxulous

Compilin' Dirty
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 03:36 AM.


 

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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3