PDA

View Full Version : Herein lies the conundrum - Summoning Items in Quest Scripts


krich
06-03-2003, 11:37 AM
I see posts from people claiming they can summon items in quest scripts by saying the following somewhere in the script:

summonitem("11000")

In fact, I read a post that says that you must use the quotation marks in order for it to work.

Well, it just flat out doesn't work for me. I can only get this to work if I remove the quotation marks.

Soooo...being on the Bug Hunt that I am today, I dive into the code to see if it's just me or what (I've been known to have a severe case of anal-cranium interlock in the past).

Looking in void Parser::CommandEx(char * command, int32 npcid, Mob* other, Mob* mob) I see that, in my case, atoi("11000") is failing to convert to 11000, rather returning 0 as it should.

Now, this explains why I can't use quotation marks, but herein lies the conundrum...who are these other people that CAN use quotation marks?

(Windoze? Say it isn't so! :roll: )

Some code snippets that snarf (in a rather brutal and ruthless way) the leading quotation mark, inserted where atoi is failing (that I have found, so far):

else if (strstr(strlwr(arglist[0]),"summonitem")) {
if (arglist[1][0] == '\"') { memset(strstr(arglist[1], "\""), 32, 1); } //ADD THIS
mob->CastToClient()->SummonItem(atoi(arglist[1]));
}
else if (strstr(strlwr(arglist[0]),"castspell")) {
if (arglist[1][0] == '\"') { memset(strstr(arglist[1], "\""), 32, 1); } //ADD THIS
other->CastSpell(atoi(arglist[2]), atoi(arglist[1]));
}


Regards,

Krich

loudent2
06-03-2003, 11:49 AM
There are various versions of the code. 4.3, 4.4 and CVS. Whether you can use quotes or not is dependant on what version you're running. I use the latest CVS code and I've found that most of the quests out there simply do not work anymore. Eventually everyone will be one the same page enough where we won't have this confusion.

Edgar1898
06-11-2003, 03:51 AM
also if your compiling on linux, the versions of gcc and glibc makes a large difference.

krich
06-11-2003, 11:06 AM
also if your compiling on linux, the versions of gcc and glibc makes a large difference.

Please elaborate, if you can...I'm a rusty c/c++ programmer, and not familiar with the intricacies of linux or the various versions of gcc libraries and compilers. I could stand to learn a thing or two on this subject. :D

The man page on atoi states that it stops trying to convert at the first non-numeric, non-space, non-plus (+), or non-minus (-). Judging from the laundry list of standards that use this function, I would think that it's behavior would be highly predictable under most circumstances.

/shrug

Regards,

krich

Edgar1898
06-12-2003, 04:45 AM
Well I was using an old version of gcc at first and everything compiled properly, but when I used quests I would have to take the quotes off. (Sorry not at home for the version numbers). Then, when I updated to a newer version of gcc I had to add the quotes back or it wouldnt work :P I also had a similiar time with glibc. Specifically it seems that it wasnt passing an int, ie it was passing "1001" instead of 1001 to atoi.

krich
06-12-2003, 06:45 AM
That's exactly what's happening to me. I'm using a pre-3 version of gcc (and presumably the old libraries along with it)

Gaaahhh! This is driving me crazy. The last thing I expected was to get bulldozered by a problem with good 'ole atoi.

Well, I'm not mentally ready to upgrade to gcc3 anytime soon. (I just don't have the patience for it.) And technically the quotes should be stripped before sending into atoi anyway, so perhaps I'll just submit more snippets if I see any more of these.

And yes, bulldozered is a word... I looked it up in Krich's Lexicon of Lexicological Oddities :lol:

Regards,

krich