Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Bagpuss

Program Object Strucure and Optimisation

This topic is 5762 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am working on an Editor for my game, and have come across what I believe is a lot of redundancy / duplication of effort. At Present, On my editor loading, it loads in all the saved data into a number of vectors which are one of the following types. CGameItem CGameMonster CGameRoom CGameCharacter All 4 of these types inherit from a CGameBaseObj which contains common core data and accessor functions. My Main Window is a Splitter window, with the Left Pane being a CTreeView. At Present, the TreeView has 4 Categories under the Root, Items, Monsters, Rooms, and Characters. Now, on Creation of the Application, or each time it changes I iterate through each of the vectors in turn, retrieve the item name and add it to the appropriate section of the TreeView. - This Means 4 Loops that access each element in each vector once during each Draw / Refresh cycle of the TreeView. I have currently allowed 3 basic functions for each group and that is "Add New", "Delete" and "Modify". This gives me either; 12 nearly identical functions to code, 3 for each object type or 3 Larger functions to code, where I would have to decode which Branch of the tree an object lived in, to decide which object type it is. (so in effect I would have 4 lumps of code in each function, each doing a similar task.) As I would like to in the future maybe add further groups (or sub groups) to my tree, I see that I am starting to get into trouble here, as if I add a new command to my menu, I will need to add in a new function for each command for each object type, and if I add in a new group I need to add a whole suite of functions. Can anyone suggest a better way of approaching my problem ? I would guess that my solution lies in either using a different container, or ditching the STL containers completely and writing my own. Failing that, I guess I could have a vector for each type as at present, and create another vector for the tree, with each object containing the HTREEITEM, Text Description and a poointer to the class in question. But then I still need to decode which type the pointer is to know what item to create ! I hope that this makes sense, and that someone out there can give me advice as to how they would solve the problem. TIA, Bp.

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!