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

05-21-2009, 10:11 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
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.
|
 |
|
 |

05-22-2009, 03:53 PM
|
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
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.
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.
|
 |
|
 |

05-22-2009, 04:25 PM
|
 |
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
Quote:
Originally Posted by KLS
This is at best a crash and at worse something far more dangerous.
|
*And by that she means the complete and total destruction of the universe. -editor
|

05-22-2009, 04:55 PM
|
|
Dragon
|
|
Join Date: Apr 2009
Location: California
Posts: 814
|
|
Ooh, yeah, some unstable referencing there.
Using char response[64]; instead of char* response; will solve the main problem by allocating 63 bytes for the phrase (plus one for the null terminator).
The second step would be changing strcpy() so that if someone gets funny and passes a phrase larger than 63 characters you won't be looking at a buffer overflow:
Code:
if (mysql_num_rows(result) == 1)
{
row = mysql_fetch_row(result);
strncpy_s(response, sizeof(response), row[0], _TRUNCATE);
}
|

05-22-2009, 05:13 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Yeah, Derision had already pointed out the Memory Allocation issue to me in a PM lol. I was gonna fix it on the next update I did. Simple fix anyway. And the code I posted here isn't the final code. I did add a sanity check to have it verify that they have a target before it tries to send the say message to the target. I will put the truncate in there too, thanks Shendare.
I was hoping for someone to review the code, but since it was already working and not a required feature by any means, I figured I would get what I had up there and add in any needed fixes later. Thanks for the info.
Edit: NM, I see KLS already got the mem allocation thing fixed. Thanks, KLS.
Last edited by trevius; 05-23-2009 at 01:16 AM..
|

06-06-2009, 03:58 PM
|
|
Fire Beetle
|
|
Join Date: Jun 2008
Location: -
Posts: 14
|
|
Is there any way to make it where when the player clicks a saylink, the npc they are talking to responds as if they said that but the player doesn't actually say anything?
Also, can you make the text you click on different than what is said/sent to npc?
|

06-06-2009, 06:30 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
You can't make the name of the link different than what is said when it gets clicked. But, if needed, you should be able to change what your script is waiting to be said so that it catches things however you want to say them. An example would be if your NPC said "bind your soul", most players would type "bind my soul", but if you clicked the link, it would say "bind your soul". In this example, you could just have the NPC look for either "bind" or "soul" to be said so that both phrases would work as replies.
It is possible to code it so the players don't actually say anything, but it may be better that they do. All we would have to do is do the parse of the text right there instead of sending the message as a say. It probably wouldn't be bad to do it that way, other than people maybe clicking the links to annoy people and no way to tell for sure who it is causing the spam.
|
 |
|
 |
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 04:14 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |