svn-id: r38817
This commit is contained in:
Nicola Mettifogo 2009-02-23 12:17:25 +00:00
parent 9bef5a0cfc
commit e3afa772e2
8 changed files with 28 additions and 24 deletions

View file

@ -222,7 +222,7 @@ DECLARE_COMMAND_OPCODE(start) {
DECLARE_COMMAND_OPCODE(speak) { DECLARE_COMMAND_OPCODE(speak) {
if ((_ctxt.cmd->u._zone->_type & 0xFFFF) == kZoneSpeak) { if (ACTIONTYPE(_ctxt.cmd->u._zone) == kZoneSpeak) {
_vm->enterDialogueMode(_ctxt.cmd->u._zone); _vm->enterDialogueMode(_ctxt.cmd->u._zone);
} else { } else {
_vm->_activeZone = _ctxt.cmd->u._zone; _vm->_activeZone = _ctxt.cmd->u._zone;

View file

@ -297,7 +297,7 @@ bool Input::translateGameInput() {
// test if mouse is hovering on an interactive zone for the currently selected inventory item // test if mouse is hovering on an interactive zone for the currently selected inventory item
ZonePtr z = _vm->hitZone(_activeItem._id, mousePos.x, mousePos.y); ZonePtr z = _vm->hitZone(_activeItem._id, mousePos.x, mousePos.y);
if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((!z) || ((z->_type & 0xFFFF) != kZoneCommand))) { if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((!z) || (ACTIONTYPE(z) != kZoneCommand))) {
walkTo(mousePos); walkTo(mousePos);
return true; return true;
} }
@ -307,7 +307,7 @@ bool Input::translateGameInput() {
return true; return true;
} }
if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || ((z->_type & 0xFFFF) == kZoneCommand))) { if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || (ACTIONTYPE(z) == kZoneCommand))) {
if (z->_flags & kFlagsNoWalk) { if (z->_flags & kFlagsNoWalk) {
// character doesn't need to walk to take specified action // character doesn't need to walk to take specified action

View file

@ -180,7 +180,7 @@ Zone::Zone() {
Zone::~Zone() { Zone::~Zone() {
// printf("~Zone(%s)\n", _name); // printf("~Zone(%s)\n", _name);
switch (_type & 0xFFFF) { switch (ACTIONTYPE(this)) {
case kZoneExamine: case kZoneExamine:
free(u.examine->_filename); free(u.examine->_filename);
u.examine->_description.clear(); u.examine->_description.clear();

View file

@ -287,6 +287,10 @@ struct TypeData {
} }
}; };
#define ACTIONTYPE(z) ((z)->_type & 0xFFFF)
#define ITEMTYPE(z) ((z)->_type & 0xFFFF0000)
#define PACK_ZONETYPE(zt,it) ((zt) & 0xFFFF | (((it) & 0xFFFF) << 16))
#define ZONENAME_LENGTH 32 #define ZONENAME_LENGTH 32

View file

@ -503,7 +503,7 @@ void Parallaction::updateZones() {
// examine the list of get zones to update // examine the list of get zones to update
for (ZoneList::iterator zit = _zonesToUpdate.begin(); zit != _zonesToUpdate.end(); zit++) { for (ZoneList::iterator zit = _zonesToUpdate.begin(); zit != _zonesToUpdate.end(); zit++) {
ZonePtr z = *zit; ZonePtr z = *zit;
if ((z->_type & 0xFFFF) == kZoneGet) { if (ACTIONTYPE(z) == kZoneGet) {
GfxObj *obj = z->u.get->gfxobj; GfxObj *obj = z->u.get->gfxobj;
obj->x = z->getX(); obj->x = z->getX();
obj->y = z->getY(); obj->y = z->getY();
@ -527,7 +527,7 @@ void Parallaction::showZone(ZonePtr z, bool visible) {
z->_flags |= kFlagsRemove; z->_flags |= kFlagsRemove;
} }
if ((z->_type & 0xFFFF) == kZoneGet) { if (ACTIONTYPE(z) == kZoneGet) {
_gfx->showGfxObj(z->u.get->gfxobj, visible); _gfx->showGfxObj(z->u.get->gfxobj, visible);
} }
} }
@ -600,10 +600,10 @@ void Parallaction::runCommentFrame() {
void Parallaction::runZone(ZonePtr z) { void Parallaction::runZone(ZonePtr z) {
debugC(3, kDebugExec, "runZone (%s)", z->_name); debugC(3, kDebugExec, "runZone (%s)", z->_name);
uint16 subtype = z->_type & 0xFFFF; uint16 actionType = ACTIONTYPE(z);
debugC(3, kDebugExec, "type = %x, object = %x", subtype, (z->_type & 0xFFFF0000) >> 16); debugC(3, kDebugExec, "actionType = %x, itemType = %x", actionType, ITEMTYPE(z));
switch(subtype) { switch(actionType) {
case kZoneExamine: case kZoneExamine:
enterCommentMode(z); enterCommentMode(z);
@ -678,8 +678,8 @@ bool Parallaction::checkSpecialZoneBox(ZonePtr z, uint32 type, uint x, uint y) {
// WORKAROUND: this huge condition is needed because we made TypeData a collection of structs // WORKAROUND: this huge condition is needed because we made TypeData a collection of structs
// instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine, // instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine,
// but we need to check it separately here. The same workaround is applied in freeZones. // but we need to check it separately here. The same workaround is applied in freeZones.
if ((((z->_type & 0xFFFF) == kZoneMerge) && (((x == z->u.merge->_obj1) && (y == z->u.merge->_obj2)) || ((x == z->u.merge->_obj2) && (y == z->u.merge->_obj1)))) || if (((ACTIONTYPE(z) == kZoneMerge) && (((x == z->u.merge->_obj1) && (y == z->u.merge->_obj2)) || ((x == z->u.merge->_obj2) && (y == z->u.merge->_obj1)))) ||
(((z->_type & 0xFFFF) == kZoneGet) && ((x == z->u.get->_icon) || (y == z->u.get->_icon)))) { ((ACTIONTYPE(z) == kZoneGet) && ((x == z->u.get->_icon) || (y == z->u.get->_icon)))) {
// WORKAROUND for bug 2070751: special zones are only used in NS, to allow the // WORKAROUND for bug 2070751: special zones are only used in NS, to allow the
// the EXAMINE/USE action to be applied on some particular item in the inventory. // the EXAMINE/USE action to be applied on some particular item in the inventory.
@ -691,7 +691,7 @@ bool Parallaction::checkSpecialZoneBox(ZonePtr z, uint32 type, uint x, uint y) {
if (z->_type == type) if (z->_type == type)
return true; return true;
// look for item match, but don't accept 0 types // look for item match, but don't accept 0 types
if (((z->_type & 0xFFFF0000) == type) && (type)) if ((ITEMTYPE(z) == type) && (type))
return true; return true;
} }
@ -718,11 +718,11 @@ bool Parallaction::checkZoneBox(ZonePtr z, uint32 type, uint x, uint y) {
} }
// normal Zone // normal Zone
if ((type == 0) && ((z->_type & 0xFFFF0000) == 0)) if ((type == 0) && (ITEMTYPE(z) == 0))
return true; return true;
if (z->_type == type) if (z->_type == type)
return true; return true;
if ((z->_type & 0xFFFF0000) == type) if (ITEMTYPE(z) == type)
return true; return true;
return false; return false;
@ -744,11 +744,11 @@ bool Parallaction::checkLinkedAnimBox(ZonePtr z, uint32 type, uint x, uint y) {
// NOTE: the implementation of the following lines is a different in the // NOTE: the implementation of the following lines is a different in the
// original... it is working so far, though // original... it is working so far, though
if ((type == 0) && ((z->_type & 0xFFFF0000) == 0)) if ((type == 0) && (ITEMTYPE(z) == 0))
return true; return true;
if (z->_type == type) if (z->_type == type)
return true; return true;
if ((z->_type & 0xFFFF0000) == type) if (ITEMTYPE(z) == type)
return true; return true;
return false; return false;
@ -778,8 +778,8 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
_ef = a->hitFrameRect(_si, _di); _ef = a->hitFrameRect(_si, _di);
_b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1; // _b: (no type specified) AND (Animation is not the character) _b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1; // _b: (no type specified) AND (Animation is not the character)
_c = (a->_type & 0xFFFF0000) ? 0 : 1; // _c: Animation is not an object _c = ITEMTYPE(a) ? 0 : 1; // _c: Animation is not an object
_d = ((a->_type & 0xFFFF0000) != type) ? 0 : 1; // _d: Animation is an object of the same type _d = (ITEMTYPE(a) != type) ? 0 : 1; // _d: Animation is an object of the same type
if ((_a != 0 && _ef) && ((_b != 0 && _c != 0) || (a->_type == type) || (_d != 0))) { if ((_a != 0 && _ef) && ((_b != 0 && _c != 0) || (a->_type == type) || (_d != 0))) {
return a; return a;

View file

@ -161,7 +161,7 @@ void Parallaction_br::runPendingZones() {
if (_activeZone) { if (_activeZone) {
z = _activeZone; // speak Zone or sound z = _activeZone; // speak Zone or sound
_activeZone = nullZonePtr; _activeZone = nullZonePtr;
if ((z->_type & 0xFFFF) == kZoneSpeak) { if (ACTIONTYPE(z) == kZoneSpeak) {
enterDialogueMode(z); enterDialogueMode(z);
} else { } else {
runZone(z); // FIXME: BRA doesn't handle sound yet runZone(z); // FIXME: BRA doesn't handle sound yet
@ -171,7 +171,7 @@ void Parallaction_br::runPendingZones() {
if (_activeZone2) { if (_activeZone2) {
z = _activeZone2; // speak Zone or sound z = _activeZone2; // speak Zone or sound
_activeZone2 = nullZonePtr; _activeZone2 = nullZonePtr;
if ((z->_type & 0xFFFF) == kZoneSpeak) { if (ACTIONTYPE(z) == kZoneSpeak) {
enterDialogueMode(z); enterDialogueMode(z);
} else { } else {
runZone(z); // FIXME: BRA doesn't handle sound yet runZone(z); // FIXME: BRA doesn't handle sound yet

View file

@ -808,7 +808,7 @@ void LocationParser_br::parseGetData(ZonePtr z) {
void LocationParser_br::parseZoneTypeBlock(ZonePtr z) { void LocationParser_br::parseZoneTypeBlock(ZonePtr z) {
debugC(7, kDebugParser, "parseZoneTypeBlock(name: %s, type: %x)", z->_name, z->_type); debugC(7, kDebugParser, "parseZoneTypeBlock(name: %s, type: %x)", z->_name, z->_type);
switch (z->_type & 0xFFFF) { switch (ACTIONTYPE(z)) {
case kZoneExamine: // examine Zone alloc case kZoneExamine: // examine Zone alloc
parseExamineData(z); parseExamineData(z);
break; break;

View file

@ -211,12 +211,12 @@ DECLARE_ANIM_PARSER(type) {
debugC(7, kDebugParser, "ANIM_PARSER(type) "); debugC(7, kDebugParser, "ANIM_PARSER(type) ");
if (_tokens[2][0] != '\0') { if (_tokens[2][0] != '\0') {
ctxt.a->_type = ((4 + _vm->_objectsNames->lookup(_tokens[2])) << 16) & 0xFFFF0000; ctxt.a->_type = PACK_ZONETYPE(0, 4 + _vm->_objectsNames->lookup(_tokens[2]));
} }
int16 _si = _zoneTypeNames->lookup(_tokens[1]); int16 _si = _zoneTypeNames->lookup(_tokens[1]);
if (_si != Table::notFound) { if (_si != Table::notFound) {
ctxt.a->_type |= 1 << (_si-1); ctxt.a->_type |= 1 << (_si-1);
if (/*((ctxt.a->_type & 0xFFFF) != kZoneNone) &&*/ ((ctxt.a->_type & 0xFFFF) != kZoneCommand)) { if (/*(ACTIONTYPE(ctxt.a) != kZoneNone) &&*/ (ACTIONTYPE(ctxt.a) != kZoneCommand)) {
parseZoneTypeBlock(ctxt.a); parseZoneTypeBlock(ctxt.a);
} }
} }
@ -1539,7 +1539,7 @@ void LocationParser_ns::parseSpeakData(ZonePtr z) {
void LocationParser_ns::parseZoneTypeBlock(ZonePtr z) { void LocationParser_ns::parseZoneTypeBlock(ZonePtr z) {
debugC(7, kDebugParser, "parseZoneTypeBlock(name: %s, type: %x)", z->_name, z->_type); debugC(7, kDebugParser, "parseZoneTypeBlock(name: %s, type: %x)", z->_name, z->_type);
switch (z->_type & 0xFFFF) { switch (ACTIONTYPE(z)) {
case kZoneExamine: // examine Zone alloc case kZoneExamine: // examine Zone alloc
parseExamineData(z); parseExamineData(z);
break; break;