Sutekh

Members
  • Content count

    24
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Sutekh

  • Rank
    Member
  1. Sneftel, So in your system, you have each subsystem store a it's own component[s] that get updated as the subsystem see fit. Each component is responsible for one entity and stores the data it requires for manipulating that entity within itself? Or do you some how store the data for each component with in the entity which is open for all other component to alter if they wish? I have been attempting to wrap my head around a component system, I was going to attempt to use boost::any to allow an extensible system which allowed any data to be stored in a map on the entity, but I wasn't sure what the limitations on boost::any were on what types of data it could actually hold(can it hold class/objects)? Thanks for all your insightful information.
  2. http://www.devmaster.net/articles/oo-game-design/ Has anyone looked at the ideas presented in this page? Any comments on it? I looked it over a while back and found it an interesting concept and was curious if anyone had actually done anything further with it.
  3. For a design rethink, what are you grabbing these values for? If you are just getting the item's values to generate a mouse-over popup of the stats and such, you could create a (pure) virtual function in the base class called "Description" which would let the derived class generate it's own info messages. This would also avoid having to use a RTTI and dynamic_cast type system. On the other hand, if you are getting values from the item to perform some stat changes you could do a simple “ModifyStats” function in the base class that would pass stats into the item and then have the item alter the stats directly. Yet again avoiding any RTTI and dynamic casting
  4. I think count is the only way? If you are getting the data at somepoint, like your sample shows, then use what da.Fill(...) returns, it will be the # of rows returned from that database( well altered in the dataset, but if the set is new then it should return them all . . i think :) )
  5. String function error

    You could also pass THE_WORD by reference, copying a string or any large structure is usually a bad idea, to quicken things up, efficiency and such :). Remember to make anything you pass that isn’t going to be altered in the function a const tho.
  6. Boost Serialization

    He explains here http://www.boost.org/libs/serialization/doc/rationale.html#trap why there is a trap on non-const objects. I agree tho, its a bit of a pain to have to cast everything to a const, in his demo's he uses save_x or load_x functions that just cast the object when its passed in.
  7. Quote:Original post by Fruny A type is polymorphic if and only if it has a virtual function. Virtual inheritance have very little to do with that. Additionally, most uses of polymorphic object also require a virtual destructor. This is perfectly correct behavior, yes. dynamic_cast relies on run-time type information that is typically only generated (and logically so) for polymorphic types. Thanks for the quick response. So virtual inheritance's only purpose is to prevent a derived class from inheriting the same base class more than once? Is there no way to create an empty base class that is polymorphic?
  8. I am toying around with some code from an article in this month’s Dr Dobb’s. It requires using virtual inheritance to provide an abstraction to templated classes. My problem is that VS2k5, doesn’t like virtual inheritance from empty classes, or classes with no virtual functions. Is this proper behavior for the compiler? edit: The error I get is: error C2683: 'dynamic_cast' : 'A' is not a polymorphic type class A {}; class B : public virtual A { public: void output() { std::cout << "test" << std::endl; } }; int main() { A* a = new B; B* b = dynamic_cast< B* > (a); b->output(); system( "pause" ); return 0; }
  9. Providing a visual queue to a person's skill ( not level because I have always despised the whole idea of levels) has always been an idea that I've favored. Warriors who start out unskilled and a very small build, who eventually, through extensive training, builds his body mass up and you can visually see larger muscles and such. Magic users power can be displayed as aura's of power around the avatar, this aura could even display this wizard's alignment or school based on certain colors IMO the idea of levels is an outdated one. All levels do is segregate the community of an MMO and provides the means to inhibit the fun a player can have with others, be it friends or strangers. An MMO should give equal power to a newbie and a vet, but the difference between them is how that power is used. A newbie would be given very few options and very little flexibility in the usage of his power, while a vet would have many options at his disposal and be extremely flexible in combat. This type of system would also allow players to get out of the “grind” and do things that are actually fun instead of always trying to reach for the highest level.
  10. Functions! Functions! Functions!

    Sounds like you may want to run the program in a debugger so you can see where the error happens instead of having the program terminate on you.
  11. try catch and throw

    Quote:Original post by smart_idiot Maybe also some custom exception object that could look at the stack and try to figure out where it was created, but that would be difficult. There is a nice article on www.cuj.com where they talk about "ELF" Exception Logging Framework. Pretty much he uses macros to insert __LINE__, __FILE__ and such into the exception when its created. Then uses macros to wrap functions to provide a stacktracing of the exception. It was pretty interesting
  12. C++ defines vs typedefs

    The biggest thing between #define and typedef is how they behave in relation to scope. All pre-proc macros (including #define) ignore scope while typedefs will obey it. class SomeClassA { typedef unsigned int SomeID; } class SomeClassB { typedef unsigned short SomeID; }; No problems there but take to make that work with #defines, you would have to make the two names unique somehow which can distract from the flow in some places. The biggest that I find myself using typedefs for is inside classes. Mostly to make things easier to read. For example class A { typedef std::map< unsigned int, std::string > HashMap; public: const std::string& GetString( unsigned int id ) { HashMap::iterator itr = m_hashMap.find( id ); if( itr == m_hashMap.end() ) //this is bad no string found return itr.second } HashMap m_hashMap; } Doing this with macros would cause problems if you had different types of maps in different classes that did different things. Edit: too late for me to be typin heh [Edited by - Sutekh on April 3, 2006 1:30:04 AM]
  13. Passing Objects by Reference.

    Using smart pointers makes things a big easier, and you have to worry about less stuff when using them. You can pass smart pointers like normal(non-pointer) objects, smart pointers also clean up after themselves by deleting what was created when they lose scope. For pointers which get passed around, used shared_ptr like so: #include <boost/shared_ptr.hpp> boost::shared_ptr< Path> mainPath( new Path); mainPath->SetPath(); To make it a bit easier to read you an use a typedef. typedef boost::shared_ptr< Path > PathPtr; PathPtr mainPath( new Path ); mainPath->Setpath(); Then your print function def would look like: void SetPath( PathPtr paraPath ); The shared pointer will track how many references of itself are out there, and when they are all released it will delete object from memory. Since you are storing pointers to objects created somewhere else, you may run across a problem if you delete an object in one place and try to access it later another. Smart pointers help prevent this problem by taking care of the deletion itself keeping you from having to worry about it. You can pick boost up at http://www.boost.org
  14. Adding methods to STL?

    Well they both beat me to it ;) Stringstream :D
  15. Quote:Original post by Tradone cool, this type of obfuscating grammar reminds me of back in grade school. radius -> radii not radiuses well, thanks. it compiled and i'm free again. edit: no it did not compile. *** Source Snippet Removed *** Print.cpp:5: error: `class Print::CSS' is not a class or namespace Print.cpp:8: error: `class Print::CSS' is not a class or namespace The CSS class needs to be in either a class called Print or a namespace called Print. Quote: hey i have another question... is it quicker to make a declare a new variable on each and every method or reuse variables declared in the header? I am not an expert but I am willing to bet you wouldn't notice a difference, besides if you stored all the variables that your methods would use inside the class itself, you would end up bloating your class. Not to mention that you would have to re-initialize the variables each time your methods used them.