findObject in HE72+ only checks object bounds
findObject in He70/71 only needs additional polygon check svn-id: r17270
This commit is contained in:
parent
26f4124873
commit
11e1e246cc
7 changed files with 57 additions and 71 deletions
|
@ -666,8 +666,6 @@ protected:
|
||||||
virtual int setupStringArray(int size);
|
virtual int setupStringArray(int size);
|
||||||
void appendSubstring(int dst, int src, int len2, int len);
|
void appendSubstring(int dst, int src, int len2, int len);
|
||||||
|
|
||||||
int findObject(int x, int y, int num, int *args);
|
|
||||||
|
|
||||||
virtual void setCursorFromImg(uint img, uint room, uint imgindex);
|
virtual void setCursorFromImg(uint img, uint room, uint imgindex);
|
||||||
|
|
||||||
/* HE version 70 script opcodes */
|
/* HE version 70 script opcodes */
|
||||||
|
@ -675,7 +673,6 @@ protected:
|
||||||
void o70_pickupObject();
|
void o70_pickupObject();
|
||||||
void o70_getActorRoom();
|
void o70_getActorRoom();
|
||||||
void o70_resourceRoutines();
|
void o70_resourceRoutines();
|
||||||
void o70_findObject();
|
|
||||||
void o70_quitPauseRestart();
|
void o70_quitPauseRestart();
|
||||||
void o70_kernelSetFunctions();
|
void o70_kernelSetFunctions();
|
||||||
void o70_copyString();
|
void o70_copyString();
|
||||||
|
@ -757,6 +754,7 @@ protected:
|
||||||
byte *heFindResourceData(uint32 tag, byte *ptr);
|
byte *heFindResourceData(uint32 tag, byte *ptr);
|
||||||
byte *heFindResource(uint32 tag, byte *ptr);
|
byte *heFindResource(uint32 tag, byte *ptr);
|
||||||
byte *findWrappedBlock(uint32 tag, byte *ptr, int state, bool flagError);
|
byte *findWrappedBlock(uint32 tag, byte *ptr, int state, bool flagError);
|
||||||
|
int findObject(int x, int y, int num, int *args);
|
||||||
|
|
||||||
/* HE version 72 script opcodes */
|
/* HE version 72 script opcodes */
|
||||||
void o72_pushDWord();
|
void o72_pushDWord();
|
||||||
|
@ -779,6 +777,7 @@ protected:
|
||||||
void o72_roomOps();
|
void o72_roomOps();
|
||||||
void o72_actorOps();
|
void o72_actorOps();
|
||||||
void o72_verbOps();
|
void o72_verbOps();
|
||||||
|
void o72_findObject();
|
||||||
void o72_arrayOps();
|
void o72_arrayOps();
|
||||||
void o72_talkActor();
|
void o72_talkActor();
|
||||||
void o72_talkEgo();
|
void o72_talkEgo();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "scumm/actor.h"
|
#include "scumm/actor.h"
|
||||||
#include "scumm/bomp.h"
|
#include "scumm/bomp.h"
|
||||||
|
#include "scumm/intern.h"
|
||||||
#include "scumm/object.h"
|
#include "scumm/object.h"
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/usage_bits.h"
|
#include "scumm/usage_bits.h"
|
||||||
|
@ -358,6 +359,10 @@ int ScummEngine::findObject(int x, int y) {
|
||||||
a = _objs[b].parentstate;
|
a = _objs[b].parentstate;
|
||||||
b = _objs[b].parent;
|
b = _objs[b].parent;
|
||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
|
if (_heversion >= 70) {
|
||||||
|
if (((ScummEngine_v70he *)this)->_wiz.polygonHit(_objs[i].obj_nr, x, y))
|
||||||
|
return _objs[i].obj_nr;
|
||||||
|
}
|
||||||
if (_objs[i].x_pos <= x && _objs[i].width + _objs[i].x_pos > x &&
|
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)
|
_objs[i].y_pos <= y && _objs[i].height + _objs[i].y_pos > y)
|
||||||
return _objs[i].obj_nr;
|
return _objs[i].obj_nr;
|
||||||
|
|
|
@ -259,7 +259,7 @@ void ScummEngine_v100he::setupOpcodes() {
|
||||||
OPCODE(o90_findAllObjectsWithClassOf),
|
OPCODE(o90_findAllObjectsWithClassOf),
|
||||||
OPCODE(o6_invalid),
|
OPCODE(o6_invalid),
|
||||||
OPCODE(o6_findInventory),
|
OPCODE(o6_findInventory),
|
||||||
OPCODE(o70_findObject),
|
OPCODE(o72_findObject),
|
||||||
/* B0 */
|
/* B0 */
|
||||||
OPCODE(o72_findObjectWithClassOf),
|
OPCODE(o72_findObjectWithClassOf),
|
||||||
OPCODE(o70_polygonHit),
|
OPCODE(o70_polygonHit),
|
||||||
|
|
|
@ -244,7 +244,7 @@ void ScummEngine_v72he::setupOpcodes() {
|
||||||
OPCODE(o72_verbOps),
|
OPCODE(o72_verbOps),
|
||||||
OPCODE(o6_getActorFromXY),
|
OPCODE(o6_getActorFromXY),
|
||||||
/* A0 */
|
/* A0 */
|
||||||
OPCODE(o70_findObject),
|
OPCODE(o72_findObject),
|
||||||
OPCODE(o6_pseudoRoom),
|
OPCODE(o6_pseudoRoom),
|
||||||
OPCODE(o6_getActorElevation),
|
OPCODE(o6_getActorElevation),
|
||||||
OPCODE(o6_getVerbEntrypoint),
|
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() {
|
void ScummEngine_v72he::o72_pushDWord() {
|
||||||
int a;
|
int a;
|
||||||
if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) {
|
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() {
|
void ScummEngine_v72he::o72_arrayOps() {
|
||||||
byte subOp = fetchScriptByte();
|
byte subOp = fetchScriptByte();
|
||||||
int array = fetchScriptWord();
|
int array = fetchScriptWord();
|
||||||
|
|
|
@ -242,7 +242,7 @@ void ScummEngine_v70he::setupOpcodes() {
|
||||||
OPCODE(o6_verbOps),
|
OPCODE(o6_verbOps),
|
||||||
OPCODE(o6_getActorFromXY),
|
OPCODE(o6_getActorFromXY),
|
||||||
/* A0 */
|
/* A0 */
|
||||||
OPCODE(o70_findObject),
|
OPCODE(o6_findObject),
|
||||||
OPCODE(o6_pseudoRoom),
|
OPCODE(o6_pseudoRoom),
|
||||||
OPCODE(o6_getActorElevation),
|
OPCODE(o6_getActorElevation),
|
||||||
OPCODE(o6_getVerbEntrypoint),
|
OPCODE(o6_getVerbEntrypoint),
|
||||||
|
@ -425,62 +425,6 @@ void ScummEngine_v70he::appendSubstring(int dst, int src, int srcOffs, int len)
|
||||||
writeArray(0, 0, dstOffs + i, 0);
|
writeArray(0, 0, dstOffs + i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScummEngine_v70he::findObject(int x, int y, int num, int *args) {
|
|
||||||
int i, b, result;
|
|
||||||
int cond, cls, tmp;
|
|
||||||
byte a;
|
|
||||||
const int mask = 0xF;
|
|
||||||
|
|
||||||
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) != 0)
|
|
||||||
result = _objs[i].obj_nr;
|
|
||||||
else if (VAR_POLYGONS_ONLY != 0xFF && VAR(VAR_POLYGONS_ONLY))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
// Check object bounds
|
|
||||||
b = i;
|
|
||||||
do {
|
|
||||||
a = _objs[b].parentstate;
|
|
||||||
b = _objs[b].parent;
|
|
||||||
if (b == 0) {
|
|
||||||
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;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while ((_objs[b].state & mask) == a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
if (!num)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
// Check object class
|
|
||||||
cond = 1;
|
|
||||||
tmp = num;
|
|
||||||
while (--tmp >= 0) {
|
|
||||||
cls = args[tmp];
|
|
||||||
b = getClass(i, cls);
|
|
||||||
if ((cls & 0x80 && !b) || (!(cls & 0x80) && b))
|
|
||||||
cond = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cond)
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScummEngine_v70he::o70_startSound() {
|
void ScummEngine_v70he::o70_startSound() {
|
||||||
byte subOp = fetchScriptByte();
|
byte subOp = fetchScriptByte();
|
||||||
|
|
||||||
|
@ -697,13 +641,6 @@ void ScummEngine_v70he::o70_resourceRoutines() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine_v70he::o70_findObject() {
|
|
||||||
int y = pop();
|
|
||||||
int x = pop();
|
|
||||||
int r = findObject(x, y, 0, 0);
|
|
||||||
push(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScummEngine_v70he::o70_quitPauseRestart() {
|
void ScummEngine_v70he::o70_quitPauseRestart() {
|
||||||
byte subOp = fetchScriptByte();
|
byte subOp = fetchScriptByte();
|
||||||
int par1;
|
int par1;
|
||||||
|
|
|
@ -241,7 +241,7 @@ void ScummEngine_v80he::setupOpcodes() {
|
||||||
OPCODE(o6_invalid),
|
OPCODE(o6_invalid),
|
||||||
OPCODE(o6_getActorFromXY),
|
OPCODE(o6_getActorFromXY),
|
||||||
/* A0 */
|
/* A0 */
|
||||||
OPCODE(o70_findObject),
|
OPCODE(o72_findObject),
|
||||||
OPCODE(o6_pseudoRoom),
|
OPCODE(o6_pseudoRoom),
|
||||||
OPCODE(o6_getActorElevation),
|
OPCODE(o6_getActorElevation),
|
||||||
OPCODE(o6_getVerbEntrypoint),
|
OPCODE(o6_getVerbEntrypoint),
|
||||||
|
|
|
@ -241,7 +241,7 @@ void ScummEngine_v90he::setupOpcodes() {
|
||||||
OPCODE(o90_paletteOps),
|
OPCODE(o90_paletteOps),
|
||||||
OPCODE(o6_getActorFromXY),
|
OPCODE(o6_getActorFromXY),
|
||||||
/* A0 */
|
/* A0 */
|
||||||
OPCODE(o70_findObject),
|
OPCODE(o72_findObject),
|
||||||
OPCODE(o6_pseudoRoom),
|
OPCODE(o6_pseudoRoom),
|
||||||
OPCODE(o6_getActorElevation),
|
OPCODE(o6_getActorElevation),
|
||||||
OPCODE(o6_getVerbEntrypoint),
|
OPCODE(o6_getVerbEntrypoint),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue