[Scummvm-cvs-logs] SF.net SVN: scummvm:[51712] scummvm/trunk/engines/sci

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Tue Aug 3 21:43:16 CEST 2010


Revision: 51712
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51712&view=rev
Author:   m_kiewitz
Date:     2010-08-03 19:43:16 +0000 (Tue, 03 Aug 2010)

Log Message:
-----------
SCI: reset ports when restoring

fixes qfg3/fairy tales restoring (bug #3035626)
also fixes ScummVM menu restoring while a window is shown (e.g. sq5)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/graphics/ports.cpp
    scummvm/trunk/engines/sci/graphics/ports.h

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2010-08-03 19:24:09 UTC (rev 51711)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2010-08-03 19:43:16 UTC (rev 51712)
@@ -760,6 +760,8 @@
 	s->gameStartTime = g_system->getMillis();
 	s->_screenUpdateTime = g_system->getMillis();
 
+	g_sci->_gfxPorts->reset();
+
 	g_sci->_soundCmd->reconstructPlayList(meta.savegame_version);
 
 	// Message state:

Modified: scummvm/trunk/engines/sci/graphics/ports.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/ports.cpp	2010-08-03 19:24:09 UTC (rev 51711)
+++ scummvm/trunk/engines/sci/graphics/ports.cpp	2010-08-03 19:43:16 UTC (rev 51712)
@@ -50,7 +50,10 @@
 }
 
 GfxPorts::~GfxPorts() {
-	// TODO: Clear _windowList and delete all stuff in it?
+	// reset frees all windows but _picWind
+	reset();
+	freeWindow(_picWind);
+	delete _wmgrPort;
 	delete _menuPort;
 }
 
@@ -135,7 +138,7 @@
 	_wmgrPort->curLeft = 0;
 	_windowList.push_front(_wmgrPort);
 
-	_picWind = newWindow(Common::Rect(0, offTop, _screen->getWidth(), _screen->getHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true);
+	_picWind = addWindow(Common::Rect(0, offTop, _screen->getWidth(), _screen->getHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true);
 	// For SCI0 games till kq4 (.502 - not including) we set _picWind top to offTop instead
 	//  Because of the menu/status bar
 	if (g_sci->_features->usesOldGfxFunctions())
@@ -144,6 +147,30 @@
 	kernelInitPriorityBands();
 }
 
+// Removes any windows from windowList
+//  is used when restoring/restarting the game
+//  Sierra SCI actually saved the whole windowList, it seems we don't need to do this at all
+//  but in some games there are still windows active when restoring. Leaving those windows open
+//  would create all sorts of issues, that's why we remove them
+void GfxPorts::reset() {
+	PortList::iterator it = _windowList.begin();
+	const PortList::iterator end = _windowList.end();
+
+	setPort(_picWind);
+
+	while (it != end) {
+		Port *pPort = *it;
+		if (pPort->id > 2) {
+			// found a window beyond _picWind
+			freeWindow((Window *)pPort);
+		}
+		it++;
+	}
+	_windowList.clear();
+	_windowList.push_front(_wmgrPort);
+	_windowList.push_back(_picWind);
+}
+
 void GfxPorts::kernelSetActive(uint16 portId) {
 	switch (portId) {
 	case 0:
@@ -179,9 +206,9 @@
 	Window *wnd = NULL;
 
 	if (restoreRect.bottom != 0 && restoreRect.right != 0)
-		wnd = newWindow(dims, &restoreRect, title, style, priority, false);
+		wnd = addWindow(dims, &restoreRect, title, style, priority, false);
 	else
-		wnd = newWindow(dims, NULL, title, style, priority, false);
+		wnd = addWindow(dims, NULL, title, style, priority, false);
 	wnd->penClr = colorPen;
 	wnd->backClr = colorBack;
 	drawWindow(wnd);
@@ -191,7 +218,7 @@
 
 void GfxPorts::kernelDisposeWindow(uint16 windowId, bool reanimate) {
 	Window *wnd = (Window *)getPortById(windowId);
-	disposeWindow(wnd, reanimate);
+	removeWindow(wnd, reanimate);
 }
 
 int16 GfxPorts::isFrontWindow(Window *pWnd) {
@@ -228,7 +255,7 @@
 	setPort(oldPort);
 }
 
-Window *GfxPorts::newWindow(const Common::Rect &dims, const Common::Rect *restoreRect, const char *title, uint16 style, int16 priority, bool draw) {
+Window *GfxPorts::addWindow(const Common::Rect &dims, const Common::Rect *restoreRect, const char *title, uint16 style, int16 priority, bool draw) {
 	// Find an unused window/port id
 	uint id = 1;
 	while (id < _windowsById.size() && _windowsById[id]) {
@@ -378,7 +405,7 @@
 	setPort(oldport);
 }
 
-void GfxPorts::disposeWindow(Window *pWnd, bool reanimate) {
+void GfxPorts::removeWindow(Window *pWnd, bool reanimate) {
 	setPort(_wmgrPort);
 	_paint16->bitsRestore(pWnd->hSaved1);
 	_paint16->bitsRestore(pWnd->hSaved2);
@@ -392,6 +419,15 @@
 	delete pWnd;
 }
 
+void GfxPorts::freeWindow(Window *pWnd) {
+	if (!pWnd->hSaved1.isNull())
+		_segMan->freeHunkEntry(pWnd->hSaved1);
+	if (!pWnd->hSaved2.isNull())
+		_segMan->freeHunkEntry(pWnd->hSaved1);
+	_windowsById[pWnd->id] = 0;
+	delete pWnd;
+}
+
 void GfxPorts::updateWindow(Window *wnd) {
 	reg_t handle;
 
@@ -413,8 +449,6 @@
 	return _windowsById[id];
 }
 
-
-
 Port *GfxPorts::setPort(Port *newPort) {
 	Port *oldPort = _curPort;
 	_curPort = newPort;

Modified: scummvm/trunk/engines/sci/graphics/ports.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/ports.h	2010-08-03 19:24:09 UTC (rev 51711)
+++ scummvm/trunk/engines/sci/graphics/ports.h	2010-08-03 19:43:16 UTC (rev 51712)
@@ -46,6 +46,7 @@
 	~GfxPorts();
 
 	void init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *text16);
+	void reset();
 
 	void kernelSetActive(uint16 portId);
 	Common::Rect kernelGetPicWindow(int16 &picTop, int16 &picLeft);
@@ -57,9 +58,10 @@
 	int16 isFrontWindow(Window *wnd);
 	void beginUpdate(Window *wnd);
 	void endUpdate(Window *wnd);
-	Window *newWindow(const Common::Rect &dims, const Common::Rect *restoreRect, const char *title, uint16 style, int16 priority, bool draw);
+	Window *addWindow(const Common::Rect &dims, const Common::Rect *restoreRect, const char *title, uint16 style, int16 priority, bool draw);
 	void drawWindow(Window *wnd);
-	void disposeWindow(Window *pWnd, bool reanimate);
+	void removeWindow(Window *pWnd, bool reanimate);
+	void freeWindow(Window *pWnd);
 	void updateWindow(Window *wnd);
 
 	Port *getPortById(uint16 id);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list