[Scummvm-cvs-logs] SF.net SVN: scummvm:[44630] scummvm/trunk

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Oct 4 20:51:02 CEST 2009


Revision: 44630
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44630&view=rev
Author:   thebluegr
Date:     2009-10-04 18:51:01 +0000 (Sun, 04 Oct 2009)

Log Message:
-----------
Replaced DblList with Common::List

Modified Paths:
--------------
    scummvm/trunk/dists/msvc8/sci.vcproj
    scummvm/trunk/dists/msvc9/sci.vcproj
    scummvm/trunk/engines/sci/gui/gui_helpers.h
    scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp
    scummvm/trunk/engines/sci/gui/gui_windowmgr.h
    scummvm/trunk/engines/sci/module.mk

Removed Paths:
-------------
    scummvm/trunk/engines/sci/gui/gui_dbllist.cpp
    scummvm/trunk/engines/sci/gui/gui_dbllist.h

Modified: scummvm/trunk/dists/msvc8/sci.vcproj
===================================================================
--- scummvm/trunk/dists/msvc8/sci.vcproj	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/dists/msvc8/sci.vcproj	2009-10-04 18:51:01 UTC (rev 44630)
@@ -95,8 +95,6 @@
 		<Filter	Name="gui">
 			<File RelativePath="..\..\engines\sci\gui\gui.cpp" />
 			<File RelativePath="..\..\engines\sci\gui\gui.h" />
-			<File RelativePath="..\..\engines\sci\gui\gui_dbllist.cpp" />
-			<File RelativePath="..\..\engines\sci\gui\gui_dbllist.h" />
 			<File RelativePath="..\..\engines\sci\gui\gui_font.cpp" />
 			<File RelativePath="..\..\engines\sci\gui\gui_font.h" />
 			<File RelativePath="..\..\engines\sci\gui\gui_gfx.cpp" />

Modified: scummvm/trunk/dists/msvc9/sci.vcproj
===================================================================
--- scummvm/trunk/dists/msvc9/sci.vcproj	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/dists/msvc9/sci.vcproj	2009-10-04 18:51:01 UTC (rev 44630)
@@ -96,8 +96,6 @@
 		<Filter	Name="gui">
 			<File RelativePath="..\..\engines\sci\gui\gui.cpp" />
 			<File RelativePath="..\..\engines\sci\gui\gui.h" />
-			<File RelativePath="..\..\engines\sci\gui\gui_dbllist.cpp" />
-			<File RelativePath="..\..\engines\sci\gui\gui_dbllist.h" />
 			<File RelativePath="..\..\engines\sci\gui\gui_font.cpp" />
 			<File RelativePath="..\..\engines\sci\gui\gui_font.h" />
 			<File RelativePath="..\..\engines\sci\gui\gui_gfx.cpp" />

