[Scummvm-cvs-logs] SF.net SVN: scummvm: [24524] scummvm/trunk/engines/agos

kirben at users.sourceforge.net kirben at users.sourceforge.net
Fri Oct 27 05:07:25 CEST 2006


Revision: 24524
          http://svn.sourceforge.net/scummvm/?rev=24524&view=rev
Author:   kirben
Date:     2006-10-26 20:07:18 -0700 (Thu, 26 Oct 2006)

Log Message:
-----------
Add code for look opcode in elvira 1

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/items.cpp
    scummvm/trunk/engines/agos/script_e1.cpp
    scummvm/trunk/engines/agos/subroutine.cpp

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-10-27 01:55:06 UTC (rev 24523)
+++ scummvm/trunk/engines/agos/agos.h	2006-10-27 03:07:18 UTC (rev 24524)
@@ -701,6 +701,10 @@
 	// Waxworks specific
 	void moveDirn_ww(Item *i, uint x);
 
+	int16 levelOf(Item *item); 
+	int16 moreText(Item *i);
+	void lobjFunc(Item *i, const char *f);
+
 	int canPlace(Item *x, Item *y);
 	int contains(Item *a, Item *b);
 	int sizeContents(Item *x);

Modified: scummvm/trunk/engines/agos/items.cpp
===================================================================
--- scummvm/trunk/engines/agos/items.cpp	2006-10-27 01:55:06 UTC (rev 24523)
+++ scummvm/trunk/engines/agos/items.cpp	2006-10-27 03:07:18 UTC (rev 24524)
@@ -102,7 +102,7 @@
 	p->size = 0;
 	p->weight = 0;
 	p->strength = 6000;
-	//p->flag = xxx;
+	p->flags = 1; // Male
 	p->level = 1;
 	p->score = 0;
 

Modified: scummvm/trunk/engines/agos/script_e1.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_e1.cpp	2006-10-27 01:55:06 UTC (rev 24523)
+++ scummvm/trunk/engines/agos/script_e1.cpp	2006-10-27 03:07:18 UTC (rev 24524)
@@ -346,7 +346,35 @@
 
 void AGOSEngine::oe1_look() {
 	// 96: look
-	debug(0, "oe1_look: stub");
+	Item *i = derefItem(me()->parent);
+	if (i == NULL)
+		return;
+
+	SubRoom *r = (SubRoom *)findChildOfType(i, 1);
+	SubObject *o = (SubObject *)findChildOfType(i, 2);
+	SubPlayer *p = (SubPlayer *)findChildOfType(i, 3);
+	if (p == NULL)
+		return;
+
+	if ((o) && (!r)) {
+		showMessageFormat("In the %s\n", (const char *)getStringPtrByID(i->itemName));
+	} else if (p) {
+		showMessageFormat("Carried by %s\n", (const char *)getStringPtrByID(i->itemName));
+	}
+
+	if (r) {
+		showMessageFormat("%s", (const char *)getStringPtrByID(r->roomLong));
+	}
+
+	showMessageFormat("\n");
+
+	Item *l = derefItem(i->child);
+	if (l) {
+		lobjFunc(l, "You can see ");	/* Show objects */
+	}
+	if (r && (r->flags & 4) && levelOf(i) < 10000) {
+		shutdown();
+	}
 }
 
 void AGOSEngine::oe1_doClass() {
@@ -714,4 +742,60 @@
 	mouseOn();
 }
 
+int16 AGOSEngine::levelOf(Item *item) {
+	SubPlayer *p = (SubPlayer *) findChildOfType(item, 3);
+	if (p == NULL)
+		return 0;
+
+	return p->level;
+}
+
+int16 AGOSEngine::moreText(Item *i) {
+	SubObject *o;
+	i = derefItem(i->next);
+
+	while (i) {
+		o = (SubObject *)findChildOfType(i, 2);
+		if ((o) && (o->objectFlags & 1))
+			goto l1;
+		if (i != me())
+			return 1;
+	l1:	i = derefItem(i->next);
+	}
+
+	return 0;
+}
+
+void AGOSEngine::lobjFunc(Item *i, const char *f) {
+	int n = 0;
+	SubObject *o;
+
+	while (i) {
+		o = (SubObject *)findChildOfType(i, 2);
+		if ((o) && (o->objectFlags & 1))
+			goto l1;
+		if (i == me())
+			goto l1;
+		if (n == 0) {
+			if (f)
+				showMessageFormat("%s", f);
+			n = 1;
+		} else {
+			if (moreText(i))
+				showMessageFormat(", ");
+			else
+				showMessageFormat(" and ");
+		}
+		showMessageFormat("%s", (const char *)getStringPtrByID(i->itemName));
+l1:		i = derefItem(i->next);
+	}
+	if (f) {
+		if (n == 1)
+			showMessageFormat(".\n");
+	} else {
+		if (n == 0)
+			showMessageFormat("nothing");
+	}
+}
+
 } // End of namespace AGOS

Modified: scummvm/trunk/engines/agos/subroutine.cpp
===================================================================
--- scummvm/trunk/engines/agos/subroutine.cpp	2006-10-27 01:55:06 UTC (rev 24523)
+++ scummvm/trunk/engines/agos/subroutine.cpp	2006-10-27 03:07:18 UTC (rev 24524)
@@ -670,7 +670,7 @@
 		int16 tmp = in->readUint16BE();
 		WRITE_BE_UINT16(q, tmp);
 		while (tmp != 10000) {
-			if (READ_BE_UINT16(q) == 0xC6) {
+			if (READ_BE_UINT16(q) == 198) {
 				in->readUint16BE();
 			} else {
 				q = readSingleOpcode(in, q);
@@ -679,9 +679,6 @@
 			tmp = in->readUint16BE();
 			WRITE_BE_UINT16(q, tmp);
 		}
-
-		size = (q - line_buffer + 1) * 2;
-		memcpy(allocateTable(size), line_buffer, size);
 	} else {
 		while ((*q = in->readByte()) != 0xFF) {
 			if (*q == 87) {
@@ -690,10 +687,10 @@
 				q = readSingleOpcode(in, q);
 			}
 		}
-
-		size = (q - line_buffer + 1);
-		memcpy(allocateTable(size), line_buffer, size);
 	}
+
+	size = (q - line_buffer + 1);
+	memcpy(allocateTable(size), line_buffer, size);
 }
 
 byte *AGOSEngine::readSingleOpcode(Common::SeekableReadStream *in, byte *ptr) {


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