True, which is why you need the load_limited_objects from the Anatolia
code to make it work.
The load_limited_objects counts and checks the pfiles during a load and
copyover.

void load_limited_objects()
{
  struct dirent *dp;

  int i;
  OBJ_INDEX_DATA *pObjIndex;
  DIR *dirp;
  FILE *pfile;
  char letter;
  char *word;
  char buf[100];
  bool fReadLevel;
  char buf2[160];
  char buf3[160];

  total_levels = 0;


  if ( (dirp = opendir(PLAYER_DIR)) == NULL)
    {
      bug("Load_limited_objects: unable to open player directory.",0);
      exit(1);
    }

  for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp) )
    {
      if (strlen(dp->d_name) >= 3)
        {
          sprintf(buf3,"%s/",dp->d_name);
          dump_to_scr( buf3 );
          sprintf(buf, "%s/",PLAYER_DIR);
          strcat(buf, dp->d_name);

          fReadLevel = FALSE;

          if ( (pfile = fopen(buf, "r")) == NULL)
            bug("Load_limited_objects: Can't open player file.",0);
          else
            {
              for (letter = fread_letter(pfile);letter != EOF;
                   letter = fread_letter(pfile) )
                {
                  if (letter == 'L')
                    {
                      if (!fReadLevel)
                      {
                        word = fread_word(pfile);
                        if (!str_cmp(word, "evl"))
                        {
                         i = fread_number(pfile);
                         fReadLevel = TRUE;
                         total_levels += UMAX(0,i - 5);
                         sprintf(buf2, "[%s]'s file +: %d\n\r", buf,
UMAX(0, i-5));
                         numplayer++;
                         dump_to_scr( buf2 );
                         continue;
                        }
                      }
                    }
                  else if (letter == '#')
                    {
                      word = fread_word(pfile);
                      if (!str_cmp(word, "O") || !str_cmp(word,
"OBJECT"))
                        {
                          fread_word(pfile);
                          pObjIndex =
get_obj_index(fread_number(pfile));
                          pObjIndex->count++;
                          if(pObjIndex->limit != -1)
                          {
                          sprintf(buf,"Limited Item %s (%d) found, count
now
%d\n\r",(remove_color(pObjIndex->short_descr)),pObjIndex->vnum,pObjIndex
->count);
                          dump_to_scr( buf );
                          }
                        }
                    }

                }
              fclose(pfile);
            }
        }
    }
  closedir(dirp);
}

I know it all works because I use it currently to do exactly what the
poster asked for.

Cheers,
        Keith

-----Original Message-----
From: Richard Lindsey [mailto:[EMAIL PROTECTED] 
Sent: Saturday, April 24, 2004 10:50 PM
To: Keith Mervine; Rainer Roomet; [email protected]
Subject: RE: question about limiting items


This function won't check anything in the pfiles, it will only check how
many of the items are currently in the MUD after a reboot (i.e. on the
ground, and on mobs), because the obj->pIndexData->count is decremented
each time the object is extracted (i.e. when a player quits), and if you
put the load_artifacts function in bootup, it won't read anything from
players because no players will be registered as logged into the MUD
during bootup, even on a copyover the MUD does a full boot and a reset
(which would load all artifact items since there would be 0 in the MUD
at that point) before it reconnects the players, so you would always
have these items loading once at startup and copyovers...
 
wavewave
Richard Lindsey.

        -----Original Message----- 
        From: Keith Mervine [mailto:[EMAIL PROTECTED] 
        Sent: Sat 4/24/2004 9:43 PM 
        To: 'Rainer Roomet'; [email protected] 
        Cc: 
        Subject: RE: question about limiting items
        
        

        Create a load artifacts function and call it during load.
        To make sure its not in someones possession (pfile) during the
initial
        load do this:
        
        Example:
        
        void load_artifacts( void )
        {
            CHAR_DATA *ch;
            OBJ_DATA *obj;
            ROOM_INDEX_DATA *location, *room;
        
        
            obj = create_object( get_obj_index( 1207 ), 0 );
            if ((obj->pIndexData->count -1 ) >= obj->pIndexData->limit)
            {
             extract_obj(obj);
            }
            else
            {
              room = rand_room();
              obj_to_room(obj,room);
            }
        }
        
        Now with this code you shouldn't have it on a standard reset,
and if you
        want it to
        Load on a mob you can do :
        
            pMob = create_mobile( get_mob_index( 25122 ) );   //Loads
mob vnum
        25122
            room = rand_room();                               //Randomly
pick a
        room
            char_to_room( pMob, room );                       //Place
the mob in
        the room
            obj = create_object( get_obj_index( 8102 ), 0 );  //Create
the
        object to put on the mob
            obj_to_char( obj, pMob );                         //Put the
object
        on the mob inventory
           
        This will ensure that the object will only load IF no-one has it
in
        their inventory.
        
        I use it to load the individual pieces of the "Rod of Seven
Parts"
        
        This will load the object and if it already exists (in pfiles)
it will
        extract it.  Otherwise it places it where you want (in this
example a
        random room)
        
        Place the function call somewhere after loading the limited
objects.
        (Somewhere in boot_db)
        Im not sure about Tartarus code but the function
load_limited_objects is
        in the Anatolia code.
        
        Hope this helps.
        
        Keith
        
        -----Original Message-----
        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Rainer
        Roomet
        Sent: Saturday, April 24, 2004 7:53 AM
        To: [email protected]
        Subject: question about limiting items
        
        
        I want to add limit item code to my rom 2.4. I look Tartarus
code base
        but
        it is not that what i need. There was somet item limit code but
it's not
        
        work properly. For example, if i set "the One Ring" limit 1.
Then "the
        One
        Ring" loads only one time per game. And if some player have the
One Ring
        and
        mud reboots then it dosen't load. Even the player is offline. It
load
        again
        when player lost this ring (is he sacrifice it etc.).
        
        Anyone have idea ? And i apologize for my bad Englis :)
        
        -- Ranka
        
        The Lost Lands of Arion -- telnet irc.nohik.ee 4242
        http://www.zone.ee/gain/forum.php
        
        
_________________________________________________________________
        The new MSN 8: smart spam protection and 2 months FREE* 
        http://join.msn.com/?page=features/junkmail
        
        
        --
        ROM mailing list
        [email protected]
        http://www.rom.org/cgi-bin/mailman/listinfo/rom
        
        
        
        --
        ROM mailing list
        [email protected]
        http://www.rom.org/cgi-bin/mailman/listinfo/rom
        




Reply via email to