diff options
author | Travis Howell | 2005-03-28 10:02:22 +0000 |
---|---|---|
committer | Travis Howell | 2005-03-28 10:02:22 +0000 |
commit | 11e1e246cc4022f088a9e68bcd4d44f7d6574932 (patch) | |
tree | c3cd310936a0d650401849c5230fd9190fa0d83d /scumm/script_v72he.cpp | |
parent | 26f41248737a056b5cf9efbaf7aae1873bb24166 (diff) | |
download | scummvm-rg350-11e1e246cc4022f088a9e68bcd4d44f7d6574932.tar.gz scummvm-rg350-11e1e246cc4022f088a9e68bcd4d44f7d6574932.tar.bz2 scummvm-rg350-11e1e246cc4022f088a9e68bcd4d44f7d6574932.zip |
findObject in HE72+ only checks object bounds
findObject in He70/71 only needs additional polygon check
svn-id: r17270
Diffstat (limited to 'scumm/script_v72he.cpp')
-rw-r--r-- | scumm/script_v72he.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index dcffaf9fac..ff6a25e96c 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -244,7 +244,7 @@ void ScummEngine_v72he::setupOpcodes() { OPCODE(o72_verbOps), OPCODE(o6_getActorFromXY), /* A0 */ - OPCODE(o70_findObject), + OPCODE(o72_findObject), OPCODE(o6_pseudoRoom), OPCODE(o6_getActorElevation), OPCODE(o6_getVerbEntrypoint), @@ -654,6 +654,44 @@ byte *ScummEngine_v72he::findWrappedBlock(uint32 tag, byte *ptr, int state, bool } } +int ScummEngine_v72he::findObject(int x, int y, int num, int *args) { + int b, cls, i, result; + + for (i = 1; i < _numLocalObjects; i++) { + result = 0; + if ((_objs[i].obj_nr < 1) || getClass(_objs[i].obj_nr, kObjectClassUntouchable)) + continue; + + // Check polygon bounds + if (_wiz.polygonDefined(_objs[i].obj_nr)) { + if (_wiz.polygonHit(_objs[i].obj_nr, x, y)) + result = _objs[i].obj_nr; + else if (VAR_POLYGONS_ONLY != 0xFF && VAR(VAR_POLYGONS_ONLY)) + continue; + } + + if (!result) { + // Check object bounds + if (_objs[i].x_pos <= x && _objs[i].width + _objs[i].x_pos > x && + _objs[i].y_pos <= y && _objs[i].height + _objs[i].y_pos > y) + result = _objs[i].obj_nr; + } + + if (result) { + if (!num) + return result; + + // Check object class + cls = args[0]; + b = getClass(i, cls); + if ((cls & 0x80 && b) || (!(cls & 0x80) && !b)) + return result; + } + } + + return 0; +} + void ScummEngine_v72he::o72_pushDWord() { int a; if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) { @@ -1334,6 +1372,13 @@ void ScummEngine_v72he::o72_verbOps() { } } +void ScummEngine_v72he::o72_findObject() { + int y = pop(); + int x = pop(); + int r = findObject(x, y, 0, 0); + push(r); +} + void ScummEngine_v72he::o72_arrayOps() { byte subOp = fetchScriptByte(); int array = fetchScriptWord(); |