[Scummvm-git-logs] scummvm master -> df74a209ca8496f08283285337181ea73a69b78f

dreammaster paulfgilbert at gmail.com
Thu Jan 3 08:25:11 CET 2019


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:
85816c8a54 GLK: Make a _gameFile field in the base Glk engine
df74a209ca GLK: FROTZ: Keep mono & prop font sizes to be the same for v6 games


Commit: 85816c8a54d77423c6400e41da93f62fe1f948ff
    https://github.com/scummvm/scummvm/commit/85816c8a54d77423c6400e41da93f62fe1f948ff
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-01-02T23:13:13-08:00

Commit Message:
GLK: Make a _gameFile field in the base Glk engine

Changed paths:
    engines/glk/alan2/alan2.cpp
    engines/glk/alan2/alan2.h
    engines/glk/frotz/frotz.cpp
    engines/glk/frotz/frotz.h
    engines/glk/frotz/windows.cpp
    engines/glk/glk.cpp
    engines/glk/glk.h
    engines/glk/glulxe/glulxe.cpp
    engines/glk/glulxe/glulxe.h
    engines/glk/magnetic/magnetic.cpp
    engines/glk/magnetic/magnetic.h
    engines/glk/scott/scott.cpp
    engines/glk/scott/scott.h
    engines/glk/tads/tads2/tads2.cpp
    engines/glk/tads/tads2/tads2.h
    engines/glk/tads/tads3/tads3.cpp
    engines/glk/tads/tads3/tads3.h


diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index f9dcb52..60889f7 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -45,9 +45,7 @@ Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, g
 	dscrstkp = 0;
 }
 
