[Scummvm-git-logs] scummvm master -> 3040135f06756de04d2b4ca2a581062baa19816b

dreammaster paulfgilbert at gmail.com
Sun Apr 28 09:42:39 CEST 2019


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:
3040135f06 GLK: Record gli arrays for memory streams


Commit: 3040135f06756de04d2b4ca2a581062baa19816b
    https://github.com/scummvm/scummvm/commit/3040135f06756de04d2b4ca2a581062baa19816b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-04-28T17:42:22+10:00

Commit Message:
GLK: Record gli arrays for memory streams

Changed paths:
    engines/glk/glulxe/exec.cpp
    engines/glk/glulxe/glkop.cpp
    engines/glk/streams.cpp
    engines/glk/streams.h


diff --git a/engines/glk/glulxe/exec.cpp b/engines/glk/glulxe/exec.cpp
index 55cd918..01faad8 100644
--- a/engines/glk/glulxe/exec.cpp
+++ b/engines/glk/glulxe/exec.cpp
@@ -39,7 +39,7 @@ void Glulxe::execute_loop() {
 	gfloat32 valf, valf1, valf2;
 #endif /* FLOAT_SUPPORT */
 
-	while (!done_executing) {
+	while (!done_executing && !g_vm->shouldQuit()) {
 
 		profile_tick();
 		debugger_tick();
diff --git a/engines/glk/glulxe/glkop.cpp b/engines/glk/glulxe/glkop.cpp
index 68e60c7..635d90b 100644
--- a/engines/glk/glulxe/glkop.cpp
+++ b/engines/glk/glulxe/glkop.cpp
@@ -1165,6 +1165,10 @@ void Glulxe::glulxe_retained_unregister(void *array, uint len, const  char *type
 	uint ix, addr2, val;
 	uint elemsize = 0;
 
+	// TODO: See if original GLULXE has code I'm overlooking to cleanly close everything before freeing memmap
+	if (!memmap)
+		return;
+
 	if (typecode[4] == 'C')
 		elemsize = 1;
 	else if (typecode[4] == 'I')
diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp
index b124e30..907cde4 100644
--- a/engines/glk/streams.cpp
+++ b/engines/glk/streams.cpp
@@ -318,6 +318,16 @@ MemoryStream::MemoryStream(Streams *streams, void *buf, size_t buflen, FileMode
 	else
 		_bufEnd = (byte *)buf + buflen;
 	_bufEof = mode == filemode_Write ? _buf : _bufEnd;
+
+	if (g_vm->gli_register_arr)
+		_arrayRock = (*g_vm->gli_register_arr)(buf, buflen, unicode ?  "&+#!Iu" : "&+#!Cn");
+}
+
+MemoryStream::~MemoryStream() {
+	if (g_vm->gli_unregister_arr) {
+		const char *typedesc = _unicode ? "&+#!Iu" : "&+#!Cn";
+		(*g_vm->gli_unregister_arr)(_buf, _bufLen, typedesc, _arrayRock);
+	}
 }
 
 void MemoryStream::putChar(unsigned char ch) {
diff --git a/engines/glk/streams.h b/engines/glk/streams.h
index a34ba6f..f899936 100644
--- a/engines/glk/streams.h
+++ b/engines/glk/streams.h
@@ -381,6 +381,7 @@ private:
 	void *_bufEnd;
 	void *_bufEof;
 	size_t _bufLen; ///< # of bytes for latin1, # of 4-byte words for unicode
+	gidispatch_rock_t _arrayRock;
 public:
 	/**
 	 * Constructor
@@ -388,6 +389,11 @@ public:
 	MemoryStream(Streams *streams, void *buf, size_t buflen, FileMode mode, uint rock = 0, bool unicode = true);
 
 	/**
+	 * Destructor
+	 */
+	virtual ~MemoryStream();
+
+	/**
 	 * Write a character
 	 */
 	virtual void putChar(unsigned char ch) override;





More information about the Scummvm-git-logs mailing list