From 2e7b16a8bdb6ad1cf51046d57eb0f5406ee2cc13 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 Jun 2012 11:28:25 +0200 Subject: HUGO: Apply coding convention (in progress) --- engines/hugo/object.cpp | 386 ++++++++++++++++++++++++------------------------ 1 file changed, 193 insertions(+), 193 deletions(-) (limited to 'engines/hugo/object.cpp') diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp index bc99abf410..92a04227d6 100644 --- a/engines/hugo/object.cpp +++ b/engines/hugo/object.cpp @@ -74,22 +74,22 @@ byte ObjectHandler::getFirstOverlay(uint16 index) const { } bool ObjectHandler::isCarried(int objIndex) const { - return _objects[objIndex].carriedFl; + return _objects[objIndex]._carriedFl; } void ObjectHandler::setCarry(int objIndex, bool val) { - _objects[objIndex].carriedFl = val; + _objects[objIndex]._carriedFl = val; } void ObjectHandler::setVelocity(int objIndex, int8 vx, int8 vy) { - _objects[objIndex].vx = vx; - _objects[objIndex].vy = vy; + _objects[objIndex]._vx = vx; + _objects[objIndex]._vy = vy; } void ObjectHandler::setPath(int objIndex, path_t pathType, int16 vxPath, int16 vyPath) { - _objects[objIndex].pathType = pathType; - _objects[objIndex].vxPath = vxPath; - _objects[objIndex].vyPath = vyPath; + _objects[objIndex]._pathType = pathType; + _objects[objIndex]._vxPath = vxPath; + _objects[objIndex]._vyPath = vyPath; } /** @@ -99,15 +99,15 @@ void ObjectHandler::saveSeq(object_t *obj) { debugC(1, kDebugObject, "saveSeq"); bool found = false; - for (int i = 0; !found && (i < obj->seqNumb); i++) { - seq_t *q = obj->seqList[i].seqPtr; - for (int j = 0; !found && (j < obj->seqList[i].imageNbr); j++) { - if (obj->currImagePtr == q) { + for (int i = 0; !found && (i < obj->_seqNumb); i++) { + seq_t *q = obj->_seqList[i]._seqPtr; + for (int j = 0; !found && (j < obj->_seqList[i]._imageNbr); j++) { + if (obj->_currImagePtr == q) { found = true; - obj->curSeqNum = i; - obj->curImageNum = j; + obj->_curSeqNum = i; + obj->_curImageNum = j; } else { - q = q->nextSeqPtr; + q = q->_nextSeqPtr; } } } @@ -119,10 +119,10 @@ void ObjectHandler::saveSeq(object_t *obj) { void ObjectHandler::restoreSeq(object_t *obj) { debugC(1, kDebugObject, "restoreSeq"); - seq_t *q = obj->seqList[obj->curSeqNum].seqPtr; - for (int j = 0; j < obj->curImageNum; j++) - q = q->nextSeqPtr; - obj->currImagePtr = q; + seq_t *q = obj->_seqList[obj->_curSeqNum]._seqPtr; + for (int j = 0; j < obj->_curImageNum; j++) + q = q->_nextSeqPtr; + obj->_currImagePtr = q; } /** @@ -137,33 +137,33 @@ void ObjectHandler::useObject(int16 objId) { object_t *obj = &_objects[objId]; // Ptr to object if (inventObjId == -1) { // Get or use objid directly - if ((obj->genericCmd & TAKE) || obj->objValue) // Get collectible item - sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_take, 0), _vm->_text->getNoun(obj->nounIndex, 0)); - else if (obj->cmdIndex != 0) // Use non-collectible item if able - sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_parser->getCmdDefaultVerbIdx(obj->cmdIndex), 0), _vm->_text->getNoun(obj->nounIndex, 0)); - else if ((verb = _vm->_parser->useBG(_vm->_text->getNoun(obj->nounIndex, 0))) != 0) - sprintf(_vm->_line, "%s %s", verb, _vm->_text->getNoun(obj->nounIndex, 0)); + if ((obj->_genericCmd & TAKE) || obj->_objValue) // Get collectible item + sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_take, 0), _vm->_text->getNoun(obj->_nounIndex, 0)); + else if (obj->_cmdIndex != 0) // Use non-collectible item if able + sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_parser->getCmdDefaultVerbIdx(obj->_cmdIndex), 0), _vm->_text->getNoun(obj->_nounIndex, 0)); + else if ((verb = _vm->_parser->useBG(_vm->_text->getNoun(obj->_nounIndex, 0))) != 0) + sprintf(_vm->_line, "%s %s", verb, _vm->_text->getNoun(obj->_nounIndex, 0)); else return; // Can't use object directly } else { // Use status.objid on objid // Default to first cmd verb - sprintf(_vm->_line, "%s %s %s", _vm->_text->getVerb(_vm->_parser->getCmdDefaultVerbIdx(_objects[inventObjId].cmdIndex), 0), - _vm->_text->getNoun(_objects[inventObjId].nounIndex, 0), - _vm->_text->getNoun(obj->nounIndex, 0)); + sprintf(_vm->_line, "%s %s %s", _vm->_text->getVerb(_vm->_parser->getCmdDefaultVerbIdx(_objects[inventObjId]._cmdIndex), 0), + _vm->_text->getNoun(_objects[inventObjId]._nounIndex, 0), + _vm->_text->getNoun(obj->_nounIndex, 0)); // Check valid use of objects and override verb if necessary - for (uses_t *use = _uses; use->objId != _numObj; use++) { - if (inventObjId == use->objId) { + for (uses_t *use = _uses; use->_objId != _numObj; use++) { + if (inventObjId == use->_objId) { // Look for secondary object, if found use matching verb bool foundFl = false; - for (target_t *target = use->targets; target->nounIndex != 0; target++) - if (target->nounIndex == obj->nounIndex) { + for (target_t *target = use->_targets; target->_nounIndex != 0; target++) + if (target->_nounIndex == obj->_nounIndex) { foundFl = true; - sprintf(_vm->_line, "%s %s %s", _vm->_text->getVerb(target->verbIndex, 0), - _vm->_text->getNoun(_objects[inventObjId].nounIndex, 0), - _vm->_text->getNoun(obj->nounIndex, 0)); + sprintf(_vm->_line, "%s %s %s", _vm->_text->getVerb(target->_verbIndex, 0), + _vm->_text->getNoun(_objects[inventObjId]._nounIndex, 0), + _vm->_text->getNoun(obj->_nounIndex, 0)); } // No valid use of objects found, print failure string @@ -171,7 +171,7 @@ void ObjectHandler::useObject(int16 objId) { // Deselect dragged icon if inventory not active if (_vm->_inventory->getInventoryState() != kInventoryActive) _vm->_screen->resetInventoryObjId(); - Utils::notifyBox(_vm->_text->getTextData(use->dataIndex)); + Utils::notifyBox(_vm->_text->getTextData(use->_dataIndex)); return; } } @@ -199,26 +199,26 @@ int16 ObjectHandler::findObject(uint16 x, uint16 y) { // Check objects on screen for (int i = 0; i < _numObj; i++, obj++) { // Object must be in current screen and "useful" - if (obj->screenIndex == *_vm->_screen_p && (obj->genericCmd || obj->objValue || obj->cmdIndex)) { - seq_t *curImage = obj->currImagePtr; + if (obj->_screenIndex == *_vm->_screen_p && (obj->_genericCmd || obj->_objValue || obj->_cmdIndex)) { + seq_t *curImage = obj->_currImagePtr; // Object must have a visible image... - if (curImage != 0 && obj->cycling != kCycleInvisible) { + if (curImage != 0 && obj->_cycling != kCycleInvisible) { // If cursor inside object - if (x >= (uint16)obj->x && x <= obj->x + curImage->x2 && y >= (uint16)obj->y && y <= obj->y + curImage->y2) { + if (x >= (uint16)obj->_x && x <= obj->_x + curImage->_x2 && y >= (uint16)obj->_y && y <= obj->_y + curImage->_y2) { // If object is closest so far - if (obj->y + curImage->y2 > y2Max) { - y2Max = obj->y + curImage->y2; + if (obj->_y + curImage->_y2 > y2Max) { + y2Max = obj->_y + curImage->_y2; objIndex = i; // Found an object! } } } else { // ...or a dummy object that has a hotspot rectangle - if (curImage == 0 && obj->vxPath != 0 && !obj->carriedFl) { + if (curImage == 0 && obj->_vxPath != 0 && !obj->_carriedFl) { // If cursor inside special rectangle - if ((int16)x >= obj->oldx && (int16)x < obj->oldx + obj->vxPath && (int16)y >= obj->oldy && (int16)y < obj->oldy + obj->vyPath) { + if ((int16)x >= obj->_oldx && (int16)x < obj->_oldx + obj->_vxPath && (int16)y >= obj->_oldy && (int16)y < obj->_oldy + obj->_vyPath) { // If object is closest so far - if (obj->oldy + obj->vyPath - 1 > (int16)y2Max) { - y2Max = obj->oldy + obj->vyPath - 1; + if (obj->_oldy + obj->_vyPath - 1 > (int16)y2Max) { + y2Max = obj->_oldy + obj->_vyPath - 1; objIndex = i; // Found an object! } } @@ -240,7 +240,7 @@ void ObjectHandler::lookObject(object_t *obj) { // Hero swapped - look at other obj = &_objects[_vm->_heroImage]; - _vm->_parser->command("%s %s", _vm->_text->getVerb(_vm->_look, 0), _vm->_text->getNoun(obj->nounIndex, 0)); + _vm->_parser->command("%s %s", _vm->_text->getVerb(_vm->_look, 0), _vm->_text->getNoun(obj->_nounIndex, 0)); } /** @@ -249,26 +249,26 @@ void ObjectHandler::lookObject(object_t *obj) { void ObjectHandler::freeObjects() { debugC(1, kDebugObject, "freeObjects"); - if (_vm->_hero != 0 && _vm->_hero->seqList[0].seqPtr != 0) { + if (_vm->_hero != 0 && _vm->_hero->_seqList[0]._seqPtr != 0) { // Free all sequence lists and image data for (int16 i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; - for (int16 j = 0; j < obj->seqNumb; j++) { - seq_t *seq = obj->seqList[j].seqPtr; + for (int16 j = 0; j < obj->_seqNumb; j++) { + seq_t *seq = obj->_seqList[j]._seqPtr; seq_t *next; if (seq == 0) // Failure during database load break; - if (seq->imagePtr != 0) { - free(seq->imagePtr); - seq->imagePtr = 0; + if (seq->_imagePtr != 0) { + free(seq->_imagePtr); + seq->_imagePtr = 0; } - seq = seq->nextSeqPtr; - while (seq != obj->seqList[j].seqPtr) { - if (seq->imagePtr != 0) { - free(seq->imagePtr); - seq->imagePtr = 0; + seq = seq->_nextSeqPtr; + while (seq != obj->_seqList[j]._seqPtr) { + if (seq->_imagePtr != 0) { + free(seq->_imagePtr); + seq->_imagePtr = 0; } - next = seq->nextSeqPtr; + next = seq->_nextSeqPtr; free(seq); seq = next; } @@ -279,13 +279,13 @@ void ObjectHandler::freeObjects() { if (_uses) { for (int16 i = 0; i < _usesSize; i++) - free(_uses[i].targets); + free(_uses[i]._targets); free(_uses); } for (int16 i = 0; i < _objCount; i++) { - free(_objects[i].stateDataIndex); - _objects[i].stateDataIndex = 0; + free(_objects[i]._stateDataIndex); + _objects[i]._stateDataIndex = 0; } free(_objects); @@ -307,20 +307,20 @@ int ObjectHandler::y2comp(const void *a, const void *b) { // Why does qsort try the same indexes? return 0; - if (p1->priority == kPriorityBackground) + if (p1->_priority == kPriorityBackground) return -1; - if (p2->priority == kPriorityBackground) + if (p2->_priority == kPriorityBackground) return 1; - if (p1->priority == kPriorityForeground) + if (p1->_priority == kPriorityForeground) return 1; - if (p2->priority == kPriorityForeground) + if (p2->_priority == kPriorityForeground) return -1; - int ay2 = p1->y + p1->currImagePtr->y2; - int by2 = p2->y + p2->currImagePtr->y2; + int ay2 = p1->_y + p1->_currImagePtr->_y2; + int by2 = p2->_y + p2->_currImagePtr->_y2; return ay2 - by2; } @@ -332,7 +332,7 @@ bool ObjectHandler::isCarrying(uint16 wordIndex) { debugC(1, kDebugObject, "isCarrying(%d)", wordIndex); for (int i = 0; i < _numObj; i++) { - if ((wordIndex == _objects[i].nounIndex) && _objects[i].carriedFl) + if ((wordIndex == _objects[i]._nounIndex) && _objects[i]._carriedFl) return true; } return false; @@ -346,10 +346,10 @@ void ObjectHandler::showTakeables() { for (int j = 0; j < _numObj; j++) { object_t *obj = &_objects[j]; - if ((obj->cycling != kCycleInvisible) && - (obj->screenIndex == *_vm->_screen_p) && - (((TAKE & obj->genericCmd) == TAKE) || obj->objValue)) { - Utils::notifyBox(Common::String::format("You can also see:\n%s.", _vm->_text->getNoun(obj->nounIndex, LOOK_NAME))); + if ((obj->_cycling != kCycleInvisible) && + (obj->_screenIndex == *_vm->_screen_p) && + (((TAKE & obj->_genericCmd) == TAKE) || obj->_objValue)) { + Utils::notifyBox(Common::String::format("You can also see:\n%s.", _vm->_text->getNoun(obj->_nounIndex, LOOK_NAME))); } } } @@ -360,19 +360,19 @@ void ObjectHandler::showTakeables() { bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) { debugC(1, kDebugObject, "findObjectSpace(obj, %d, %d)", *destx, *desty); - seq_t *curImage = obj->currImagePtr; - int16 y = obj->y + curImage->y2 - 1; + seq_t *curImage = obj->_currImagePtr; + int16 y = obj->_y + curImage->_y2 - 1; bool foundFl = true; // Try left rear corner - for (int16 x = *destx = obj->x + curImage->x1; x < *destx + kHeroMaxWidth; x++) { + for (int16 x = *destx = obj->_x + curImage->_x1; x < *destx + kHeroMaxWidth; x++) { if (checkBoundary(x, y)) foundFl = false; } if (!foundFl) { // Try right rear corner foundFl = true; - for (int16 x = *destx = obj->x + curImage->x2 - kHeroMaxWidth + 1; x <= obj->x + (int16)curImage->x2; x++) { + for (int16 x = *destx = obj->_x + curImage->_x2 - kHeroMaxWidth + 1; x <= obj->_x + (int16)curImage->_x2; x++) { if (checkBoundary(x, y)) foundFl = false; } @@ -381,7 +381,7 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) { if (!foundFl) { // Try left front corner foundFl = true; y += 2; - for (int16 x = *destx = obj->x + curImage->x1; x < *destx + kHeroMaxWidth; x++) { + for (int16 x = *destx = obj->_x + curImage->_x1; x < *destx + kHeroMaxWidth; x++) { if (checkBoundary(x, y)) foundFl = false; } @@ -389,7 +389,7 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) { if (!foundFl) { // Try right rear corner foundFl = true; - for (int16 x = *destx = obj->x + curImage->x2 - kHeroMaxWidth + 1; x <= obj->x + (int16)curImage->x2; x++) { + for (int16 x = *destx = obj->_x + curImage->_x2 - kHeroMaxWidth + 1; x <= obj->_x + (int16)curImage->_x2; x++) { if (checkBoundary(x, y)) foundFl = false; } @@ -400,13 +400,13 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) { } void ObjectHandler::readUse(Common::ReadStream &in, uses_t &curUse) { - curUse.objId = in.readSint16BE(); - curUse.dataIndex = in.readUint16BE(); + curUse._objId = in.readSint16BE(); + curUse._dataIndex = in.readUint16BE(); uint16 numSubElem = in.readUint16BE(); - curUse.targets = (target_t *)malloc(sizeof(target_t) * numSubElem); + curUse._targets = (target_t *)malloc(sizeof(target_t) * numSubElem); for (int j = 0; j < numSubElem; j++) { - curUse.targets[j].nounIndex = in.readUint16BE(); - curUse.targets[j].verbIndex = in.readUint16BE(); + curUse._targets[j]._nounIndex = in.readUint16BE(); + curUse._targets[j]._verbIndex = in.readUint16BE(); } } /** @@ -414,7 +414,7 @@ void ObjectHandler::readUse(Common::ReadStream &in, uses_t &curUse) { */ void ObjectHandler::loadObjectUses(Common::ReadStream &in) { uses_t tmpUse; - tmpUse.targets = 0; + tmpUse._targets = 0; //Read _uses for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { @@ -429,68 +429,68 @@ void ObjectHandler::loadObjectUses(Common::ReadStream &in) { readUse(in, _uses[i]); else { readUse(in, tmpUse); - free(tmpUse.targets); - tmpUse.targets = 0; + free(tmpUse._targets); + tmpUse._targets = 0; } } } } void ObjectHandler::readObject(Common::ReadStream &in, object_t &curObject) { - curObject.nounIndex = in.readUint16BE(); - curObject.dataIndex = in.readUint16BE(); + curObject._nounIndex = in.readUint16BE(); + curObject._dataIndex = in.readUint16BE(); uint16 numSubElem = in.readUint16BE(); if (numSubElem == 0) - curObject.stateDataIndex = 0; + curObject._stateDataIndex = 0; else - curObject.stateDataIndex = (uint16 *)malloc(sizeof(uint16) * numSubElem); + curObject._stateDataIndex = (uint16 *)malloc(sizeof(uint16) * numSubElem); for (int j = 0; j < numSubElem; j++) - curObject.stateDataIndex[j] = in.readUint16BE(); - - curObject.pathType = (path_t) in.readSint16BE(); - curObject.vxPath = in.readSint16BE(); - curObject.vyPath = in.readSint16BE(); - curObject.actIndex = in.readUint16BE(); - curObject.seqNumb = in.readByte(); - curObject.currImagePtr = 0; - - if (curObject.seqNumb == 0) { - curObject.seqList[0].imageNbr = 0; - curObject.seqList[0].seqPtr = 0; + curObject._stateDataIndex[j] = in.readUint16BE(); + + curObject._pathType = (path_t) in.readSint16BE(); + curObject._vxPath = in.readSint16BE(); + curObject._vyPath = in.readSint16BE(); + curObject._actIndex = in.readUint16BE(); + curObject._seqNumb = in.readByte(); + curObject._currImagePtr = 0; + + if (curObject._seqNumb == 0) { + curObject._seqList[0]._imageNbr = 0; + curObject._seqList[0]._seqPtr = 0; } - for (int j = 0; j < curObject.seqNumb; j++) { - curObject.seqList[j].imageNbr = in.readUint16BE(); - curObject.seqList[j].seqPtr = 0; + for (int j = 0; j < curObject._seqNumb; j++) { + curObject._seqList[j]._imageNbr = in.readUint16BE(); + curObject._seqList[j]._seqPtr = 0; } - curObject.cycling = (cycle_t)in.readByte(); - curObject.cycleNumb = in.readByte(); - curObject.frameInterval = in.readByte(); - curObject.frameTimer = in.readByte(); - curObject.radius = in.readByte(); - curObject.screenIndex = in.readByte(); - curObject.x = in.readSint16BE(); - curObject.y = in.readSint16BE(); - curObject.oldx = in.readSint16BE(); - curObject.oldy = in.readSint16BE(); - curObject.vx = in.readByte(); - curObject.vy = in.readByte(); - curObject.objValue = in.readByte(); - curObject.genericCmd = in.readSint16BE(); - curObject.cmdIndex = in.readUint16BE(); - curObject.carriedFl = (in.readByte() != 0); - curObject.state = in.readByte(); - curObject.verbOnlyFl = (in.readByte() != 0); - curObject.priority = in.readByte(); - curObject.viewx = in.readSint16BE(); - curObject.viewy = in.readSint16BE(); - curObject.direction = in.readSint16BE(); - curObject.curSeqNum = in.readByte(); - curObject.curImageNum = in.readByte(); - curObject.oldvx = in.readByte(); - curObject.oldvy = in.readByte(); + curObject._cycling = (cycle_t)in.readByte(); + curObject._cycleNumb = in.readByte(); + curObject._frameInterval = in.readByte(); + curObject._frameTimer = in.readByte(); + curObject._radius = in.readByte(); + curObject._screenIndex = in.readByte(); + curObject._x = in.readSint16BE(); + curObject._y = in.readSint16BE(); + curObject._oldx = in.readSint16BE(); + curObject._oldy = in.readSint16BE(); + curObject._vx = in.readByte(); + curObject._vy = in.readByte(); + curObject._objValue = in.readByte(); + curObject._genericCmd = in.readSint16BE(); + curObject._cmdIndex = in.readUint16BE(); + curObject._carriedFl = (in.readByte() != 0); + curObject._state = in.readByte(); + curObject._verbOnlyFl = (in.readByte() != 0); + curObject._priority = in.readByte(); + curObject._viewx = in.readSint16BE(); + curObject._viewy = in.readSint16BE(); + curObject._direction = in.readSint16BE(); + curObject._curSeqNum = in.readByte(); + curObject._curImageNum = in.readByte(); + curObject._oldvx = in.readByte(); + curObject._oldvy = in.readByte(); } /** * Load ObjectArr from Hugo.dat @@ -498,7 +498,7 @@ void ObjectHandler::readObject(Common::ReadStream &in, object_t &curObject) { void ObjectHandler::loadObjectArr(Common::ReadStream &in) { debugC(6, kDebugObject, "loadObject(&in)"); object_t tmpObject; - tmpObject.stateDataIndex = 0; + tmpObject._stateDataIndex = 0; for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { uint16 numElem = in.readUint16BE(); @@ -514,8 +514,8 @@ void ObjectHandler::loadObjectArr(Common::ReadStream &in) { else { // Skip over uneeded objects. readObject(in, tmpObject); - free(tmpObject.stateDataIndex); - tmpObject.stateDataIndex = 0; + free(tmpObject._stateDataIndex); + tmpObject._stateDataIndex = 0; } } } @@ -528,7 +528,7 @@ void ObjectHandler::loadObjectArr(Common::ReadStream &in) { void ObjectHandler::setCarriedScreen(int screenNum) { for (int i = kHeroIndex + 1; i < _numObj; i++) {// Any others if (isCarried(i)) // being carried - _objects[i].screenIndex = screenNum; + _objects[i]._screenIndex = screenNum; } } @@ -562,30 +562,30 @@ void ObjectHandler::saveObjects(Common::WriteStream *out) { // 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); + 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); } } @@ -594,30 +594,30 @@ void ObjectHandler::saveObjects(Common::WriteStream *out) { */ void ObjectHandler::restoreObjects(Common::SeekableReadStream *in) { for (int i = 0; i < _numObj; i++) { - _objects[i].pathType = (path_t) in->readByte(); - _objects[i].vxPath = in->readSint16BE(); - _objects[i].vyPath = in->readSint16BE(); - _objects[i].cycling = (cycle_t) in->readByte(); - _objects[i].cycleNumb = in->readByte(); - _objects[i].frameTimer = in->readByte(); - _objects[i].screenIndex = in->readByte(); - _objects[i].x = in->readSint16BE(); - _objects[i].y = in->readSint16BE(); - _objects[i].oldx = in->readSint16BE(); - _objects[i].oldy = in->readSint16BE(); - _objects[i].vx = in->readSByte(); - _objects[i].vy = in->readSByte(); - _objects[i].objValue = in->readByte(); - _objects[i].carriedFl = (in->readByte() == 1); - _objects[i].state = in->readByte(); - _objects[i].priority = in->readByte(); - _objects[i].viewx = in->readSint16BE(); - _objects[i].viewy = in->readSint16BE(); - _objects[i].direction = in->readSint16BE(); - _objects[i].curSeqNum = in->readByte(); - _objects[i].curImageNum = in->readByte(); - _objects[i].oldvx = in->readSByte(); - _objects[i].oldvy = in->readSByte(); + _objects[i]._pathType = (path_t) in->readByte(); + _objects[i]._vxPath = in->readSint16BE(); + _objects[i]._vyPath = in->readSint16BE(); + _objects[i]._cycling = (cycle_t) in->readByte(); + _objects[i]._cycleNumb = in->readByte(); + _objects[i]._frameTimer = in->readByte(); + _objects[i]._screenIndex = in->readByte(); + _objects[i]._x = in->readSint16BE(); + _objects[i]._y = in->readSint16BE(); + _objects[i]._oldx = in->readSint16BE(); + _objects[i]._oldy = in->readSint16BE(); + _objects[i]._vx = in->readSByte(); + _objects[i]._vy = in->readSByte(); + _objects[i]._objValue = in->readByte(); + _objects[i]._carriedFl = (in->readByte() == 1); + _objects[i]._state = in->readByte(); + _objects[i]._priority = in->readByte(); + _objects[i]._viewx = in->readSint16BE(); + _objects[i]._viewy = in->readSint16BE(); + _objects[i]._direction = in->readSint16BE(); + _objects[i]._curSeqNum = in->readByte(); + _objects[i]._curImageNum = in->readByte(); + _objects[i]._oldvx = in->readSByte(); + _objects[i]._oldvy = in->readSByte(); } } @@ -627,7 +627,7 @@ void ObjectHandler::restoreObjects(Common::SeekableReadStream *in) { int ObjectHandler::calcMaxScore() { int score = 0; for (int i = 0; i < _numObj; i++) - score += _objects[i].objValue; + score += _objects[i]._objValue; return score; } @@ -788,26 +788,26 @@ void ObjectHandler::boundaryCollision(object_t *obj) { if (obj == _vm->_hero) { // Hotspots only relevant to HERO int x; - if (obj->vx > 0) - x = obj->x + obj->currImagePtr->x2; + if (obj->_vx > 0) + x = obj->_x + obj->_currImagePtr->_x2; else - x = obj->x + obj->currImagePtr->x1; - int y = obj->y + obj->currImagePtr->y2; + x = obj->_x + obj->_currImagePtr->_x1; + int y = obj->_y + obj->_currImagePtr->_y2; - int16 index = _vm->_mouse->findExit(x, y, obj->screenIndex); + int16 index = _vm->_mouse->findExit(x, y, obj->_screenIndex); if (index >= 0) _vm->_scheduler->insertActionList(_vm->_mouse->getHotspotActIndex(index)); } else { // Check whether an object collided with HERO - int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - obj->currImagePtr->x1; - int dy = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - obj->y - obj->currImagePtr->y2; + int dx = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1 - obj->_x - obj->_currImagePtr->_x1; + int dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - obj->_currImagePtr->_y2; // If object's radius is infinity, use a closer value - int8 radius = obj->radius; + int8 radius = obj->_radius; if (radius < 0) radius = kStepDx * 2; if ((abs(dx) <= radius) && (abs(dy) <= radius)) - _vm->_scheduler->insertActionList(obj->actIndex); + _vm->_scheduler->insertActionList(obj->_actIndex); } } -- cgit v1.2.3