Game Development Reference
In-Depth Information
// reading from the storage media at the same time.
void recordClash( FileEntry* entry, FileEntry * clash_entry )
{
entry->addEntryToClashList( clash_entry );
clash_entry ->addEntryToClashList( entry );
}
// Add a new entry to this FileEntry ￿ s clash list.
void FileEntry::addEntryToClashList( FileEntry * clash_entry )
{
Iterator<ReadClash*> it = this->m_clash_list.start();
while(;it != this->m_clash_list.end(); ++it)
{
if ( (*it)->m_clashed_file_entry == clash_entry )
{
// Increment the number of clashes found
// and return.
++(*it)->m_num_clashes;
return;
}
}
// No previous entry found so create a new one!
ReadClash new_clash = new ReadClash();
new_clash->m_clashed_file_entry = clash_entry;
new_clash->m_num_clashes = 1;
this->m_clash_list.push( new_clash );
}
Listing 11.13. Building up a table of read clashes.
Once the identifyFileReadClashes function from Listing 11.13 is run, we will
have generated the data within our linked list variable file_list containing an
entry for each file that was opened when the game was run. Each entry will store
the number of times the file was read from as well as a list of all other file entries
that were reading whenever this entry was being read.
The information stored in our generated linked list allows us to generate a report
for the sound designer. It is from this information that we can check the number
of times a file clash occurred compared to the number of times a file was read. If
there are files that have a frequent number of clashes, such as a sound pack for
city noises and a sound pack for street gang members, then we can combine those
two files into a single sound pack. This reduces the amount of seeking performed
on the storage media, as the files will be loaded in a single read. We can tell if
a file is a sound pack or a streamed sound by either checking the file extension,
cross-referencing the file with the sound system, or writing out the file type when
the file is opened. If there are files that are mostly accessed at the same time or are
streamed files, then we can mark these files out to be placed physically closer to
each other on the storage media when we build up the final disk image we intend
to create. Files that are repeatedly loaded into and out of memory can be potential
Search WWH ::




Custom Search