[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Disabling the Auto-Disconnect

Disabling the Auto-Disconnect

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


Posted by Zune   (76 posts)  [Biography] 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?
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] 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
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] 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.
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] 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.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] 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
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] 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.
[Go to top] 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.


17,463 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]