PDA

View Full Version : WesQuests.cpp on 2.4 Pre 5


Stud
03-11-2002, 11:46 AM
Need a bit of help from someone in the know. I'm attempting to create quests scripts on my Linux server.

At first the zone was unable to locate the Quests folder and the zonename.qst files inside it. This I was able to correct by changing line 125 from reading:

_snprintf(filename, 254, "Quests\\%s.qst", zonename);
if (pFile = fopen ( filename , "rb" )) {
printf("Reading quests from %s\n", filename);
}

to

_snprintf(filename, 254, "./Quests/%s.qst", zonename);
if (pFile = fopen ( filename , "rb" )) {
printf("Reading quests from %s\n", filename);
}

Now it locates and attempts to read the file whenever you hail an NPC but immediately crashes the zoneserver with a segmentation fault when you do.

As long as you have no quest script in the Quests directory for the zone you are in, it functions fine. But if you have a .qst file, even a blank one, for the zone you are in in the Quests directory. It immediately crashes the zoneserver when hailing an NPC.

The quests do however work properly on a windows server.

Can someone possibly you Misa (wink wink) take a look at WesQuests.cpp and see what else other than the backslash problem would keep it from functioning the same under Windows as it does Linux, I've looked at it, and I just don't see it.

Pyrotek
03-12-2002, 12:55 AM
I'm guessing it's having difficulty parsing the file due to the difference in linefeeds etc.

Stud
03-13-2002, 10:27 AM
Okay, narrowed down a bit.... I think.... when it hits this chunk of code from WesQuest.cpp , is when the segmentation fault occurs...see anything non-linux friendly?

char * command;
char * temp;
temp = sep3.arghz[i];
if (temp == NULL) return;
Seperator sep(temp);
Seperator4 sep4(temp);
command = sep4.arghza[0];
if (!IsCommented(temp)) {
if (ps) {
char * nmessage = strreplace(sep4.arghza[1],"%CHARNAME%", this->GetName());

nmessage[strlen(nmessage) - 1] = '\0';
if (strstr(strupr(command),"SAY") != NULL) {
if (tt2 || ti2 || td) {
entity_list.Message(0, MT_Say, "%s says, '%s'", this->target->GetName(), nmessage);
}

theCoder
03-13-2002, 05:09 PM
I don't know if this is the problem, but the implementation of strreplace contains a local static char array newstringza (OT: what's with all the za's all over the code?), which it fills with the new constructed string. At the end, it returns this array as a char*. I don't remember all the intricacies of C++, but I think this may be a problem (I'll write a quick program to see). A quick fix would be to change the last line (line 92) from:

return newstringza;

to:

return strdup(newstringza);

which allocates a buffer the correct size, copies the string to the buffer, and returns a pointer to the buffer.

Or, you could try moving the declaration of the char[] outside the function (just before it should work).

It's probably not a good idea to return a pointer to a local variable in any case. Anyone with more extensive C++ experience want to comment (I've been doing Java too long...).

theCoder
03-13-2002, 05:16 PM
nevermind... that's not it... I just wrote a quick program showing that the static modifier should make it just fine (even non-static works, but generates a compiler warning). The problem must be something else...

Maybe some excessive printf's are in order...

Stud
03-19-2002, 12:53 PM
Here's an strace of the segmentation fault, if this helps:

recvfrom(7 0xbfffe5d0 1024 0 0xbfffe5b0 0xbfffe5a8) = -1 EAGAIN (Resource temporarily unavailable)
gettimeofday({1016517324 915707} NULL) = 0
recvfrom(7 " ""\22\0\0A\200%\1\31\7!\0\0\0\0\377\377\377\377\365\ 26\365""..." 1024 0 {sin_family=AF_INET sin_port=htons(1440) " sin_addr=inet_addr(""12.232.20.23"")}}" [16]) = 117
nanosleep({0 1000000} 0) = -1 EINTR (Interrupted system call)
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++

Stud
03-26-2002, 03:31 AM
Has anyone managed a work around on this yet, and have NPC scripting working on linux on their servers? I really don't want to suffer the performance hit of going back to Windows, but NPC scripts, and customized quests are the one feature I was looking forward to.

misanthropicfnd
04-02-2002, 12:30 PM
With any luck quests should work in Linux in the next release (IWFMATM (It Works For Me At The Moment)). It appears a memory management problem was the cause of the segfaults. While it no longer segfaults, it's not clear if memory leaks exist. If you are able to test quests on a public server and determine if the zone server grows as quests are invoked let us know.

Baltar
05-23-2002, 06:38 PM
trying to get scripts to work, but don't know the syntax for SETSKILL. Been tracing wesquests and it seems the separator datatype is used to parse the line (sep). Can't find where Seperator is declared though because separator-2.h has separator2, separator3, separator4. If anyone understands wesquest, please help me thanks.

theCoder
05-25-2002, 07:54 AM
I don't know how to do the SETSKILL directive (I haven't messed around with quests at all yet, and in the next couple weeks I won't have time to either), but I can tell you that the Seperator class is defined in common/seperator.h. Notice that it is spelled (incorrectly) with an 'e' instead of an 'a': seperator.h. I know it confused me when I grepped for serarator and found nothing even though I knew I had seen classes like that before.

HTH

Baltar
05-25-2002, 09:28 AM
thanks found it. Yeah it looked like the syntax needed a space
or some div as they call it in the end:

SETSKILL x y (space here)

Thanks for the help coder