[Scummvm-git-logs] scummvm master -> 166e8fc5b416b1ff60d109e27e0f5537b0e773af

joostp noreply at scummvm.org
Fri Aug 5 15:05:56 UTC 2022


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:
166e8fc5b4 ICB: ELDORADO: handle fn_play_sting and fn_preload_sting differences


Commit: 166e8fc5b416b1ff60d109e27e0f5537b0e773af
    https://github.com/scummvm/scummvm/commit/166e8fc5b416b1ff60d109e27e0f5537b0e773af
Author: Joost Peters (joostp at 7fc1.org)
Date: 2022-08-05T17:05:08+02:00

Commit Message:
ICB: ELDORADO: handle fn_play_sting and fn_preload_sting differences

Changed paths:
    engines/icb/fn_sting_pc.cpp


diff --git a/engines/icb/fn_sting_pc.cpp b/engines/icb/fn_sting_pc.cpp
index 74be05da19c..1bba49d4d2c 100644
--- a/engines/icb/fn_sting_pc.cpp
+++ b/engines/icb/fn_sting_pc.cpp
@@ -25,9 +25,11 @@
  */
 
 #include "engines/icb/debug.h"
+#include "engines/icb/icb.h"
 #include "engines/icb/global_objects.h"
 #include "engines/icb/mission.h"
 #include "engines/icb/session.h"
+#include "engines/icb/common/ptr_util.h"
 #include "engines/icb/sound/direct_sound.h"
 #include "engines/icb/sound/music_manager.h"
 #include "engines/icb/sound.h"
@@ -56,7 +58,7 @@ int32 inSpeechMusicAllocated = 0;
 // Useful prototype
 bool8 DoesClusterContainFile(const char *clustername, uint32 hash_to_find, uint32 &fileoffset, uint32 &filesize);
 
-void LoadSting(uint32 looking_for_hash) {
+void LoadSting(uint32 looking_for_hash, bool8 looping = FALSE8) {
 #ifdef PC_DEMO
 	return;
 #endif
@@ -89,11 +91,11 @@ void LoadSting(uint32 looking_for_hash) {
 
 	// Pass parameters to the music manager through this low-level interface
 	if (g_theMusicManager) {
-		g_theMusicManager->LoadMusic(clustername, file_offset, GetMusicVolume());
+		g_theMusicManager->LoadMusic(clustername, file_offset, /*looping,*/ GetMusicVolume());
 	}
 }
 
-void PlaySting(uint32 looking_for_hash) {
+void PlaySting(uint32 looking_for_hash, bool8 looping = FALSE8) {
 #ifdef PC_DEMO
 	return;
 #endif
@@ -116,34 +118,68 @@ void PlaySting(uint32 looking_for_hash) {
 
 	if (g_theMusicManager) {
 		// This loads only if not already loaded then starts playback
-		g_theMusicManager->StartMusic(clustername, file_offset, GetMusicVolume());
+		g_theMusicManager->StartMusic(clustername, file_offset, /*looping,*/ GetMusicVolume());
 	}
 }
 
 mcodeFunctionReturnCodes _game_session::fn_play_sting(int32 &, int32 *params) {
-	if (inSpeechMusicAllocated != 0)
-		return IR_REPEAT;
+	if (g_icb->getGameType() == GType_ICB) {
+		if (inSpeechMusicAllocated != 0)
+			return IR_REPEAT;
 
-	if (g_theMusicManager) {
-		// Stop playback
-		g_theMusicManager->StopMusic();
-	}
+		if (g_theMusicManager) {
+			// Stop playback
+			g_theMusicManager->StopMusic();
+		}
 
-	PlaySting((uint32)params[0]);
+		PlaySting((uint32)params[0]);
+	} else if (g_icb->getGameType() == GType_ELDORADO) {
+		const char *sting_name = (const char *)MemoryUtil::resolvePtr(params[0]);
+
+		bool8 looping = FALSE8;
+
+		// Check for looping tag on sting name
+		uint32 len = strlen(sting_name);
+
+		if (len < 3)
+			Fatal_error("fn_play_sting(%s): Invalid sting name!", sting_name);
+
+		if (sting_name[len - 2] == '_' && sting_name[len - 1] == 't')
+			looping = TRUE8;
+
+		PlaySting(HashString(sting_name), looping);
+	}
 
 	return IR_CONT;
 }
 
 mcodeFunctionReturnCodes _game_session::fn_preload_sting(int32 &, int32 *params) {
-	if (inSpeechMusicAllocated != 0)
-		return IR_REPEAT;
+	if (g_icb->getGameType() == GType_ICB) {
+		if (inSpeechMusicAllocated != 0)
+			return IR_REPEAT;
 
-	if (g_theMusicManager) {
-		// Stop playback
-		g_theMusicManager->StopMusic();
-	}
+		if (g_theMusicManager) {
+			// Stop playback
+			g_theMusicManager->StopMusic();
+		}
 
-	LoadSting((uint32)params[0]);
+		LoadSting((uint32)params[0]);
+	} else if (g_icb->getGameType() == GType_ELDORADO) {
+		const char *sting_name = (const char *)MemoryUtil::resolvePtr(params[0]);
+
+		bool8 looping = FALSE8;
+
+		// Check for looping tag on sting name
+		uint32 len = strlen(sting_name);
+
+		if (len < 3)
+			Fatal_error("fn_play_sting(%s): Invalid sting name!", sting_name);
+
+		if (sting_name[len - 2] == '_' && sting_name[len - 1] == 't')
+			looping = TRUE8;
+
+		LoadSting(HashString(sting_name), looping);
+	}
 
 	return IR_CONT;
 }




More information about the Scummvm-git-logs mailing list