[Scummvm-cvs-logs] scummvm master -> d19af62e6b5a00cd837502d4efede85e80588ff7

Strangerke Strangerke at scummvm.org
Thu Jan 9 08:33:11 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d19af62e6b MORTEVIELLE: Get rid of setParent() in TextHandler and SoundManager


Commit: d19af62e6b5a00cd837502d4efede85e80588ff7
    https://github.com/scummvm/scummvm/commit/d19af62e6b5a00cd837502d4efede85e80588ff7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-01-08T23:32:21-08:00

Commit Message:
MORTEVIELLE: Get rid of setParent() in TextHandler and SoundManager

Changed paths:
    engines/mortevielle/actions.cpp
    engines/mortevielle/dialogs.cpp
    engines/mortevielle/mortevielle.cpp
    engines/mortevielle/mortevielle.h
    engines/mortevielle/outtext.cpp
    engines/mortevielle/outtext.h
    engines/mortevielle/sound.cpp
    engines/mortevielle/sound.h
    engines/mortevielle/utils.cpp



diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp
index 0c45f8d..22c1f53 100644
--- a/engines/mortevielle/actions.cpp
+++ b/engines/mortevielle/actions.cpp
@@ -663,11 +663,11 @@ void MortevielleEngine::fctOpen() {
 				  || (_coreVar._currPlace == PURPLE_ROOM)
 				  || (_coreVar._currPlace == BLUE_ROOM)) {
 					if (getRandomNumber(1, 4) == 3)
-						_soundManager.startSpeech(7, 9, 1);
+						_soundManager->startSpeech(7, 9, 1);
 				}
 				_openObjects[i] = _num;
 				displayAnimFrame(1, _num);
-				_soundManager.waitSpeech();
+				_soundManager->waitSpeech();
 			}
 			int tmpPlace = _coreVar._currPlace;
 			if (_coreVar._currPlace == CRYPT)
