i wrote this little function to list all the weapons in the game and their average damage, with two options, you can search for options of a particular level, particular name, particular name and level, or just list all the objects. my problems are: a) that when it tries to list by name(without level) it only shows weapons that are level 0
b) when it tries to list by name and level it doesnt spit anything out

heres the code, can someone find whats wrong? ive been looking at it and just cant figure it out.

void do_checkweaps(CHAR_DATA *ch, char *argument)
{
   char buf[MAX_INPUT_LENGTH];
   char name[MAX_INPUT_LENGTH];
   char level[MAX_INPUT_LENGTH];
   BUFFER *buffer;
   OBJ_DATA *obj;
   bool found;
   int number = 0;

   found = FALSE;
   number = 0;

   buffer = new_buf();

   argument = one_argument(argument, name);
   argument = one_argument(argument, level);
   if (name[0] == '\0' || ( !str_cmp( name, "null" ) && level[0] == '\0'))
   {
                log_string("1");
            for ( obj = object_list; obj != NULL; obj = obj->next )
            {
                        if(obj->wear_loc == WEAR_WIELD)
                        {
                                number++;
sprintf(buf," %d ) [ AVG DAM: %3d ] [ LEVEL: %3d ] %s\n\r",number,((1 + obj->value[2]) * obj->value[1] / 2),obj->level,obj->short_descr);
                        add_buf(buffer,buf);
                        }
                }
       page_to_char(buf_string(buffer),ch);
       return;
   }
   if (str_cmp( name, "null" ) && level[0] == '\0')
   {
                log_string("2");
            for ( obj = object_list; obj != NULL; obj = obj->next )
            {
                        if(str_cmp(name,obj->name))
                                continue;
                        if(obj->wear_loc == WEAR_WIELD)
                        {
                                number++;
sprintf(buf," %d ) [ AVG DAM: %3d ] [ LEVEL: %3d ] %s\n\r",number,((1 + obj->value[2]) * obj->value[1] / 2),obj->level,obj->short_descr);
                        add_buf(buffer,buf);
                        }
                }
       page_to_char(buf_string(buffer),ch);
       return;
   }
   if (!str_cmp( name, "null" ))
   {
                log_string("3");
            for ( obj = object_list; obj != NULL; obj = obj->next )
            {
                        if(obj->level != atoi(level))
                                continue;
                        if(obj->wear_loc == WEAR_WIELD)
                        {
                                number++;
sprintf(buf," %d ) [ AVG DAM: %3d ] [ LEVEL: %3d ] %s\n\r",number,((1 + obj->value[2]) * obj->value[1] / 2),obj->level,obj->short_descr);
                        add_buf(buffer,buf);
                        }
                }
       page_to_char(buf_string(buffer),ch);
       return;
   }
        log_string("4");
   for ( obj = object_list; obj != NULL; obj = obj->next )
   {
                if(str_cmp(name,obj->name))
                        continue;
                if(obj->level != atoi(level))
                        continue;
                if(obj->wear_loc == WEAR_WIELD)
                {
                        number++;
sprintf(buf," %d ) [ AVG DAM: %3d ] [ LEVEL: %3d ] %s\n\r",number,((1 + obj->value[2]) * obj->value[1] / 2),obj->level,obj->short_descr);
                add_buf(buffer,buf);
                }
        }
   page_to_char(buf_string(buffer),ch);
   return;
}

_________________________________________________________________
Take charge with a pop-up guard built on patented Microsoft® SmartScreen Technology http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.


Reply via email to