Inside3D!
     

List plugins

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
gnounc



Joined: 06 Apr 2009
Posts: 120

PostPosted: Sat Jul 03, 2010 8:50 am    Post subject: List plugins Reply with quote

Would anybody be interested in a List plugin? Something along
the lines of :

Code:

void reverseList(ent reverselistname) =
{
while (ownername != world);
   {   
   insert (player.chain, reverselistname);
   player.chain = player.chain.chain;
   }
};

void insertItem(ent item,ent list) =
   {
   item.chain = owner.chain;
   player.chain = newItem;
   };

void popItem(ent listname) =
   {
   reverseList(listname);
   return player.chain;   
   player.chain = player.chain.chain;

   };

void removeItem (ent listname) =
   {
   player.chain = player.chain.chain
   };   

void append (item, listname) =
   {

   };
Back to top
View user's profile Send private message
mk



Joined: 04 Jul 2008
Posts: 94

PostPosted: Sat Jul 03, 2010 2:22 pm    Post subject: Reply with quote

Generic linked lists are bloody great.

In fact, I've gotta do some research to find the best way of implementing this in C. In Java we can just use LinkedList <type> var_name = new LinkedList <type_or_inherited_type> (); .
_________________
Makaqu engine blog / website.

Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
Back to top
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Sun Jul 04, 2010 5:30 am    Post subject: Reply with quote

I used to look for ways to do generic linked lists in C, but I eventually came full circle and now just recode it for every new structure. The other ways are too ugly and convoluted, involving macros and/or a lot of casting pointers to do poor man's inheritance. Recoding it every time isn't too much extra code and it's a lot more straightforward and readable.

Anyway, this thread was about QuakeC linked lists...
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
gnounc



Joined: 06 Apr 2009
Posts: 120

PostPosted: Sun Jul 04, 2010 7:47 am    Post subject: Reply with quote

which im guessing would be harder?
Back to top
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Sun Jul 04, 2010 5:42 pm    Post subject: Reply with quote

No, it wouldn't be harder. However, I wouldn't have a use for a generic linked list "library", but maybe someone else would. It would be fun to use QC field pointers so you can use more than the "chain" field.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
mk



Joined: 04 Jul 2008
Posts: 94

PostPosted: Sun Jul 04, 2010 8:08 pm    Post subject: Reply with quote

Sajt wrote:
Anyway, this thread was about QuakeC linked lists...

Whoops.

In this case, I'd suggest taking a look at the FrikBot X source. The way its waypoints are linked can be very useful.
_________________
Makaqu engine blog / website.

Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group