[Scummvm-git-logs] scummvm master -> 38643a418f76a1bc94d90cde8d646f49c1aad8ab

mduggan noreply at scummvm.org
Wed Mar 1 10:41:23 UTC 2023


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

Summary:
28142edb3d TETRAEDGE: Fix small memory leak on load
ce96aa32cf TETRAEDGE: Search harder for logic lua on changing warp
0b54a0c3ff TETRAEDGE: Work around another bad Syberia 2 config file
3ab1b9cbb1 TETRAEDGE: Support Syberia 2 version of PlayMusic
38643a418f TETRAEDGE: Implement addDocument for Syberia 2


Commit: 28142edb3dfff3a8f7c08ae45c648dc17381ca77
    https://github.com/scummvm/scummvm/commit/28142edb3dfff3a8f7c08ae45c648dc17381ca77
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-03-01T19:36:39+09:00

Commit Message:
TETRAEDGE: Fix small memory leak on load

Changed paths:
    engines/tetraedge/game/character.cpp


diff --git a/engines/tetraedge/game/character.cpp b/engines/tetraedge/game/character.cpp
index d06513a1fcf..7b317a4b741 100644
--- a/engines/tetraedge/game/character.cpp
+++ b/engines/tetraedge/game/character.cpp
@@ -454,6 +454,7 @@ bool Character::loadSettings(const Common::String &path) {
 	buf[bufsize] = '\0';
 	xmlFile.read(buf, bufsize);
 	Common::String fixedbuf(buf);
+	delete [] buf;
 	size_t offset = fixedbuf.find("------------");
 	while (offset != Common::String::npos) {
 		fixedbuf.replace(offset, 12, "--");


Commit: ce96aa32cfb25313f3288811022f0fbc5f503a61
    https://github.com/scummvm/scummvm/commit/ce96aa32cfb25313f3288811022f0fbc5f503a61
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-03-01T19:36:39+09:00

Commit Message:
TETRAEDGE: Search harder for logic lua on changing warp

Changed paths:
    engines/tetraedge/game/game.cpp


diff --git a/engines/tetraedge/game/game.cpp b/engines/tetraedge/game/game.cpp
index 43cc71e428c..1f4661cf1ca 100644
--- a/engines/tetraedge/game/game.cpp
+++ b/engines/tetraedge/game/game.cpp
@@ -245,7 +245,7 @@ bool Game::changeWarp2(const Common::String &zone, const Common::String &scene,
 	luapath.appendInPlace(scene);
 	luapath.appendInPlace(".lua");
 
-	if (Common::File::exists(luapath)) {
+	if (g_engine->getCore()->findFile(luapath).exists()) {
 		_luaScript.execute("OnLeave");
 		_luaContext.removeGlobal("On");
 		_luaContext.removeGlobal("OnEnter");


Commit: 0b54a0c3ffd49b4ecc0039d0a615fb7877bbd4d2
    https://github.com/scummvm/scummvm/commit/0b54a0c3ffd49b4ecc0039d0a615fb7877bbd4d2
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-03-01T19:36:39+09:00

Commit Message:
TETRAEDGE: Work around another bad Syberia 2 config file

Changed paths:
    engines/tetraedge/game/in_game_scene.cpp


diff --git a/engines/tetraedge/game/in_game_scene.cpp b/engines/tetraedge/game/in_game_scene.cpp
index 8cda3bf8457..19e9406a19b 100644
--- a/engines/tetraedge/game/in_game_scene.cpp
+++ b/engines/tetraedge/game/in_game_scene.cpp
@@ -806,8 +806,39 @@ bool InGameScene::loadXml(const Common::String &zone, const Common::String &scen
 	InGameSceneXmlParser parser;
 	parser._scene = this;
 	parser.setAllowText();
-	if (!parser.loadFile(node))
-		error("InGameScene::loadXml: Can't load %s", node.getPath().c_str());
+
+	Common::String fixedbuf;
+	if (g_engine->gameType() == TetraedgeEngine::kSyberia2 && scene == "GangcarVideo") {
+		//
+		// WORKAROUND: scenes/A1_RomHaut/GangcarVideo/SceneGangcarVideo.xml
+		// in Syberia 2 has an embedded comment, which is invalid XML.
+		// Patch the contents of the file before loading.
+		//
+		Common::File xmlFile;
+		if (!xmlFile.open(node))
+			error("InGameScene::loadXml: Can't open %s", node.getPath().c_str());
+		const int64 bufsize = xmlFile.size();
+		char *buf = new char[bufsize+1];
+		buf[bufsize] = '\0';
+		xmlFile.read(buf, bufsize);
+		fixedbuf = Common::String(buf);
+		delete [] buf;
+		size_t offset = fixedbuf.find("<!-- <rippleMask");
+		if (offset != Common::String::npos)
+			fixedbuf.replace(offset, 4, "    ");  // replace the <! at the start
+		offset = fixedbuf.find("texture=\"R11280-1-00.png\"/> -->");
+		if (offset != Common::String::npos)
+			fixedbuf.replace(offset + 29, 3, "   "); // replace the > at the end
+		offset = fixedbuf.find("<!--<light ");
+		if (offset != Common::String::npos)
+			fixedbuf.replace(offset, 4, "    ");  // replace the <! at the start
+		parser.loadBuffer((const byte *)fixedbuf.c_str(), bufsize);
+	} else {
+		// Regular loading.
+		if (!parser.loadFile(node))
+			error("InGameScene::loadXml: Can't load %s", node.getPath().c_str());
+	}
+
 	if (!parser.parse())
 		error("InGameScene::loadXml: Can't parse %s", node.getPath().c_str());
 


Commit: 3ab1b9cbb1a2a0ed0219f2b13bd3df28135ddc45
    https://github.com/scummvm/scummvm/commit/3ab1b9cbb1a2a0ed0219f2b13bd3df28135ddc45
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-03-01T19:36:39+09:00

Commit Message:
TETRAEDGE: Support Syberia 2 version of PlayMusic

Changed paths:
    engines/tetraedge/game/lua_binds.cpp


diff --git a/engines/tetraedge/game/lua_binds.cpp b/engines/tetraedge/game/lua_binds.cpp
index e1be446212b..8cc0f42fd3b 100644
--- a/engines/tetraedge/game/lua_binds.cpp
+++ b/engines/tetraedge/game/lua_binds.cpp
@@ -1907,7 +1907,7 @@ static int tolua_ExportedFunctions_PlayRandomSound00(lua_State *L) {
 	error("#ferror in function 'PlayRandomSound': %d %d %s", err.index, err.array, err.type);
 }
 
-static void PlayMusic(const Common::String &path) {
+static void PlayMusic(const Common::String &path, float volume) {
 	TeMusic &music = g_engine->getApplication()->music();
 	// Note: stop and set repeat before starting,
 	// very slightly different to original because we can't
@@ -1916,14 +1916,15 @@ static void PlayMusic(const Common::String &path) {
 	music.repeat(false);
 	music.load(path);
 	music.play();
-	music.volume(1.0);
+	music.volume(volume);
 }
 
 static int tolua_ExportedFunctions_PlayMusic00(lua_State *L) {
 	tolua_Error err;
-	if (tolua_isstring(L, 1, 0, &err) && tolua_isnoobj(L, 2, &err)) {
+	if (tolua_isstring(L, 1, 0, &err) && tolua_isnumber(L, 2, 1, &err) && tolua_isnoobj(L, 3, &err)) {
 		Common::String s1(tolua_tostring(L, 1, nullptr));
-		PlayMusic(s1);
+		float f1 = tolua_tonumber(L, 2, 1.0);
+		PlayMusic(s1, f1);
 		return 0;
 	}
 	error("#ferror in function 'PlayMusic': %d %d %s", err.index, err.array, err.type);


Commit: 38643a418f76a1bc94d90cde8d646f49c1aad8ab
    https://github.com/scummvm/scummvm/commit/38643a418f76a1bc94d90cde8d646f49c1aad8ab
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-03-01T19:36:39+09:00

Commit Message:
TETRAEDGE: Implement addDocument for Syberia 2

Changed paths:
    engines/tetraedge/game/document.cpp
    engines/tetraedge/game/document.h
    engines/tetraedge/game/documents_browser.cpp
    engines/tetraedge/game/documents_browser.h


diff --git a/engines/tetraedge/game/document.cpp b/engines/tetraedge/game/document.cpp
index 75bf42ff255..e7e62fbd060 100644
--- a/engines/tetraedge/game/document.cpp
+++ b/engines/tetraedge/game/document.cpp
@@ -19,16 +19,32 @@
  *
  */
 
+#include "tetraedge/tetraedge.h"
 #include "tetraedge/game/document.h"
+#include "tetraedge/game/documents_browser.h"
+#include "tetraedge/te/te_core.h"
+#include "tetraedge/te/te_sprite_layout.h"
 
 namespace Tetraedge {
 
-Document::Document(DocumentsBrowser *browser) /*: _browser(browser)*/ {
+Document::Document(DocumentsBrowser *browser) : _browser(browser) {
 
 }
 
 void Document::load(const Common::String &name) {
-	error("TODO: Implement Document::load");
+	setSizeType(RELATIVE_TO_PARENT);
+	setSize(TeVector3f32(1, 1, 1));
+	_gui.load("DocumentsBrowser/Document.lua");
+	addChild(_gui.layoutChecked("object"));
+	setName(name);
+	const Common::Path sprPath = spritePath();
+	_gui.spriteLayoutChecked("upLayout")->load(g_engine->getCore()->findFile(sprPath));
+	_gui.buttonLayoutChecked("object")->onMouseClickValidated().add(this, &Document::onButtonDown);
+	TeITextLayout *txtLayout = _gui.textLayout("text");
+	if (!txtLayout)
+		error("can't find text layout in document");
+	Common::String header("<section style=\"center\" /><color r=\"255\" g=\"255\" b=\"255\"/><font file=\"Common/Fonts/arial.ttf\" size=\"16\" />");
+	txtLayout->setText(header + _browser->documentName(name));
 }
 
 void Document::unload() {
diff --git a/engines/tetraedge/game/document.h b/engines/tetraedge/game/document.h
index 60771eb3156..307e1f4f882 100644
--- a/engines/tetraedge/game/document.h
+++ b/engines/tetraedge/game/document.h
@@ -53,7 +53,7 @@ public:
 	void unload();
 
 private:
-	//DocumentsBrowser *_browser;
+	DocumentsBrowser *_browser;
 	TeLuaGUI _gui;
 	TeSignal1Param<Document &> _onButtonDownSignal;
 };
diff --git a/engines/tetraedge/game/documents_browser.cpp b/engines/tetraedge/game/documents_browser.cpp
index 94b47eccbf8..533e928c31a 100644
--- a/engines/tetraedge/game/documents_browser.cpp
+++ b/engines/tetraedge/game/documents_browser.cpp
@@ -165,8 +165,28 @@ bool DocumentsBrowser::onZoomedButton() {
 	return false;
 }
 
-int DocumentsBrowser::addDocument(Document *document) {
-	error("TODO: Implement DocumentsBrowser::addDocument");
+bool DocumentsBrowser::addDocument(Document *document) {
+	int pageno = 0;
+	while (true) {
+		Common::String pageName = Common::String::format("page%d", pageno);
+		TeLayout *page = _gui1.layout(pageName);
+		if (!page)
+			break;
+		int slotno = 0;
+		while (true) {
+			Common::String pageSlotName = Common::String::format("page%dSlot%d", pageno, slotno);
+			TeLayout *slot = _gui1.layout(pageSlotName);
+			if (!slot)
+				break;
+			if (slot->childCount() == 0) {
+				slot->addChild(document);
+				return true;
+			}
+			slotno++;
+		}
+		pageno++;
+	}
+	return false;
 }
 
 void DocumentsBrowser::addDocument(const Common::String &str) {
@@ -176,6 +196,11 @@ void DocumentsBrowser::addDocument(const Common::String &str) {
 		delete doc;
 }
 
+Common::String DocumentsBrowser::documentName(const Common::String &name) {
+	// Note: this returns a value from an xml file,
+	// but the xml file doesn't exist in either game.
+	return "";
+}
 
 void DocumentsBrowser::showDocument(const Common::String &docName, int startPage) {
 	_curPage = startPage;
diff --git a/engines/tetraedge/game/documents_browser.h b/engines/tetraedge/game/documents_browser.h
index eadf96b0a8c..2504d2e3d6f 100644
--- a/engines/tetraedge/game/documents_browser.h
+++ b/engines/tetraedge/game/documents_browser.h
@@ -32,7 +32,7 @@ class DocumentsBrowser : public TeLayout {
 public:
 	DocumentsBrowser();
 
-	int addDocument(Document *document);
+	bool addDocument(Document *document);
 	void addDocument(const Common::String &str);
 
 	void currentPage(int page);




More information about the Scummvm-git-logs mailing list