-void Alan2::runGame(Common::SeekableReadStream *gameFile) {
-	_gameFile = gameFile;
-
+void Alan2::runGame() {
 	// TODO: Initialize these properly
 	int tmp = 0;
 	Common::String gameFileName;
@@ -73,12 +71,12 @@ Common::Error Alan2::saveGameData(strid_t file, const Common::String &desc) {
 }
 
 bool Alan2::is_gamefile_valid() {
-	if (_gameFile->size() < 8) {
+	if (_gameFile.size() < 8) {
 		GUIErrorMessage(_("This is too short to be a valid Alan2 file."));
 		return false;
 	}
 
-	if (_gameFile->readUint32BE() != MKTAG(2, 8, 1, 0)) {
+	if (_gameFile.readUint32BE() != MKTAG(2, 8, 1, 0)) {
 		GUIErrorMessage(_("This is not a valid Alan2 file."));
 		return false;
 	}
diff --git a/engines/glk/alan2/alan2.h b/engines/glk/alan2/alan2.h
index e2fe6ae..a6ded43 100644
--- a/engines/glk/alan2/alan2.h
+++ b/engines/glk/alan2/alan2.h
@@ -45,7 +45,6 @@ class SaveLoad;
  */
 class Alan2 : public GlkAPI {
 public:
-	Common::SeekableReadStream *_gameFile;
 	bool vm_exited_cleanly;
 private:
 	/**
@@ -61,7 +60,7 @@ public:
 	/**
 	 * Run the game
 	 */
-	void runGame(Common::SeekableReadStream *gameFile);
+	void runGame();
 
 	/**
 	 * Returns the running interpreter type
diff --git a/engines/glk/frotz/frotz.cpp b/engines/glk/frotz/frotz.cpp
index e837f65..8ec3db7 100644
--- a/engines/glk/frotz/frotz.cpp
+++ b/engines/glk/frotz/frotz.cpp
@@ -44,8 +44,8 @@ Screen *Frotz::createScreen() {
 	return new FrotzScreen();
 }
 
-void Frotz::runGame(Common::SeekableReadStream *gameFile) {
-	story_fp = gameFile;
+void Frotz::runGame() {
+	story_fp = &_gameFile;
 	initialize();
 
 	// If save was selected from the launcher, handle loading it
diff --git a/engines/glk/frotz/frotz.h b/engines/glk/frotz/frotz.h
index 28902c5..d05971a 100644
--- a/engines/glk/frotz/frotz.h
+++ b/engines/glk/frotz/frotz.h
@@ -61,7 +61,7 @@ public:
 	/**
 	 * Execute the game
 	 */
-	virtual void runGame(Common::SeekableReadStream *gameFile) override;
+	virtual void runGame() override;
 
 	/**
 	 * Load a savegame from the passed stream
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index e4179ca..4fa291e 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -52,7 +52,6 @@ winid_t Window::getWindow() {
 		// Window doesn't exist, so create it
 		// TODO: For now I'm assuming all the extra created windows will be graphics, since Glk requires
 		// us to specify it at creation time. Not sure if it's true or not for all V6 games
-		winid_t parent = _windows->_lower;
 		_win = g_vm->glk_window_open(g_vm->glk_window_get_root(), winmethod_Arbitrary | winmethod_Fixed,
 			0, wintype_Graphics, 0);
 	}
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index 2525c0b..e7d10fa 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -107,7 +107,6 @@ void GlkEngine::initGraphicsMode() {
 }
 
 Common::Error GlkEngine::run() {
-	Common::File f;
 	Common::String filename = getFilename();
 	if (!Common::File::exists(filename))
 		return Common::kNoGameDataFoundError;
@@ -119,7 +118,7 @@ Common::Error GlkEngine::run() {
 		_blorb = new Blorb(filename, getInterpreterType());
 		SearchMan.add("blorb", _blorb, 99, false);
 
-		if (!f.open("game", *_blorb))
+		if (!_gameFile.open("game", *_blorb))
 			return Common::kNoGameDataFoundError;
 	} else {
 		// Check for a secondary blorb file with the same filename
@@ -127,20 +126,20 @@ Common::Error GlkEngine::run() {
 		while (baseName.contains('.'))
 			baseName.deleteLastChar();
 
-		if (f.exists(baseName + ".blorb")) {
+		if (Common::File::exists(baseName + ".blorb")) {
 			_blorb = new Blorb(baseName + ".blorb", getInterpreterType());
 			SearchMan.add("blorb", _blorb, 99, false);
-		} else if (f.exists(baseName + ".blb")) {
+		} else if (Common::File::exists(baseName + ".blb")) {
 			_blorb = new Blorb(baseName + ".blb", getInterpreterType());
 			SearchMan.add("blorb", _blorb, 99, false);
 		}
 
 		// Open up the game file
-		if (!f.open(filename))
+		if (!_gameFile.open(filename))
 			return Common::kNoGameDataFoundError;
 	}
 
-	runGame(&f);
+	runGame();
 
 	return Common::kNoError;
 }
diff --git a/engines/glk/glk.h b/engines/glk/glk.h
index a2cc3e4..2782353 100644
--- a/engines/glk/glk.h
+++ b/engines/glk/glk.h
@@ -81,6 +81,7 @@ protected:
 	const GlkGameDescription _gameDescription;
 	Common::RandomSource _random;
 	int _loadSaveSlot;
+	Common::File _gameFile;
 
 	// Engine APIs
 	virtual Common::Error run();
@@ -98,7 +99,7 @@ protected:
 	/**
 	 * Main game loop for the individual interpreters
 	 */
-	virtual void runGame(Common::SeekableReadStream *gameFile) = 0;
+	virtual void runGame() = 0;
 public:
 	Blorb *_blorb;
 	Clipboard *_clipboard;
diff --git a/engines/glk/glulxe/glulxe.cpp b/engines/glk/glulxe/glulxe.cpp
index aaa63b6..40f4bdd 100644
--- a/engines/glk/glulxe/glulxe.cpp
+++ b/engines/glk/glulxe/glulxe.cpp
@@ -31,9 +31,7 @@ Glulxe::Glulxe(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst,
 		vm_exited_cleanly(false) {
 }
 
-void Glulxe::runGame(Common::SeekableReadStream *gameFile) {
-	_gameFile = gameFile;
-
+void Glulxe::runGame() {
 	if (!is_gamefile_valid())
 		return;
 
@@ -51,18 +49,18 @@ Common::Error Glulxe::saveGameData(strid_t file, const Common::String &desc) {
 }
 
 bool Glulxe::is_gamefile_valid() {
-	if (_gameFile->size() < 8) {
+	if (_gameFile.size() < 8) {
 		GUIErrorMessage(_("This is too short to be a valid Glulx file."));
 		return false;
 	}
 
-	if (_gameFile->readUint32BE() != MKTAG('G', 'l', 'u', 'l')) {
+	if (_gameFile.readUint32BE() != MKTAG('G', 'l', 'u', 'l')) {
 		GUIErrorMessage(_("This is not a valid Glulx file."));
 		return false;
 	}
 
 	// We support version 2.0 through 3.1.*
-	uint version = _gameFile->readUint32BE();
+	uint version = _gameFile.readUint32BE();
 	if (version < 0x20000) {
 		GUIErrorMessage(_("This Glulx file is too old a version to execute."));
 		return false;
diff --git a/engines/glk/glulxe/glulxe.h b/engines/glk/glulxe/glulxe.h
index 3764ca4..decdc29 100644
--- a/engines/glk/glulxe/glulxe.h
+++ b/engines/glk/glulxe/glulxe.h
@@ -34,7 +34,6 @@ namespace Glulxe {
  */
 class Glulxe : public GlkAPI {
 public:
-	Common::SeekableReadStream *_gameFile;
 	bool vm_exited_cleanly;
 private:
 	/**
@@ -50,7 +49,7 @@ public:
 	/**
 	 * Run the game
 	 */
-	void runGame(Common::SeekableReadStream *gameFile);
+	void runGame();
 
 	/**
 	 * Returns the running interpreter type
diff --git a/engines/glk/magnetic/magnetic.cpp b/engines/glk/magnetic/magnetic.cpp
index f3f3e79..9bfdc48 100644
--- a/engines/glk/magnetic/magnetic.cpp
+++ b/engines/glk/magnetic/magnetic.cpp
@@ -31,9 +31,7 @@ Magnetic::Magnetic(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(s
 		vm_exited_cleanly(false) {
 }
 
-void Magnetic::runGame(Common::SeekableReadStream *gameFile) {
-	_gameFile = gameFile;
-
+void Magnetic::runGame() {
 	if (!is_gamefile_valid())
 		return;
 
@@ -51,18 +49,18 @@ Common::Error Magnetic::saveGameData(strid_t file, const Common::String &desc) {
 }
 
 bool Magnetic::is_gamefile_valid() {
-	if (_gameFile->size() < 8) {
+	if (_gameFile.size() < 8) {
 		GUIErrorMessage(_("This is too short to be a valid Glulx file."));
 		return false;
 	}
 
-	if (_gameFile->readUint32BE() != MKTAG('G', 'l', 'u', 'l')) {
+	if (_gameFile.readUint32BE() != MKTAG('G', 'l', 'u', 'l')) {
 		GUIErrorMessage(_("This is not a valid Glulx file."));
 		return false;
 	}
 
 	// We support version 2.0 through 3.1.*
-	uint version = _gameFile->readUint32BE();
+	uint version = _gameFile.readUint32BE();
 	if (version < 0x20000) {
 		GUIErrorMessage(_("This Glulx file is too old a version to execute."));
 		return false;
diff --git a/engines/glk/magnetic/magnetic.h b/engines/glk/magnetic/magnetic.h
index 6f30768..024ef51 100644
--- a/engines/glk/magnetic/magnetic.h
+++ b/engines/glk/magnetic/magnetic.h
@@ -34,7 +34,6 @@ namespace Magnetic {
  */
 class Magnetic : public GlkAPI {
 public:
-	Common::SeekableReadStream *_gameFile;
 	bool vm_exited_cleanly;
 private:
 	/**
@@ -50,7 +49,7 @@ public:
 	/**
 	 * Run the game
 	 */
-	void runGame(Common::SeekableReadStream *gameFile);
+	void runGame();
 
 	/**
 	 * Returns the running interpreter type
diff --git a/engines/glk/scott/scott.cpp b/engines/glk/scott/scott.cpp
index 640679c..b918f8c 100644
--- a/engines/glk/scott/scott.cpp
+++ b/engines/glk/scott/scott.cpp
@@ -35,7 +35,7 @@ Scott::Scott(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, g
 	Common::fill(&_roomSaved[0], &_roomSaved[16], 0);
 }
 
-void Scott::runGame(Common::SeekableReadStream *gameFile) {
+void Scott::runGame() {
 	int vb, no;
 	initialize();
 
@@ -70,7 +70,7 @@ void Scott::runGame(Common::SeekableReadStream *gameFile) {
 	_saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
 
 	// Load the game
-	loadDatabase(gameFile, (_options & DEBUGGING) ? 1 : 0);
+	loadDatabase(&_gameFile, (_options & DEBUGGING) ? 1 : 0);
 
 	// Main game loop
 	while (!shouldQuit()) {
diff --git a/engines/glk/scott/scott.h b/engines/glk/scott/scott.h
index b490fd6..4739e94 100644
--- a/engines/glk/scott/scott.h
+++ b/engines/glk/scott/scott.h
@@ -174,7 +174,7 @@ public:
 	/**
 	 * Execute the game
 	 */
-	virtual void runGame(Common::SeekableReadStream *gameFile) override;
+	virtual void runGame() override;
 
 	/**
 	 * Load a savegame from the passed stream
diff --git a/engines/glk/tads/tads2/tads2.cpp b/engines/glk/tads/tads2/tads2.cpp
index 79a36fa..a772b44 100644
--- a/engines/glk/tads/tads2/tads2.cpp
+++ b/engines/glk/tads/tads2/tads2.cpp
@@ -30,7 +30,7 @@ TADS2::TADS2(OSystem *syst, const GlkGameDescription &gameDesc) : OS(syst, gameD
 	cmap_init_default();
 }
 
-void TADS2::runGame(Common::SeekableReadStream *gameFile) {
+void TADS2::runGame() {
 	errcxdef errctx;
 	errctx.errcxlgc = &errctx;
 	errctx.errcxfp = nullptr;
diff --git a/engines/glk/tads/tads2/tads2.h b/engines/glk/tads/tads2/tads2.h
index f0c42b3..2472929 100644
--- a/engines/glk/tads/tads2/tads2.h
+++ b/engines/glk/tads/tads2/tads2.h
@@ -167,7 +167,7 @@ public:
 	/**
 	 * Execute the game
 	 */
-	virtual void runGame(Common::SeekableReadStream *gameFile) override;
+	virtual void runGame() override;
 
 	/**
 	 * Returns the running interpreter type
diff --git a/engines/glk/tads/tads3/tads3.cpp b/engines/glk/tads/tads3/tads3.cpp
index 911e87f..10fb602 100644
--- a/engines/glk/tads/tads3/tads3.cpp
+++ b/engines/glk/tads/tads3/tads3.cpp
@@ -29,7 +29,7 @@ namespace TADS3 {
 TADS3::TADS3(OSystem *syst, const GlkGameDescription &gameDesc) : TADS(syst, gameDesc) {
 }
 
-void TADS3::runGame(Common::SeekableReadStream *gameFile) {
+void TADS3::runGame() {
 	// TODO
 }
 
diff --git a/engines/glk/tads/tads3/tads3.h b/engines/glk/tads/tads3/tads3.h
index 2fc4961..45a3f09 100644
--- a/engines/glk/tads/tads3/tads3.h
+++ b/engines/glk/tads/tads3/tads3.h
@@ -42,7 +42,7 @@ public:
 	/**
 	 * Execute the game
 	 */
-	virtual void runGame(Common::SeekableReadStream *gameFile) override;
+	virtual void runGame() override;
 
 	/**
 	 * Returns the running interpreter type


Commit: df74a209ca8496f08283285337181ea73a69b78f
    https://github.com/scummvm/scummvm/commit/df74a209ca8496f08283285337181ea73a69b78f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-01-02T23:24:50-08:00

Commit Message:
GLK: FROTZ: Keep mono & prop font sizes to be the same for v6 games

Changed paths:
    engines/glk/frotz/config.cpp
    engines/glk/frotz/frotz.h
    engines/glk/frotz/screen.cpp
    engines/glk/glk.cpp


diff --git a/engines/glk/frotz/config.cpp b/engines/glk/frotz/config.cpp
index f98e1e8..ad0764a 100644
--- a/engines/glk/frotz/config.cpp
+++ b/engines/glk/frotz/config.cpp
@@ -92,6 +92,7 @@ Header::Header() : h_version(0), h_config(0), h_release(0), h_resident_size(0),
 }
 
 void Header::loadHeader(Common::SeekableReadStream &f) {
+	f.seek(0);
 	h_version = f.readByte();
 	h_config = f.readByte();
 
diff --git a/engines/glk/frotz/frotz.h b/engines/glk/frotz/frotz.h
index d05971a..b5de82d 100644
--- a/engines/glk/frotz/frotz.h
+++ b/engines/glk/frotz/frotz.h
@@ -28,10 +28,13 @@
 namespace Glk {
 namespace Frotz {
 
+class FrotzScreen;
+
 /**
  * Frotz interpreter for Z-code games
  */
 class Frotz : public Processor {
+	friend class FrotzScreen;
 protected:
 	/**
 	 * Create the screen class
diff --git a/engines/glk/frotz/screen.cpp b/engines/glk/frotz/screen.cpp
index d843528..06b3616 100644
--- a/engines/glk/frotz/screen.cpp
+++ b/engines/glk/frotz/screen.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "glk/frotz/screen.h"
+#include "glk/frotz/frotz.h"
 #include "glk/conf.h"
 #include "common/file.h"
 #include "graphics/fonts/ttf.h"
@@ -36,6 +37,17 @@ FrotzScreen::FrotzScreen() : Glk::Screen() {
 }
 
 void FrotzScreen::loadFonts(Common::Archive *archive) {
+	// Get the zmachine version. At this point the header isn't loaded, so we have to do it manually
+	g_vm->_gameFile.seek(0);
+	byte version = g_vm->_gameFile.readByte();
+
+	if (version == 6) {
+		// For graphical games, force both mono and proportinate fonts to be the same size.
+		// This simplifies calculation of pixels when setting window position and sizes
+		g_conf->_monoInfo._size = g_conf->_propInfo._size = MAX(g_conf->_monoInfo._size, g_conf->_propInfo._size);
+	}
+
+	// Load the basic fonts
 	Screen::loadFonts(archive);
 
 	// Add character graphics font
@@ -46,7 +58,7 @@ void FrotzScreen::loadFonts(Common::Archive *archive) {
 
 	Common::Point fontSize(_fonts[0]->getMaxCharWidth(), _fonts[0]->getFontHeight());
 	decoder.loadStream(f);
-	_fonts.push_back(new Frotz::BitmapFont(*decoder.getSurface(), fontSize));
+	_fonts.push_back(new BitmapFont(*decoder.getSurface(), fontSize));
 	f.close();
 
 	// Add Runic font. It provides cleaner versions of the runic characters in the
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index e7d10fa..f39ef6a 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -107,12 +107,11 @@ void GlkEngine::initGraphicsMode() {
 }
 
 Common::Error GlkEngine::run() {
+	// Open up the game file
 	Common::String filename = getFilename();
 	if (!Common::File::exists(filename))
 		return Common::kNoGameDataFoundError;
 
-	initialize();
-
 	if (Blorb::isBlorb(filename)) {
 		// Blorb archive
 		_blorb = new Blorb(filename, getInterpreterType());
@@ -139,6 +138,10 @@ Common::Error GlkEngine::run() {
 			return Common::kNoGameDataFoundError;
 	}
 
+	// Perform initialization
+	initialize();
+
+	// Play the game
 	runGame();
 
 	return Common::kNoError;





More information about the Scummvm-git-logs mailing list