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

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #12  
Old 11-17-2008, 07:09 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

I had a chance to revisit this a little (no testing yet, just theory), and this is what I came up with this time...

Quote:
Originally Posted by AndMetal View Post
In zone/questmgr.h, change
Code:
	char* itemlink(int item_id);
In zone/questmgr.cpp, change
Code:
char* QuestManager::itemlink(int item_id) {
	//I dont think this is right anymore, need the hash
/*
uint32_t calc_hash (const char *string)
{
    register hash = 0;

    while (*string != '\0')
    {
        register c = toupper(*string);

        asm volatile("
            imul $31, %1, %1;
            movzx %%ax, %%edx;
            addl %%edx, %1;
            movl %1, %0;
            "
            :"=r"(hash)
            :"D"(hash), "a"(c)
            :"%edx"
             );

        //This is what the inline asm is doing:
        //hash *= 0x1f;
        //hash += (int)c;

        string++;
    }

    return hash;
}


Now the not so simple part, generating the string to feed into the hash function.

The string for normal (unaugmented) items looks like this:
Code:
sprintf(hashstr, "%d%s%s%d %d %d %d %d %d %d %d", id, name, "-1-1-1-1-1", hp, mana, ac, light, icon, price, size, weight);


The string for bags looks like this:
Code:
sprintf(hashstr, "%d%s%d%d%d%d", id, name, bagslots, bagwr, price, weight);


The string for books looks like this:
Code:
sprintf(hashstr, "%d%s%d%d", id, name, weight, booktype);
*/

// MYRA - added itemlink(ID) command
	const Item_Struct* item = 0;
	int16 itemid = item_id;
	item = database.GetItem(itemid);
	return (sprintf("%c%06X%s%s%c",0x12,itemid,"000000000000000000000000000000000000000",item,0x12));
}
And in zone/perlparser.cpp (really not sure about this part), change
Code:
XS(XS__itemlink);
XS(XS__itemlink)
{
	dXSARGS;
	if (items != 1)
		Perl_croak(aTHX_ "Usage: itemlink(item_id)");

	char* RETVAL;
	int	item_id = (int)SvIV(ST(0));

	RETVAL = quest_manager.itemlink(item_id);

	ST(0) = RETVAL;
	sv_2mortal(ST(0));
	XSRETURN(1);
}
zone/questmgr.h:
Code:
	void itemlink(char &ret, int item_id);
zone/questmgr.cpp:
Code:
void QuestManager::itemlink(char &ret, int item_id) {
	const Item_Struct* item = 0;
	uint32 itemid = item_id;
	item = database.GetItem(itemid);
	ret = sprintf(ret, "%c%06X%s%s%c",0x12,itemid,"000000000000000000000000000000000000000",item,0x12);
}
zone/perlparser.cpp:
Code:
XS(XS__itemlink);
XS(XS__itemlink)
{
	dXSARGS;
	if (items != 1)
		Perl_croak(aTHX_ "Usage: itemlink(item_id)");

	char* RETVAL;	//may need to set this to a fixed size
	int	item_id = (int)SvIV(ST(0));

	quest_manager.itemlink(RETVAL, item_id);

	ST(0) = RETVAL;
	sv_2mortal(ST(0));
	XSRETURN(1);
}
If that works, then we can easily add in support for Augments.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
 


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