Ticket #7916: owner_state.patch

File owner_state.patch, 4.2 KB (added by SF/japj, 23 years ago)

owner / state patch

  • object.cpp

    RCS file: /cvsroot/scummvm/scummvm/object.cpp,v
    retrieving revision 1.13
    diff -u -r1.13 object.cpp
     
    4545
    4646int Scumm::getOwner(int obj) {
    4747        checkRange(_numGlobalObjects-1, 0, obj, "Object %d out of range in getOwner");
    48         return _objectFlagTable[obj]&0xF;
     48        return _objectFlagTable[obj]&OBJECTFLAG_OWNER_MASK;
    4949}
    5050
    5151void Scumm::putOwner(int act, int owner) {
    5252        checkRange(_numGlobalObjects-1, 0, act, "Object %d out of range in putOwner");
    5353        checkRange(15, 0, owner, "Owner %d out of range in putOwner");
    54         _objectFlagTable[act] = (_objectFlagTable[act]&0xF0) | owner;
     54        _objectFlagTable[act] = (_objectFlagTable[act]&OBJECTFLAG_STATE_MASK) | owner;
    5555}
    5656
    5757int Scumm::getState(int act) {
     
    6262void Scumm::putState(int act, int state) {
    6363        checkRange(_numGlobalObjects-1, 0, act, "Object %d out of range in putState");
    6464        checkRange(15, 0, state, "State %d out of range in putState");
    65         _objectFlagTable[act] = (_objectFlagTable[act]&0x0F) | (state<<4);
     65        _objectFlagTable[act] = (_objectFlagTable[act]&OBJECTFLAG_OWNER_MASK) | (state<<4);
    6666}
    6767
    6868int Scumm::getObjectIndex(int object) {
    6969        int i;
    7070
    71         if ((_objectFlagTable[object]&0xF)!=0xF) {
     71        if ((_objectFlagTable[object]&OBJECTFLAG_OWNER_MASK)!=OBJECTFLAG_OWNER_ROOM) {
    7272                for (i=0; i<_maxInventoryItems; i++)
    7373                        if (_inventory[i] == object)
    7474                                return i;
     
    8888        if (object >= _numGlobalObjects)
    8989                return -1;
    9090
    91         if ((_objectFlagTable[object]&0xF)!=0xF) {
     91        if ((_objectFlagTable[object]&OBJECTFLAG_OWNER_MASK)!=OBJECTFLAG_OWNER_ROOM) {
    9292                for (i=0; i<_maxInventoryItems; i++)
    9393                        if (_inventory[i] == object)
    9494                                return 0;
     
    112112        case -1:
    113113                return -1;
    114114        case 0:
    115                 return getActorXYPos(derefActorSafe(_objectFlagTable[object]&0xF,"getObjectOrActorXY(2)"));
     115                return getActorXYPos(derefActorSafe(_objectFlagTable[object]&OBJECTFLAG_OWNER_MASK,"getObjectOrActorXY(2)"));
    116116        }
    117117        getObjectXYPos(object);
    118118        return 0;
     
    223223
    224224        do {
    225225                od = &_objs[num];
    226                 if (!od->obj_nr || !(od->ownerstate&0xF0))
     226                if (!od->obj_nr || !(od->ownerstate&OBJECTFLAG_STATE_MASK))
    227227                        continue;
    228228               
    229229                do {
     
    233233                                break;
    234234                        }
    235235                        od = &_objs[od->parent];
    236                 } while ((od->ownerstate & 0xF0)==a);
     236                } while ((od->ownerstate & OBJECTFLAG_STATE_MASK)==a);
    237237
    238238        } while (--num);
    239239}
     
    437437
    438438        stopObjectScript(obj);
    439439       
    440         if (getOwner(obj)==0xF) {
     440        if (getOwner(obj)==OBJECTFLAG_OWNER_ROOM) {
    441441                i = 0;
    442442                do {
    443443                        if (_objs[i].obj_nr==obj) {
     
    518518uint32 Scumm::getOBCDOffs(int object) {
    519519        int i;
    520520
    521         if ((_objectFlagTable[object]&0xF)!=0xF)
     521        if ((_objectFlagTable[object]&OBJECTFLAG_OWNER_MASK)!=OBJECTFLAG_OWNER_ROOM)
    522522                return 0;
    523523        for (i=_numObjectsInRoom; i>0; i--) {
    524524                if (_objs[i].obj_nr == object) {
     
    533533byte *Scumm::getObjectAddress(int obj) {
    534534        int i;
    535535
    536         if ((_objectFlagTable[obj]&0xF)!=0xF) {
     536        if ((_objectFlagTable[obj]&OBJECTFLAG_OWNER_MASK)!=OBJECTFLAG_OWNER_ROOM) {
    537537                for(i=0; i<_maxInventoryItems; i++) {
    538538                        if (_inventory[i] == obj)
    539539                                return getResourceAddress(rtInventory, i);
  • script.cpp

    RCS file: /cvsroot/scummvm/scummvm/script.cpp,v
    retrieving revision 1.10
    diff -u -r1.10 script.cpp
     
    573573        if (_newNames) {
    574574                for (i=0; i<50; i++) {
    575575                        int j = _newNames[i];
    576                         if (j && (getOwner(j)&0xF) == 0) {
     576                        if (j && (getOwner(j)&OBJECTFLAG_OWNER_MASK) == 0) {
    577577                                _newNames[i] = 0;
    578578                                nukeResource(rtObjectName, i);
    579579                        }
  • scumm.h

    RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
    retrieving revision 1.25
    diff -u -r1.25 scumm.h
     
    3131#define NUM_SCRIPT_SLOT 25
    3232#define NUM_ACTORS 13
    3333
     34#define OBJECTFLAG_OWNER_MASK   0x0f
     35#define OBJECTFLAG_STATE_MASK   0xf0
     36#define OBJECTFLAG_OWNER_ROOM   0x0f
     37
    3438#pragma START_PACK_STRUCTS
    3539       
    3640struct Point {