[Scummvm-git-logs] scummvm master -> 072c54318d5c4073004635f3f249bbaec6cf53a3

athrxx athrxx at scummvm.org
Tue Oct 12 18:47:16 UTC 2021


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:
072c54318d KYRA: (LOL) - replace sound list char* array with Common::StringArray


Commit: 072c54318d5c4073004635f3f249bbaec6cf53a3
    https://github.com/scummvm/scummvm/commit/072c54318d5c4073004635f3f249bbaec6cf53a3
Author: athrxx (athrxx at scummvm.org)
Date: 2021-10-12T20:45:52+02:00

Commit Message:
KYRA: (LOL) - replace sound list char* array with Common::StringArray

Changed paths:
    engines/kyra/engine/lol.cpp
    engines/kyra/engine/lol.h
    engines/kyra/gui/gui_lol.cpp
    engines/kyra/resource/staticres_lol.cpp
    engines/kyra/script/script_lol.cpp
    engines/kyra/sound/sound_lol.cpp


diff --git a/engines/kyra/engine/lol.cpp b/engines/kyra/engine/lol.cpp
index f344350989..0748461129 100644
--- a/engines/kyra/engine/lol.cpp
+++ b/engines/kyra/engine/lol.cpp
@@ -163,7 +163,6 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraRpgEngine(sy
 	_dscDoorMonsterX = _dscDoorMonsterY = 0;
 	_dscDoor4 = 0;
 
-	_ingameSoundList = 0;
 	_ingameSoundIndex = 0;
 	_ingameSoundListSize = 0;
 	_musicTrackMap = 0;
@@ -330,12 +329,6 @@ LoLEngine::~LoLEngine() {
 
 	delete _lvlShpFileHandle;
 
-	if (_ingameSoundList) {
-		for (int i = 0; i < _ingameSoundListSize; i++)
-			delete[] _ingameSoundList[i];
-		delete[] _ingameSoundList;
-	}
-
 	for (int i = 0; i < 3; i++) {
 		for (int ii = 0; ii < 40; ii++)
 			delete[] _characterFaceShapes[ii][i];
diff --git a/engines/kyra/engine/lol.h b/engines/kyra/engine/lol.h
index f6458bb511..9537aae8db 100644
--- a/engines/kyra/engine/lol.h
+++ b/engines/kyra/engine/lol.h
@@ -464,7 +464,7 @@ private:
 
 	int _curTlkFile;
 
-	char **_ingameSoundList;
+	Common::StringArray _ingameSoundList;
 	int _ingameSoundListSize;
 
 	const uint8 *_musicTrackMap;
diff --git a/engines/kyra/gui/gui_lol.cpp b/engines/kyra/gui/gui_lol.cpp
index 9c008a66bd..08fafc961f 100644
--- a/engines/kyra/gui/gui_lol.cpp
+++ b/engines/kyra/gui/gui_lol.cpp
@@ -2817,7 +2817,7 @@ int GUI_LoL::clickedAudioMenu(Button *button) {
 				vocIndex = (int16)READ_LE_UINT16(&_vm->_ingameSoundIndex[_sliderSfx * 2]);
 				if (vocIndex == -1)
 					continue;
-				if (!scumm_stricmp(_vm->_ingameSoundList[vocIndex], "EMPTY"))
+				if (_vm->_ingameSoundList[vocIndex].equalsIgnoreCase("EMPTY"))
 					continue;
 				break;
 			} while (1);
diff --git a/engines/kyra/resource/staticres_lol.cpp b/engines/kyra/resource/staticres_lol.cpp
index 1c7c9bd54d..9cfac24399 100644
--- a/engines/kyra/resource/staticres_lol.cpp
+++ b/engines/kyra/resource/staticres_lol.cpp
@@ -307,11 +307,8 @@ void LoLEngine::initStaticResource() {
 
 	const char *const *tmpSndList = _staticres->loadStrings(kLoLIngameSfxFiles, _ingameSoundListSize);
 	if (tmpSndList) {
-		_ingameSoundList = new char*[_ingameSoundListSize];
-		for (int i = 0; i < _ingameSoundListSize; i++) {
-			_ingameSoundList[i] = new char[strlen(tmpSndList[i]) + 1];
-			strcpy(_ingameSoundList[i], tmpSndList[i]);
-		}
+		for (int i = 0; i < _ingameSoundListSize; i++)
+			_ingameSoundList.push_back(Common::String(tmpSndList[i]));
 		_staticres->unloadId(kLoLIngameSfxFiles);
 	}
 
diff --git a/engines/kyra/script/script_lol.cpp b/engines/kyra/script/script_lol.cpp
index 33f8e674f9..6358dff34c 100644
--- a/engines/kyra/script/script_lol.cpp
+++ b/engines/kyra/script/script_lol.cpp
@@ -1843,7 +1843,7 @@ int LoLEngine::olol_assignCustomSfx(EMCState *script) {
 	if (t == 0xFFFF)
 		return 0;
 
-	strcpy(_ingameSoundList[t], c);
+	_ingameSoundList[t] = c;
 
 	return 0;
 }
diff --git a/engines/kyra/sound/sound_lol.cpp b/engines/kyra/sound/sound_lol.cpp
index ae64af91b9..08b4245418 100644
--- a/engines/kyra/sound/sound_lol.cpp
+++ b/engines/kyra/sound/sound_lol.cpp
@@ -182,13 +182,13 @@ void LoLEngine::snd_playSoundEffect(int track, int volume) {
 
 	bool hasVocFile = false;
 	if (vocIndex != -1) {
-		if (scumm_stricmp(_ingameSoundList[vocIndex], "EMPTY"))
+		if (!_ingameSoundList[vocIndex].equalsIgnoreCase("EMPTY"))
 			hasVocFile = true;
 	}
 
 	if (hasVocFile) {
-		if (_sound->isVoicePresent(_ingameSoundList[vocIndex]))
-			_sound->voicePlay(_ingameSoundList[vocIndex], 0, volume, priority, true);
+		if (_sound->isVoicePresent(_ingameSoundList[vocIndex].c_str()))
+			_sound->voicePlay(_ingameSoundList[vocIndex].c_str(), 0, volume, priority, true);
 	} else if (_flags.platform == Common::kPlatformDOS) {
 		if (_sound->getSfxType() == Sound::kMidiMT32)
 			track = (track < _ingameMT32SoundIndexSize) ? (_ingameMT32SoundIndex[track] - 1) : -1;




More information about the Scummvm-git-logs mailing list