Thread: Resource Management question..

  1. #16
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Also, is it reasonable(Safe) to use a template class for the Manager?
    Safe = yes. Reasonable = depends on your design.
    If you need the complexity and robustness it offers then sure but if it just serves to obfuscate the code or derail you from the final goal then I'd say no. Besides if you design it correctly in the first place you can always add template support later on in the project.

    I actually have a templated version of what I described. Let me know how yours turns out and we can compare code. I've called it a SmartArray although it's not very smart if it cannot reduce the max index. Perhaps you can solve this problem.

  2. #17
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    I am going to work on it, and see. I am sure your code will be far better than mine. This thought is based strictly on observation.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I see Bubba has put a lot of effort and thought into this...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I see Bubba has put a lot of effort and thought into this...
    Yes I had to for my recent game. Since my system operated on ID's (indexes into containers) it really sucked when I removed one asteroid and then every asteroid that had an ID greater than the one I just removed disappeared. Then I knew I had to create a custom container. There is no simple solution or STL container you can use as-is to gain the functionality you need. You could use a map for this but performance would become an issue.

    Raigne if you would like the source code for the project I'd be more than happy to give it to you. It would clearly illustrate how the array setup works. There are also functions that will output debug info to the screen about how many indices are actually being used in the array and the size of the current index stack.
    Last edited by VirtualAce; 03-05-2008 at 06:35 PM.

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    So what else are you using? Blazingly fast dynamic arrays?
    I'm pretty sure the container could be made "smarter" to "downsize" the array too, but I'm guessing it's just not worth the time it would take to get such a system working, huh?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #21
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    That would be wonderful Bubba. Do I just PM you my email? Thank you so much.

  7. #22
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'm pretty sure the container could be made "smarter" to "downsize" the array too, but I'm guessing it's just not worth the time it would take to get such a system working, huh?
    It's worth the time because I will use it in my StarX project which is my main focus right now. I just haven't got around to it mainly due to work and my insistence on waiting till the weekend to do hobby coding. GTA Vice City and the COD's have had my attention for some time now.
    I've never beaten Vice City so I want to beat it.

    That would be wonderful Bubba. Do I just PM you my email? Thank you so much.
    Sure. I just loaded the game up to see if it still works and it does. I'll zip the project up minus the ncb and pdb's since they are so huge.

  8. #23
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    I sent you the address.
    Also, I was wondering are there any third party libraries that the project uses that i may not have?

  9. #24
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You will need the DirectX Aug. 2007 SDK as well as DirectX 9.0c installed on the system.

    I'm trying to clean up the folder structure a bit so I'll email it when I get it building with the new structure. Also I have not tested release mode yet nor configured it so it probably won't do a release build.

    You will need to change the library paths and include paths for the DirectX headers and libs to where you install the DirectX SDK. The dependencies should be set but if not I'll let you know which libs it needs to link with.

  10. #25
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Ok, Thank you very much for all the assistance.

  11. #26
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code has been sent. Let me know if you have any problems.

    As a test I increased the starting asteroid counts, spawn asteroid counts, fire rate of the ship, and speeds of everything.

    This is a ridiculous situation that is obviously far too hard to be any fun but the engine and underlying container handle it quite well.

    This uses the container I've described above.
    Last edited by VirtualAce; 03-12-2011 at 11:41 AM.

  12. #27
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    It looks good Bubba. I got it working for the most part I think. I get a lot of exceptions, but I am working them out. I looked and your smartArray class, and I am seeing if I can where I can change the size of it.

    [EDIT]: I got it working, but I am still getting a few errors in the debugger so, if I can get it working completely I will make a thread about it.

  13. #28
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    What specific errors are you getting?

  14. #29
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    I am pretty sure the remaining errors are due to bad variable data. I think when I remove an index from the array that it is doing the wrong thing to the m_Size variable.

    may have something to do with this piece..
    Code:
    ...
    --m_Size;
    delete m_Array[m_Size+1];
    ...
    m_Size += 50;
    m_Array = copyArray(new Array[m_Size]);
    ...
    the delete works, and the copy works, but after the copy phase I can only access the elements I copied, I get memory errors when I try to use the indexes after end of the previous array size. If that makes sense.
    Last edited by Raigne; 03-06-2008 at 06:42 PM.

  15. #30
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    **deleted**
    EDIT: there was a bad error with memory allocation... New one is below
    Last edited by Raigne; 03-06-2008 at 09:42 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WIN32 API Controls used with Resource
    By parad0x13 in forum C++ Programming
    Replies: 0
    Last Post: 07-19-2008, 02:05 PM
  2. Loading an image in from a resource file
    By starcatcher in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2008, 06:44 AM
  3. unmanaged resource
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2008, 04:23 AM
  4. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  5. Lame question on dialog controls appearance
    By Templario in forum Windows Programming
    Replies: 2
    Last Post: 03-18-2003, 08:22 PM