imc.patch

patches · 9.8 KB · 2010-03-30

Download   « Back to the patches list

p*** imc.c.org	2008-08-17 18:29:02.000000000 -0400
--- imc.c	2008-08-17 18:46:55.000000000 -0400
***************
*** 4,9 ****
--- 4,11 ----
   * Contributions by Johnathan Walker ( Xorith ), Copyright (C)2004
   * Additional contributions by Jesse Defer ( Garil ), Copyright (C)2004
   * Additional contributions by Rogel, Copyright (C)2004
+  * Additional contributions by Madison Koenig (Pedlar, Syxx), Copyright (C) 2008.
+  * Added in Channel Separator, and Tell Delimiter. For Color code issues, and customization.
   * Comments and suggestions welcome: imc@imc2.intermud.us
   * License terms are available in the imc2freedom.license file.
   */
***************
*** 96,101 ****
--- 98,104 ----
  char *imc_send_social( CHAR_DATA * ch, char *argument, int telloption );
  void imc_save_config( void );
  void imc_save_channels( void );
+ char* fix_sender(char* string);
  
  char *const imcperm_names[] = {
     "Notset", "None", "Mort", "Imm", "Admin", "Imp"
***************
*** 619,624 ****
--- 622,643 ----
     return name;
  }
  
+ char *imc_nameof_delim( char *src, char delim )
+ {
+    static char name[SMST];
+    size_t x;
+ 
+    for( x = 0; x < strlen( src ); x++ )
+    {
+       if( src[x] == '@' )
+          break;
+       name[x] = src[x];
+    }
+    name[x] = '\0';
+ 
+    return name;
+ }
+ 
  char *imc_mudof( char *src )
  {
     static char mud[SMST];
***************
*** 631,636 ****
--- 650,667 ----
     return mud;
  }
  
+ char *imc_mudof_delim( char *src, char delim)
+ {
+    static char mud[SMST];
+    char *person;
+ 
+    if( !( person = strchr( src, delim ) ) )
+       imcstrlcpy( mud, src, SMST );
+    else
+       imcstrlcpy( mud, person + 1, SMST );
+    return mud;
+ }
+ 
  char *imc_channel_mudof( char *src )
  {
     static char mud[SMST];
***************
*** 812,817 ****
--- 843,849 ----
     IMCSTRFREE( this_imcmud->details );
     IMCSTRFREE( this_imcmud->versionid );
     IMCSTRFREE( this_imcmud->base );
+    IMCSTRFREE( this_imcmud->channsep);
     IMCDISPOSE( this_imcmud );
  }
  
***************
*** 906,911 ****
--- 938,948 ----
     return check_mud( ch, imc_mudof( mud ) );
  }
  
+ bool check_mudof_delim( CHAR_DATA * ch, char *mud, char delim)
+ {
+    return check_mud( ch, imc_mudof_delim( mud, delim ) );
+ }
+ 
  int get_imcpermvalue( const char *flag )
  {
     unsigned int x;
***************
*** 1725,1731 ****
     if( reply == 2 )
        snprintf( buf, LGST, "~WImctell: ~c%s\n\r", txt );
     else
!       snprintf( buf, LGST, "~C%s ~cimctells you ~c'~W%s~c'~!\n\r", imcgetname( q->from ), txt );
     imc_to_char( buf, vic );
     imc_update_tellhistory( vic, buf );
     return;
--- 1762,1768 ----
     if( reply == 2 )
        snprintf( buf, LGST, "~WImctell: ~c%s\n\r", txt );
     else
!       snprintf( buf, LGST, "~C%s ~cimctells you ~c'~W%s~c'~!\n\r", fix_sender ( imcgetname( q->from ) ), txt );
     imc_to_char( buf, vic );
     imc_update_tellhistory( vic, buf );
     return;
***************
*** 1884,1889 ****
--- 1921,1960 ----
     update_imchistory( c, buf );
  }
  
