[Scummvm-git-logs] scummvm master -> 912b2f03eb353e317cb5a34c7c43b3884ac79786

dreammaster paulfgilbert at gmail.com
Thu May 7 00:46:46 UTC 2020


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

Summary:
23161b27dc ULTIMA4: Merge of sound manager into a single code file
912b2f03eb XEEN: Bugfix for bad mob data, WOXCD top of witches tower


Commit: 23161b27dcc24c46b410676057089ef950674937
    https://github.com/scummvm/scummvm/commit/23161b27dcc24c46b410676057089ef950674937
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-06T17:42:29-07:00

Commit Message:
ULTIMA4: Merge of sound manager into a single code file

Changed paths:
  R engines/ultima/ultima4/sound/sound_p.h
  R engines/ultima/ultima4/sound/sound_scummvm.cpp
    engines/ultima/module.mk
    engines/ultima/ultima4/sound/sound.cpp
    engines/ultima/ultima4/sound/sound.h


diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index c20dccc82e..f4a0fbcab9 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -213,7 +213,6 @@ MODULE_OBJS := \
 	ultima4/map/tileset.o \
 	ultima4/sound/music.o \
 	ultima4/sound/sound.o \
-	ultima4/sound/sound_scummvm.o \
 	ultima4/views/imageview.o \
 	ultima4/views/menu.o \
 	ultima4/views/menuitem.o \
diff --git a/engines/ultima/ultima4/sound/sound.cpp b/engines/ultima/ultima4/sound/sound.cpp
index c0f5a69c3d..a1e0a8276f 100644
--- a/engines/ultima/ultima4/sound/sound.cpp
+++ b/engines/ultima/ultima4/sound/sound.cpp
@@ -22,11 +22,10 @@
 
 #include "ultima/ultima4/sound/sound.h"
 #include "ultima/ultima4/core/config.h"
-#include "ultima/ultima4/core/utils.h"
 #include "ultima/ultima4/sound/music.h"
 #include "ultima/ultima4/core/settings.h"
 #include "ultima/ultima4/filesys/u4file.h"