@@ -731,7 +731,7 @@ void MortevielleEngine::fctPlace() {
 					displayAnimFrame(1, 1);
 					handleDescriptionText(2, 165);
 					displayEmptyHand();
-					_soundManager.startSpeech(6, -9, 1);
+					_soundManager->startSpeech(6, -9, 1);
 
 					// Do you want to enter the hidden passage?
 					int answer = _dialogManager.show(getEngineString(S_YES_NO));
@@ -832,7 +832,7 @@ void MortevielleEngine::fctTurn() {
 		_crep = 997;
 		if ((_coreVar._currPlace == ATTIC) && (_coreVar._atticRodHoleObjectId == 159) && (_coreVar._atticBallHoleObjectId == 141)) {
 			handleDescriptionText(2, 167);
-			_soundManager.startSpeech(7, 9, 1);
+			_soundManager->startSpeech(7, 9, 1);
 			int answer = _dialogManager.show(getEngineString(S_YES_NO));
 			if (answer == 1)
 				_endGame = true;
@@ -842,7 +842,7 @@ void MortevielleEngine::fctTurn() {
 		if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId == 143)) {
 			handleDescriptionText(2, 175);
 			clearVerbBar();
-			_soundManager.startSpeech(6, -9, 1);
+			_soundManager->startSpeech(6, -9, 1);
 			int answer = _dialogManager.show(getEngineString(S_YES_NO));
 			if (answer == 1) {
 				_coreVar._currPlace = CRYPT;
@@ -967,7 +967,7 @@ void MortevielleEngine::fctKnock() {
 
 	if (_coreVar._currPlace == ROOM26) {
 		int rand = (getRandomNumber(0, 8)) - 4;
-		_soundManager.startSpeech(11, rand, 1);
+		_soundManager->startSpeech(11, rand, 1);
 		int pres = getPresenceStats(rand, _coreVar._faithScore, _roomDoorId);
 		if (_roomDoorId != OWN_ROOM) {
 			if (pres != -500) {
@@ -1185,9 +1185,9 @@ void MortevielleEngine::fctEnter() {
 				_crep = 179;
 			else {
 				int randVal = (getRandomNumber(0, 10)) - 5;
-				_soundManager.startSpeech(7, randVal, 1);
+				_soundManager->startSpeech(7, randVal, 1);
 				displayAnimFrame(1, 1);
-				_soundManager.waitSpeech();
+				_soundManager->waitSpeech();
 
 				int charIndex = convertBitIndexToCharacterIndex(pres);
 				++_coreVar._faithScore;
@@ -1207,9 +1207,9 @@ void MortevielleEngine::fctEnter() {
 			}
 		} else {
 			int randVal = (getRandomNumber(0, 10)) - 5;
-			_soundManager.startSpeech(7, randVal, 1);
+			_soundManager->startSpeech(7, randVal, 1);
 			displayAnimFrame(1, 1);
-			_soundManager.waitSpeech();
+			_soundManager->waitSpeech();
 
 			_coreVar._currPlace = _roomDoorId;
 			prepareDisplayText();
@@ -1627,7 +1627,7 @@ void MortevielleEngine::endGame() {
 	testKey(false);
 	_mouse->hideMouse();
 	_caff = 70;
-	_text.taffich();
+	_text->taffich();
 	clearScreen();
 	drawDiscussionBox();
 	startDialog(141);
diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp
index 9e197ab..2aa2757 100644
--- a/engines/mortevielle/dialogs.cpp
+++ b/engines/mortevielle/dialogs.cpp
@@ -298,7 +298,7 @@ bool DialogManager::showKnowledgeCheck() {
 		int dialogHeight = 23;
 		_vm->_screenSurface.fillRect(15, Common::Rect(0, 14, 630, dialogHeight));
 		Common::String tmpStr = _vm->getString(textIndexArr[indx]);
-		_vm->_text.displayStr(tmpStr, 20, 15, 100, 2, 0);
+		_vm->_text->displayStr(tmpStr, 20, 15, 100, 2, 0);
 
 		int firstOption;
 		int lastOption;
@@ -318,7 +318,7 @@ bool DialogManager::showKnowledgeCheck() {
 			tmpStr = _vm->getString(j);
 			if ((int) tmpStr.size() > maxLength)
 				maxLength = tmpStr.size();
-			_vm->_text.displayStr(tmpStr, 100, optionPosY, 100, 1, 0);
+			_vm->_text->displayStr(tmpStr, 100, optionPosY, 100, 1, 0);
 			choiceArray[prevChoice] = tmpStr;
 			optionPosY += 8;
 		}
@@ -352,16 +352,16 @@ bool DialogManager::showKnowledgeCheck() {
 			if (coor[currChoice]._enabled) {
 				if ((prevChoice != 0) && (prevChoice != currChoice)) {
 					tmpStr = choiceArray[prevChoice] + '$';
-					_vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
+					_vm->_text->displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
 				}
 				if (prevChoice != currChoice) {
 					tmpStr = choiceArray[currChoice] + '$';
-					_vm->_text.displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1);
+					_vm->_text->displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1);
 					prevChoice = currChoice;
 				}
 			} else if (prevChoice != 0) {
 				tmpStr = choiceArray[prevChoice] + '$';
-				_vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
+				_vm->_text->displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
 				prevChoice = 0;
 			}
 		} while (!((prevChoice != 0) && _vm->getMouseClick()));
@@ -412,7 +412,7 @@ void DialogManager::drawF3F8() {
 void DialogManager::checkForF8(int SpeechNum, bool drawFrame2Fl) {
 	_vm->testKeyboard();
 	do {
-		_vm->_soundManager.startSpeech(SpeechNum, 0, 0);
+		_vm->_soundManager->startSpeech(SpeechNum, 0, 0);
 		_vm->_key = waitForF3F8();
 		if (_vm->shouldQuit())
 			return;
@@ -442,7 +442,7 @@ int DialogManager::waitForF3F8() {
 void DialogManager::displayIntroScreen(bool drawFrame2Fl) {
 	_vm->_caff = 50;
 	_vm->_maff = 0;
-	_vm->_text.taffich();
+	_vm->_text->taffich();
 	_vm->draw(63, 12);
 	if (drawFrame2Fl)
 		displayIntroFrame2();
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index 01750b0..01e0492 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -47,15 +47,14 @@ namespace Mortevielle {
 MortevielleEngine *g_vm;
 
 MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescription *gameDesc):
-		Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle"),
-		_soundManager(_mixer) {
+		Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle") {
 	g_vm = this;
 	_debugger.setParent(this);
 	_dialogManager.setParent(this);
 	_screenSurface.setParent(this);
 	_mouse = new MouseHandler(this);
-	_text.setParent(this);
-	_soundManager.setParent(this);
+	_text = new TextHandler(this);
+	_soundManager = new SoundManager(this, _mixer);
 	_savegameManager.setParent(this);
 	_menu = new Menu(this);
 
@@ -106,6 +105,8 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescr
 
 MortevielleEngine::~MortevielleEngine() {
 	delete _menu;
+	delete _soundManager;
+	delete _text;
 	delete _mouse;
 
 	free(_curPict);
@@ -238,8 +239,8 @@ Common::ErrorCode MortevielleEngine::initialize() {
 	testKeyboard();
 	clearScreen();
 
-	_soundManager.loadNoise();
-	_soundManager.loadAmbiantSounds();
+	_soundManager->loadNoise();
+	_soundManager->loadAmbiantSounds();
 
 	return Common::kNoError;
 }
@@ -372,7 +373,7 @@ Common::Error MortevielleEngine::run() {
 		showIntroduction();
 	else {
 		_caff = 51;
-		_text.taffich();
+		_text->taffich();
 	}
 
 	// Either load the initial game state savegame, or the specified savegame number
@@ -386,7 +387,7 @@ Common::Error MortevielleEngine::run() {
 
 	// Cleanup (allocated in initialize())
 	_screenSurface.free();
-	free(_soundManager._cfiphBuffer);
+	free(_soundManager->_cfiphBuffer);
 	free(_cfiecBuffer);
 
 	return Common::kNoError;
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index b0f1af3..180d846 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -432,11 +432,11 @@ public:
 	PaletteManager _paletteManager;
 	GfxSurface _backgroundSurface;
 	Common::RandomSource _randomSource;
-	SoundManager _soundManager;
+	SoundManager *_soundManager;
 	SavegameManager _savegameManager;
 	Menu *_menu;
 	MouseHandler *_mouse;
-	TextHandler _text;
+	TextHandler *_text;
 	DialogManager _dialogManager;
 
 	MortevielleEngine(OSystem *system, const MortevielleGameDescription *gameDesc);
diff --git a/engines/mortevielle/outtext.cpp b/engines/mortevielle/outtext.cpp
index 79b04e3..16bce24 100644
--- a/engines/mortevielle/outtext.cpp
+++ b/engines/mortevielle/outtext.cpp
@@ -35,6 +35,10 @@
 
 namespace Mortevielle {
 
+TextHandler::TextHandler(MortevielleEngine *vm) {
+	_vm = vm;
+}
+
 /**
  * Next word
  * @remarks	Originally called 'l_motsuiv'
@@ -301,8 +305,4 @@ void TextHandler::taffich() {
 	}
 }
 
-void TextHandler::setParent(MortevielleEngine *vm) {
-	_vm = vm;
-}
-
 } // End of namespace Mortevielle
diff --git a/engines/mortevielle/outtext.h b/engines/mortevielle/outtext.h
index 4486803..397ca85 100644
--- a/engines/mortevielle/outtext.h
+++ b/engines/mortevielle/outtext.h
@@ -38,7 +38,8 @@ private:
 	MortevielleEngine *_vm;
 	int  nextWord(int p, const char *ch, int &tab);
 public:
-	void setParent(MortevielleEngine *vm);
+	TextHandler (MortevielleEngine *vm);
+
 	void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ);
 	void loadPictureFile(Common::String filename, Common::String altFilename, int32 skipSize, int length);
 	void loadAniFile(Common::String filename, int32 skipSize, int length);
diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp
index b670246..c39c8e7 100644
--- a/engines/mortevielle/sound.cpp
+++ b/engines/mortevielle/sound.cpp
@@ -55,7 +55,8 @@ namespace Mortevielle {
 	const byte _tabdph[16] = {0, 10, 2, 0, 2, 10, 3, 0, 3, 7, 5, 0, 6, 7, 7, 10};
 	const byte _tabdbc[18] = {7, 23, 7, 14, 13, 9, 14, 9, 5, 12, 6, 12, 13, 4, 0, 4, 5, 9};
 
-SoundManager::SoundManager(Audio::Mixer *mixer) {
+SoundManager::SoundManager(MortevielleEngine *vm, Audio::Mixer *mixer) {
+	_vm = vm;
 	_mixer = mixer;
 	_audioStream = nullptr;
 	_ambiantNoiseBuf = nullptr;
@@ -281,10 +282,6 @@ void SoundManager::playSong(const byte* buf, uint size, uint loops) {
 	_mixer->stopHandle(songHandle);
 }
 
-void SoundManager::setParent(MortevielleEngine *vm) {
-	_vm = vm;
-}
-
 void SoundManager::spfrac(int wor) {
 	_queue[2]._rep = (uint)wor >> 12;
 	if ((_soundType == 0) && (_queue[2]._code != 9)) {
diff --git a/engines/mortevielle/sound.h b/engines/mortevielle/sound.h
index cc0567f..5321c89 100644
--- a/engines/mortevielle/sound.h
+++ b/engines/mortevielle/sound.h
@@ -84,15 +84,13 @@ private:
 	void litph(tablint &t, int typ, int tempo);
 
 public:
-	SoundManager(Audio::Mixer *mixer);
+	SoundManager(MortevielleEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
 
 	Audio::Mixer *_mixer;
 	Audio::SoundHandle _soundHandle;
 	uint16 *_cfiphBuffer;
 
-	void setParent(MortevielleEngine *vm);
-
 	int decodeMusic(const byte *PSrc, byte *PDest, int size);
 	void playSong(const byte *buf, uint usize, uint loops);
 	void loadAmbiantSounds();
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp
index 991ff89..433d063 100644
--- a/engines/mortevielle/utils.cpp
+++ b/engines/mortevielle/utils.cpp
@@ -277,7 +277,7 @@ void MortevielleEngine::handleAction() {
 				return;
 			++temps;
 			if (keyPressed() || _mouseClick) {
-				_soundManager._mixer->stopHandle(_soundManager._soundHandle);
+				_soundManager->_mixer->stopHandle(_soundManager->_soundHandle);
 			}
 		} while (!((_menu->_menuSelected) || (temps > lim) || (funct) || (_anyone)));
 		_inMainGameLoop = false;
@@ -341,7 +341,7 @@ void MortevielleEngine::handleAction() {
 					handleOpcode();
 
 				if ((_controlMenu == 0) && (! _loseGame) && (! _endGame)) {
-					_text.taffich();
+					_text->taffich();
 					if (_destinationOk) {
 						_destinationOk = false;
 						drawPicture();
@@ -1255,24 +1255,24 @@ void MortevielleEngine::startMusicOrSpeech(int so) {
 		;
 	} else if ((!_introSpeechPlayed) && (!_coreVar._alreadyEnteredManor)) {
 		// Type 1: Speech
-		_soundManager.startSpeech(10, 1, 1);
+		_soundManager->startSpeech(10, 1, 1);
 		_introSpeechPlayed = true;
 	} else {
 		if (((_coreVar._currPlace == MOUNTAIN) || (_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK)) && (getRandomNumber(1, 3) == 2))
 			// Type 1: Speech
-			_soundManager.startSpeech(9, getRandomNumber(2, 4), 1);
+			_soundManager->startSpeech(9, getRandomNumber(2, 4), 1);
 		else if ((_coreVar._currPlace == CHAPEL) && (getRandomNumber(1, 2) == 1))
 			// Type 1: Speech
-			_soundManager.startSpeech(8, 1, 1);
+			_soundManager->startSpeech(8, 1, 1);
 		else if ((_coreVar._currPlace == WELL) && (getRandomNumber(1, 2) == 2))
 			// Type 1: Speech
-			_soundManager.startSpeech(12, 1, 1);
+			_soundManager->startSpeech(12, 1, 1);
 		else if (_coreVar._currPlace == INSIDE_WELL)
 			// Type 1: Speech
-			_soundManager.startSpeech(13, 1, 1);
+			_soundManager->startSpeech(13, 1, 1);
 		else
 			// Type 2 : music
-			_soundManager.startSpeech(getRandomNumber(1, 17), 1, 2);
+			_soundManager->startSpeech(getRandomNumber(1, 17), 1, 2);
 	}
 }
 
@@ -1335,12 +1335,12 @@ void MortevielleEngine::startDialog(int16 rep) {
 
 	_mouse->hideMouse();
 	Common::String dialogStr = getString(rep + kDialogStringIndex);
-	_text.displayStr(dialogStr, 230, 4, 65, 26, 5);
+	_text->displayStr(dialogStr, 230, 4, 65, 26, 5);
 	_dialogManager.drawF3F8();
 
 	key = 0;
 	do {
-		_soundManager.startSpeech(rep, haut[_caff - 69], 0);
+		_soundManager->startSpeech(rep, haut[_caff - 69], 0);
 		key = _dialogManager.waitForF3F8();
 		if (shouldQuit())
 			return;
@@ -2074,10 +2074,10 @@ void MortevielleEngine::loadCFIPH() {
 			error("Missing file - *cfiph.mor");
 	}
 
-	_soundManager._cfiphBuffer = (uint16 *)malloc(sizeof(uint16) * (f.size() / 2));
+	_soundManager->_cfiphBuffer = (uint16 *)malloc(sizeof(uint16) * (f.size() / 2));
 
 	for (int i = 0; i < (f.size() / 2); ++i)
-		_soundManager._cfiphBuffer[i] = f.readUint16BE();
+		_soundManager->_cfiphBuffer[i] = f.readUint16BE();
 
 	f.close();
 }
@@ -2102,10 +2102,10 @@ void MortevielleEngine::music() {
 	f.read(compMusicBuf, size);
 	f.close();
 
-	int musicSize = _soundManager.decodeMusic(compMusicBuf, musicBuf, size);
+	int musicSize = _soundManager->decodeMusic(compMusicBuf, musicBuf, size);
 	free(compMusicBuf);
 
-	_soundManager.playSong(musicBuf, musicSize, 5);
+	_soundManager->playSong(musicBuf, musicSize, 5);
 	while (keyPressed())
 		getChar();
 
@@ -2120,7 +2120,7 @@ void MortevielleEngine::showTitleScreen() {
 	clearScreen();
 	handleDescriptionText(7, 2035);
 	_caff = 51;
-	_text.taffich();
+	_text->taffich();
 	testKeyboard();
 	clearScreen();
 	draw(0, 0);
@@ -2280,8 +2280,8 @@ void MortevielleEngine::prepareRoom() {
 							prepareScreenType2();
 							displayTextInVerbBar(getEngineString(S_HEAR_NOISE));
 							int rand = (getRandomNumber(0, 4)) - 2;
-							_soundManager.startSpeech(1, rand, 1);
-							_soundManager.waitSpeech();
+							_soundManager->startSpeech(1, rand, 1);
+							_soundManager->waitSpeech();
 							clearVerbBar();
 						}
 					}
@@ -2391,8 +2391,8 @@ void MortevielleEngine::initCaveOrCellar() {
 	prepareScreenType2();
 	displayTextInVerbBar(getEngineString(S_SOMEONE_ENTERS));
 	int rand = (getRandomNumber(0, 4)) - 2;
-	_soundManager.startSpeech(2, rand, 1);
-	_soundManager.waitSpeech();
+	_soundManager->startSpeech(2, rand, 1);
+	_soundManager->waitSpeech();
 	// The original was doing here a useless loop.
 	// It has been removed
 
@@ -2465,7 +2465,7 @@ void MortevielleEngine::displayTextInDescriptionBar(int x, int y, int nb, int me
 	Common::String tmpStr = getString(mesgId);
 	if ((y == 182) && ((int) tmpStr.size() > nb))
 		y = 176;
-	_text.displayStr(tmpStr, x, y, nb, 20, _textColor);
+	_text->displayStr(tmpStr, x, y, nb, 20, _textColor);
 }
 
 /**
@@ -2482,7 +2482,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) {
 			_largestClearScreen = false;
 
 		clearDescriptionBar();
-		_text.displayStr(tmpStr, 8, 176, 85, 3, 5);
+		_text->displayStr(tmpStr, 8, 176, 85, 3, 5);
 	} else {
 		mapMessageId(mesgId);
 		switch (f) {
@@ -2511,7 +2511,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) {
 				i = 5;
 
 			Common::String tmpStr = getString(mesgId);
-			_text.displayStr(tmpStr, 80, 40, 60, 25, i);
+			_text->displayStr(tmpStr, 80, 40, 60, 25, i);
 
 			if (mesgId == 180)
 				_coreVar._pctHintFound[6] = '*';
@@ -2910,7 +2910,7 @@ void MortevielleEngine::drawPicture() {
 }
 
 void MortevielleEngine::drawPictureWithText() {
-	_text.taffich();
+	_text->taffich();
 	drawPicture();
 	_destinationOk = false;
 }
@@ -3123,9 +3123,9 @@ L1:
 			_crep = 138;
 		handleDescriptionText(2, _crep);
 		if (_crep == 138)
-			_soundManager.startSpeech(5, 2, 1);
+			_soundManager->startSpeech(5, 2, 1);
 		else
-			_soundManager.startSpeech(4, 4, 1);
+			_soundManager->startSpeech(4, 4, 1);
 
 		if (_openObjCount == 0)
 			_coreVar._faithScore += 2;
@@ -3150,7 +3150,7 @@ L1:
 		} else {
 			handleDescriptionText(2, 136);
 			int rand = (getRandomNumber(0, 4)) - 2;
-			_soundManager.startSpeech(3, rand, 1);
+			_soundManager->startSpeech(3, rand, 1);
 			clearDescriptionBar();
 			displayAloneText();
 			resetRoomVariables(MANOR_FRONT);






More information about the Scummvm-git-logs mailing list