Immortal Idle Timeout

Posted by Nexela on Fri 31 Jan 2003 03:40 AM — 11 posts, 38,078 views.

USA #0
ok being fairly new to coding I gues Ill post my question here and let you guys do all the work *duck* errr I mean thanks for all help I get

ok Heres my dilema Running Smaug 1.4a Cygwin source and I want to stop the server from disconnecting Immortals I think I have narrowed it down to this bit of code in Comm.c

if ( (!d->character && d->idle > 360) /* 2 mins */
|| ( d->connected != CON_PLAYING && d->idle > 1200) /* 5 mins */
|| d->idle > 28800 ) /* 2 hrs */
{
write_to_descriptor( d->descriptor,
"Idle timeout... disconnecting.\n\r", 0 );
d->outtop = 0;
close_socket( d, TRUE );
continue;
}


how would rewrite that so It doesnt dissconnect Immortals?
Australia Forum Administrator #1

if ( (!d->character && d->idle > 360)	/* 2 mins */
|| ( d->connected != CON_PLAYING && d->idle > 1200) /* 5 mins */
|| d->idle > 28800 )	/* 2 hrs */
if (d->character && d->character->level < LEVEL_IMMORTAL)
  { 
  write_to_descriptor( d->descriptor,
           "Idle timeout... disconnecting.\n\r", 0 );
  d->outtop	= 0;
  close_socket( d, TRUE );
  continue;
  }


New line in bold.
USA #2
Hey, I tried to insert that into the code, and boy... it put a terrible horrible lag on the executable. i couldn't even log in. it would load my character after about a minute and a half then it wouldn't do anything else. any thoughts? and did it happen to the first person who wrote this subject?

Ithildin

i took that line back out and it ran fine
USA #3
The first time I rebooted with this change it was a lil slower then usual but after that reboots and restarts are back up to there normal speed for me.

Didnt test the timeout yet though but I have a feeling it will work I'll be sure to let ya know sometime tommorow
Australia Forum Administrator #4
Whoops! Sorry, didn't notice it was a nested IF. Try this variation ...



if ( ((!d->character && d->idle > 360)	/* 2 mins */
|| ( d->connected != CON_PLAYING && d->idle > 1200) /* 5 mins */
|| d->idle > 28800 )	/* 2 hrs */
/* allow imms to stay on indefinitely */
&& !(d->character && d->character->level >= LEVEL_IMMORTAL)
  )
  { 
  write_to_descriptor( d->descriptor,
           "Idle timeout... disconnecting.\n\r", 0 );
  d->outtop	= 0;
  close_socket( d, TRUE );
  continue;
  }


Amended on Fri 31 Jan 2003 10:21 PM by Nick Gammon
USA #5
Thanks for the help Nick worked like a charm the second time around.. maybe I wont ask questions when Im half alseep :P
USA #6
when putting this in smaugfuss 1.6 you get many many errors, why might it do this?
Australia Forum Administrator #7
You sure you did exactly that? There is a bracket on a line on its own. Try pasting here what your code looks like with your change.
USA #8
well first i tired to just change it and it didn't work so i copy and pasted and didnt work again, donno really... but because its and else if and not just an if have anything to do with it?
USA #9
If you show us the lines, I'm sure we'd be able to see what's wrong.
USA #10
Well ok... nevermind i think i fixed it... not sure will seen later tonight, but i forgot to place the extra ( after the if in the first line of it. heh.