[Scummvm-git-logs] scummvm master -> 77582aa8233b3037dec2ef71e6220205a31fbcda

sev- noreply at scummvm.org
Tue Dec 26 01:01:28 UTC 2023


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:
77582aa823 DIRECTOR: Better handling of empty STXT resources


Commit: 77582aa8233b3037dec2ef71e6220205a31fbcda
    https://github.com/scummvm/scummvm/commit/77582aa8233b3037dec2ef71e6220205a31fbcda
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-12-26T02:00:44+01:00

Commit Message:
DIRECTOR: Better handling of empty STXT resources

Changed paths:
    engines/director/stxt.cpp


diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
index ef62ff63815..a8b366af620 100644
--- a/engines/director/stxt.cpp
+++ b/engines/director/stxt.cpp
@@ -68,6 +68,8 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
 
 	debugC(3, kDebugText, "Stxt init: formattingCount: %u", formattingCount);
 
+	uint16 totalFormatting = formattingCount;
+
 	Common::U32String logText;
 
 	while (formattingCount) {
@@ -94,13 +96,16 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
 		_ftext += u32TextPart;
 		logText += Common::toPrintable(u32TextPart);
 
-		// Do not add formatting of empty blocks
-		if (textPart.size()) {
-			Common::String format = Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _style.fontId, _style.textSlant, _style.fontSize, _style.r, _style.g, _style.b);
-			_ftext += format;
-			logText += Common::toPrintable(format);
+		// Reset formatting if the text is completely empty
+		if (totalFormatting == 1 && textPart.empty()) {
+			_style = FontStyle();
+			debugC(4, kDebugText, "Stxt init: the font formatting was reset due to empty string");
 		}
 
+		Common::String format = Common::String::format("\001\016%04x%02x%04x%04x%04x%04x", _style.fontId, _style.textSlant, _style.fontSize, _style.r, _style.g, _style.b);
+		_ftext += format;
+		logText += Common::toPrintable(format);
+
 		formattingCount--;
 	}
 
@@ -111,12 +116,6 @@ Stxt::Stxt(Cast *cast, Common::SeekableReadStreamEndian &textStream) : _cast(cas
 	_ftext += u32Text;
 	logText += Common::toPrintable(u32Text);
 
-	// Reset style if there is no text
-	if (_ftext.empty()) {
-		debugC(4, kDebugText, "Stxt init: the font formatting was reset due to empty string");
-		_style = FontStyle();
-	}
-
 	debugC(4, kDebugText, "#### text:\n%s\n####", logText.encode(Common::kUtf8).c_str());
 }
 




More information about the Scummvm-git-logs mailing list