Deleted: scummvm/trunk/engines/sci/gui/gui_dbllist.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_dbllist.cpp	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/engines/sci/gui/gui_dbllist.cpp	2009-10-04 18:51:01 UTC (rev 44630)
@@ -1,257 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/util.h"
-
-#include "sci/sci.h"
-#include "sci/gui/gui_helpers.h"
-#include "sci/gui/gui_memmgr.h"
-#include "sci/gui/gui_dbllist.h"
-
-namespace Sci {
-
-DblList::DblList() {
-	_hFirst = 0;
-	_hLast = 0;
-}
-
-DblList::DblList(HEAPHANDLE heap) {
-	byte *ptr = heap2Ptr(heap);
-	_hFirst = READ_UINT16(ptr);
-	_hLast = READ_UINT16(ptr + 2);
-}
-
-DblList::~DblList(void) {
-}
-//--------------------------------------
-// Prints all list contents
-void DblList::Dump(char*caption) {
-	debug("DumpList %s:", caption);
-	debug("  First: %04X Last: %04X", _hFirst, _hLast);
-	HEAPHANDLE node = _hFirst;
-	while (node) {
-		GUINode *pNode = (GUINode *)heap2Ptr(node);
-		debug("  %04X key=%04X prev=%04X next=%04X add.data=%db", node,
-				pNode->key, pNode->prev, pNode->next, heapGetDataSize(node) - 6);
-		node = pNode->next;
-	}
-	debug("End of list");
-}
-//--------------------------------------
-// Add a new node to front of the list
-HEAPHANDLE DblList::AddToFront(HEAPHANDLE node, uint16 key) {
-	if (!node) {
-		warning("Bad node handler (%04X) passed to DblList::AddToFront !",
-				node);
-		return node;
-	}
-	GUINode *pNode = (GUINode *)heap2Ptr(node);
-	pNode->key = key;
-	if (_hFirst) { // we already have  a 1st node
-		GUINode *pnext = (GUINode *)heap2Ptr(_hFirst);
-		pnext->prev = node;
-		pNode->next = _hFirst;
-	} else { // list is empty, to passed node becames 1st one
-		_hLast = node;
-		pNode->next = 0;
-	}
-	_hFirst = node;
-	pNode->prev = 0;
-	return node;
-}
-
-//-------------------------------------
-//
-HEAPHANDLE DblList::AddToEnd(HEAPHANDLE node, uint16 key) {
-	if (!node) {
-		warning("Bad node handler (%04X) passed to DblList::AddToEnd !", node);
-		return node;
-	}
-	GUINode *pNode = (GUINode *)heap2Ptr(node);
-	if (_hFirst) { // list is not empty
-		GUINode *plast = (GUINode *)heap2Ptr(_hLast);
-		plast->next = node;
-		pNode->prev = _hLast;
-	} else { // list is empty, so the node becames 1st one
-		_hFirst = node;
-		pNode->prev = 0;
-	}
-	_hLast = node;
-	pNode->next = 0;
-	pNode->key = key;
-
-	return node;
-}
-
-//------------------------------------------------
-// returns node that contains the key
-HEAPHANDLE DblList::FindKey(uint16 key) {
-	HEAPHANDLE node = _hFirst;
-	while (node) {
-		GUINode *pNode = (GUINode *)heap2Ptr(node);
-		if (pNode->key == key)
-			break;
-		node = pNode->next;
-	}
-	return node;
-}
-//------------------------------------------------
-// detaches node with specified key and returning the node
-HEAPHANDLE DblList::DeleteKey(uint16 key) {
-	HEAPHANDLE node = FindKey(key);
-	if (node)
-		DeleteNode(node);
-	return node;
-}
-//------------------------------------------------
-// detaches specified node from list
-byte DblList::DeleteNode(HEAPHANDLE node) {
-	if (!node) {
-		warning("Bad node handler (%04X) passed to DblList::AddToEnd !", node);
-		return node;
-	}
-	// updating the links
-	GUINode *pNode = (GUINode *)heap2Ptr(node);
-	if (pNode->prev) {
-		GUINode *pprev = (GUINode *)heap2Ptr(pNode->prev);
-		pprev->next = pNode->next;
-	}
-	if (pNode->next) {
-		GUINode *pnext = (GUINode *)heap2Ptr(pNode->next);
-		pnext->prev = pNode->prev;
-	}
-	// updating list head if needed
-	if (_hFirst == node)
-		_hFirst = pNode->next;
-	if (_hLast == node)
-		_hLast = pNode->prev;
-	pNode->prev = 0;
-	pNode->next = 0;
-	return 1;
-}
-//------------------------------------------------
-// Moves node to the end of the list
-HEAPHANDLE DblList::MoveToEnd(HEAPHANDLE node) {
-	if (!node) {
-		warning("Bad node handler (%04X) passed to DblList::MoveToEnd !", node);
-		return node;
-	}
-	GUINode *pNode = (GUINode *)heap2Ptr(node);
-	if (pNode->next) { // node is not the last one in list
-		DeleteNode(node);
-		AddToEnd(node, pNode->key);
-	}
-	return node;
-}
-//------------------------------------------------
-// Moves node to the front of the list
-HEAPHANDLE DblList::MoveToFront(HEAPHANDLE node) {
-	if (!node) {
-		warning("Bad node handler (%04X) passed to DblList::MoveToFront !",
-				node);
-		return node;
-	}
-	GUINode *pNode = (GUINode *)heap2Ptr(node);
-	if (pNode->prev) { // node is not 1st one in list
-		DeleteNode(node);
-		AddToFront(node, pNode->key);
-	}
-	return node;
-}
-//------------------------------------------------
-HEAPHANDLE DblList::AddAfter(HEAPHANDLE ref, HEAPHANDLE node, uint16 key) {
-	if (!node) {
-		warning("Bad node handler (%04X) passed to DblList::AddAfter !", node);
-		return node;
-	}
-	GUINode *pNode = (GUINode *)heap2Ptr(node);
-	GUINode *pref = (GUINode *)heap2Ptr(ref);
-	pNode->key = key;
-	if (pref->next == 0) { // ref node is the last one
-		pNode->next = 0;
-		_hLast = node;
-	} else {
-		GUINode *pnext = (GUINode *)heap2Ptr(pref->next);
-		pNode->next = pref->next;
-		pnext->prev = node;
-	}
-	pref->next = node;
-	pNode->prev = ref;
-	return node;
-}
-//------------------------------------------------
-//
-HEAPHANDLE DblList::AddBefore(HEAPHANDLE ref, HEAPHANDLE node, uint16 key) {
-	if (!node) {
-		warning("Bad node handler (%04X) passed to DblList::AddBefore !", node);
-		return node;
-	}
-	GUINode *pNode = (GUINode *)heap2Ptr(node);
-	GUINode *pref = (GUINode *)heap2Ptr(ref);
-	pNode->key = key;
-	if (pref->prev == 0) { // ref node is the 1st one
-		pNode->prev = 0;
-		_hFirst = node;
-	} else {
-		GUINode*pprev = (GUINode *)heap2Ptr(pref->prev);
-		pNode->prev = pref->prev;
-		pprev->next = node;
-	}
-	pref->prev = node;
-	pNode->next = ref;
-	return node;
-}
-//------------------------------------------------
-void DblList::toHeap(HEAPHANDLE heap) {
-	byte *ptr = heap2Ptr(heap);
-	WRITE_UINT16(ptr, _hFirst);
-	WRITE_UINT16(ptr + 2, _hLast);
-}
-//------------------------------------------------
-void DblList::DeleteList() {
-	HEAPHANDLE node = getFirst(), next;
-	GUINode *pNode;
-	while (node) {
-		pNode = (GUINode *)heap2Ptr(node);
-		next = pNode->next;
-		heapDisposePtr(node);
-		node = next;
-	}
-	_hFirst = _hLast = 0;
-}
-//------------------------------------------------
-uint16 DblList::getSize() {
-	uint16 cnt = 0;
-	HEAPHANDLE node = getFirst();
-	GUINode *pNode;
-	while (node) {
-		pNode = (GUINode *)heap2Ptr(node);
-		node = pNode->next;
-		cnt++;
-	}
-	return cnt;
-}
-//------------------------------------------------
-} // end of namespace

