Game Development Reference
In-Depth Information
enum CMD_TYPE
{
CMD_SND_PLAY ,
CMD_SND_STOP ,
// More CMD enums would be added here.
CMD_MAX
};
struct SoundCommandEntry
{
unsigned int m_command; // CMD_TYPE
float m_game_time; // When was command executed.
unsigned int m_size;
// Size of m_data used by command
void *
m_data;
// Data used by this command.
};
Listing 11.8. Sample class for a sound log entry.
was running when the command was issued. Listing 11.8 shows a sample class to
store the command for the log file. It is worth noting that m_data is a pointer to
an unspecified object and m_size is the size of that object to serialize to the file.
Thetypeofobjectpointedtoby m_data is determined by checking the value of
m_command .
Listing 11.9 shows a simple pseudocode sample resembling how we'd log a play
sound event command.
// Structure we need to fill in when logging a sound being
// played. We will need to change the size of m_instance_id if
// pointers on the target platform are bigger than the size of
//
an unsigned int.
struct LogDataForPlayingASound
{
char m_event_name[ MAX_LENGTH_OF_EVENT_NAMES ];
Parms m_params;
unsigned int
m_owner_id;
unsigned int
m_instance_id;
};
// Function to log the sound being played.
void SoundLog::logPlaySoundEvent( SoundEvent * event,
Params & params,
unsigned int owner_id,
SoundInstance * inst )
{
writeData( CMD_SND_PLAY , sizeof(int) );
writeData( Game::getTime(), sizeof(float) );
int data_size = sizeof(LogDataForPlayingASound);
writeData( data_size, sizeof(int) );
Search WWH ::




Custom Search