Re: Some Questions about Storing Information and Efficiency

From: Thomas Arp (t_arp@stofanet.dk)
Date: 07/09/02


From: "Mathew Earle Reuther" <graymere@zipcon.net>
> First off, I need to store potentially 1000+ separate pieces of yes/no
> info per character.  (I have ascii pfiles, btw.)  Would it be best to
> store the pieces of info in the char files, or should I create a new file
> which has the pieces of info (rnums, the info will be attatched to rooms
> and doing actions in the rooms will cause the character to need the fact
> that they've completed the action flipped on) stored inside along with
> space to record the idnum of the character?
>
> I'm not too handy with parsing, having only just added a field to my
> pfiles yesterday!  (Successfully, mind you, now I just need to figure out
> how to make a new con state work in nanny so i can set it's value!)  I was
> thinking maybe a file format like this might work?
>
> 3011
> 1 2 34 586 (etc..)
> #
> $
>
> The first number being the rnum, the rest being people (idnum) who have
> done the required task to flip the switch for the room.
>
> Otherwise I could add the info to the pfile, but I don't know a good way
> to do that in order to store a very large number of rnums.  Anyone have
> any suggestions or opinions on this?
>
> The other part of this is just adding a numeric value to the pfiles which
> is not that hard.
>
I'm assuming this is for some kind of quest system. If you wish to keep
track for _every_ player if s/he has been in every room in the game, this
method is not good. To do this would mean needing a lot of storage space.

If you save it all into the pfiles, the full list will have to be in
memory whenever the player is logged on - with room_vnum typedefed to
sh_int, 1000 rooms fill up 4k of memory - per player.

I suggest you save a sorted list of room numbers. And I'd suggest you
use vnums and not rnums, since rnums can be changed if a new area is
added.

You could add the list in char_data - probably in
player_special_data_saved

room_vnum *rooms;            /* pointer to first element of room list */
int        num_rooms;        /* length of room list */

with an access macro like

#define ROOM_LIST(ch) CHECK_PLAYER_SPECIAL((ch),
                      ((ch)->player_specials->saved.rooms))
#define ROOM_LLEN(ch) CHECK_PLAYER_SPECIAL((ch),
                      ((ch)->player_specials->saved.num_rooms))

A usable file format could be something like
..
RLEN: 4
ROOM:
3001
3012
12134
14003
-1
..

Then a
  CREATE(ROOM_LIST(ch), int, ROOM_LLEN(ch));
will create the list, and make it the right length.

> ***
>
> The next thing I need to do is to add another two numeric values (easy as
> i said above) but also find a way of tracking a set of completed tasks.
> Could be quite a few of them eventually as well, and I'm not sure how to
> store states for them.  At the very least I need to be able to set them as
> done so I can not allow them to be repeated.  (As it's not too difficult
> to guess, this is for quests.)

Have you thought of trying dg scripts ? They save 'player variables' which
can be used for a multitude of things. A quick glance at one of my var
files:

solved_jester_quest_area_31 0 1
old_man_area_140 0 1
dwarf_gate_guard 0 4
preferred_meal 0 bread

The last line shows I've been talking to the gateguard a little while,
and his next response (or rather list of responses) should be number 4.
Of course this requires some in-game scripting.

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT