Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Enabling MXP in SmaugFUSS 1.9

Enabling MXP in SmaugFUSS 1.9

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Bobo   USA  (16 posts)  Bio
Date Mon 11 Oct 2010 04:42 AM (UTC)

Amended on Mon 11 Oct 2010 05:04 AM (UTC) by Bobo

Message
So, in trying to put in MXP in the most recent SmaugFUSS-1.9 version, I've run into an issue (which is somewhat embarrassing, since I had MXP working awhile ago, before a computer crash + data loss). I've got the code to compile correctly, but I had had to change all instances of 'unsigned char' to just 'char' because, well, that seems to be what the fine folks in charge of the SmaugFUSS project have wanted to do.

Now the code compiles fine and dandy and everything, but the 'turning MXP on' thing doesn't seem to be working at all. A quick use of bug-messages shows that neither of the lines

if (memcmp (p, do_mxp_str, strlen (do_mxp_str)) == 0)


and

else  if (memcmp (p, dont_mxp_str, strlen (dont_mxp_str)) == 0)


ever are true, which leads me to think that I'm not sending the MXP request to the client correctly with

write_to_buffer( d, will_mxp_str, 0 );



Any help?

Bleh!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 11 Oct 2010 04:58 AM (UTC)
Message
I wouldn't change all that stuff blindly. These definitions:


const unsigned char will_mxp_str  [] = { IAC, WILL, TELOPT_MXP, '\0' };
const unsigned char start_mxp_str [] = { IAC, SB, TELOPT_MXP, IAC, SE, '\0' };
const unsigned char do_mxp_str    [] = { IAC, DO, TELOPT_MXP, '\0' };
const unsigned char dont_mxp_str  [] = { IAC, DONT, TELOPT_MXP, '\0' };



... will have a different meaning with char rather than unsigned char. In particular IAC (hex 0xFF) will fit into unsigned char, but a signed char only goes up to 0x7F in value, so the compiler is probably truncating it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Bobo   USA  (16 posts)  Bio
Date Reply #2 on Mon 11 Oct 2010 05:06 AM (UTC)

Amended on Mon 11 Oct 2010 06:39 AM (UTC) by Bobo

Message
Yeah, I figured -- fearing -- that was the problem. Is there an "easy" solution beneath going through and changing the code to use unsigned char's instead of what is there now?

Edit: Granted, rather than re-invent the wheel I might just go back to an earlier version of SmaugFUSS. That wouldn't pose any problems either, really, though I'm sure others would crop up.

Bleh!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 11 Oct 2010 06:28 AM (UTC)
Message
What's wrong with changing those 4 lines? Or is it more complex than that?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Bobo   USA  (16 posts)  Bio
Date Reply #4 on Mon 11 Oct 2010 06:44 AM (UTC)
Message
write_to_buffer() takes const char, in the rendition of the code that I have, and it seems like they've changed most things to use char, as descriptor->inbuf[] and those sorts of thing are now char values also (so, to get a compile, I had to remove unsigned from *p in the telnet querying as well) .. Though I'm wandering why, now. Why would you need negative values for these things -- or are char and signed char different?

Bleh!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Mon 11 Oct 2010 07:35 AM (UTC)
Message
In decimal, unsigned char goes from 0 to 255. Signed char goes from -128 to +127.

However for character input, it is more logical to consider them as unsigned char, that is 0 to 255 (or 0x00 to 0xFF).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #6 on Mon 11 Oct 2010 07:58 AM (UTC)
Message
You might consider posting this as a bug report to:
http://www.smaugmuds.org/index.php
There might be a work-around here, and it might be worth asking why the function was changed to char rather than unsigned char.

It should be worth noting that if you store the command sequences as unsigned char, but when you pass them, you cast it to a pointer to const char*, it should work. You don't want to assign the values into a signed char array directly because of what Nick said.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Bobo   USA  (16 posts)  Bio
Date Reply #7 on Mon 11 Oct 2010 08:06 AM (UTC)

Amended on Mon 11 Oct 2010 08:55 AM (UTC) by Bobo

Message
It seems to be that SmaugFUSS 1.9 uses a lot of library commands, like strlen -- to name the first one I came to -- that requires const char * in order to work. No changing that, so I think I'll instead just go ahead and not have MXP be auto-detected and, instead, have it only be an option to turn on once you're within the game itself. Shucks, but I think it's the simplest solution at the moment, other than looking around for a different codebase.

Edit: Though no harm in asking the fine folk over at SmaugMUDs if they've got a work around. I did a quick search for a solution and came away with nothing, so onwards I go.

Bleh!
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #8 on Mon 11 Oct 2010 06:15 PM (UTC)
Message
I had it auto-detected without any problem even with library functions that use signed chars. I think you're giving up without really giving potential solutions a chance. :-) Did you try the casting thing I mentioned?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #9 on Mon 11 Oct 2010 08:11 PM (UTC)
Message
I wouldn't just omit the negotation because of one compiler error. As David says, you can cast at the last moment, like this:


/* telnet negotiation to see if they support MXP */

    write_to_buffer( d, (const char *) will_mxp_str, 0 );


That's only in a couple of spots you will need to do that.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Bobo   USA  (16 posts)  Bio
Date Reply #10 on Mon 11 Oct 2010 08:36 PM (UTC)
Message
David Haley said:

I had it auto-detected without any problem even with library functions that use signed chars. I think you're giving up without really giving potential solutions a chance. :-) Did you try the casting thing I mentioned?


I did, but I pulled a genius move by trying to cast it (const char) instead of (const char *) until I saw Nick's response. And I wasn't reading the compiler errors right, either. Thanks for the help, both of you. :-)

Bleh!
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #11 on Mon 11 Oct 2010 09:53 PM (UTC)
Message
Is the telnet negotiation working now? (Just asking for the record in case somebody else has this problem later on.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Bobo   USA  (16 posts)  Bio
Date Reply #12 on Tue 12 Oct 2010 12:45 AM (UTC)
Message
It is, yes. Casting as (const char *) worked.

Bleh!
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #13 on Sat 16 Oct 2010 05:21 AM (UTC)
Message
Happened across this earlier, would have been nice to have had it reported, but no biggie. I honestly couldn't say why the arrays in SmaugFUSS were using signed chars when they should obviously be using unsigned chars.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


36,946 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.