[Scummvm-cvs-logs] CVS: scummvm engine.cpp,1.3,1.4 engine.h,1.3,1.4 insane.cpp,1.58,1.59 saveload.cpp,1.59,1.60 scumm.h,1.206,1.207 scummvm.cpp,1.207,1.208 sound.cpp,1.127,1.128

Max Horn fingolfin at users.sourceforge.net
Sun Aug 18 15:48:02 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv30668

Modified Files:
	engine.cpp engine.h insane.cpp saveload.cpp scumm.h 
	scummvm.cpp sound.cpp 
Log Message:
more code unification; as a side effect, simon can take advantage of the save path settings in the config file (inspired by patch #587694)

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/engine.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- engine.cpp	18 Aug 2002 21:42:52 -0000	1.3
+++ engine.cpp	18 Aug 2002 22:47:10 -0000	1.4
@@ -20,10 +20,11 @@
 
 #include "stdafx.h"
 #include "engine.h"
-#include "sound/mixer.h"
 #include "gameDetector.h"
+#include "config-file.h"
 #include "scumm.h"
 #include "simon/simon.h"
+#include "sound/mixer.h"
 
 /* FIXME - BIG HACK for MidiEmu */
 OSystem *g_system = 0;
@@ -34,6 +35,8 @@
 {
 	_mixer = new SoundMixer();
 
+	_gameDataPath = detector->_gameDataPath;
+
 	/* FIXME - BIG HACK for MidiEmu */
 	g_system = _system;
 	g_mixer = _mixer;
@@ -42,6 +45,34 @@
 Engine::~Engine()
 {
 	delete _mixer;
+}
+
+const char *Engine::getSavePath() const
+{
+	const char *dir = NULL;
+
+#ifdef _WIN32_WCE
+	dir = _gameDataPath;
+#else
+
+#if !defined(MACOS_CARBON)
+	dir = getenv("SCUMMVM_SAVEPATH");
+#endif
+
+	// If SCUMMVM_SAVEPATH was not specified, try to use game specific savepath from config
+	if (!dir || dir[0] == 0)
+		dir = scummcfg->get("savepath");
+
+	// If SCUMMVM_SAVEPATH was not specified, try to use general path from config
+	if (!dir || dir[0] == 0)
+		dir = scummcfg->get("savepath", "scummvm");
+
+	// If no save path was specified, use no directory prefix
+	if (dir == NULL)
+		dir = "";
+#endif
+
+	return dir;
 }
 
 Engine *Engine::createFromDetector(GameDetector *detector, OSystem *syst)

Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/engine.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- engine.h	18 Aug 2002 18:39:41 -0000	1.3
+++ engine.h	18 Aug 2002 22:47:10 -0000	1.4
@@ -34,14 +34,22 @@
 class Engine {
 public:
 	OSystem *_system;
-
 	SoundMixer *_mixer;
 
+protected:
+	char *_gameDataPath;
+
+public:
 	Engine(GameDetector *detector, OSystem *syst);
 	virtual ~Engine();
 
 	// Invoke the main engine loop using this method
 	virtual void go() = 0;
+	
+	// Get the save game dir path
+	const char *getSavePath() const;
+
+	const char *getGameDataPath() const { return _gameDataPath; }
 
 	// Create a new engine object based on the detector - either 
 	// a Scumm or a SimonState object currently.

Index: insane.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/insane.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- insane.cpp	18 Aug 2002 21:51:15 -0000	1.58
+++ insane.cpp	18 Aug 2002 22:47:10 -0000	1.59
@@ -50,11 +50,11 @@
 	FILE * f_tres;
 	uint32 tmp, l;
 
-	sprintf((char *)buf, "%sVIDEO/DIGTXT.TRS", (byte *)_scumm->_gameDataPath);
+	sprintf((char *)buf, "%sVIDEO/DIGTXT.TRS", (byte *)_scumm->getGameDataPath());
 	f_tres = (FILE*)_scumm->fileOpen((char *)&buf, 1);
 	
 	if (f_tres == NULL) {
-		sprintf((char *)buf, "%svideo/digtxt.trs", (byte *)_scumm->_gameDataPath);
+		sprintf((char *)buf, "%svideo/digtxt.trs", (byte *)_scumm->getGameDataPath());
 		f_tres = (FILE*)_scumm->fileOpen((char *)&buf, 1);
 		if (f_tres == NULL)
 			return NULL;
@@ -101,11 +101,11 @@
 	for (l = 0; l < SP_MAX_FONTS; l++)
 	{
 		_fonts [l] = NULL;
-		sprintf((char *)buf, "%sVIDEO/FONT%d.NUT", (char *)_scumm->_gameDataPath, l);
+		sprintf((char *)buf, "%sVIDEO/FONT%d.NUT", (char *)_scumm->getGameDataPath(), l);
 		f_tres = (FILE*)_scumm->fileOpen((char *)buf, 1);
 
 		if (f_tres == NULL) {
-			sprintf((char *)buf, "%svideo/font%d.nut", (char *)_scumm->_gameDataPath, l);
+			sprintf((char *)buf, "%svideo/font%d.nut", (char *)_scumm->getGameDataPath(), l);
 			f_tres = (FILE*)_scumm->fileOpen((char *)buf, 1);
 			if (f_tres == NULL) 
 				continue;
@@ -425,11 +425,11 @@
 void SmushPlayer::openFile(byte *fileName) {
 	byte buf[100];
 
-	sprintf((char *)buf, "%sVIDEO/%s", (char *)_scumm->_gameDataPath, (char *)fileName);
+	sprintf((char *)buf, "%sVIDEO/%s", (char *)_scumm->getGameDataPath(), (char *)fileName);
 	_in = (FILE*)_scumm->fileOpen((char *)buf, 1);
 
 	if (_in == NULL) {
-		sprintf((char *)buf, "%svideo/%s", (char *)_scumm->_gameDataPath, (char *)fileName);
+		sprintf((char *)buf, "%svideo/%s", (char *)_scumm->getGameDataPath(), (char *)fileName);
 		_in = (FILE*)_scumm->fileOpen((char *)buf, 1);
 	}
 }

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- saveload.cpp	14 Aug 2002 20:43:55 -0000	1.59
+++ saveload.cpp	18 Aug 2002 22:47:10 -0000	1.60
@@ -166,29 +166,7 @@
 
 void Scumm::makeSavegameName(char *out, int slot, bool compatible)
 {
-
-	const char *dir = NULL;
-
-#ifdef _WIN32_WCE
-	dir = _gameDataPath;
-#else
-
-#if !defined(MACOS_CARBON)
-	dir = getenv("SCUMMVM_SAVEPATH");
-#endif
-
-	// If SCUMMVM_SAVEPATH was not specified, try to use game specific savepath from config
-	if (!dir || dir[0] == 0)
-		dir = scummcfg->get("savepath");
-
-	// If SCUMMVM_SAVEPATH was not specified, try to use general path from config
-	if (!dir || dir[0] == 0)
-		dir = scummcfg->get("savepath", "scummvm");
-
-	// If no save path was specified, use no directory prefix
-	if (dir == NULL)
-		dir = "";
-#endif
+	const char *dir = getSavePath();
 
 	// snprintf should be used here, but it's not portable enough
 	sprintf(out, "%s%s.%c%.2d", dir, _exe_name, compatible ? 'c' : 's', slot);

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.206
retrieving revision 1.207
diff -u -d -r1.206 -r1.207
--- scumm.h	18 Aug 2002 18:39:41 -0000	1.206
+++ scumm.h	18 Aug 2002 22:47:10 -0000	1.207
@@ -412,7 +412,6 @@
 	/* Core variable definitions */
 	byte _gameId;
 	const char *_gameText;
-	char *_gameDataPath;
 
 	/* Core class/array definitions */
 	Gdi gdi;

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -d -r1.207 -r1.208
--- scummvm.cpp	18 Aug 2002 18:39:41 -0000	1.207
+++ scummvm.cpp	18 Aug 2002 22:47:10 -0000	1.208
@@ -77,7 +77,6 @@
 
 	_debugMode = detector->_debugMode;
 	_bootParam = detector->_bootParam;
-	_gameDataPath = detector->_gameDataPath;
 	_exe_name = detector->_exe_name;
 	_gameId = detector->_gameId;
 	_gameText = detector->_gameText;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -d -r1.127 -r1.128
--- sound.cpp	14 Aug 2002 20:43:56 -0000	1.127
+++ sound.cpp	18 Aug 2002 22:47:11 -0000	1.128
@@ -684,10 +684,10 @@
 #ifdef COMPRESSED_SOUND_FILE
 	offset_table = NULL;
 
-	sprintf(buf, "%s%s.so3", _scumm->_gameDataPath, _scumm->_exe_name);
+	sprintf(buf, "%s%s.so3", _scumm->getGameDataPath(), _scumm->_exe_name);
 	file = fopen(buf, "rb");
 	if (!file) {
-		sprintf(buf, "%smonster.so3", _scumm->_gameDataPath);
+		sprintf(buf, "%smonster.so3", _scumm->getGameDataPath());
 		file = fopen(buf, "rb");
 	}
 	if (file != NULL) {
@@ -725,10 +725,10 @@
 		return file;
 	}
 #endif
-	sprintf(buf, "%s%s.sou", _scumm->_gameDataPath, _scumm->_exe_name);
+	sprintf(buf, "%s%s.sou", _scumm->getGameDataPath(), _scumm->_exe_name);
 	file = fopen(buf, "rb");
 	if (!file) {
-		sprintf(buf, "%smonster.sou", _scumm->_gameDataPath);
+		sprintf(buf, "%smonster.sou", _scumm->getGameDataPath());
 		file = fopen(buf, "rb");
 	}
 	return file;
@@ -775,7 +775,7 @@
 	char buf[256];
 
 	if (_numberBundleMusic == -1) {
-		sprintf(buf, "%s%smusic.bun", _scumm->_gameDataPath, _scumm->_exe_name);
+		sprintf(buf, "%s%smusic.bun", _scumm->getGameDataPath(), _scumm->_exe_name);
 		if (_scumm->_bundle->openMusicFile((char*)&buf) == false)
 			return;
 		_musicBundleBufFinal = (byte*)malloc(OUTPUT_SIZE);
@@ -883,7 +883,8 @@
 		l = 0;
 
 	size = OUTPUT_SIZE;
-	ptr = _musicBundleBufFinal;
+	ptr = _musicBundleBufFinal;
+
 	byte * buffer = NULL;
 	uint32 final_size = decode12BitsSample(ptr, &buffer, size);
 	_scumm->_mixer->play_raw(NULL, buffer, final_size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO);
@@ -893,7 +894,7 @@
 	char buf[256];
 	byte * ptr;
 
-	sprintf(buf, "%s%svoice.bun", _scumm->_gameDataPath, _scumm->_exe_name);
+	sprintf(buf, "%s%svoice.bun", _scumm->getGameDataPath(), _scumm->_exe_name);
 	_scumm->_bundle->openVoiceFile((char*)&buf);
 	ptr = (byte *)malloc(1000000);
 	if (_scumm->_bundle->decompressVoiceSampleByName(sound, ptr) == 0) {
@@ -989,7 +990,7 @@
 	_current_cache %= CACHE_TRACKS;
 
 	// Not found, see if it exists
-	sprintf(track_name, "%strack%d.mp3", _scumm->_gameDataPath, track);
+	sprintf(track_name, "%strack%d.mp3", _scumm->getGameDataPath(), track);
 	file = fopen(track_name, "rb");
 	_cached_tracks[current_index] = track;
 





More information about the Scummvm-git-logs mailing list