Forum

List plugins

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

List plugins

Postby gnounc » Sat Jul 03, 2010 8:50 am

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

Code: Select all
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) =
   {

   };
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby mankrip » Sat Jul 03, 2010 2:22 pm

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> (); .
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby Sajt » Sun Jul 04, 2010 5:30 am

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.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby gnounc » Sun Jul 04, 2010 7:47 am

which im guessing would be harder?
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby Sajt » Sun Jul 04, 2010 5:42 pm

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.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby mankrip » Sun Jul 04, 2010 8:08 pm

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.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest