示例#1
0
void AGOSEngine::handleVerbClicked(uint verb) {
	Subroutine *sub;
	int result;

	if (shouldQuit())
		return;

	_objectItem = _hitAreaObjectItem;
	if (_objectItem == _dummyItem2) {
		_objectItem = me();
	}
	if (_objectItem == _dummyItem3) {
		_objectItem = derefItem(me()->parent);
	}

	_subjectItem = _hitAreaSubjectItem;
	if (_subjectItem == _dummyItem2) {
		_subjectItem = me();
	}
	if (_subjectItem == _dummyItem3) {
		_subjectItem = derefItem(me()->parent);
	}

	if (_subjectItem) {
		_scriptNoun1 = _subjectItem->noun;
		_scriptAdj1 = _subjectItem->adjective;
	} else {
		_scriptNoun1 = -1;
		_scriptAdj1 = -1;
	}

	if (_objectItem) {
		_scriptNoun2 = _objectItem->noun;
		_scriptAdj2 = _objectItem->adjective;
	} else {
		_scriptNoun2 = -1;
		_scriptAdj2 = -1;
	}

	_scriptVerb = _verbHitArea;

	sub = getSubroutineByID(0);
	if (sub == NULL)
		return;

	result = startSubroutine(sub);
	if (result == -1)
		showMessageFormat("I don't understand");

	_runScriptReturn1 = false;

	sub = getSubroutineByID(100);
	if (sub)
		startSubroutine(sub);

	if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP)
		_runScriptReturn1 = false;

	permitInput();
}
示例#2
0
void AGOSEngine::o_process() {
	// 71: start subroutine
	uint16 id = getVarOrWord();

	if (!_copyProtection && getGameType() == GType_WW && id == 71) {
		// Copy protection was disabled in Good Old Games release
		return;
	}

	Subroutine *sub = getSubroutineByID(id);
	if (sub != NULL) {
#ifdef __DS__
		// HACK: Skip scene of Simon reading letter from Calypso
		// due to speech segment been too large to fit into memory
		if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE) &&
			getPlatform() == Common::kPlatformWindows && sub->id == 2922) {
			// set parent special
			_noParentNotify = true;
			setItemParent(derefItem(16), me());
			_noParentNotify = false;

			// set parent special
			_noParentNotify = true;
			setItemParent(derefItem(14), me());
			_noParentNotify = false;

			// set item parent
			setItemParent(derefItem(12), me());

			return;
		}
#endif
		startSubroutine(sub);
	}
}
示例#3
0
void AGOSEngine::unlinkItem(Item *item) {
	Item *first, *parent, *next;

	// can't unlink item without parent
	if (item->parent == 0)
		return;

	// get parent and first child of parent
	parent = derefItem(item->parent);
	first = derefItem(parent->child);

	// the node to remove is first in the parent's children?
	if (first == item) {
		parent->child = item->next;
		item->parent = 0;
		item->next = 0;
		return;
	}

	for (;;) {
		if (!first)
			error("unlinkItem: parent empty");
		if (first->next == 0)
			error("unlinkItem: parent does not contain child");

		next = derefItem(first->next);
		if (next == item) {
			first->next = next->next;
			item->parent = 0;
			item->next = 0;
			return;
		}
		first = next;
	}
}
示例#4
0
void AGOSEngine::o_getParent() {
	// 90: set minusitem to parent
	Item *i = getNextItemPtr();
	if (getVarOrByte() == 1)
		_subjectItem = derefItem(i->parent);
	else
		_objectItem = derefItem(i->parent);
}
示例#5
0
void AGOSEngine::o_getChildren() {
	// 92: set minusitem to child
	Item *i = getNextItemPtr();
	if (getVarOrByte() == 1)
		_subjectItem = derefItem(i->child);
	else
		_objectItem = derefItem(i->child);
}
示例#6
0
void AGOSEngine::o_getNext() {
	// 91: set minusitem to next
	Item *i = getNextItemPtr();
	if (getVarOrByte() == 1)
		_subjectItem = derefItem(i->next);
	else
		_objectItem = derefItem(i->next);
}
示例#7
0
int AGOSEngine::contains(Item *a, Item *b) {
    while (derefItem(b->parent)) {
        if (derefItem(b->parent) == a)
            return 1;
        b = derefItem(b->parent);
    }

    return 0;
}
示例#8
0
void AGOSEngine_Waxworks::oww_goto() {
	// 55: set itemA parent
	uint item = getNextItemID();
	if (derefItem(item) == NULL) {
		setItemParent(me(), NULL);
		loadRoomItems(item);
	}
	setItemParent(me(), derefItem(item));
}
示例#9
0
void AGOSEngine_Waxworks::oww_whereTo() {
	// 85: where to
	Item *i = getNextItemPtr();
	int16 d = getVarOrByte();
	int16 f = getVarOrByte();

	if (f == 1)
		_subjectItem = derefItem(getExitOf(i, d));
	else
		_objectItem = derefItem(getExitOf(i, d));
}
示例#10
0
int AGOSEngine::weightRec(Item *x, int d) {
    int n = weightOf(x);
    Item *o;

    if (d > 32)
        return 0;
    o = derefItem(x->child);
    while (o) {
        n += weightRec(o, d + 1);
        o = derefItem(o->next);
    }

    return n;
}
示例#11
0
Item *AGOSEngine::nextInByClass(Item *i, int16 m) {
	i = _findNextPtr;
	while (i) {
		if (i->classFlags & m) {
			_findNextPtr = derefItem(i->next);
			return i;
		}
		if (m == 0) {
			_findNextPtr = derefItem(i->next);
			return i;
		}
		i = derefItem(i->next);
	}
	return NULL;
}
示例#12
0
int AGOSEngine::sizeRec(Item *x, int d) {
    Item *o;
    int n = 0;

    o = derefItem(x->child);

    if (d > 32)
        return(0);
    while (o) {
        n += sizeOfRec(o,d);
        o = derefItem(o->child);
    }

    return n;
}
示例#13
0
int AGOSEngine_Elvira2::canPlace(Item *x, Item *y) {
    Item *z = derefItem(x->parent);

    SubObject *o = (SubObject *)findChildOfType(y, kObjectType);
    int ct;
    int cap = 0;

    if (o == NULL)
        return 0;	/* Fits Fine */

    xPlace(x,NULL);		/* Avoid disturbing figures */
    if (o)
        cap = sizeContents(y);

    xPlace(x, z);
    if ((o) && (o->objectFlags & kOFVolume)) {
        ct = getOffsetOfChild2Param(o, kOFVolume);
        cap = o->objectFlagValue[ct] - cap;
        cap -= sizeOfRec(x, 0);	/* - size of item going in */
        if (cap < 0)
            return -1;	/* Too big to fit */
    }

    return 0;
}
示例#14
0
int AGOSEngine::canPlace(Item *x, Item *y) {
    Item *z = derefItem(x->parent);

    SubPlayer *p = (SubPlayer *)findChildOfType(y, kPlayerType);
    SubContainer *c = (SubContainer *)findChildOfType(y, kContainerType);
    int cap = 0;
    int wt;

    if ((c == NULL) && (p == NULL))
        return 0;		/* Fits Fine */

    xPlace(x, NULL);		/* Avoid disturbing figures */
    if (c)
        cap = sizeContents(y);

    wt = weightOf(y);
    xPlace(x, z);
    if (c) {
        cap = c->volume - cap;
        cap -= sizeOfRec(x, 0);	/* - size of item going in */
        if (cap < 0)
            return -1;	/* Too big to fit */
    }
    if (p) {
        if (wt + weightOf(x) > p->strength * 10)
            return -2;	/* Too heavy */
    }

    return 0;
}
示例#15
0
void AGOSEngine::synchChain(Item *i) {
	SubChain *c = (SubChain *)findChildOfType(i, kChainType);
	while (c) {
		setItemState(derefItem(c->chChained), i->state);
		c = (SubChain *)nextSub((Child *)c, kChainType);
	}
}
示例#16
0
Item *AGOSEngine::getNextItemPtr() {
	int a = getNextWord();
	switch (a) {
	case -1:
		return _subjectItem;
	case -3:
		return _objectItem;
	case -5:
		return me();
	case -7:
		return actor();
	case -9:
		return derefItem(me()->parent);
	default:
		return derefItem(a);
	}
}
示例#17
0
void AGOSEngine::setItemParent(Item *item, Item *parent) {
	Item *old_parent = derefItem(item->parent);

	if (item == parent)
		error("setItemParent: Trying to set item as its own parent");

	// unlink it if it has a parent
	if (old_parent)
		unlinkItem(item);
	itemChildrenChanged(old_parent);
	linkItem(item, parent);
	itemChildrenChanged(parent);
}
示例#18
0
Item *AGOSEngine::findMaster(int16 a, int16 n) {
	uint j;

	for (j = 1; j < _itemArraySize; j++) {
		Item *item = derefItem(j);
		if (item == NULL)
			continue;

		if (wordMatch(item, a, n))
			return item;
	}

	return NULL;
}
示例#19
0
Item *AGOSEngine::nextMaster(Item *i, int16 a, int16 n) {
	uint j;
	uint first = itemPtrToID(i) + 1;

	for (j = first; j < _itemArraySize; j++) {
		Item *item = derefItem(j);
		if (item == NULL)
			continue;

		if (wordMatch(item, a, n))
			return item;
	}

	return NULL;
}
示例#20
0
Item *AGOSEngine::getNextItemPtrStrange() {
	int a = getNextWord();
	switch (a) {
	case -1:
		return _subjectItem;
	case -3:
		return _objectItem;
	case -5:
		return _dummyItem2;
	case -7:
		return NULL;
	case -9:
		return _dummyItem3;
	default:
		return derefItem(a);
	}
}
示例#21
0
Child *AGOSEngine::findChildOfType(Item *i, uint type) {
	Item *b = NULL;
	Child *child = i->children;

	for (; child; child = child->next) {
		if (child->type == type)
			return child;
		if (child->type == 255)
			b = derefItem(((SubInherit *)(child))->inMaster);
	}
	if (b) {
		child = b->children;
		for (; child; child = child->next) {
			if (child->type == type)
				return child;
		}
	}

	return NULL;
}
示例#22
0
void AGOSEngine_Elvira2::oe2_getDollar2() {
	// 175
	_showPreposition = true;

	setup_cond_c_helper();

	_objectItem = _hitAreaObjectItem;

	if (_objectItem == _dummyItem2)
		_objectItem = me();

	if (_objectItem == _dummyItem3)
		_objectItem = derefItem(me()->parent);

	if (_objectItem != NULL) {
		_scriptNoun2 = _objectItem->noun;
		_scriptAdj2 = _objectItem->adjective;
	} else {
		_scriptNoun2 = -1;
		_scriptAdj2 = -1;
	}

	_showPreposition = false;
}
示例#23
0
void AGOSEngine::xPlace(Item *x, Item *y) {
    if (derefItem(x->parent))
        unlinkItem(x);

    linkItem(x, y);
}
示例#24
0
void AGOSEngine::o_putBy() {
	// 58: make siblings
	Item *item = getNextItemPtr();
	setItemParent(item, derefItem(getNextItemPtr()->parent));
}