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)

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2009, 07:39 AM
janusd
Sarnak
 
Join Date: Jan 2008
Posts: 47
Default

What're you saying Trev? That we've had some great ideas that showed up on Live? Why, that just means SoE listens to its fanbase.
Reply With Quote
  #2  
Old 04-20-2009, 12:04 PM
realityincarnate
Developer
 
Join Date: Dec 2007
Posts: 122
Default

Ok, that's a good point. You could also probably cram a second string into the space that's normally used for augments and that sort of thing. It would mean you're limited to just under 40 characters for the response string, but that doesn't seem like it would be a problem very often.
Reply With Quote
  #3  
Old 04-20-2009, 07:34 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I thought about using the augments section for handling the phrase, but coding that is out of my skill range. It would have to be able to take the string and then fill in the rest of the nulls after it to make sure that it builds the link properly. Then, after the link is clicked, it would need to have a way to take each of those fields and tie them together and then convert them back into a string.

If you know how to do that, I am sure 40 characters would be plenty for almost any scenario. That would probably be the best possible way to handle say links. By putting the string into the actual link, the item ID wouldn't matter at all. So, the item ID that the quest::saylink() command creates could be hard set to 999999 (or any other invalid item ID number) for all links it creates.


Also, an a related topic, I was playing with the code you posted to handle saylinks and was trying to get it to work where you only input the item ID, and have it create a normal item link from just that. There is already a quest command for quest::itemlink(), but that command causes the NPC to send a tell to the player with a link to the item. Something I have wanted for a long time is a very simple way to create an item link to an actual item that can be set as a variable for use in the middle of a say message. On Storm Haven, we currently have to do something like this to create an itemlink:

Code:
my $cloth_cap = sprintf("%c%06X%s%s%c",0x12,1001,"000000000000000000000000000000000000000","Cloth Cap",0x12);

sub EVENT_SAY {

  if ($text =~/Hail/i) {
  quest::say ("Here is a link to a $cloth_cap."); }

}
While that isn't overly complex to do, it would be nice if we could do something like this instead:

Code:
my $cloth_cap = quest::itemlink(1001);

sub EVENT_SAY {

  if ($text =~/Hail/i) {
  quest::say ("Here is a link to a $cloth_cap."); }

}
The way you wrote the quest::saylink() command above actually works nicely for this. But it could be simplified a bit more by having it do a GetItem() and then an item->name to automatically populate the name of the itemlink. I worked with what you wrote for a while last night, but everything I tried to do was crashing the zone lol. Not trying to derail this thread at all, but figured I would mention this since I worked on it a while last night.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 04-21-2009, 11:04 AM
realityincarnate
Developer
 
Join Date: Dec 2007
Posts: 122
Default

I haven't gotten a chance to look at using the augments section to store anything yet, but I did come up with some code for storing a link as a perl variable. The syntax is just $var = quest::itemlink2(item id).

My source is way too messed up for a diff right now, but here's the changes I made for this. The total string, including all the link variables and stuff, is limited to 250 chars (totally arbitrary number) right now, so no ridiculously long item names.

questmgr.h add:
Code:
const char* ItemLink2(char* perltext, int item_id);
questmgr.cpp:
Code:
const char* QuestManager::ItemLink2(char* perltext, int item_id) {
	const ItemInst* inst = database.CreateItem(item_id, 20, 99999, 99999, 99999, 99999, 99998);
	if (!inst) return 0;	// return an empty string if the item is invalid
	char* link = 0;
	char* tempstr = 0;
	if (initiator->MakeItemLink(link, inst)) {	// make a link to the item
		MakeAnyLenString(&tempstr, "%c%s%s%c", 0x12, link, inst->GetItem()->Name, 0x12);	// format the string that the client receives
		strncpy(perltext, tempstr,250);	// the perl string is only 250 chars, so make sure the link isn't too large
		safe_delete_array(tempstr);	// MakeAnyLenString() uses new, so clean up after it
	}
	safe_delete_array(link);	// MakeItemLink() uses new also
	return perltext;
}
perlparser.cpp:
Code:
XS(XS__ItemLink2);
XS(XS__ItemLink2) {
	dXSARGS;
	if (items != 1)
		Perl_croak(aTHX_ "Usage: itemlink2(itemID)");
	dXSTARG;

	Const_char * RETVAL;
	char text[250];
	uint16 itemID;
	itemID = (int)SvUV(ST(0));
	
	RETVAL = quest_manager.ItemLink2(text, itemID);

	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
	XSRETURN(1);
}
and at the bottom of perlparser add:
Code:
newXS(strcpy(buf, "itemlink2"), XS__ItemLink2, file);

By the way, the most likely cause of your zone crashes is in passing (char *) strings back and forth between functions. It's really easy to accidently write more to the char array than you allocated and overwrite other stuff on the stack. At least, that's what seemed to cause all of my problems.
Reply With Quote
  #5  
Old 04-21-2009, 05:06 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Thanks, realityincarnate! I will get that tested and submitted if it tests good. I may rename it to something like quest::varlink() so it is easier to remember that it is for creating variables with item links if that is ok with you.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #6  
Old 04-21-2009, 07:28 PM
realityincarnate
Developer
 
Join Date: Dec 2007
Posts: 122
Default

Change anything you want, I just wasn't feeling especially creative when I tried to think of what to call it. Definitely give it some real testing; all I did was try with a couple of newbie items and one fake item id to make sure it wasn't crashing anything. I'm sure there's a more efficient way to handle the string as well, but I just wanted something that didn't take much work and wouldn't cause an overflow.

I played around with the say links a little bit more, also, and I was able to force a test string into the augments, lore, etc. variables, but clicking the item link no longer triggered any response from the server at all. The normal item links still worked fine, so I'm not sure if the client does some checking of it's own, or if I just broke something. In any case, I probably won't have much chance to take a look at it for a few days, but I'm cautiously optimistic for now.

And while we're talking about links, I have what's probably a really dumb question. How do you actually create a link to an item in game? I know I've done it before, but I can't for the life of me remember how.
Reply With Quote
  #7  
Old 04-21-2009, 10:59 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

You just right click the item to show it's properties and then click on the icon for the item in the item stats window. That will send a link to your chat window if that is what you were asking about.

Sounds like you are making some interesting progress on putting the string into the say link. I figured it wouldn't be too hard to get the string in there. But, getting it out correctly would be the hard part. Maybe you can change it slightly to have it make the NPC do a say message with whatever it things the string from the say link is. That should work to help debug what is happening when you click the link.

Since the packet breaks down the link into the ItemViewRequest_Structure for use in the link click handling, the string that you put in there would be split into multiple chunks. Then they just need to be put back together into a string that we can use. Maybe that wouldn't be all that hard to do afterall. We would need to get the info in Hex form, and then convert it from hex into a section of a string. Then, just create a string by adding them all together end-to-end back into 1 string.

If you get time to post what you have so far, I could look at the packet being sent by the client and see if it is sending the right string. If so, then it probably just isn't being put back together properly after it gets to the link click handling. If you are too busy though, no rush. This isn't high priority or anything
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
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 07:25 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