[CF-Devel] Patch submission: 'tell' improvement

crossfire-devel-admin at archives.real-time.com crossfire-devel-admin at archives.real-time.com
Mon Oct 20 12:24:48 CDT 2003


Hello.

Here's a small patch to tweak the 'tell' command.
You can now enter the first letters of the name only, provided there is only one 
matching player.
IE if you have 'playerA', 'playerB' and 'human', you can do 'tell h hello'.
But you'll have to use 'tell playera hello' since 'player' can be 2 players.

Note: not case sensitive.

If I don't have any negative feedback, I'll commit it in 1 or 2 weeks...

Nicolas 'Ryo'

(note: patch directly in mail, since it isn't that big)


Index: include/sproto.h
===================================================================
RCS file: /cvsroot/crossfire/crossfire/include/sproto.h,v
retrieving revision 1.96
diff -r1.96 sproto.h
476c476,477
< player *find_player(char *plname);
---
 > player *find_player(char *plname);
 > player* find_player_partial_name( char* plname );
Index: server/c_chat.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/c_chat.c,v
retrieving revision 1.15
diff -r1.15 c_chat.c
149,152c149,153
<
<     for(pl=first_player;pl!=NULL;pl=pl->next)
< 	if(strncasecmp(pl->ob->name,name,MAX_NAME)==0) {
<
---
 >
 >     pl = find_player_partial_name( name );
 >
 >     if ( pl )
 >         {
155c156
< 			     "You tell %s: %s", name, msg);
---
 > 			     "You tell %s: %s", pl->ob->name, msg);
159,161c160,163
< 	    return 1;
< 	}
<     new_draw_info(NDI_UNIQUE, 0,op,"No such player.");
---
 > 	    return 1;
 >         }
 >
 >     new_draw_info(NDI_UNIQUE, 0,op,"No such player or ambiguous name.");
Index: server/player.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/player.c,v
retrieving revision 1.137
diff -r1.137 player.c
52c52,73
< }
---
 > }
 >
 > player* find_player_partial_name( char* plname )
 >     {
 >     player* pl;
 >     player* found = NULL;
 >     size_t namelen = strlen( plname );
 >     for ( pl = first_player; pl != NULL; pl = pl->next )
 >         {
 >         if ( strlen( pl->ob->name ) < namelen )
 >             continue;
 >
 >         if ( !strnicmp( pl->ob->name, plname, namelen ) )
 >             {
 >             if ( found )
 >                 return NULL;
 >
 >             found = pl;
 >             }
 >         }
 >     return found;
 >     }


_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list