Deleted: scummvm/trunk/engines/sci/gui/gui_dbllist.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_dbllist.h	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/engines/sci/gui/gui_dbllist.h	2009-10-04 18:51:01 UTC (rev 44630)
@@ -1,74 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- Each node contains handles to next and previous node and an optional key for searching
- Head node contains handles to first and last node
- */
-
-namespace Sci {
-
-typedef uint16 HEAPHANDLE;
-
-class DblList {
-public:
-	DblList();
-	DblList(HEAPHANDLE heap);
-	~DblList(void);
-protected:
-	HEAPHANDLE _hFirst, _hLast;
-public:
-	// Add a new node to front of the list
-	HEAPHANDLE AddToFront(HEAPHANDLE node, uint16 key = 0);
-	HEAPHANDLE AddToEnd(HEAPHANDLE node, uint16 key = 0);
-	HEAPHANDLE MoveToEnd(HEAPHANDLE node);
-	HEAPHANDLE MoveToFront(HEAPHANDLE node);
-	HEAPHANDLE AddAfter(HEAPHANDLE ref, HEAPHANDLE node, uint16 key = 0);
-	HEAPHANDLE AddBefore(HEAPHANDLE ref, HEAPHANDLE node, uint16 key = 0);
-
-	HEAPHANDLE FindKey(uint16 key);
-	HEAPHANDLE DeleteKey(uint16 key);
-	byte DeleteNode(HEAPHANDLE node);
-	void DeleteList();
-	void Dump(char*caption = ""); // for debug
-	HEAPHANDLE getFirst() {
-		return _hFirst;
-	}
-	HEAPHANDLE getLast() {
-		return _hLast;
-	}
-	void toHeap(HEAPHANDLE heap);
-	bool isEmpty() {
-		return (_hFirst == 0 && _hLast == 0);
-	}
-	uint16 getSize();
-	void set(HEAPHANDLE first, HEAPHANDLE last){
-		_hFirst = first;
-		_hLast = last;
-	}
-
-};
-
-} // end of namespace

