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
  #6  
Old 08-31-2008, 05:52 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

I think this would be better, because it would just return the link to the item from the function, rather than outputting it as a generic tell (great for seeing what you're working for in a quest):

Note: I haven't tested this, it's just a specific idea. All changes are in red.

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);
}
Any thoughts?
__________________
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 01:52 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