Abbreviations [by Zigg]
Snippet Posted Wednesday, August 12th @ 11:23:26 PM, by George Greer in the Utils dept.
. Click the link below to read it or download it.

From: Jvrgen Zigge Sigvardsson <di4sig@cse.hks.se>
Subject: Abbreviations for objects, mobs and players.

If anyone is interested here is a piece of code that will allow
everything to be abbreviated. Instead of typing 'kill
mobwithaverylongandcomplicatedname' you could type 'kill mob'.
It is VERY appreciated by players.

In 'handler.c', change isname() to this:

#define WHITESPACE " \t"

int isname(char *str, char *namelist)
{
  char *newlist;
  char *curtok;

  newlist = strdup(namelist); /* make a copy since strtok 'modifies' strings */

  for(curtok = strtok(newlist, WHITESPACE); curtok; curtok = strtok(NULL,


WHITESPACE))
     if(curtok && is_abbrev(str, curtok))
     {
        free(newlist);
        return 1;
     }
  free(newlist);
  return 0;
}

This will check for an abbreviation on every word in the namelist.


<< 128 Bit Converters (again) [by The Count] | Reply | View as text | Flattened | Ability Score Rolling Function [by fantasia] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.