[Scummvm-cvs-logs] SF.net SVN: scummvm: [23944] scummvm/trunk/engines/simon

kirben at users.sourceforge.net kirben at users.sourceforge.net
Wed Sep 20 08:39:38 CEST 2006


Revision: 23944
          http://svn.sourceforge.net/scummvm/?rev=23944&view=rev
Author:   kirben
Date:     2006-09-19 23:39:27 -0700 (Tue, 19 Sep 2006)

Log Message:
-----------
Fix crashes during WW startup

Modified Paths:
--------------
    scummvm/trunk/engines/simon/game.cpp
    scummvm/trunk/engines/simon/intern.h
    scummvm/trunk/engines/simon/items.cpp
    scummvm/trunk/engines/simon/module.mk
    scummvm/trunk/engines/simon/res.cpp
    scummvm/trunk/engines/simon/simon.cpp
    scummvm/trunk/engines/simon/simon.h

Added Paths:
-----------
    scummvm/trunk/engines/simon/rooms.cpp

Modified: scummvm/trunk/engines/simon/game.cpp
===================================================================
--- scummvm/trunk/engines/simon/game.cpp	2006-09-20 02:50:40 UTC (rev 23943)
+++ scummvm/trunk/engines/simon/game.cpp	2006-09-20 06:39:27 UTC (rev 23944)
@@ -590,6 +590,7 @@
 static GameFileDescription WAXWORKS_GameFiles[] = {
 	{ "gamepc",		GAME_BASEFILE,	"7751e9358e894e32ef40ef3b3bae0f2a"},
 	{ "icon.dat",		GAME_ICONFILE,	"ef1b8ad3494cf103dc10a99fe152ef9a"},
+	{ "roomslst",		GAME_RMSLFILE,	"e3758c46ab8f3c23a1ac012bd607108d"},
 	{ "stripped.txt",	GAME_STRFILE,	"f259e3e07a1cde8d0404a767d815e12c"},
 	{ "tbllist",		GAME_TBLFILE,	"95c44bfc380770a6b6dd0dfcc69e80a0"},
 	{ "xtbllist",		GAME_XTBLFILE,	"6c7b3db345d46349a5226f695c03e20f"},

Modified: scummvm/trunk/engines/simon/intern.h
===================================================================
--- scummvm/trunk/engines/simon/intern.h	2006-09-20 02:50:40 UTC (rev 23943)
+++ scummvm/trunk/engines/simon/intern.h	2006-09-20 06:39:27 UTC (rev 23944)
@@ -176,10 +176,11 @@
 	GAME_ICONFILE = 1 << 1,
 	GAME_GMEFILE  = 1 << 2,
 	GAME_STRFILE  = 1 << 3,
-	GAME_TBLFILE  = 1 << 4,
-	GAME_XTBLFILE  = 1 << 5,
+	GAME_RMSLFILE = 1 << 4,
+	GAME_TBLFILE  = 1 << 5,
+	GAME_XTBLFILE  = 1 << 6,
 
-	GAME_GFXIDXFILE = 1 << 6
+	GAME_GFXIDXFILE = 1 << 7
 };
 
 enum GameIds {

Modified: scummvm/trunk/engines/simon/items.cpp
===================================================================
--- scummvm/trunk/engines/simon/items.cpp	2006-09-20 02:50:40 UTC (rev 23943)
+++ scummvm/trunk/engines/simon/items.cpp	2006-09-20 06:39:27 UTC (rev 23944)
@@ -679,7 +679,12 @@
 
 void SimonEngine::o_goto() {
 	// 55: set itemA parent
-	setItemParent(me(), getNextItemPtr());
+	uint item = getNextItemID();
+	if (_itemArrayPtr[item] == NULL) {
+		setItemParent(me(), NULL);
+		loadRoomItems(item);
+	}
+	setItemParent(me(), _itemArrayPtr[item]);
 }
 
 void SimonEngine::o_oset() {
@@ -1542,38 +1547,6 @@
 // Waxworks 1 Opcodes
 // -----------------------------------------------------------------------
 
-uint16 SimonEngine::getDoorState(Item *item, uint16 d) {
-	uint16 mask = 3;
-	uint16 n;
-
-	SubRoom *subRoom = (SubRoom *)findChildOfType(item, 1);
-	if (subRoom == NULL)
-	    return 0;
-
-	d <<= 1;
-	mask <<= d;
-	n = subRoom->roomExitStates & mask;
-	n >>= d;
-
-	return n;
-}
-
-uint16 SimonEngine::getExitOf(Item *item, uint16 d) {
-	uint16 x;
-	uint16 y = 0;
-
-	SubRoom *subRoom = (SubRoom *)findChildOfType(item, 1);
-	if (subRoom == NULL)
-		return 0;
-	x = d;
-	while (x > y) {
-		if (getDoorState(item, y) == 0)
-			d--;
-		y++;
-	}
-	return subRoom->roomExit[d];
-}
-
 void SimonEngine::oww_whereTo() {
 	// 85: where to
 	Item *i = getNextItemPtr();

Modified: scummvm/trunk/engines/simon/module.mk
===================================================================
--- scummvm/trunk/engines/simon/module.mk	2006-09-20 02:50:40 UTC (rev 23943)
+++ scummvm/trunk/engines/simon/module.mk	2006-09-20 06:39:27 UTC (rev 23944)
@@ -15,6 +15,7 @@
 	midiparser_s1d.o \
  	oracle.o \
 	res.o \
+	rooms.o \
 	saveload.o \
 	simon.o \
 	sound.o \

Modified: scummvm/trunk/engines/simon/res.cpp
===================================================================
--- scummvm/trunk/engines/simon/res.cpp	2006-09-20 02:50:40 UTC (rev 23943)
+++ scummvm/trunk/engines/simon/res.cpp	2006-09-20 06:39:27 UTC (rev 23944)
@@ -269,27 +269,6 @@
 
 	in.close();
 
-	if (getGameType() == GType_WW) {
-		/* Read list of TABLE resources */
-		in.open(getFileName(GAME_XTBLFILE));
-		if (in.isOpen() == false) {
-			error("loadGamePcFile: Can't load table resources file '%s'", getFileName(GAME_XTBLFILE));
-		}
-
-		file_size = in.size();
-
-		_xtblList = (byte *)malloc(file_size);
-		if (_xtblList == NULL)
-			error("loadGamePcFile: Out of memory for strip table list");
-		in.read(_xtblList, file_size);
-		in.close();
-
-		/* Remember the current state */
-		_xsubroutineListOrg = _subroutineList;
-		_xtablesHeapPtrOrg = _tablesHeapPtr;
-		_xtablesHeapCurPosOrg = _tablesHeapCurPos;
-	}
-
 	/* Read list of TABLE resources */
 	in.open(getFileName(GAME_TBLFILE));
 	if (in.isOpen() == false) {
@@ -323,6 +302,43 @@
 		error("loadGamePcFile: Out of memory for strip text list");
 	in.read(_strippedTxtMem, file_size);
 	in.close();
+
+	if (getGameType() != GType_WW)
+		return;
+
+	/* Read list of ROOM ITEMS resources */
+	in.open(getFileName(GAME_RMSLFILE));
+	if (in.isOpen() == false) {
+		error("loadGamePcFile: Can't load room resources file '%s'", getFileName(GAME_XTBLFILE));
+	}
+
+	file_size = in.size();
+
+	_roomsList = (byte *)malloc(file_size);
+	if (_roomsList == NULL)
+		error("loadGamePcFile: Out of memory for room items list");
+	in.read(_roomsList, file_size);
+	in.close();
+
+	/* Read list of XTABLE resources */
+	in.open(getFileName(GAME_XTBLFILE));
+	if (in.isOpen() == false) {
+		error("loadGamePcFile: Can't load xtable resources file '%s'", getFileName(GAME_XTBLFILE));
+	}
+
+	file_size = in.size();
+
+	_xtblList = (byte *)malloc(file_size);
+	if (_xtblList == NULL)
+		error("loadGamePcFile: Out of memory for strip xtable list");
+	in.read(_xtblList, file_size);
+	in.close();
+
+	/* Remember the current state */
+	_xsubroutineListOrg = _subroutineList;
+	_xtablesHeapPtrOrg = _tablesHeapPtr;
+	_xtablesHeapCurPosOrg = _tablesHeapCurPos;
+
 }
 
 void SimonEngine::readGamePcText(Common::File *in) {

Added: scummvm/trunk/engines/simon/rooms.cpp
===================================================================
--- scummvm/trunk/engines/simon/rooms.cpp	                        (rev 0)
+++ scummvm/trunk/engines/simon/rooms.cpp	2006-09-20 06:39:27 UTC (rev 23944)
@@ -0,0 +1,114 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001  Ludvig Strigeus
+ * Copyright (C) 2001-2006 The ScummVM project
+ *
+ * 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/stdafx.h"
+
+#include "simon/simon.h"
+#include "simon/intern.h"
+
+using Common::File;
+
+namespace Simon {
+
+uint16 SimonEngine::getDoorState(Item *item, uint16 d) {
+	uint16 mask = 3;
+	uint16 n;
+
+	SubRoom *subRoom = (SubRoom *)findChildOfType(item, 1);
+	if (subRoom == NULL)
+	    return 0;
+
+	d <<= 1;
+	mask <<= d;
+	n = subRoom->roomExitStates & mask;
+	n >>= d;
+
+	return n;
+}
+
+uint16 SimonEngine::getExitOf(Item *item, uint16 d) {
+	uint16 x;
+	uint16 y = 0;
+
+	SubRoom *subRoom = (SubRoom *)findChildOfType(item, 1);
+	if (subRoom == NULL)
+		return 0;
+	x = d;
+	while (x > y) {
+		if (getDoorState(item, y) == 0)
+			d--;
+		y++;
+	}
+	return subRoom->roomExit[d];
+}
+
+bool SimonEngine::loadRoomItems(uint item) {
+	byte *p;
+	uint i, min_num, max_num;
+	char filename[30];
+	File in;
+
+	p = _roomsList;
+	if (p == NULL)
+		return 0;
+
+	while (*p) {
+		for (i = 0; *p; p++, i++)
+			filename[i] = *p;
+		filename[i] = 0;
+		p++;
+
+		for (;;) {
+			min_num = (p[0] * 256) | p[1];
+			p += 2;
+
+			if (min_num == 0)
+				break;
+
+			max_num = (p[0] * 256) | p[1];
+			p += 2;
+
+			if (item >= min_num && item <= max_num) {
+
+				in.open(filename);
+				if (in.isOpen() == false) {
+					error("loadRoomItems: Can't load rooms file '%s'", filename);
+				}
+
+				for (i = min_num; i <= max_num; i++) {
+					_itemArrayPtr[i] = (Item *)allocateItem(sizeof(Item));
+					in.readUint16BE();
+					readItemFromGamePc(&in, _itemArrayPtr[i]);
+				}
+				in.close();
+
+				return 1;
+			}
+		}
+	}
+
+	debug(1,"loadRoomItems: didn't find %d", item);
+	return 0;
+}
+
+} // End of namespace Simon


Property changes on: scummvm/trunk/engines/simon/rooms.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp	2006-09-20 02:50:40 UTC (rev 23943)
+++ scummvm/trunk/engines/simon/simon.cpp	2006-09-20 06:39:27 UTC (rev 23944)
@@ -105,6 +105,8 @@
 	_stringIdLocalMin = 0;
 	_stringIdLocalMax = 0;
 
+	_roomsList = 0;
+
 	_xtblList = 0;
 	_xtablesHeapPtrOrg = 0;
 	_xtablesHeapCurPosOrg = 0;
@@ -769,7 +771,6 @@
 	case -7:
 		return actor();
 	case -9:
-		assert (derefItem(me()->parent) != NULL);
 		return derefItem(me()->parent);
 	default:
 		return derefItem(a);

Modified: scummvm/trunk/engines/simon/simon.h
===================================================================
--- scummvm/trunk/engines/simon/simon.h	2006-09-20 02:50:40 UTC (rev 23943)
+++ scummvm/trunk/engines/simon/simon.h	2006-09-20 06:39:27 UTC (rev 23944)
@@ -222,6 +222,8 @@
 	byte **_localStringtable;
 	uint _stringIdLocalMin, _stringIdLocalMax;
 
+	byte *_roomsList;
+
 	byte *_xtblList;
 	byte *_xtablesHeapPtrOrg;
 	uint _xtablesHeapCurPosOrg;
@@ -631,6 +633,8 @@
 	bool loadTablesIntoMem(uint subr_id);
 	bool loadXTablesIntoMem(uint subr_id);
 
+	bool loadRoomItems(uint item);
+
 	uint loadTextFile(const char *filename, byte *dst);
 	Common::File *openTablesFile(const char *filename);
 	void closeTablesFile(Common::File *in);


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