[Scummvm-cvs-logs] SF.net SVN: scummvm:[41345] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Jun 7 19:07:25 CEST 2009


Revision: 41345
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41345&view=rev
Author:   fingolfin
Date:     2009-06-07 17:07:25 +0000 (Sun, 07 Jun 2009)

Log Message:
-----------
SCI: Simplified SongLibrary code a bit

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/sfx/core.cpp
    scummvm/trunk/engines/sci/sfx/songlib.cpp
    scummvm/trunk/engines/sci/sfx/songlib.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-06-07 17:07:07 UTC (rev 41344)
+++ scummvm/trunk/engines/sci/console.cpp	2009-06-07 17:07:25 UTC (rev 41345)
@@ -1530,7 +1530,7 @@
 bool Console::cmdSongLib(int argc, const char **argv) {
 	DebugPrintf("Song library:\n");
 
-	Song *seeker = *(g_EngineState->_sound._songlib._lib);
+	Song *seeker = g_EngineState->_sound._songlib._lib;
 
 	do {
 		DebugPrintf("    %p", (void *)seeker);

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-06-07 17:07:07 UTC (rev 41344)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-06-07 17:07:25 UTC (rev 41345)
@@ -408,14 +408,14 @@
 	s.syncAsUint32LE(songcount);
 
 	if (s.isLoading()) {
-		obj.initSounds();
+		obj._lib = 0;
 		while (songcount--) {
 			Song *newsong = (Song *)calloc(1, sizeof(Song));
 			sync_song_t(s, *newsong);
 			obj.addSong(newsong);
 		}
 	} else {
-		Song *seeker = *(obj._lib);
+		Song *seeker = obj._lib;
 		while (seeker) {
 			seeker->_restoreTime = seeker->_it->getTimepos();
 			sync_song_t(s, *seeker);
@@ -695,12 +695,7 @@
 	Song *seeker;
 	SongIteratorType it_type = s->resmgr->_sciVersion >= SCI_VERSION_01 ? SCI_SONG_ITERATOR_TYPE_SCI1 : SCI_SONG_ITERATOR_TYPE_SCI0;
 
-	if (s->_sound._songlib._lib)
-		seeker = *(s->_sound._songlib._lib);
-	else {
-		s->_sound._songlib.initSounds();
-		seeker = NULL;
-	}
+	seeker = s->_sound._songlib._lib;
 
 	while (seeker) {
 		SongIterator *base, *ff;

Modified: scummvm/trunk/engines/sci/sfx/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.cpp	2009-06-07 17:07:07 UTC (rev 41344)
+++ scummvm/trunk/engines/sci/sfx/core.cpp	2009-06-07 17:07:25 UTC (rev 41345)
@@ -638,7 +638,7 @@
 #define DELAY (1000000 / SFX_TICKS_PER_SEC)
 
 void SfxState::sfx_init(ResourceManager *resmgr, int flags) {
-	_songlib.initSounds();
+	_songlib._lib = 0;
 	_song = NULL;
 	_flags = flags;
 	_soundSync = NULL;

Modified: scummvm/trunk/engines/sci/sfx/songlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/songlib.cpp	2009-06-07 17:07:07 UTC (rev 41344)
+++ scummvm/trunk/engines/sci/sfx/songlib.cpp	2009-06-07 17:07:25 UTC (rev 41345)
@@ -78,14 +78,7 @@
 		return;
 	}
 
-	if (*_lib == NULL) {
-		*_lib = song;
-		song->_next = NULL;
-
-		return;
-	}
-
-	seeker = _lib;
+	seeker = &_lib;
 	while (*seeker && ((*seeker)->_priority > pri))
 		seeker = &((*seeker)->_next);
 
@@ -93,13 +86,8 @@
 	*seeker = song;
 }
 
-void SongLibrary::initSounds() {
-	_lib = &_s;
-	_s = NULL;
-}
-
 void SongLibrary::freeSounds() {
-	Song *next = *_lib;
+	Song *next = _lib;
 	while (next) {
 		Song *song = next;
 		delete song->_it;
@@ -107,12 +95,12 @@
 		next = song->_next;
 		delete song;
 	}
-	*_lib = NULL;
+	_lib = NULL;
 }
 
 
 Song *SongLibrary::findSong(SongHandle handle) {
-	Song *seeker = *_lib;
+	Song *seeker = _lib;
 
 	while (seeker) {
 		if (seeker->_handle == handle)
@@ -124,7 +112,7 @@
 }
 
 Song *SongLibrary::findNextActive(Song *other) {
-	Song *seeker = other ? other->_next : *_lib;
+	Song *seeker = other ? other->_next : _lib;
 
 	while (seeker) {
 		if ((seeker->_status == SOUND_STATUS_WAITING) ||
@@ -146,13 +134,13 @@
 
 int SongLibrary::removeSong(SongHandle handle) {
 	int retval;
-	Song *goner = *_lib;
+	Song *goner = _lib;
 
 	if (!goner)
 		return -1;
 
 	if (goner->_handle == handle)
-		*_lib = goner->_next;
+		_lib = goner->_next;
 
 	else {
 		while ((goner->_next) && (goner->_next->_handle != handle))
@@ -175,10 +163,10 @@
 }
 
 void SongLibrary::resortSong(Song *song) {
-	if (*_lib == song)
-		*_lib = song->_next;
+	if (_lib == song)
+		_lib = song->_next;
 	else {
-		Song *seeker = *_lib;
+		Song *seeker = _lib;
 
 		while (seeker->_next && (seeker->_next != song))
 			seeker = seeker->_next;
@@ -191,7 +179,7 @@
 }
 
 int SongLibrary::countSongs() {
-	Song *seeker = *_lib;
+	Song *seeker = _lib;
 	int retval = 0;
 
 	while (seeker) {

Modified: scummvm/trunk/engines/sci/sfx/songlib.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/songlib.h	2009-06-07 17:07:07 UTC (rev 41344)
+++ scummvm/trunk/engines/sci/sfx/songlib.h	2009-06-07 17:07:25 UTC (rev 41345)
@@ -99,16 +99,11 @@
 
 class SongLibrary {
 public:
-	Song **_lib;
-protected:
-	Song *_s;
+	Song *_lib;
 
 public:
-	SongLibrary() {}
+	SongLibrary() : _lib(0) {}
 
-	/** Initializes a static song library */
-	void initSounds();
-
 	/** Frees a song library. */
 	void freeSounds();
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list