Modified: scummvm/trunk/engines/sci/gui/gui_helpers.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_helpers.h	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/engines/sci/gui/gui_helpers.h	2009-10-04 18:51:01 UTC (rev 44630)
@@ -35,17 +35,7 @@
 
 typedef uint16 GUIHandle;
 
-struct GUINode {
-	GUIHandle next; // heap handle to next node
-	GUIHandle prev; // heap handle to data
-	uint16 key; // maybe also a heap handle
-};
-struct GUINode1 : GUINode {
-	uint16 value;
-};
-
 struct GUIPort {
-	GUINode node; // node struct for list operations
 	int16 top, left;
 	Common::Rect rect;
 	int16 curTop, curLeft;
@@ -67,7 +57,6 @@
 };
 
 struct GUICast {
-	GUINode node;
 	uint16 view;
 	uint16 loop;
 	uint16 cel;

Modified: scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp	2009-10-04 18:51:01 UTC (rev 44630)
@@ -23,6 +23,7 @@
  *
  */
 
+#include "common/algorithm.h"	// for Common::find()
 #include "common/util.h"
 
 #include "sci/sci.h"
@@ -68,7 +69,7 @@
 	_wmgrPort->curTop = 0;
 	_wmgrPort->curLeft = 0;
 
-	windowList.AddToFront(wmgrPortH);
+	windowList.push_front(wmgrPortH);
 
 	_picWind = NewWindow(s_picRect, 0, 0, kTransparent | kNoFrame, 0, 1);
 }
@@ -77,7 +78,7 @@
 }
 
 int16 SciGUIwindowMgr::isFrontWindow(GUIWindow *pWnd) {
-	if (heap2Ptr(windowList.getLast()) == (byte *)pWnd)
+	if (heap2Ptr(windowList.back()) == (byte *)pWnd)
 		return 1;
 	return 0;
 }
@@ -85,10 +86,14 @@
 void SciGUIwindowMgr::SelectWindow(HEAPHANDLE hh) {
 	GUIPort *port = (GUIPort *)heap2Ptr(hh);
 	_gfx->SetPort(port);
-	if (hh != windowList.getLast()) { // selecting not topmost window
-		GUIWindow *prevwnd = (GUIWindow *)heap2Ptr(port->node.prev);
+	if (hh != windowList.back()) { // selecting not topmost window
+		Common::List<HEAPHANDLE>::iterator curWindowIterator = Common::find(windowList.begin(), windowList.end(), hh);
+		Common::List<HEAPHANDLE>::iterator prevWindowIterator = --curWindowIterator;
+		curWindowIterator++; // restore iterator position
+		GUIWindow *prevwnd = (GUIWindow *)heap2Ptr(*prevWindowIterator);
 		BeginUpdate(prevwnd);
-		windowList.MoveToEnd(hh);
+		windowList.erase(curWindowIterator);
+		windowList.push_back(hh);
 		EndUpdate(prevwnd);
 	}
 	_gfx->SetPort(port);
@@ -96,19 +101,23 @@
 
 void SciGUIwindowMgr::BeginUpdate(GUIWindow *wnd) {
 	GUIPort *oldPort = _gfx->SetPort(_wmgrPort);
-	GUIWindow *node = (GUIWindow *)heap2Ptr(windowList.getLast());
+	Common::List<HEAPHANDLE>::iterator curWindowIterator = windowList.end();
+	GUIWindow *node = (GUIWindow *)heap2Ptr(*curWindowIterator);
 	while (node != wnd) {
 		UpdateWindow(node);
-		node = (GUIWindow *)heap2Ptr(node->node.prev);
+		curWindowIterator--;	// previous node
+		node = (GUIWindow *)heap2Ptr(*curWindowIterator);
 	}
 	_gfx->SetPort(oldPort);
 }
 
 void SciGUIwindowMgr::EndUpdate(GUIWindow *wnd) {
 	GUIPort *oldPort = _gfx->SetPort(_wmgrPort);
-	GUIWindow *last = (GUIWindow *)heap2Ptr(windowList.getLast());
+	Common::List<HEAPHANDLE>::iterator curWindowIterator = windowList.end();
+	GUIWindow *last = (GUIWindow *)heap2Ptr(*curWindowIterator);
 	while (wnd != last) {
-		wnd = (GUIWindow *)heap2Ptr(wnd->node.next);
+		curWindowIterator++;	// next node
+		wnd = (GUIWindow *)heap2Ptr(*curWindowIterator);
 		UpdateWindow(wnd);
 	}
 	_gfx->SetPort(oldPort);
@@ -124,9 +133,9 @@
 	}
 	heapClearPtr(hWnd);
 	if (style & kTopmost)
-		windowList.AddToFront(hWnd);
+		windowList.push_front(hWnd);
 	else
-		windowList.AddToEnd(hWnd);
+		windowList.push_back(hWnd);
 	GUIWindow *pwnd = (GUIWindow *)heap2Ptr(hWnd);
 	_gfx->OpenPort((GUIPort *)pwnd);
 	r = dims;
@@ -250,8 +259,8 @@
 //	else
 //		g_sci->ReAnimate(&pwnd->dims);
 	HEAPHANDLE hh = ptr2heap((byte *)pWnd);
-	windowList.DeleteNode(hh);
-	SelectWindow(windowList.getLast());
+	windowList.remove(hh);
+	SelectWindow(windowList.back());
 	if (pWnd->hTitle)
 		heapDisposePtr(pWnd->hTitle);
 	heapDisposePtr(hh);

Modified: scummvm/trunk/engines/sci/gui/gui_windowmgr.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_windowmgr.h	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/engines/sci/gui/gui_windowmgr.h	2009-10-04 18:51:01 UTC (rev 44630)
@@ -23,10 +23,13 @@
  *
  */
 
-#include "sci/gui/gui_dbllist.h"
+#include "common/list.h"
 
 namespace Sci {
 
+// TODO: remove HEAPHANDLE and make a list of GUIWindow pointers instead
+typedef uint16 HEAPHANDLE;
+
 class SciGUIwindowMgr {
 public:
 	SciGUIwindowMgr(EngineState *state, SciGUIgfx *gfx);
@@ -48,7 +51,7 @@
 	EngineState *_s;
 	SciGUIgfx *_gfx;
 
-	DblList windowList;
+	Common::List<HEAPHANDLE> windowList;
 };
 
 } // end of namespace Sci

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2009-10-04 18:38:18 UTC (rev 44629)
+++ scummvm/trunk/engines/sci/module.mk	2009-10-04 18:51:01 UTC (rev 44630)
@@ -56,7 +56,6 @@
 	gfx/res_view.o \
 	gfx/seq_decoder.o \
 	gui/gui.o \
-	gui/gui_dbllist.o \
 	gui/gui_font.o \
 	gui/gui_gfx.o \
 	gui/gui_memmgr.o \


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