[SEMI-NEWBIE/LONG] Cycling a linked list for characters

From: Surgeon (webremedies@ca.inter.net)
Date: 03/04/02


Hello all,

    I am currently in the process of "trying" to make one of my first
snippets for the CircleMUD community, but running into a bit of problems in
terms of cycling an object for more than one char.  For
example (in relation to what's below) if I was to create a couch, with
an infinite player limit and infinite weight restriction how would I
properly go about cycling that object for ALL the characters on it.  This is
what I am currently tampering with now.


struct rest_object_data {
 long weight_capacity;  /* how much weight can object hold -1 infinite*/
 int player_capacity;   /* how many players can use this object -1 " */
 int regen_bonus;         /* bonus regen per tick */
 int rest_type[4];          /* POS's: sleep, rest, kneel, sit */
 struct char_data *rested_on_by;  /* This is where I need assistance */
 struct rest_object_data *next;
};

Two problems I can forsee:

    One:  I am planning on writing extra bits to the object files obviously
for all fields, rest_type[1] being sleep position, 1 (can be slept on), 0 if
not.  Just so as to provide a way for builders to make furniture restable
upon in some ways while restricting others.

   Two:  I am somewhat left blinded as to how I would go about cycling
ONE object for the amount of chars that are currently resting on it.  Would
I have to create a whole new structure all together similar to the
below inorder to succesfully shuffle through the chars?

 struct example {
    struct char_data *rested_on_by;
    struct example *next;
};

And then replace the first instance of *rested_on_by (at the top) with:
struct example *resting_plist;

And then cycle through example independantly?

I'm sorry if I'm not coming across 100% clear, I've only recently begun
to grasp the concept of linked lists, pointers and structures.

Anyhow, that's the dilemna towhich I am sunk knee deep in.  Any available
help and or references to helpful material would be greatly appreciated.

Thanks in advance,

        Surgeon (webremedies@ca.inter.net)

--
   +---------------------------------------------------------------+
   | 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