Search the world for a room name: This extension to the do_vnum will search through your world for any rooms that match the search word. It is essentially a hack of the other to vnum search options, but comes in pretty handy for when you know that a room is somewhere, but can't remember where (in a very large world this can be quite a problem :P) (it will max out at 100 found results to avoid spamming the viewer into oblivion if they search for "vnum room a") - Dana ... Questions? Comments? etc? ;) email to luthers@ex-pressnet.com (Note: This is a fix to the original that I put out last week. Thanks to Tim Yohn who pointed out my omission - for anyone who got the original, the fix is to add: page_string(ch->desc, buf, TRUE); before the return(found) in vnum_room().) in act.wizard.c ****************** ACMD(do_vnum) { half_chop(argument, buf, buf2); ! if (!*buf || !*buf2 || (!is_abbrev(buf, "mob") && !is_abbrev(buf, "room") ! && !is_abbrev(buf, "obj"))) { send_to_char("Usage: vnum { obj | mob } \r\n", ch); return; } if (is_abbrev(buf, "mob")) if (!vnum_mobile(buf2, ch)) send_to_char("No mobiles by that name.\r\n", ch); if (is_abbrev(buf, "obj")) if (!vnum_object(buf2, ch)) send_to_char("No objects by that name.\r\n", ch); + if (is_abbrev(buf, "room")) + if (!vnum_room(buf2, ch)) + send_to_char(" No room name containing that word.\r\n", ch); } in db.h ************ search for: int vnum_object(char *searchname, struct char_data *ch); then add: + int vnum_room(char *searchname, struct char_data * ch); in db.c somewhere add: ************************* +int vnum_room(char *searchname, struct char_data * ch) +{ + int nr, found = 0; + char tempbuf[MAX_STRING_LENGTH]; + + sprintf(buf, "Results:\r\n"); + for (nr = 0; nr <= top_of_world && found <=100 ; nr++) { // note: if you don't use color codes, you can take comment out the following // two lines, and do the isname as if(isname(searchname, world[nr].name)) - // you can also remove the tempbuf variable above - not used for anything else. // note: buf2 is the same as searchname so don't use buf2 (you'll end up spitting // out all your rooms as a result). - don't add this comment to your code... + sprintf(tempbuf, "%s", world[nr].name); + remove_colorcodes(tempbuf); + if (isname(searchname, tempbuf)) { + sprintf(buf + strlen(buf), "%3d. [%5d] %s\r\n", ++found, + world[nr].number, + world[nr].name); + if (found == 100) + sprintf(buf + strlen(buf), "**Too many results, please use a less common search word.**\r\n"); + } + } + page_string(ch->desc, buf, TRUE); + return (found); +} If you don't have something like this - and you use color codes, add this to utils.c (with a declaration in utils.h so that it can be used anywhere you might need it. If you already have a function like this - or for some reason don't want it to match up if there is color on the target string, either use your own function, or take out the call to this entirely ;) ******************************* + // check to make sure that these color code letters match what + // you're using and adjust as necessary. +#define IS_COLOR_CHAR(c) (c == 'n' || c == 'R' || c == 'r' || c == 'Y' || c == 'y' || c == 'G' || c == 'g' || c == 'B'\ + || c == 'b' || c == 'f' || c == 'M' || c == 'm' || c == 'W' || c == 'w' || c == 'D' || c == 'd' || c == 'C'\ + || c == 'c' || c == '0') + +void remove_colorcodes(char *string){ + int i, j, stringLen; + + stringLen = (strlen(string) + 1); + + for (i = 0; i < stringLen; i++) { + if ((string[i] == '&') && (string[i-1] != '&') && IS_COLOR_CHAR(string[i+1])){ + j = i; + while ( j < (stringLen - 2)){ /* String will be two characters shorter */ + string[j] = string[j+2]; + j++; + } + string[j] = '\0'; + } + } + return; +}