+ 
+ 
+ char* fix_sender(char* string)
+ {
+ 	char from[SMST];
+ 	char senders[SMST];
+ 	static char buf[SMST];
+ 	char *x, *y, *z;
+ 	senders[0] = '\0';
+ 	from[0] = '\0';
+ 
+ 	y = string;
+ 
+ 	x = senders;
+ 	while(*y != '\0') {
+ 		if(*y == '@') {
+ 			y++;
+ 			*x++ = '\0';
+ 			break;
+ 		}
+ 
+ 		*x++ = *y++;
+ 	}
+ 
+ 	z = from;
+ 	while(*y != '\0') {
+                 *z++ = *y++;
+         }
+ 	*z++ = '\0';
+ 
+ 	sprintf(buf, "%s%s%s", senders, this_imcmud->channsep, from);
+ 	return buf;
+ }
+ 
  PFUN( imc_recv_pbroadcast )
  {
     IMC_CHANNEL *c;
***************
*** 1902,1908 ****
     if( !( c = imc_findchannel( chan ) ) )
        return;
  
!    imc_display_channel( c, sender, txt, em );
     return;
  }
  
--- 1973,1979 ----
     if( !( c = imc_findchannel( chan ) ) )
        return;
  
!    imc_display_channel( c, fix_sender( sender ), txt, em );
     return;
  }
  
***************
*** 1925,1933 ****
        return;
  
     if( !sender || sender[0] == '\0' )
!       imc_display_channel( c, q->from, txt, em );
     else
!       imc_display_channel( c, sender, txt, em );
     return;
  }
  
--- 1996,2004 ----
        return;
  
     if( !sender || sender[0] == '\0' )
!       imc_display_channel( c, fix_sender( q->from ), txt, em );
     else
!       imc_display_channel( c, fix_sender( sender ), txt, em );
     return;
  }
  
***************
*** 2282,2288 ****
  {
     static char pline[LGST];
  
!    imcstrlcpy( pline, whot->immline, LGST );
     imcstrlcpy( pline, imcstrrep( pline, "<%charrank%>", plrrank ), LGST );
     imcstrlcpy( pline, imcstrrep( pline, "<%charflags%>", plrflags ), LGST );
     imcstrlcpy( pline, imcstrrep( pline, "<%charname%>", plrname ), LGST );
--- 2352,2358 ----
  {
     static char pline[LGST];
  
!    imcstrlcpy( pline, whot->plrline, LGST );
     imcstrlcpy( pline, imcstrrep( pline, "<%charrank%>", plrrank ), LGST );
     imcstrlcpy( pline, imcstrrep( pline, "<%charflags%>", plrflags ), LGST );
     imcstrlcpy( pline, imcstrrep( pline, "<%charname%>", plrname ), LGST );
***************
*** 4287,4293 ****
        fprintf( fp, "%s", "#HELP\n" );
        fprintf( fp, "Name %s\n", help->name );
        fprintf( fp, "Perm %s\n", imcperm_names[help->level] );
!       fprintf( fp, "Text %s¢\n", help->text );
        fprintf( fp, "%s", "End\n\n" );
     }
     fprintf( fp, "%s", "#END\n" );
--- 4357,4363 ----
        fprintf( fp, "%s", "#HELP\n" );
        fprintf( fp, "Name %s\n", help->name );
        fprintf( fp, "Perm %s\n", imcperm_names[help->level] );
!       fprintf( fp, "Text %s�\n", help->text );
        fprintf( fp, "%s", "End\n\n" );
     }
     fprintf( fp, "%s", "#END\n" );
***************
*** 4697,4702 ****
--- 4767,4774 ----
     fprintf( fp, "ServerPort     %d\n", this_imcmud->rport );
     fprintf( fp, "ClientPwd      %s\n", this_imcmud->clientpw );
     fprintf( fp, "ServerPwd      %s\n", this_imcmud->serverpw );
+    fprintf( fp, "ChannSep       %s\n", this_imcmud->channsep );
+    fprintf( fp, "TellDelim      %c\n", this_imcmud->telldelim );
     fprintf( fp, "#MD5 auth: 0 = disabled, 1 = enabled\n" );
     fprintf( fp, "MD5            %d\n", this_imcmud->md5 );
     if( this_imcmud->md5pass )
***************
*** 4735,4740 ****
--- 4807,4813 ----
  
           case 'C':
              IMCKEY( "ClientPwd", this_imcmud->clientpw, imcfread_line( fin ) );
+ 	    IMCKEY( "ChannSep", this_imcmud->channsep, imcfread_line( fin ) );
              break;
  
           case 'E':
