diff options
author | Max Horn | 2009-06-07 17:07:07 +0000 |
---|---|---|
committer | Max Horn | 2009-06-07 17:07:07 +0000 |
commit | 62f596821e7c1e8c696cb3e4190822b33aa1a98c (patch) | |
tree | ca0c8f63986b3bee8de8b9ba751f6d5f318f458c /engines | |
parent | d07e9dfb1306f24fedcf521d3eb27144ad686bb4 (diff) | |
download | scummvm-rg350-62f596821e7c1e8c696cb3e4190822b33aa1a98c.tar.gz scummvm-rg350-62f596821e7c1e8c696cb3e4190822b33aa1a98c.tar.bz2 scummvm-rg350-62f596821e7c1e8c696cb3e4190822b33aa1a98c.zip |
SCI: Objectified Song struct 'a bit'
svn-id: r41344
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/sfx/core.cpp | 2 | ||||
-rw-r--r-- | engines/sci/sfx/songlib.cpp | 59 | ||||
-rw-r--r-- | engines/sci/sfx/songlib.h | 27 |
3 files changed, 52 insertions, 36 deletions
diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index 57561672d3..572da29c0d 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -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; diff --git a/engines/sci/sfx/songlib.cpp b/engines/sci/sfx/songlib.cpp index 8fafe4a7f3..2572dc01f5 100644 --- a/engines/sci/sfx/songlib.cpp +++ b/engines/sci/sfx/songlib.cpp @@ -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)); - -#ifdef SATISFY_PURIFY - memset(retval, 0, sizeof(Song)); -#endif - - 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; +Song::Song() { + _handle = 0; + _priority = 0; + _status = SOUND_STATUS_STOPPED; - return retval; + _restoreBehavior = RESTORE_BEHAVIOR_CONTINUE; + _restoreTime = 0; + + _loops = 0; + _hold = 0; + + _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; } diff --git a/engines/sci/sfx/songlib.h b/engines/sci/sfx/songlib.h index f9caedeefb..55c3ddf4fd 100644 --- a/engines/sci/sfx/songlib.h +++ b/engines/sci/sfx/songlib.h @@ -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 library commands: */ -/**************************/ + Song(); -/* 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); + /** + * 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); +}; class SongLibrary { public: Song **_lib; +protected: Song *_s; public: |