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; }
int AGOSEngine::weightOf(Item *x) { SubObject *o = (SubObject *)findChildOfType(x, kObjectType); SubPlayer *p = (SubPlayer *)findChildOfType(x, kPlayerType); if (o) return o->objectWeight; if (p) return p->weight; return 0; }
void AGOSEngine::o_oclear() { // 57: clear child2 fr bit SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); int value = getVarOrByte(); if (subObject != NULL && value >= 16) subObject->objectFlags &= ~(1 << value); }
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); } }
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; }
void AGOSEngine_Elvira2::oe2_pObj() { // 73: print object SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) showMessageFormat("%s", (const char *)getStringPtrByID(subObject->objectFlagValue[0])); }
void AGOSEngine_Feeble::off_screenTextPObj() { // 177: inventory descriptions uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); const char *string_ptr = NULL; TextLocation *tl = NULL; char buf[256]; SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) { string_ptr = (const char *)getStringPtrByID(subObject->objectFlagValue[0]); tl = getTextLocation(vgaSpriteId); } if (subObject != NULL && subObject->objectFlags & kOFVoice) { uint offs = getOffsetOfChild2Param(subObject, kOFVoice); playSpeech(subObject->objectFlagValue[offs], vgaSpriteId); } if (subObject != NULL && (subObject->objectFlags & kOFText) && _subtitles) { if (subObject->objectFlags & kOFNumber) { sprintf(buf, "%d%s", subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)], string_ptr); string_ptr = buf; } if (string_ptr != NULL) printScreenText(vgaSpriteId, color, string_ptr, tl->x, tl->y, tl->width); } }
void AGOSEngine_Waxworks::oww_boxPObj() { // 188: print object name to box SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (subObject != NULL && subObject->objectFlags & kOFText) boxTextMsg((const char *)getStringPtrByID(subObject->objectFlagValue[0])); }
void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) { if (type == kRoomType) { SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, kRoomType, sizeof(SubRoom)); subRoom->roomShort = in->readUint32BE(); subRoom->roomLong = in->readUint32BE(); subRoom->flags = in->readUint16BE(); } else if (type == kObjectType) { SubObject *subObject = (SubObject *)allocateChildBlock(item, kObjectType, sizeof(SubObject)); in->readUint32BE(); in->readUint32BE(); in->readUint32BE(); subObject->objectName = in->readUint32BE(); subObject->objectSize = in->readUint16BE(); subObject->objectWeight = in->readUint16BE(); subObject->objectFlags = in->readUint16BE(); } else if (type == kGenExitType) { SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, kGenExitType, sizeof(SubGenExit)); genExit->dest[0] = (uint16)fileReadItemID(in); genExit->dest[1] = (uint16)fileReadItemID(in); genExit->dest[2] = (uint16)fileReadItemID(in); genExit->dest[3] = (uint16)fileReadItemID(in); genExit->dest[4] = (uint16)fileReadItemID(in); genExit->dest[5] = (uint16)fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); } else if (type == kContainerType) { SubContainer *container = (SubContainer *)allocateChildBlock(item, kContainerType, sizeof(SubContainer)); container->volume = in->readUint16BE(); container->flags = in->readUint16BE(); } else if (type == kChainType) { SubChain *chain = (SubChain *)allocateChildBlock(item, kChainType, sizeof(SubChain)); chain->chChained = (uint16)fileReadItemID(in); } else if (type == kUserFlagType) { setUserFlag(item, 0, in->readUint16BE()); setUserFlag(item, 1, in->readUint16BE()); setUserFlag(item, 2, in->readUint16BE()); setUserFlag(item, 3, in->readUint16BE()); setUserFlag(item, 4, in->readUint16BE()); setUserFlag(item, 5, in->readUint16BE()); setUserFlag(item, 6, in->readUint16BE()); setUserFlag(item, 7, in->readUint16BE()); SubUserFlag *subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); subUserFlag->userItems[0] = (uint16)fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); fileReadItemID(in); } else if (type == kInheritType) { SubInherit *inherit = (SubInherit *)allocateChildBlock(item, kInheritType, sizeof(SubInherit)); inherit->inMaster = (uint16)fileReadItemID(in); } else { error("readItemChildren: invalid type %d", type); } }
int AGOSEngine_Elvira2::weightOf(Item *x) { SubObject *o = (SubObject *)findChildOfType(x, kObjectType); if ((o) && (o->objectFlags & kOFWeight)) { int ct = getOffsetOfChild2Param(o, kOFWeight); return (o->objectFlagValue[ct]); } return 0; }
uint AGOSEngine_Elvira2::itemGetIconNumber(Item *item) { SubObject *child = (SubObject *)findChildOfType(item, kObjectType); uint offs; if (child == NULL || !(child->objectFlags & kOFIcon)) return 0; offs = getOffsetOfChild2Param(child, 0x10); return child->objectFlagValue[offs]; }
int AGOSEngine::sizeOfRec(Item *i, int d) { SubObject *o = (SubObject *)findChildOfType(i, kObjectType); SubPlayer *p = (SubPlayer *)findChildOfType(i, kPlayerType); SubContainer *c = (SubContainer *)findChildOfType(i, kContainerType); if ((c) && (c->flags & 1)) { if (o) return (o->objectSize + sizeRec(i, d + 1)); if (p) return (p->size + sizeRec(i, d + 1)); return (sizeRec(i, d + 1)); } if (o) return (o->objectWeight); if (p) return (p->weight); return 0; }
void AGOSEngine::setUserItem(Item *item, int n, int m) { SubUserFlag *subUserFlag; subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) { subUserFlag = (SubUserFlag *)allocateChildBlock(item, kUserFlagType, sizeof(SubUserFlag)); } if (n == 0) subUserFlag->userItems[n] = m; }
// Elvira 2 specific uint AGOSEngine::menuFor_e2(Item *item) { if (item == NULL || item == _dummyItem2 || item == _dummyItem3) return 0xFFFF; SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (subObject != NULL && subObject->objectFlags & kOFMenu) { uint offs = getOffsetOfChild2Param(subObject, kOFMenu); return subObject->objectFlagValue[offs]; } return _agosMenu; }
void AGOSEngine_Elvira2::oe2_setOValue() { // 158: set item prop Item *item = getNextItemPtr(); SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); uint prop = getVarOrByte(); int value = getVarOrWord(); if (subObject != NULL && subObject->objectFlags & (1 << prop) && prop < 16) { uint offs = getOffsetOfChild2Param(subObject, 1 << prop); subObject->objectFlagValue[offs] = value; } }
int AGOSEngine::getUserItem(Item *item, int n) { SubUserFlag *subUserFlag; subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; if (n < 0 || n > 0) return 0; return subUserFlag->userItems[n]; }
int AGOSEngine::getUserFlag(Item *item, int a) { SubUserFlag *subUserFlag; subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; int max = (getGameType() == GType_ELVIRA1) ? 7 : 3; if (a < 0 || a > max) return 0; return subUserFlag->userFlags[a]; }
void AGOSEngine_Elvira2::oe2_getOValue() { // 157: get item int prop Item *item = getNextItemPtr(); SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); uint prop = getVarOrByte(); if (subObject != NULL && subObject->objectFlags & (1 << prop) && prop < 16) { uint offs = getOffsetOfChild2Param(subObject, 1 << prop); writeNextVarContents(subObject->objectFlagValue[offs]); } else { writeNextVarContents(0); } }
void AGOSEngine::setUserFlag(Item *item, int a, int b) { SubUserFlag *subUserFlag; subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) { subUserFlag = (SubUserFlag *)allocateChildBlock(item, kUserFlagType, sizeof(SubUserFlag)); } if (a < 0 || a > 7) return; subUserFlag->userFlags[a] = b; }
void AGOSEngine_Elvira2::oe2_doTable() { // 143: start item sub Item *i = getNextItemPtr(); SubRoom *r = (SubRoom *)findChildOfType(i, kRoomType); if (r != NULL) { Subroutine *sub = getSubroutineByID(r->subroutine_id); if (sub) { startSubroutine(sub); return; } } if (getGameType() == GType_ELVIRA2) { SubSuperRoom *sr = (SubSuperRoom *)findChildOfType(i, kSuperRoomType); if (sr != NULL) { Subroutine *sub = getSubroutineByID(sr->subroutine_id); if (sub) { startSubroutine(sub); return; } } } }
// Waxworks specific uint AGOSEngine::menuFor_ww(Item *item, uint id) { if (id != 0xFFFF && id < 10 && _textMenu[id] != 0) return _textMenu[id]; if (item == NULL || item == _dummyItem2 || item == _dummyItem3) return _agosMenu; SubObject *subObject = (SubObject *)findChildOfType(item, kObjectType); if (subObject != NULL && subObject->objectFlags & kOFMenu) { uint offs = getOffsetOfChild2Param(subObject, kOFMenu); return subObject->objectFlagValue[offs]; } return _agosMenu; }
int AGOSEngine::getUserFlag1(Item *item, int a) { SubUserFlag *subUserFlag; if (item == NULL || item == _dummyItem2 || item == _dummyItem3) return -1; subUserFlag = (SubUserFlag *)findChildOfType(item, kUserFlagType); if (subUserFlag == NULL) return 0; if (a < 0 || a > 7) return 0; return subUserFlag->userFlags[a]; }
int AGOSEngine_Elvira2::sizeOfRec(Item *i, int d) { SubObject *o = (SubObject *)findChildOfType(i, kObjectType); int ct; if ((o) && (o->objectFlags & kOFSoft)) { if (o->objectFlags & kOFSize) { ct = getOffsetOfChild2Param(o, kOFSize); return o->objectFlagValue[ct] + sizeRec(i, d + 1); } return sizeRec(i, d + 1); } if ((o) && (o->objectFlags & kOFSize)) { ct = getOffsetOfChild2Param(o, kOFSize); return o->objectFlagValue[ct]; } return 0; }
void AGOSEngine_Simon1::os1_screenTextPObj() { // 177: inventory descriptions uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (getFeatures() & GF_TALKIE) { if (subObject != NULL && subObject->objectFlags & kOFVoice) { uint offs = getOffsetOfChild2Param(subObject, kOFVoice); playSpeech(subObject->objectFlagValue[offs], vgaSpriteId); } else if (subObject != NULL && subObject->objectFlags & kOFNumber) { uint offs = getOffsetOfChild2Param(subObject, kOFNumber); playSpeech(subObject->objectFlagValue[offs] + 3550, vgaSpriteId); } } if (subObject != NULL && subObject->objectFlags & kOFText && _subtitles) { const char *stringPtr = (const char *)getStringPtrByID(subObject->objectFlagValue[0]); TextLocation *tl = getTextLocation(vgaSpriteId); char buf[256]; int j, k; if (subObject->objectFlags & kOFNumber) { if (_language == Common::HE_ISR) { j = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)]; k = (j % 10) * 10; k += j / 10; if (!(j % 10)) sprintf(buf,"0%d%s", k, stringPtr); else sprintf(buf,"%d%s", k, stringPtr); } else { sprintf(buf,"%d%s", subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)], stringPtr); } stringPtr = buf; } if (stringPtr != NULL && stringPtr[0] != 0) printScreenText(vgaSpriteId, color, stringPtr, tl->x, tl->y, tl->width); } }
bool SimonEngine::printNameOf(Item *item, uint x, uint y) { SubObject *subObject; const byte *stringPtr; uint16 pixels, w; if (item == 0 || item == _dummyItem2 || item == _dummyItem3) return false; subObject = (SubObject *)findChildOfType(item, 2); if (subObject == NULL) return false; stringPtr = getStringPtrByID(subObject->objectName); if (getGameType() == GType_FF) { getPixelLength((const char *)stringPtr, 400, pixels); w = pixels + 1; x -= w / 2; printScreenText(6, 0, (const char *)stringPtr, x, y, w); } else { showActionString(stringPtr); } return true; }
void AGOSEngine_Simon2::os2_screenTextPObj() { // 177: inventory descriptions uint vgaSpriteId = getVarOrByte(); uint color = getVarOrByte(); SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), kObjectType); if (getFeatures() & GF_TALKIE) { if (subObject != NULL && subObject->objectFlags & kOFVoice) { uint speechId = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFVoice)]; if (subObject->objectFlags & kOFNumber) { uint speechIdOffs = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)]; if (speechId == 116) speechId = speechIdOffs + 115; if (speechId == 92) speechId = speechIdOffs + 98; if (speechId == 99) speechId = 9; if (speechId == 97) { switch (speechIdOffs) { case 12: speechId = 109; break; case 14: speechId = 108; break; case 18: speechId = 107; break; case 20: speechId = 106; break; case 22: speechId = 105; break; case 28: speechId = 104; break; case 90: speechId = 103; break; case 92: speechId = 102; break; case 100: speechId = 51; break; default: error("os2_screenTextPObj: invalid case %d", speechIdOffs); } } } if (_speech) playSpeech(speechId, vgaSpriteId); } } if (subObject != NULL && subObject->objectFlags & kOFText && _subtitles) { const char *stringPtr = (const char *)getStringPtrByID(subObject->objectFlagValue[0]); TextLocation *tl = getTextLocation(vgaSpriteId); char buf[256]; int j, k; if (subObject->objectFlags & kOFNumber) { if (_language == Common::HE_ISR) { j = subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)]; k = (j % 10) * 10; k += j / 10; if (!(j % 10)) sprintf(buf,"0%d%s", k, stringPtr); else sprintf(buf,"%d%s", k, stringPtr); } else { sprintf(buf,"%d%s", subObject->objectFlagValue[getOffsetOfChild2Param(subObject, kOFNumber)], stringPtr); } stringPtr = buf; } if (stringPtr != NULL) printScreenText(vgaSpriteId, color, stringPtr, tl->x, tl->y, tl->width); } }
bool AGOSEngine_Elvira2::hasIcon(Item *item) { SubObject *child = (SubObject *)findChildOfType(item, kObjectType); return (child && (child->objectFlags & kOFIcon) != 0); }
bool AGOSEngine::isPlayer(Item *item) { return findChildOfType(item, kPlayerType) != NULL; }
bool AGOSEngine::isObject(Item *item) { return findChildOfType(item, kObjectType) != NULL; }
bool AGOSEngine::isRoom(Item *item) { return findChildOfType(item, kRoomType) != NULL; }