Game Development Reference
In-Depth Information
the sound instance identified in the log file with a new SoundInstance returned
by the sound engine when running the game in replay mode. This is required, as
the memory address of the SoundInstances may have changed between multiple
runs of the game. Your implementation of SoundInstance, or your sound engine's
equivalent, may provide a neater method of performing this mapping, such as each
SoundInstance having a unique identifier.
When a sound command is executed, we check the address of the logged sound
instance against the m_assumed_identifier within the SoundReplay's list of
LoggedSoundInstances in order to find the mapping SoundInstance. We assume
an unsigned int is the same size as a pointer in this example.
The user should be able to stop the game at any time while the replay is
occurring and use other debugging tools, such as the snapshot tool, to examine
the soundscape. As well as being able to stop the game while it is running, the
user should be able to set a breakpoint within the log file on a particular com-
mand. This can be done by setting the top bit of the m_command variable of a
SoundCommandEntry object. We can set this bit since we should not require the
full bit range of the variable, because we will not have too many command types.
The overall number of commands this system will have to support varies depending
on your application. This top bit can be set either when writing out the command
log or by having the sound designer pause the game while it is logging to set break-
points. This requires a simple user interface element be presented to the designer.
When activated, it sets the top bit on the last sound command executed.
Listing 11.11 shows a very simple pseudocode sample of reading and executing
a sound command.
#define BREAKPOINT_BIT (0x80000000)
void SoundLog::replayNextCommand( void )
{
unsigned int size_of_data;
float game_time;
unsigned int command;
void * data;
// Copy the command structure out of our log file
// and into local variables.
copyDataAndMoveToNextVariable( &command, sizeof(int) );
copyDataAndMoveToNextVariable( &size_of_data ,sizeof(int) );
copyDataAndMoveToNextVariable( &game_time, sizeof(float));
// Now point out local data pointer to the data saved
// out by this command and move to the next command.
setCMDDataPtrAndPrepareNextCommand(data,*size_of_data);
if ( command &
BREAKPOINT_BIT )
{
launch_snapshot_tools();
}
// Clear the BREAKPOINT_BIT
Search WWH ::




Custom Search