Ticket #8161: clear-objects.diff

File clear-objects.diff, 3.0 KB (added by eriktorbjorn, 21 years ago)

Patch against a January 19 CVS snapshot

  • scummvm/scumm/object.cpp

    diff -ur ScummVM-cvs20030119/scummvm/scumm/object.cpp ScummVM-cvs20030119+hack/scummvm/scumm/object.cpp
    old new  
    410410        }
    411411}
    412412
     413void Scumm::clearRoomObjects()
     414{
     415        int i;
     416
     417        if (_features & GF_SMALL_HEADER) {
     418                for (i = 0; i < _numLocalObjects; i++) {
     419                        _objs[i].obj_nr = 0;
     420                }
     421        } else {
     422                // FIXME: Locking/FlObjects stuff?
     423                for (i = 0; i < _numLocalObjects; i++) {
     424                        if (_objs[i].obj_nr < 1)        // Optimise codepath
     425                                continue;
     426
     427                        // Nuke all non-flObjects (flObjects are nuked in script.cpp)
     428                        if (_objs[i].fl_object_index == 0) {
     429                                _objs[i].obj_nr = 0;
     430                        } else {
     431                                // Nuke all unlocked flObjects
     432                                if (!(res.flags[rtFlObject][_objs[i].fl_object_index] & RF_LOCK)) {
     433                                        nukeResource(rtFlObject, _objs[i].fl_object_index);
     434                                        _objs[i].obj_nr = 0;
     435                                        _objs[i].fl_object_index = 0;
     436                                }
     437                        }
     438                }
     439        }
     440}
     441
    413442void Scumm::loadRoomObjects()
    414443{
    415444        int i, j;
     
    432461        else
    433462                _numObjectsInRoom = READ_LE_UINT16(&(roomhdr->old.numObjects));
    434463
    435         // Clear out old room objects (FIXME: Locking/FlObjects stuff?)
    436         for (i = 0; i < _numLocalObjects; i++) {
    437                 if (_objs[i].obj_nr < 1)        // Optimise codepath
    438                         continue;
    439 
    440                 // Nuke all non-flObjects (flObjects are nuked in script.cpp)
    441                 if (_objs[i].fl_object_index == 0) {
    442                         _objs[i].obj_nr = 0;
    443                 } else {
    444                         // Nuke all unlocked flObjects
    445                         if (!(res.flags[rtFlObject][_objs[i].fl_object_index] & RF_LOCK)) {
    446                                 nukeResource(rtFlObject, _objs[i].fl_object_index);
    447                                 _objs[i].obj_nr = 0;
    448                                 _objs[i].fl_object_index = 0;
    449                         }
    450                 }
    451         }
    452 
    453464        if (_numObjectsInRoom == 0)
    454465                return;
    455466
     
    544555        if (_numObjectsInRoom > _numLocalObjects)
    545556                error("More than %d objects in room %d", _numLocalObjects, _roomResource);
    546557
    547         // Clear out old room objects
    548         for (i = 0; i < _numLocalObjects; i++) {
    549                 _objs[i].obj_nr = 0;
    550         }
    551 
    552558        searchptr = room;
    553559        for (i = 0; i < _numObjectsInRoom; i++) {
    554560                od = &_objs[findLocalObjectSlot()];
  • scummvm/scumm/scumm.h

    diff -ur ScummVM-cvs20030119/scummvm/scumm/scumm.h ScummVM-cvs20030119+hack/scummvm/scumm/scumm.h
    old new  
    532532        bool isResourceInUse(int type, int i);
    533533        bool isResourceLoaded(int type, int index);
    534534        void initRoomSubBlocks();
     535        void clearRoomObjects();
    535536        void loadRoomObjects();
    536537        void loadRoomObjectsSmall();
    537538        void readArrayFromIndexFile();
  • scummvm/scumm/scummvm.cpp

    diff -ur ScummVM-cvs20030119/scummvm/scumm/scummvm.cpp ScummVM-cvs20030119+hack/scummvm/scumm/scummvm.cpp
    old new  
    651651        if (room != 0)
    652652                ensureResourceLoaded(rtRoom, room);
    653653
     654        clearRoomObjects();
     655
    654656        if (_currentRoom == 0) {
    655657                _ENCD_offs = _EXCD_offs = 0;
    656658                _numObjectsInRoom = 0;