/* * This code is was written for Dark Hope MUD by Theodryck * Copyright 2009. You may freely use and distribute this * code as long as the documentation remains unaltered. * * To install into your code simply copy the entire * snippet and paste into the end of your act_wiz.c file, * set DECLARE_DO_FUN( do otype ) in merc.h and add the * command table in interp.c. That should be all you need. */ /* * Code that searches for an item based on wear type using * struct wear_flags as a guide (arms, wield, legs, etc). This * is mainly for builders who are looking for eq consistancy. * --Theo */ void do_otype( CHAR_DATA *ch, char *argument ) { CHAR_DATA *rch; OBJ_INDEX_DATA *pObjIndex; AREA_DATA *pArea; char buf [ MAX_STRING_LENGTH ]; char arg [ MAX_INPUT_LENGTH ]; char arg1 [ MAX_INPUT_LENGTH ]; char type [ MAX_STRING_LENGTH ]; extern int top_vnum_obj; int vnum; int bottom; int top; int count = 0; bool fWorld; bool found; rch = get_char( ch ); type[0] = '\0'; pArea = ch->in_room->area; if ( !authorized( rch, "otype" ) ) return; argument = one_argument( argument, arg ); argument = one_argument( argument, arg1 ); if ( arg[0] == '\0' || ( str_cmp( arg, "world" ) && str_cmp( arg, "area" ) ) ) { send_to_char( "Syntax: otype world \n\r", ch ); send_to_char( "or: otype area \n\r", ch ); return; } if ( arg1[0] == '\0' ) { send_to_char( "Otype what?\n\r", ch ); return; } found = FALSE; fWorld = !str_cmp( arg, "world" ); /* To keep silly people from intentionally causing a buffer overflow */ if( ( !str_cmp( arg1, "take" ) || !str_cmp( arg1, "wield" ) || !str_cmp( arg1, "hold" ) ) && ( fWorld ) ) { send_to_char( "Don't be silly. That'll cause an overflow.\n\r", ch ); return; } /* * Since all wearable eq has a "take" flag, let's add it arg1 * so we don't have to type it every single time. */ strcat( type, "take " ); strcat( type, arg1 ); if ( fWorld ) { bottom = 0; top = top_vnum_obj; } else { bottom = pArea->low_o_vnum; top = pArea->hi_o_vnum + 1; } for ( vnum = bottom; vnum < top; vnum++ ) { if ( !( pObjIndex = get_obj_index( vnum ) ) ) continue; if ( !fWorld && pArea != pObjIndex->area ) continue; if ( !str_cmp( type, flag_string( wear_flags, pObjIndex->wear_flags ) ) ) { found = TRUE; count++; /* * OK. We've found an item of the type we are looking for. * Now we'll display it with some formatting and include the * area name that the object is located */ sprintf( buf, "{o{w[%5d]{x%-45s %-30s\n\r", pObjIndex->vnum, capitalize( pObjIndex->name ), pObjIndex->area->name ); send_to_char( buf, ch ); } } if ( !found ) { send_to_char( "Nothing like that in hell, earth, or heaven.\n\r", ch); return; } sprintf( buf, "{xYou found %d total items of type %s.\n\r", count, arg1 ); send_to_char( buf, ch ); return; }