***************
*** 4786,4791 ****
--- 4859,4876 ----
              IMCKEY( "ServerPwd", this_imcmud->serverpw, imcfread_line( fin ) );
              IMCKEY( "ServerAddr", this_imcmud->rhost, imcfread_line( fin ) );
              IMCKEY( "ServerPort", this_imcmud->rport, imcfread_number( fin ) );
+ 	    break;
+     	 case 'T':
+ 		 if( !strcasecmp( word, "TellDelim" ) )
+ 		 {
+ 			 char *c;
+ 			 c = imcfread_line(fin);
+ 			 this_imcmud->telldelim = *c;
+ 			 IMCSTRFREE(c);
+ 			 fMatch = TRUE;
+ 			 break;
+ 		 }
+ 	    /* Add in case 'T': Tell Delim. */
              break;
        }
        if( !fMatch )
***************
*** 4846,4851 ****
--- 4931,4938 ----
           this_imcmud->md5 = TRUE;
           this_imcmud->md5pass = FALSE;
           this_imcmud->desc = desc;
+ 	 this_imcmud->channsep = IMCSTRALLOC( "@" );
+ 	 this_imcmud->telldelim = '@';
  
           imcfread_config_file( fin );
           continue;
***************
*** 6000,6006 ****
     {
        int x;
  
!       imc_to_char( "Usage: imctell user@mud <message>\n\r", ch );
        imc_to_char( "Usage: imctell [on]/[off]\n\r\n\r", ch );
        imc_printf( ch, "&cThe last %d things you were told:\n\r", MAX_IMCTELLHISTORY );
  
--- 6087,6093 ----
     {
        int x;
  
!       imc_printf(ch,  "Usage: imctell user%cmud <message>\n\r", this_imcmud->telldelim );
        imc_to_char( "Usage: imctell [on]/[off]\n\r\n\r", ch );
        imc_printf( ch, "&cThe last %d things you were told:\n\r", MAX_IMCTELLHISTORY );
  
***************
*** 6039,6045 ****
        return;
     }
  
!    if( !check_mudof( ch, buf ) )
        return;
  
     /*
--- 6126,6132 ----
        return;
     }
  
!    if( !check_mudof_delim( ch, buf, this_imcmud->telldelim ) )
        return;
  
     /*
***************
*** 6593,6598 ****
--- 6680,6687 ----
        imc_to_char( "~wServerPort     : ~GPort of the server your mud connects to.\n\r", ch );
        imc_to_char( "~wClientPwd      : ~GClient password for your mud.\n\r", ch );
        imc_to_char( "~wServerPwd      : ~GServer password for your mud.\n\r", ch );
+       imc_to_char( "~wChannSep       : ~GName @ Mud Separator.\n\r", ch );
+       imc_to_char( "~wTellDelim      : ~GName @ Mud Delimiter\n\r", ch );
        return;
     }
  
***************
*** 6651,6656 ****
--- 6740,6747 ----
        imc_printf( ch, "~wServerPort     : ~G%d\n\r", this_imcmud->rport );
        imc_printf( ch, "~wClientPwd      : ~G%s\n\r", this_imcmud->clientpw );
        imc_printf( ch, "~wServerPwd      : ~G%s\n\r", this_imcmud->serverpw );
+       imc_printf( ch, "~wChannSep       : ~G%s\n\r", this_imcmud->channsep );
+       imc_printf( ch, "~wTellDelim      : ~G%c\n\rr", this_imcmud->telldelim );
        if( this_imcmud->md5 )
           imc_to_char( "~RThis mud has enabled MD5 authentication.\n\r", ch );
        else
***************
*** 6818,6823 ****
--- 6909,6931 ----
        imc_save_config(  );
        return;
     }
+    
+    if( !strcasecmp( arg1, "channsep" ) )
+    {
+       IMCSTRFREE( this_imcmud->channsep );
+       this_imcmud->channsep = IMCSTRALLOC( argument );
+       imc_printf( ch, "ChannSep changed to %s\n\r", argument );
+       imc_save_config(  );
+       return;
+    }
+    
+    if( !strcasecmp( arg1, "telldelim" ) )
+    {
+       this_imcmud->telldelim = *argument;
+       imc_printf( ch, "TellDelim changed to %c\n\r", *argument );
+       imc_save_config(  );
+       return;
+    }
  
     if( !strcasecmp( arg1, "localname" ) )
     {

Site Stats

Snippets: 1791
Codebases: 571