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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2008, 02:37 PM
Rocker8956
Hill Giant
 
Join Date: Sep 2007
Posts: 117
Default

I rewrote the getlevel quest command so it does less accessing of the database.
This also changes the syntax to
quest::getlevel(type)

zone\groups.cpp
Add at end
Code:
uint16 Group::GetAvgLevel()
{
	double levelHolder = 0;
	uint8 i = 0;
	uint8 numMem = 0;
	while(i < MAX_GROUP_MEMBERS)
	{
		if (members[i])
		{
			numMem++;
			levelHolder = levelHolder + (members[i]->GetLevel());
		}
		i++;
	}
	levelHolder = ((levelHolder/numMem)+.5); // total levels divided by num of characters
	return (uint16(levelHolder));
}
zone\groups.h
Around line 94 Insert
Code:
uint16	GetAvgLevel();
zone\raids.cpp
Add to end
Code:
uint16 Raid::GetAvgLevel()
{
	double levelHolder = 0;
	uint8 i = 0;
	uint8 numMem = 0;
	while(i < MAX_RAID_MEMBERS)
	{
		if(strlen(members[i].membername))
		{
			levelHolder = levelHolder + members[i].level;
			numMem++;
		}
		i++;
	}
	levelHolder = ((levelHolder/(numMem))+.5); // total levels divided by num of characters
	return (uint16(levelHolder));
}
zone\raids.h
Near line 126 Insert
Code:
uint16	GetAvgLevel();
zone\perlparser.cpp
Find XS(XS__getlevel); replace function with
Code:
XS(XS__getlevel);
XS(XS__getlevel)
{
    dXSARGS;
    if (items != 1)
        Perl_croak(aTHX_ "Usage: getlevel(type)");

    int		RETVAL;
    dXSTARG;

	int		type = (int)SvIV(ST(0));

	RETVAL = quest_manager.getlevel(type);
	XSprePUSH; PUSHu((IV)RETVAL);

	XSRETURN(1);
}
zone\questmgr.cpp
Find QuestManager::getlevel replace entire function with
Code:
int QuestManager::getlevel(uint8 type)
{
	if (type == 0)
	{
		return (initiator->GetLevel());
	}
	else if(type == 1)
	{
		Group *g = entity_list.GetGroupByClient(initiator);
       	if (g != NULL)
			return (g->GetAvgLevel());
		else
			return 0;
	}
	else if(type == 2)
	{
		Raid *r = entity_list.GetRaidByClient(initiator);
       	if (r != NULL)
			return (r->GetAvgLevel());
		else
			return 0;
	}
	else if(type == 3)
	{
		Raid *r = entity_list.GetRaidByClient(initiator);
		if(r != NULL)
		{
			return (r->GetAvgLevel());
		}
		Group *g = entity_list.GetGroupByClient(initiator);
		if(g != NULL)
		{
			return (g->GetAvgLevel());
		}
		else
			return (initiator->GetLevel());
	}
	else
		return 0;
}
zone\questmgr.h
Find int getlevel replace it with
Code:
int getlevel(uint8 type);
common\database.cpp
The following can be removed
Code:
int Database::getCharLevel(int charID)
int Database::getRaidAvgLvl(int charID)
int Database::getGroupAvgLvl(int charID)
common\database.h
These can be removed
Code:
int		getCharLevel(int charID);
int		getRaidAvgLvl(int charID);
int		getGroupAvgLvl(int charID);
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:34 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