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 ➜ Disabling the Auto-Disconnect

Disabling the Auto-Disconnect

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


Posted by Zune   (76 posts)  Bio
Date Fri 12 May 2006 12:09 AM (UTC)
Message
Hey guys. Long time no bug.

Looking to turn off the autodisconnect in SMAUG. I'd prefer to enact it just for immortals, but I'll settle for all players. Any directions from you almighty C magnates?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Fri 12 May 2006 12:16 AM (UTC)
Message
There's an idle counter that's incremented every tick, and reset to zero when the user types something.

To find the counter, search for "Idle timeout... disconnecting" in the code (it should be in comm.c). There you'll see the logic that controls kicking people out.

You would either not increment the counter for immortals, or not disconnect a connection if it belongs to an immortal.

It should be fairly simple; something like:

if ( !IS_IMMORTAL(d->character) )
{
   /* proceed with disconnect */
}
else
{
   /* don't disconnect */
}

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #2 on Fri 12 May 2006 02:42 AM (UTC)
Message
There is a thead on these boards that tackles this very issue, and i beleive it was Nick who provided a solution that looked something like this:


else if( ( ( !d->character && d->idle > 1200 )  /* 5 mins */
                 || ( d->connected != CON_PLAYING && d->idle > 2400 )   /* 10 mins */
                 || d->idle > 57600 )  /* 4 hrs */
               && !( d->character && d->character->level >= LEVEL_IMMORTAL ) )
      {


you should be able to find that in comm.c.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #3 on Fri 12 May 2006 05:24 PM (UTC)
Message

else if( ( ( !d->character && d->idle > 1200 )  /* 5 mins */
                 || ( d->connected != CON_PLAYING && d->idle > 2400 )   /* 10 mins */
                 || d->idle > 57600 )  /* 4 hrs */
               && !( d->character && d->character->level >= LEVEL_IMMORTAL ) )
      {


Should be pointed out that the main reason this works to keep imms from getting booted is because d->idle is being compared to 57600. d->idle by default is a short int, which maxes out at 32767 before rolling over negative. In effect, because it never hits 57600, this lets the imm stay on forever. If someone were to later change the type for d->idle to an unsigned short, an int, or anything else that goes beyond the current limit then it would in fact kick them after 4 hours.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Fri 12 May 2006 06:57 PM (UTC)
Message
Actually the imm check is on a different boolean branch from the idle-check part of the expression; the second part of the check (after the &&) is true, not negated it's false, which stops the whole check.

It should be pointed out though that it's rather unsafe practice to be comparing numbers of different sizes.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #5 on Fri 12 May 2006 11:33 PM (UTC)
Message
The type for idle was changed sometime ago in my code, after noticing that it was busting the bounds of a short, so yes if you were to stick that into an unmodified base then it could perfrom inconsistantly.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
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.


20,280 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.