Thread: Mmk, I give up, lets try your way. (Resource Management)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    True. I don't like functions relying on a special value, but I wasn't sure how to go about it. It is a DWORD return type so -1 is 0xFFFFFFFF but returning -1 in a DWORD return type function didn't look quite right.

    Any ideas on how I can change this?

    Code:
    bool GetID(DWORD dwSeqID,DWORD dwFrameID,DWORD &dwOutID)
      {
        if (dwSeqID<AnimSeqs.size())
        {
          dwOutID=AnimSeqs[dwSeqID]->GetID(dwFrameID);
          return false;
        } else return true;
      }
    Ya like?

    GetID might seem redundant but there are reasons for it. The ID's assigned by the editor are stored on disk in the main file and the actual ID or index of the object in memory is also stored.

    The reason for this is that ID's must be assigned in the editor to represent the index in the vector/array, but these IDs cannot be placed into the map. This is because the engine would then have to load the bitmaps in the exact same order as the editor. This would require either a naming convention that used values in the filename or it would require a game def file that showed the order. I opted for something else.

    At load time, the engine knows how many bitmaps are in the data file. It creates an array and then proceeds to load. As it loads it uses the ResourceID as the index into the engine array. In this way, the final engine array should exactly match the editor array. However, the editor need not do this when it loads resource files. It can simply load and as long as it places the ResourceID into the map instead of the ID of the bitmap in the current editor vector, it will work. The IDs will match.

    Using these methods requires no look ups and I don't have to use any of the STL find() functions on my container in the editor.
    It took some time to come up with this system, but it seems to work ok.
    Last edited by VirtualAce; 01-11-2006 at 11:23 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. VC++ 6 Menu resource question
    By Mecnels in forum Windows Programming
    Replies: 1
    Last Post: 04-22-2003, 12:04 PM
  2. JPEG Resource
    By dragunsflame in forum Windows Programming
    Replies: 2
    Last Post: 04-08-2003, 10:07 PM
  3. resource problem/question
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 01-29-2003, 02:08 PM
  4. menu resource file
    By satriani in forum Windows Programming
    Replies: 5
    Last Post: 06-08-2002, 10:52 PM
  5. Radiohead rule
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-18-2002, 07:37 PM