-#include "ultima/ultima4/sound/sound_p.h"
+#include "ultima/ultima4/core/utils.h"
 
 namespace Ultima {
 namespace Ultima4 {
@@ -47,6 +46,8 @@ void soundStop(int channel) {
 	SoundManager::getInstance()->stop(channel);
 }
 
+/*-------------------------------------------------------------------*/
+
 SoundManager *SoundManager::_instance = 0;
 
 SoundManager::SoundManager() {
@@ -120,5 +121,46 @@ void SoundManager::stop(int channel) {
 	stop_sys(channel);
 }
 
+bool SoundManager::load_sys(Sound sound, const Common::String &pathname) {
+#ifdef TODO
+	soundChunk[sound] = Mix_LoadWAV(pathname.c_str());
+	if (!soundChunk[sound]) {
+		warning("Unable to load sound effect file %s: %s", soundFilenames[sound].c_str(), Mix_GetError());
+		return false;
+	}
+#endif
+	return true;
+}
+
+void SoundManager::play_sys(Sound sound, bool onlyOnce, int specificDurationInTicks) {
+#ifdef TODO
+	/**
+	 * Use Channel 1 for sound effects
+	 */
+	if (!onlyOnce || !Mix_Playing(1)) {
+		if (Mix_PlayChannelTimed(1, soundChunk[sound], specificDurationInTicks == -1 ? 0 : -1, specificDurationInTicks) == -1)
+			fprintf(stderr, "Error playing sound %d: %s\n", sound, Mix_GetError());
+	}
+#endif
+}
+
+void SoundManager::stop_sys(int channel) {
+#ifdef TODO
+	// If music didn't initialize correctly, then we shouldn't try to stop it
+	if (!g_music->functional || !settings.soundVol)
+		return;
+
+	if (Mix_Playing(channel))
+		Mix_HaltChannel(channel);
+#endif
+}
+
+int SoundManager::init_sys() {
+	return 1;
+}
+
+void SoundManager::del_sys() {
+}
+
 } // End of namespace Ultima4
 } // End of namespace Ultima
diff --git a/engines/ultima/ultima4/sound/sound.h b/engines/ultima/ultima4/sound/sound.h
index 78c2a4737b..d2ca9883ce 100644
--- a/engines/ultima/ultima4/sound/sound.h
+++ b/engines/ultima/ultima4/sound/sound.h
@@ -20,8 +20,11 @@
  *
  */
 
-#ifndef ULTIMA4_SOUND_SOUND_H
-#define ULTIMA4_SOUND_SOUND_H
+#ifndef ULTIMA4_SOUND_H
+#define ULTIMA4_SOUND_H
+
+#include "ultima/shared/std/containers.h"
+#include "common/str.h"
 
 namespace Ultima {
 namespace Ultima4 {
@@ -68,6 +71,32 @@ void soundPlay(Sound sound, bool onlyOnce = true, int specificDurationInTicks =
 
 void soundStop(int channel = 1);
 
+struct Mix_Chunk;
+typedef Mix_Chunk OSSoundChunk;
+
+class SoundManager {
+public:
+	~SoundManager();
+	static SoundManager *getInstance();
+	int init();
+	void play(Sound sound, bool onlyOnce = true, int specificDurationInTicks = -1);
+	void stop(int channel = 1);
+private:
+	bool load(Sound sound);
+	int init_sys();
+	void del() {
+		del_sys();
+	}
+	void del_sys();
+	void play_sys(Sound sound, bool onlyOnce, int specificDurationInTicks);
+	bool load_sys(Sound sound, const Common::String &soundPathName);
+	void stop_sys(int channel);
+	Std::vector<Common::String> _soundFilenames;
+	Std::vector<OSSoundChunk *> _soundChunk;
+	SoundManager();
+	static SoundManager *_instance;
+};
+
 } // End of namespace Ultima4
 } // End of namespace Ultima
 
diff --git a/engines/ultima/ultima4/sound/sound_p.h b/engines/ultima/ultima4/sound/sound_p.h
deleted file mode 100644
index 3cd37488d7..0000000000
--- a/engines/ultima/ultima4/sound/sound_p.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA4_SOUND_SOUND_P_H
-#define ULTIMA4_SOUND_SOUND_P_H
-
-#include "ultima/ultima4/sound/sound.h"
-#include "ultima/shared/std/containers.h"
-#include "common/str.h"
-
-namespace Ultima {
-namespace Ultima4 {
-
-struct Mix_Chunk;
-typedef Mix_Chunk OSSoundChunk;
-
-class SoundManager {
-public:
-	~SoundManager();
-	static SoundManager *getInstance();
-	int init();
-	void play(Sound sound, bool onlyOnce = true, int specificDurationInTicks = -1);
-	void stop(int channel = 1);
-private:
-	bool load(Sound sound);
-	int init_sys();
-	void del() {
-		del_sys();
-	}
-	void del_sys();
-	void play_sys(Sound sound, bool onlyOnce, int specificDurationInTicks);
-	bool load_sys(Sound sound, const Common::String &soundPathName);
-	void stop_sys(int channel);
-	Std::vector<Common::String> _soundFilenames;
-	Std::vector<OSSoundChunk *> _soundChunk;
-	SoundManager();
-	static SoundManager *_instance;
-};
-
-} // End of namespace Ultima4
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima4/sound/sound_scummvm.cpp b/engines/ultima/ultima4/sound/sound_scummvm.cpp
deleted file mode 100644
index 5f373aadfb..0000000000
--- a/engines/ultima/ultima4/sound/sound_scummvm.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima4/sound/sound_p.h"
-#include "ultima/ultima4/sound/sound.h"
-#include "ultima/ultima4/core/config.h"
-#include "ultima/ultima4/sound/music.h"
-#include "ultima/ultima4/core/settings.h"
-#include "ultima/ultima4/filesys/u4file.h"
-
-namespace Ultima {
-namespace Ultima4 {
-
-bool SoundManager::load_sys(Sound sound, const Common::String &pathname) {
-#ifdef TODO
-	soundChunk[sound] = Mix_LoadWAV(pathname.c_str());
-	if (!soundChunk[sound]) {
-		warning("Unable to load sound effect file %s: %s", soundFilenames[sound].c_str(), Mix_GetError());
-		return false;
-	}
-#endif
-	return true;
-}
-
-void SoundManager::play_sys(Sound sound, bool onlyOnce, int specificDurationInTicks) {
-#ifdef TODO
-	/**
-	 * Use Channel 1 for sound effects
-	 */
-	if (!onlyOnce || !Mix_Playing(1)) {
-		if (Mix_PlayChannelTimed(1, soundChunk[sound], specificDurationInTicks == -1 ? 0 : -1, specificDurationInTicks) == -1)
-			fprintf(stderr, "Error playing sound %d: %s\n", sound, Mix_GetError());
-	}
-#endif
-}
-
-void SoundManager::stop_sys(int channel) {
-#ifdef TODO
-	// If music didn't initialize correctly, then we shouldn't try to stop it
-	if (!g_music->functional || !settings.soundVol)
-		return;
-
-	if (Mix_Playing(channel))
-		Mix_HaltChannel(channel);
-#endif
-}
-
-int SoundManager::init_sys() {
-	return 1;
-}
-
-void SoundManager::del_sys() {
-}
-
-} // End of namespace Ultima4
-} // End of namespace Ultima


Commit: 912b2f03eb353e317cb5a34c7c43b3884ac79786
    https://github.com/scummvm/scummvm/commit/912b2f03eb353e317cb5a34c7c43b3884ac79786
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-06T17:42:29-07:00

Commit Message:
XEEN: Bugfix for bad mob data, WOXCD top of witches tower

Changed paths:
    NEWS.md
    engines/xeen/files.h
    engines/xeen/map.cpp


diff --git a/NEWS.md b/NEWS.md
index 97b0b3f706..254ed301c6 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -36,6 +36,7 @@ For a more comprehensive changelog of the latest experimental code, see:
 
  Xeen:
    - Add missing sprite drawer for enemies hit by Energy Blast.
+   - Fixed freeze due to bad mob data at the top of Witches Tower
 
  Linux port:
    - Added option to use the system file browser instead of the ScummVM file browser.
diff --git a/engines/xeen/files.h b/engines/xeen/files.h
index cac69c4ecd..da9c34fd42 100644
--- a/engines/xeen/files.h
+++ b/engines/xeen/files.h
@@ -244,13 +244,18 @@ public:
 class XeenSerializer : public Common::Serializer {
 private:
 	Common::SeekableReadStream *_in;
+	int _filesize;
 public:
 	XeenSerializer(Common::SeekableReadStream *in, Common::WriteStream *out) :
-		Common::Serializer(in, out), _in(in) {}
+		Common::Serializer(in, out), _in(in), _filesize(-1) {}
 
 	SYNC_AS(Sint8, Byte, int8, 1)
 
-	bool finished() const { return _in != nullptr && _in->pos() >= _in->size(); }
+	bool finished() {
+		if (_in && _filesize == -1)
+			_filesize = _in->size();
+		return _in != nullptr && _in->pos() >= _filesize;
+	}
 };
 
 /**
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index 9e6c7c1549..24062e67f0 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -477,6 +477,9 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
 
 			_objects.push_back(obj);
 			mobStruct.synchronize(s);
+			if (s.finished())
+				// WORKAROUND: If end of data abnormally reached
+				return;
 		} while (mobStruct._id != 255 || mobStruct._pos.x != -1);
 
 		// Load monsters
@@ -486,6 +489,10 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
 			mobStruct.synchronize(s);
 
 		while (mobStruct._id != 255 || mobStruct._pos.x != -1) {
+			if (s.finished())
+				// WORKAROUND: If end of data abnormally reached
+				return;
+
 			MazeMonster mon;
 			mon._position = mobStruct._pos;
 			mon._id = mobStruct._id;
@@ -514,6 +521,10 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData)
 		// Load wall items. Unlike the previous two arrays, this has no dummy entry for an empty array
 		mobStruct.synchronize(s);
 		while (mobStruct._id != 255 || mobStruct._pos.x != -1) {
+			if (s.finished())
+				// WORKAROUND: If end of data abnormally reached
+				return;
+
 			if (mobStruct._id < (int)_wallItemSprites.size()) {
 				MazeWallItem wi;
 				wi._position = mobStruct._pos;




More information about the Scummvm-git-logs mailing list