Re: [CODE] item loading/limits?

From: Robin C Andersson (mb@BAMZE.HULE.HARRYDA.SE)
Date: 04/02/98


Here is a code snippet which i use on my mud...
Its take straight out of my code and i dont really have time to change it
but it should give you an idea of how to count limited objects from
playerfiles... otherwise forget this mail ;)

argument should be the players name


void count_player_objects(char *argument)
{
   FILE *fl;
   char fname[MAX_INPUT_LENGTH];
   struct obj_file_elem object;
   struct obj_data *obj;
   struct rent_info rent;
   skip_spaces(&argument);
   if(!get_filename(argument, fname, CRASH_FILE))
     return;
   if(!(fl = fopen(fname, "rb"))) {
      return;
   }
   if(!feof(fl))
     fread(&rent, sizeof(struct rent_info), 1, fl);
   while(!feof(fl)){
      fread(&object, sizeof(struct obj_file_elem), 1, fl);
      if(ferror(fl)){
         fclose(fl);
         return;
      }
      if(!feof(fl))
        if(real_object(object.item_number) > 1){
           obj = read_object(object.item_number, VIRTUAL);
              if(update){
                 object_count_struct[GET_OBJ_VNUM(obj)].nr = GET_OBJ_VNUM(obj);
                 object_count_struct[GET_OBJ_VNUM(obj)].exist++;
              }
           if(GET_OBJ_LIMITED(obj) != 0)
               nr_counted_objects.limited++;
           nr_counted_objects.all++;
           extract_obj(obj);
        }
   }
   fclose(fl);
}


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST