View Single Post
Re: Pointer to vector element
Old
  (#3)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Pointer to vector element - 08-03-2004

wow, C++.
I suck at C++.

Personally I would get rid of the STL and use my own struct for that. Then using an array like this:
Code:
struct usermessage_t messages[MAX_USERMESSAGES];
I would just fill this array for each call of pfnRegUserMsg(), then parse this array and return a pointer to the right slot each time pfnMessageBegin() is called (actually that's what I do already in my bot code).

Adding a pointer to the callback function in the network message structure is a smart idea, I think I will borrow this one !

What's the advantage of using the STL by the way ? Auto-sorting by name or by ID ? This can be done using a binary tree and a linked list instead of an array for sorting by name; and sorting by ID can be done just by inserting the messages at their right position in the array since there's 256 registerable user messages at max in the HL engine.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote