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 05-20-2009, 09:52 AM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

Can't you just create a new temporary string, set the query result to it, then come up with a substring from that and pass it to the variable? Might be easier than trying to edit the query directly.
__________________
Hmm.
Reply With Quote
  #2  
Old 05-20-2009, 05:19 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Drakelord, I think you are overestimating my code knowledge lol. I work purely from examples, so if I can't find something that does nearly exactly what I want to do from somewhere else in the source, I probably can't do it. I have learned a ton in the past year, but still have no technical training at all lol. I think determination is the only reason why I can even code at all.

Basically, I am asking that you give me an example of what you mean. I can't find anywhere in the source where we query to get a string and use it. Maybe if I think about it more I can figure out a place that might do that.

EDIT:
Checked into it a bit more from other stuff in the source and maybe I can just do this:


Code:
				if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid),errbuf,&result))
				{

					if (mysql_num_rows(result) == 1)
					{
						row = mysql_fetch_row(result);

						strcpy(response, row[0]);
					}
						
					mysql_free_result(result);
					safe_delete_array(query);
				}
I will try that later and see what happens.

Oh, and I just realized that I had "response" instead of "sayid" in that query, so I corrected that. I am sure that was my problem the whole time lol (or the main one anyway).
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 05-21-2009 at 05:42 AM..
Reply With Quote
  #3  
Old 05-21-2009, 02:25 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Yup, that did it! It works now

I am just going to clean it up a bit and get it on the SVN. If there are issues found with it at some point, they can be fixed at any time I am sure, but it seems pretty rock solid from my testing so far.

One thing I am still debating is if I should have it say the "You say" messages as if you had actually said it. Right now, I just have it set to send that message to the player that actually clicks the link, so it still seems similar to normal EQ, but that can be removed. The only concern I have with it not showing who is clicking the link is if people start spamming with it and no one can tell for sure who is doing it. If this gets to be popular, I guess we could always add a rule so admins could decide if they want the "You say" messages or whatever.

With this and $client->message, you could actually have a complete conversation with an NPC without anyone else even seeing the conversation at all. I think that has positive and negative benefits, but is definitely something interesting.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 05-21-2009, 05:26 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I did some more testing and found that the code I had needed a couple other tweaks and stuff to prevent possible crashes, but it looks to be working perfectly now. I added this to the SVN. All you need to do is add the required SQL and it should work just fine.

To use the new quest function, simply follow this example:
Code:
sub EVENT_SAY {

my $test = quest::saylink("test a saylink");
my $click = quest::saylink("click");
my $say = quest::saylink("say");

  if($text=~/hail/i)
  {
    quest::say("Hello, $name.  Would you like to [$test]? If so, simply [$click] on the pink text and wait for my response.  You may also simply /$say the message like normal if you prefer that method instead.");
  }

  if($text=~/test a saylink/i)
  {
    quest::say("The test was a huge success!  Well done :P");
  }

  if($text=~/click/i)
  {
    quest::say("Yes, click the pink text exactly like you just did!");
  }

  if($text=~/^say$/i)
  {
    quest::say("Saying or clicking the text is the same thing to me!");
  }

}
It's pretty cool if you ask me. Now let's see if EQLive shows up with something similar soon :p

I just added quest::saylink() to the wiki and went ahead and wrote a quick wiki page for using it as well:
http://www.eqemulator.net/wiki/wikka.php?wakka=SayLink

I have some say links setup on Storm Haven if anyone wants to log in to check them out. I have them in both the Titanium and SoF starting areas. The areas aren't full of say links yet, but the nearby NPCs from where you start will have them.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 05-21-2009 at 03:15 PM..
Reply With Quote
  #5  
Old 05-21-2009, 09:54 PM
drakelord
Hill Giant
 
Join Date: Nov 2002
Location: NC, USA
Posts: 182
Default

Works great Trev, except for one thing, ;

I looked through the diff files, and noticed that instead of actually sending the text to the zone channel, you send it directly to the client and to the targeted npc. The problem with this is now that we have the option for npcs to respond without being targeted, this wouldn't work if they tried to implement say links at the same time.

So, it should be an easy fix, right? Just have it actually say the reply instead of sending it directly to the npc. It will be visible to everyone sadly, but it will circumvent this problem.
__________________
Hmm.
Reply With Quote
  #6  
Old 05-21-2009, 10:11 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I don't really know how hard it would be to do that. Without a target, it crashes the zone as it is currently set. Maybe a messageclose would work, but I haven't tried that yet. Though, I think it would be a pretty extremely rare case that someone would use both proximity say and say links at the same time. Feel free to submit a working change to the code if you want though.

Everyone already sees the message as long as an NPC is actually targeted when the link is clicked. The only way to not have it send the message is to simply parse it instead of doing the message sending stuff. I originally had it set to do that, but there may be issues with doing it that way.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #7  
Old 05-22-2009, 03:53 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Code:
			char* response;
			int sayid = ivrs->item_id - 500000;

			if (sayid && sayid > 0) 
			{
				const char *ERR_MYSQLERROR = "Error in saylink phrase queries after clicking the link";
				char errbuf[MYSQL_ERRMSG_SIZE];
				char *query = 0;
				MYSQL_RES *result;
				MYSQL_ROW row;
				

				if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid),errbuf,&result))
				{
					if (mysql_num_rows(result) == 1)
					{
						row = mysql_fetch_row(result);
						strcpy(response, row[0]);
					}
This is at best a crash and at worse something far more dangerous. You can't simply strcpy to memory that does not exist. While there's a chance because you don't initialize response that the memory does exist you're going to be overwriting random data and it's going to do *bad* things to your server.

Code:
char response[64];
Also it better not be crashing the zone just because of something as trivial as not having a target, there should be sanity checks in place to counter that.
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 12:37 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