SCI: Objectified Song struct 'a bit'

svn-id: r41344
This commit is contained in:
Max Horn 2009-06-07 17:07:07 +00:00
parent d07e9dfb13
commit 62f596821e
3 changed files with 52 additions and 36 deletions

View File

@ -824,7 +824,7 @@ void SfxState::sfx_add_song(SongIterator *it, int priority, SongHandle handle, i
}
song = song_new(handle, it, priority);
song = new Song(handle, it, priority);
song->_resourceNum = number;
song->_hold = 0;
song->_loops = 0;

View File

@ -31,27 +31,42 @@ namespace Sci {
#define debug_stream stderr
Song *song_new(SongHandle handle, SongIterator *it, int priority) {
Song *retval;
retval = (Song *)malloc(sizeof(Song));
Song::Song() {
_handle = 0;
_priority = 0;
_status = SOUND_STATUS_STOPPED;
#ifdef SATISFY_PURIFY
memset(retval, 0, sizeof(Song));
#endif
_restoreBehavior = RESTORE_BEHAVIOR_CONTINUE;
_restoreTime = 0;
retval->_handle = handle;
retval->_priority = priority;
retval->_next = NULL;
retval->_delay = 0;
retval->_wakeupTime = Audio::Timestamp();
retval->_it = it;
retval->_status = SOUND_STATUS_STOPPED;
retval->_nextPlaying = NULL;
retval->_nextStopping = NULL;
retval->_restoreBehavior = RESTORE_BEHAVIOR_CONTINUE;
retval->_restoreTime = 0;
_loops = 0;
_hold = 0;
return retval;
_it = 0;
_delay = 0;
_next = NULL;
_nextPlaying = NULL;
_nextStopping = NULL;
}
Song::Song(SongHandle handle, SongIterator *it, int priority) {
_handle = handle;
_priority = priority;
_status = SOUND_STATUS_STOPPED;
_restoreBehavior = RESTORE_BEHAVIOR_CONTINUE;
_restoreTime = 0;
_loops = 0;
_hold = 0;
_it = it;
_delay = 0;
_next = NULL;
_nextPlaying = NULL;
_nextStopping = NULL;
}
void SongLibrary::addSong(Song *song) {
@ -90,7 +105,7 @@ void SongLibrary::freeSounds() {
delete song->_it;
song->_it = NULL;
next = song->_next;
free(song);
delete song;
}
*_lib = NULL;
}
@ -154,7 +169,7 @@ int SongLibrary::removeSong(SongHandle handle) {
retval = goner->_status;
delete goner->_it;
free(goner);
delete goner;
return retval;
}

View File

@ -50,7 +50,8 @@ enum RESTORE_BEHAVIOR {
RESTORE_BEHAVIOR_RESTART /* continue it from where it was */
};
struct Song {
class Song {
public:
SongHandle _handle;
int _resourceNum; /**<! Resource number */
int _priority; /**!< Song priority (more important if priority is higher) */
@ -80,26 +81,26 @@ struct Song {
* _update_multi_song()
*/
Song *_nextStopping;
public:
Song();
/**
* Initializes a new song.
* @param handle the sound handle
* @param it the song
* @param priority the song's priority
* @return a freshly allocated song
*/
Song(SongHandle handle, SongIterator *it, int priority);
};
/**************************/
/* Song library commands: */
/**************************/
/* Initializes a new song
** Parameters: (SongHandle) handle: The sound handle
** (SongIterator *) it: The song
** (int) priority: The song's priority
** Returns : (Song *) A freshly allocated song
** Other values are set to predefined defaults.
*/
Song *song_new(SongHandle handle, SongIterator *it, int priority);
class SongLibrary {
public:
Song **_lib;
protected:
Song *_s;
public: