Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, Yandex

Members: 0
Guests: 18
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » Replacement for do_disconnect...
Forum Rules | Mark all | Recent Posts

Replacement for do_disconnect and do_forceclose
< Newer Topic :: Older Topic > Why have two commands?!

Pages:<< prev 1 next >>
Post is unread #1 Sep 23, 2003, 4:27 pm   Last edited Nov 24, 2007, 3:50 pm by Samson
Go to the top of the page
Go to the bottom of the page

Xorith
The Null Value
GroupAFKMud Team
Posts254
JoinedFeb 23, 2003

Hello Folks!
I noticed that we have do_disconnect and do_forceclose. Now, I know that disconnect takes a character as an argument, while forceclose takes a descriptor number... but in reality what the hell is the difference? *grins*
Now I know some MUDs like to leave forceclose to a higher level, but I mean... I don't see a need for this added precaution. Even so, you could easily write in a check.
So I've written a replacement for both.
Code as follows:
void do_disconnect( CHAR_DATA *ch, char *argument )
{
   char buf[MSL];
   int desc;
   DESCRIPTOR_DATA *d;
   CHAR_DATA *victim;
   set_char_color( AT_IMMORT, ch );
   if ( argument[0] == '\0' )
   {
      send_to_char( "You must specify a player or descriptor to disconnect.\r\n", ch );
      return;
   }

   if ( isdigit( argument[0] ) )
      desc = atoi( argument );
   else if ( ( victim = get_char_world( ch, argument ) ) )
   {
      if ( victim->desc == NULL )
      {
         ch_printf( ch, "%s does not have a descriptor.\r\n", victim->name );
         return;
      }
      else
         desc = victim->desc->descriptor; /* Seems weird... but this seems faster? --X */
   }
   else
   {
      ch_printf( ch, "Disconnect: '%s' was not found!\r\n", argument );
      return;
   }
  
   for ( d = first_descriptor; d; d = d->next )
   {
      if ( d->descriptor == desc )
      {
         if ( ( d->character && get_trust( d->character ) >= get_trust( ch ) )
            || ( d->original && get_trust( d->original ) >= get_trust( ch ) ) )
         {
            send_to_char( "You failed to disconnect them, and they saw the attempt!\r\n", ch );
            sprintf( buf, "\r\n*** disconnect: %s just tried to disconnect you! ***\r\n", ch->name );
            write_to_descriptor( d, buf, 0 );
            return;
         }
         close_socket( d, FALSE );
         send_to_char( "Ok.\r\n", ch );
         return;
      }
   }
   bug( "%s: desc of '%d' not found!", , desc );
   send_to_char( "Descriptor not found!\r\n", ch );
   return;
}

Now you will need to prototype write_to_descriptor...
bool write_to_descriptor( DESCRIPTOR_DATA *d, char *txt, int length ); /* New Disconnect Command */

Anywho... hope someone finds this useful :P
-- X
       
Post is unread #2 Sep 25, 2003, 4:17 pm
Go to the top of the page
Go to the bottom of the page

Greven
Magician
GroupMembers
Posts204
JoinedMar 5, 2005

Good idea, but what if you want to force close someone that has a descriptor, but no d->character, like then they first log in and are sitting at your login screen. Seems unlikely that it would happen, or that you would want to disconnect someone without knowing who they are, but it might happen.
       
Post is unread #3 Sep 30, 2003, 1:43 pm
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

Actually, that might be quite common. If one were to allow chat during the character creation process for example, or someone were being annoying by typing in user1, user2, user3 but never actually loggin in...

I'd be more inclined to keep the descriptor based version, since you normally can follow ch->descriptor to find that (assuming they aren't link dead... in which case they are already disconnected).
       
Pages:<< prev 1 next >>