/** * Save objects */ void ObjectHandler::saveObjects(Common::WriteStream *out) { for (int i = 0; i < _numObj; i++) { // Save where curr_seq_p is pointing to saveSeq(&_objects[i]); out->writeByte(_objects[i].pathType); out->writeSint16BE(_objects[i].vxPath); out->writeSint16BE(_objects[i].vyPath); out->writeByte(_objects[i].cycling); out->writeByte(_objects[i].cycleNumb); out->writeByte(_objects[i].frameTimer); out->writeByte(_objects[i].screenIndex); out->writeSint16BE(_objects[i].x); out->writeSint16BE(_objects[i].y); out->writeSint16BE(_objects[i].oldx); out->writeSint16BE(_objects[i].oldy); out->writeSByte(_objects[i].vx); out->writeSByte(_objects[i].vy); out->writeByte(_objects[i].objValue); out->writeByte((_objects[i].carriedFl) ? 1 : 0); out->writeByte(_objects[i].state); out->writeByte(_objects[i].priority); out->writeSint16BE(_objects[i].viewx); out->writeSint16BE(_objects[i].viewy); out->writeSint16BE(_objects[i].direction); out->writeByte(_objects[i].curSeqNum); out->writeByte(_objects[i].curImageNum); out->writeSByte(_objects[i].oldvx); out->writeSByte(_objects[i].oldvy); } }
/** * Swap all the images of one object with another. Set hero_image (we make * the assumption for now that the first obj is always the HERO) to the object * number of the swapped image */ void ObjectHandler_v1w::swapImages(int objIndex1, int objIndex2) { debugC(1, kDebugObject, "swapImages(%d, %d)", objIndex1, objIndex2); saveSeq(&_objects[objIndex1]); SeqList tmpSeqList[kMaxSeqNumb]; int seqListSize = sizeof(SeqList) * kMaxSeqNumb; memmove(tmpSeqList, _objects[objIndex1]._seqList, seqListSize); memmove(_objects[objIndex1]._seqList, _objects[objIndex2]._seqList, seqListSize); memmove(_objects[objIndex2]._seqList, tmpSeqList, seqListSize); restoreSeq(&_objects[objIndex1]); _objects[objIndex2]._currImagePtr = _objects[objIndex2]._seqList[0]._seqPtr; _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex; // Make sure baseline stays constant _objects[objIndex1]._y += _objects[objIndex2]._currImagePtr->_y2 - _objects[objIndex1]._currImagePtr->_y2; }
/** * Swap all the images of one object with another. Set hero_image (we make * the assumption for now that the first obj is always the HERO) to the object * number of the swapped image */ void ObjectHandler_v1w::swapImages(int objIndex1, int objIndex2) { debugC(1, kDebugObject, "swapImages(%d, %d)", objIndex1, objIndex2); saveSeq(&_objects[objIndex1]); seqList_t tmpSeqList[MAX_SEQUENCES]; int seqListSize = sizeof(seqList_t) * MAX_SEQUENCES; memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); restoreSeq(&_objects[objIndex1]); _objects[objIndex2].currImagePtr = _objects[objIndex2].seqList[0].seqPtr; _vm->_heroImage = (_vm->_heroImage == HERO) ? objIndex2 : HERO; // Make sure baseline stays constant _objects[objIndex1].y += _objects[objIndex2].currImagePtr->y2 - _objects[objIndex1].currImagePtr->y2; }