Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

Table of Contents
[Tutorial 6 - RWS files and Tables of Contents]

The first chunk in an RWS file has an ID of rwID_TOC indicating that it is a Table of Contents. This contains a list of TOC entries that describe the remaining chunks; what they are and where they are in the RWS file.

In order to extract information from the TOC, you must first read it. This is done in the same way as for all RenderWare Graphics' stream chunks, and using the RtTOCStreamRead function.

In the utils.c file, add the function RwsLoadTOC.

    RtTOC *
    RwsLoadTOC( RwChar *filename )
    {
        RwChar      *pathName;
        RwStream    *stream;
        RtTOC       *rwsTOC;
        pathName = RsPathnameCreate( filename );
        if ( NULL == pathName )
        {
            return (void *)NULL;
        }
        rwsTOC = (RtTOC *)NULL;
        /* try to read the stream */
        stream = RwStreamOpen( rwSTREAMFILENAME,
                               rwSTREAMREAD,
                               pathName );
        if ( NULL != stream )
        {
            /* find and read the TOC */
            if ( FALSE != RwStreamFindChunk( stream,
                                             rwID_TOC,
                                             NULL,
                                             NULL ) )
            {
                rwsTOC = RtTOCStreamRead( stream );
            }
            RwStreamClose( stream, NULL );
        }
        RsPathnameDestroy( pathName );
        return rwsTOC;
    }
and an appropriate prototype in utils.h.

The interface to the TOC is very simple: get the number of entries, and get individual entries. The number of entries in the TOC can be found with RtTOCGetNumEntries. An individual entry, identified by it's zero-based index, can be obtained with RtTOCGetEntry. This returns a pointer to an RtTOCEntry object.

Next...


Criterion Software © 1993-2004 Criterion Software Limited. All rights reserved. Built Thu Feb 12 13:47:00 2004. Send Feedback