diff options
28 files changed, 1290 insertions, 1298 deletions
diff --git a/engines/hugo/console.cpp b/engines/hugo/console.cpp index 19fd91e3fa..414c86e1d4 100644 --- a/engines/hugo/console.cpp +++ b/engines/hugo/console.cpp @@ -96,8 +96,8 @@ bool HugoConsole::Cmd_listObjects(int argc, const char **argv) { DebugPrintf("Available objects for this game are:\n"); for (int i = 0; i < _vm->_object->_numObj; i++) { - if (_vm->_object->_objects[i].genericCmd & TAKE) - DebugPrintf("%2d - %s\n", i, _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)); + if (_vm->_object->_objects[i]._genericCmd & TAKE) + DebugPrintf("%2d - %s\n", i, _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 2)); } return true; } @@ -111,7 +111,7 @@ bool HugoConsole::Cmd_getObject(int argc, const char **argv) { return true; } - if (_vm->_object->_objects[strToInt(argv[1])].genericCmd & TAKE) + if (_vm->_object->_objects[strToInt(argv[1])]._genericCmd & TAKE) _vm->_parser->takeObject(&_vm->_object->_objects[strToInt(argv[1])]); else DebugPrintf("Object not available\n"); @@ -129,7 +129,7 @@ bool HugoConsole::Cmd_getAllObjects(int argc, const char **argv) { } for (int i = 0; i < _vm->_object->_numObj; i++) { - if (_vm->_object->_objects[i].genericCmd & TAKE) + if (_vm->_object->_objects[i]._genericCmd & TAKE) _vm->_parser->takeObject(&_vm->_object->_objects[i]); } @@ -145,7 +145,7 @@ bool HugoConsole::Cmd_boundaries(int argc, const char **argv) { return true; } - _vm->getGameStatus().showBoundariesFl = !_vm->getGameStatus().showBoundariesFl; + _vm->getGameStatus()._showBoundariesFl = !_vm->getGameStatus()._showBoundariesFl; return false; } diff --git a/engines/hugo/dialogs.cpp b/engines/hugo/dialogs.cpp index e0b0198470..0efd47a3bd 100644 --- a/engines/hugo/dialogs.cpp +++ b/engines/hugo/dialogs.cpp @@ -34,19 +34,19 @@ namespace Hugo { -TopMenu::TopMenu(HugoEngine *vm) : Dialog(0, 0, kMenuWidth, kMenuHeight), arrayBmp(0), arraySize(0), +TopMenu::TopMenu(HugoEngine *vm) : Dialog(0, 0, kMenuWidth, kMenuHeight), _arrayBmp(0), _arraySize(0), _vm(vm) { init(); } TopMenu::~TopMenu() { - for (int i = 0; i < arraySize; i++) { - arrayBmp[i * 2]->free(); - delete arrayBmp[i * 2]; - arrayBmp[i * 2 + 1]->free(); - delete arrayBmp[i * 2 + 1]; + for (int i = 0; i < _arraySize; i++) { + _arrayBmp[i * 2]->free(); + delete _arrayBmp[i * 2]; + _arrayBmp[i * 2 + 1]->free(); + delete _arrayBmp[i * 2 + 1]; } - delete[] arrayBmp; + delete[] _arrayBmp; } void TopMenu::init() { @@ -108,23 +108,23 @@ void TopMenu::reflowLayout() { x += kButtonWidth + kButtonPad; // Set the graphics to the 'on' buttons, except for the variable ones - _whatButton->setGfx(arrayBmp[4 * kMenuWhat + scale - 1]); - _musicButton->setGfx(arrayBmp[4 * kMenuMusic + scale - 1 + ((_vm->_config.musicFl) ? 0 : 2)]); - _soundFXButton->setGfx(arrayBmp[4 * kMenuSoundFX + scale - 1 + ((_vm->_config.soundFl) ? 0 : 2)]); - _saveButton->setGfx(arrayBmp[4 * kMenuSave + scale - 1]); - _loadButton->setGfx(arrayBmp[4 * kMenuLoad + scale - 1]); - _recallButton->setGfx(arrayBmp[4 * kMenuRecall + scale - 1]); - _turboButton->setGfx(arrayBmp[4 * kMenuTurbo + scale - 1 + ((_vm->_config.turboFl) ? 0 : 2)]); - _lookButton->setGfx(arrayBmp[4 * kMenuLook + scale - 1]); - _inventButton->setGfx(arrayBmp[4 * kMenuInventory + scale - 1]); + _whatButton->setGfx(_arrayBmp[4 * kMenuWhat + scale - 1]); + _musicButton->setGfx(_arrayBmp[4 * kMenuMusic + scale - 1 + ((_vm->_config.musicFl) ? 0 : 2)]); + _soundFXButton->setGfx(_arrayBmp[4 * kMenuSoundFX + scale - 1 + ((_vm->_config.soundFl) ? 0 : 2)]); + _saveButton->setGfx(_arrayBmp[4 * kMenuSave + scale - 1]); + _loadButton->setGfx(_arrayBmp[4 * kMenuLoad + scale - 1]); + _recallButton->setGfx(_arrayBmp[4 * kMenuRecall + scale - 1]); + _turboButton->setGfx(_arrayBmp[4 * kMenuTurbo + scale - 1 + ((_vm->_config.turboFl) ? 0 : 2)]); + _lookButton->setGfx(_arrayBmp[4 * kMenuLook + scale - 1]); + _inventButton->setGfx(_arrayBmp[4 * kMenuInventory + scale - 1]); } void TopMenu::loadBmpArr(Common::SeekableReadStream &in) { - arraySize = in.readUint16BE(); + _arraySize = in.readUint16BE(); - delete arrayBmp; - arrayBmp = new Graphics::Surface *[arraySize * 2]; - for (int i = 0; i < arraySize; i++) { + delete _arrayBmp; + _arrayBmp = new Graphics::Surface *[_arraySize * 2]; + for (int i = 0; i < _arraySize; i++) { uint16 bmpSize = in.readUint16BE(); uint32 filPos = in.pos(); Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize); @@ -137,28 +137,28 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) { if (bitmapSrc->format.bytesPerPixel == 1) error("TopMenu::loadBmpArr(): Unhandled paletted image"); - arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat()); - arrayBmp[i * 2 + 1] = new Graphics::Surface(); - arrayBmp[i * 2 + 1]->create(arrayBmp[i * 2]->w * 2, arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat()); - byte *src = (byte *)arrayBmp[i * 2]->pixels; - byte *dst = (byte *)arrayBmp[i * 2 + 1]->pixels; - - for (int j = 0; j < arrayBmp[i * 2]->h; j++) { - src = (byte *)arrayBmp[i * 2]->getBasePtr(0, j); - dst = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2); - for (int k = arrayBmp[i * 2]->w; k > 0; k--) { - for (int m = arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) { + _arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat()); + _arrayBmp[i * 2 + 1] = new Graphics::Surface(); + _arrayBmp[i * 2 + 1]->create(_arrayBmp[i * 2]->w * 2, _arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat()); + byte *src = (byte *)_arrayBmp[i * 2]->pixels; + byte *dst = (byte *)_arrayBmp[i * 2 + 1]->pixels; + + for (int j = 0; j < _arrayBmp[i * 2]->h; j++) { + src = (byte *)_arrayBmp[i * 2]->getBasePtr(0, j); + dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2); + for (int k = _arrayBmp[i * 2]->w; k > 0; k--) { + for (int m = _arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) { *dst++ = *src++; } - src -= arrayBmp[i * 2]->format.bytesPerPixel; + src -= _arrayBmp[i * 2]->format.bytesPerPixel; - for (int m = arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) { + for (int m = _arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) { *dst++ = *src++; } } - src = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2); - dst = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2 + 1); - for (int k = arrayBmp[i * 2 + 1]->pitch; k > 0; k--) { + src = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2); + dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2 + 1); + for (int k = _arrayBmp[i * 2 + 1]->pitch; k > 0; k--) { *dst++ = *src++; } } @@ -171,12 +171,12 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d switch (command) { case kCmdWhat: close(); - _vm->getGameStatus().helpFl = true; + _vm->getGameStatus()._helpFl = true; break; case kCmdMusic: _vm->_sound->toggleMusic(); - _musicButton->setGfx(arrayBmp[4 * kMenuMusic + (g_system->getOverlayWidth() > 320 ? 2 : 1) - 1 + ((_vm->_config.musicFl) ? 0 : 2)]); + _musicButton->setGfx(_arrayBmp[4 * kMenuMusic + (g_system->getOverlayWidth() > 320 ? 2 : 1) - 1 + ((_vm->_config.musicFl) ? 0 : 2)]); _musicButton->draw(); g_gui.theme()->updateScreen(); g_system->updateScreen(); @@ -194,8 +194,8 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d break; case kCmdSave: close(); - if (_vm->getGameStatus().viewState == kViewPlay) { - if (_vm->getGameStatus().gameOverFl) + if (_vm->getGameStatus()._viewState == kViewPlay) { + if (_vm->getGameStatus()._gameOverFl) _vm->gameOverMsg(); else _vm->_file->saveGame(-1, Common::String()); @@ -207,7 +207,7 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d break; case kCmdRecall: close(); - _vm->getGameStatus().recallFl = true; + _vm->getGameStatus()._recallFl = true; break; case kCmdTurbo: _vm->_parser->switchTurbo(); diff --git a/engines/hugo/dialogs.h b/engines/hugo/dialogs.h index 4e710ff2f8..114bcf56a9 100644 --- a/engines/hugo/dialogs.h +++ b/engines/hugo/dialogs.h @@ -94,8 +94,8 @@ protected: GUI::PicButtonWidget *_lookButton; GUI::PicButtonWidget *_inventButton; - Graphics::Surface **arrayBmp; - uint16 arraySize; + Graphics::Surface **_arrayBmp; + uint16 _arraySize; }; class EntryDialog : public GUI::Dialog { diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index fa18d6b791..7028195dd4 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -239,13 +239,13 @@ void Screen::setBackgroundColor(const uint16 color) { void Screen::displayFrame(const int sx, const int sy, seq_t *seq, const bool foreFl) { debugC(3, kDebugDisplay, "displayFrame(%d, %d, seq, %d)", sx, sy, (foreFl) ? 1 : 0); - image_pt image = seq->imagePtr; // Ptr to object image data + image_pt image = seq->_imagePtr; // Ptr to object image data image_pt subFrontBuffer = &_frontBuffer[sy * kXPix + sx]; // Ptr to offset in _frontBuffer - int16 frontBufferwrap = kXPix - seq->x2 - 1; // Wraps dest_p after each line - int16 imageWrap = seq->bytesPerLine8 - seq->x2 - 1; + int16 frontBufferwrap = kXPix - seq->_x2 - 1; // Wraps dest_p after each line + int16 imageWrap = seq->_bytesPerLine8 - seq->_x2 - 1; overlayState_t overlayState = (foreFl) ? kOvlForeground : kOvlUndef; // Overlay state of object - for (uint16 y = 0; y < seq->lines; y++) { // Each line in object - for (uint16 x = 0; x <= seq->x2; x++) { + for (uint16 y = 0; y < seq->_lines; y++) { // Each line in object + for (uint16 x = 0; x <= seq->_x2; x++) { if (*image) { // Non-transparent byte ovlBound = _vm->_object->getFirstOverlay((uint16)(subFrontBuffer - _frontBuffer) >> 3); // Ptr into overlay bits if (ovlBound & (0x80 >> ((uint16)(subFrontBuffer - _frontBuffer) & 7))) { // Overlay bit is set @@ -265,7 +265,7 @@ void Screen::displayFrame(const int sx, const int sy, seq_t *seq, const bool for } // Add this rectangle to the display list - displayList(kDisplayAdd, sx, sy, seq->x2 + 1, seq->lines); + displayList(kDisplayAdd, sx, sy, seq->_x2 + 1, seq->_lines); } /** @@ -359,8 +359,8 @@ void Screen::displayList(dupdate_t update, ...) { // Don't blit if newscreen just loaded because _frontBuffer will // get blitted via InvalidateRect() at end of this cycle // and blitting here causes objects to appear too soon. - if (_vm->getGameStatus().newScreenFl) { - _vm->getGameStatus().newScreenFl = false; + if (_vm->getGameStatus()._newScreenFl) { + _vm->getGameStatus()._newScreenFl = false; break; } @@ -563,7 +563,7 @@ void Screen::initNewScreenDisplay() { displayBackground(); // Stop premature object display in Display_list(D_DISPLAY) - _vm->getGameStatus().newScreenFl = true; + _vm->getGameStatus()._newScreenFl = true; } /** @@ -650,19 +650,19 @@ bool Screen::isOverlapping(const rect_t *rectA, const rect_t *rectB) const { * White = Fix objects, parts of background */ void Screen::drawBoundaries() { - if (!_vm->getGameStatus().showBoundariesFl) + if (!_vm->getGameStatus()._showBoundariesFl) return; _vm->_mouse->drawHotspots(); for (int i = 0; i < _vm->_object->_numObj; i++) { object_t *obj = &_vm->_object->_objects[i]; // Get pointer to object - if (obj->screenIndex == *_vm->_screen_p) { - if ((obj->currImagePtr != 0) && (obj->cycling != kCycleInvisible)) - drawRectangle(false, obj->x + obj->currImagePtr->x1, obj->y + obj->currImagePtr->y1, - obj->x + obj->currImagePtr->x2, obj->y + obj->currImagePtr->y2, _TLIGHTGREEN); - else if ((obj->currImagePtr == 0) && (obj->vxPath != 0) && !obj->carriedFl) - drawRectangle(false, obj->oldx, obj->oldy, obj->oldx + obj->vxPath, obj->oldy + obj->vyPath, _TBRIGHTWHITE); + if (obj->_screenIndex == *_vm->_screen_p) { + if ((obj->_currImagePtr != 0) && (obj->_cycling != kCycleInvisible)) + drawRectangle(false, obj->_x + obj->_currImagePtr->_x1, obj->_y + obj->_currImagePtr->_y1, + obj->_x + obj->_currImagePtr->_x2, obj->_y + obj->_currImagePtr->_y2, _TLIGHTGREEN); + else if ((obj->_currImagePtr == 0) && (obj->_vxPath != 0) && !obj->_carriedFl) + drawRectangle(false, obj->_oldx, obj->_oldy, obj->_oldx + obj->_vxPath, obj->_oldy + obj->_vyPath, _TBRIGHTWHITE); } } g_system->copyRectToScreen(_frontBuffer, 320, 0, 0, 320, 200); @@ -735,7 +735,7 @@ overlayState_t Screen_v1d::findOvl(seq_t *seq_p, image_pt dst_p, uint16 y) { uint16 index = (uint16)(dst_p - _frontBuffer) >> 3; - for (int i = 0; i < seq_p->lines-y; i++) { // Each line in object + for (int i = 0; i < seq_p->_lines-y; i++) { // Each line in object if (_vm->_object->getBaseBoundary(index)) // If any overlay base byte is non-zero then the object is foreground, else back. return kOvlForeground; index += kCompLineSize; @@ -802,7 +802,7 @@ void Screen_v1w::loadFontArr(Common::ReadStream &in) { overlayState_t Screen_v1w::findOvl(seq_t *seq_p, image_pt dst_p, uint16 y) { debugC(4, kDebugDisplay, "findOvl()"); - for (; y < seq_p->lines; y++) { // Each line in object + for (; y < seq_p->_lines; y++) { // Each line in object byte ovb = _vm->_object->getBaseBoundary((uint16)(dst_p - _frontBuffer) >> 3); // Ptr into overlay bits if (ovb & (0x80 >> ((uint16)(dst_p - _frontBuffer) & 7))) // Overlay bit is set return kOvlForeground; // Found a bit - must be foreground diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index f94f3b0443..8b03a9a430 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -143,11 +143,11 @@ seq_t *FileManager::readPCX(Common::ReadStream &f, seq_t *seqPtr, byte *imagePtr // Find size of image data in 8-bit DIB format // Note save of x2 - marks end of valid data before garbage uint16 bytesPerLine4 = PCC_header.bytesPerLine * 4; // 4-bit bpl - seqPtr->bytesPerLine8 = bytesPerLine4 * 2; // 8-bit bpl - seqPtr->lines = PCC_header.y2 - PCC_header.y1 + 1; - seqPtr->x2 = PCC_header.x2 - PCC_header.x1 + 1; + seqPtr->_bytesPerLine8 = bytesPerLine4 * 2; // 8-bit bpl + seqPtr->_lines = PCC_header.y2 - PCC_header.y1 + 1; + seqPtr->_x2 = PCC_header.x2 - PCC_header.x1 + 1; // Size of the image - uint16 size = seqPtr->lines * seqPtr->bytesPerLine8; + uint16 size = seqPtr->_lines * seqPtr->_bytesPerLine8; // Allocate memory for image data if NULL if (imagePtr == 0) @@ -155,13 +155,13 @@ seq_t *FileManager::readPCX(Common::ReadStream &f, seq_t *seqPtr, byte *imagePtr assert(imagePtr); - seqPtr->imagePtr = imagePtr; + seqPtr->_imagePtr = imagePtr; // Process the image data, converting to 8-bit DIB format uint16 y = 0; // Current line index byte pline[kXPix]; // Hold 4 planes of data byte *p = pline; // Ptr to above - while (y < seqPtr->lines) { + while (y < seqPtr->_lines) { byte c = f.readByte(); if ((c & kRepeatMask) == kRepeatMask) { byte d = f.readByte(); // Read data byte @@ -193,7 +193,7 @@ void FileManager::readImage(const int objNum, object_t *objPtr) { uint32 objLength; }; - if (!objPtr->seqNumb) // This object has no images + if (!objPtr->_seqNumb) // This object has no images return; if (_vm->isPacked()) { @@ -206,9 +206,9 @@ void FileManager::readImage(const int objNum, object_t *objPtr) { _objectsArchive.seek(objBlock.objOffset, SEEK_SET); } else { Common::String buf; - buf = _vm->_picDir + Common::String(_vm->_text->getNoun(objPtr->nounIndex, 0)) + ".PIX"; + buf = _vm->_picDir + Common::String(_vm->_text->getNoun(objPtr->_nounIndex, 0)) + ".PIX"; if (!_objectsArchive.open(buf)) { - buf = Common::String(_vm->_text->getNoun(objPtr->nounIndex, 0)) + ".PIX"; + buf = Common::String(_vm->_text->getNoun(objPtr->_nounIndex, 0)) + ".PIX"; if (!_objectsArchive.open(buf)) error("File not found: %s", buf.c_str()); } @@ -218,60 +218,60 @@ void FileManager::readImage(const int objNum, object_t *objPtr) { seq_t *seqPtr = 0; // Ptr to sequence structure // Now read the images into an images list - for (int j = 0; j < objPtr->seqNumb; j++) { // for each sequence - for (int k = 0; k < objPtr->seqList[j].imageNbr; k++) { // each image + for (int j = 0; j < objPtr->_seqNumb; j++) { // for each sequence + for (int k = 0; k < objPtr->_seqList[j]._imageNbr; k++) { // each image if (k == 0) { // First image // Read this image - allocate both seq and image memory - seqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->nounIndex, 0)); - objPtr->seqList[j].seqPtr = seqPtr; + seqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->_nounIndex, 0)); + objPtr->_seqList[j]._seqPtr = seqPtr; firstImgFl = false; } else { // Subsequent image // Read this image - allocate both seq and image memory - seqPtr->nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->nounIndex, 0)); - seqPtr = seqPtr->nextSeqPtr; + seqPtr->_nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->_nounIndex, 0)); + seqPtr = seqPtr->_nextSeqPtr; } // Compute the bounding box - x1, x2, y1, y2 // Note use of x2 - marks end of valid data in row - uint16 x2 = seqPtr->x2; - seqPtr->x1 = seqPtr->x2; - seqPtr->x2 = 0; - seqPtr->y1 = seqPtr->lines; - seqPtr->y2 = 0; - - image_pt dibPtr = seqPtr->imagePtr; - for (int y = 0; y < seqPtr->lines; y++, dibPtr += seqPtr->bytesPerLine8 - x2) { + uint16 x2 = seqPtr->_x2; + seqPtr->_x1 = seqPtr->_x2; + seqPtr->_x2 = 0; + seqPtr->_y1 = seqPtr->_lines; + seqPtr->_y2 = 0; + + image_pt dibPtr = seqPtr->_imagePtr; + for (int y = 0; y < seqPtr->_lines; y++, dibPtr += seqPtr->_bytesPerLine8 - x2) { for (int x = 0; x < x2; x++) { if (*dibPtr++) { // Some data found - if (x < seqPtr->x1) - seqPtr->x1 = x; - if (x > seqPtr->x2) - seqPtr->x2 = x; - if (y < seqPtr->y1) - seqPtr->y1 = y; - if (y > seqPtr->y2) - seqPtr->y2 = y; + if (x < seqPtr->_x1) + seqPtr->_x1 = x; + if (x > seqPtr->_x2) + seqPtr->_x2 = x; + if (y < seqPtr->_y1) + seqPtr->_y1 = y; + if (y > seqPtr->_y2) + seqPtr->_y2 = y; } } } } assert(seqPtr); - seqPtr->nextSeqPtr = objPtr->seqList[j].seqPtr; // loop linked list to head + seqPtr->_nextSeqPtr = objPtr->_seqList[j]._seqPtr; // loop linked list to head } // Set the current image sequence to first or last - switch (objPtr->cycling) { + switch (objPtr->_cycling) { case kCycleInvisible: // (May become visible later) case kCycleAlmostInvisible: case kCycleNotCycling: case kCycleForward: - objPtr->currImagePtr = objPtr->seqList[0].seqPtr; + objPtr->_currImagePtr = objPtr->_seqList[0]._seqPtr; break; case kCycleBackward: - objPtr->currImagePtr = seqPtr; + objPtr->_currImagePtr = seqPtr; break; default: - warning("Unexpected cycling: %d", objPtr->cycling); + warning("Unexpected cycling: %d", objPtr->_cycling); } if (!_vm->isPacked()) @@ -298,25 +298,25 @@ sound_pt FileManager::getSound(const int16 sound, uint16 *size) { if (!has_read_header) { for (int i = 0; i < kMaxSounds; i++) { - s_hdr[i].size = fp.readUint16LE(); - s_hdr[i].offset = fp.readUint32LE(); + s_hdr[i]._size = fp.readUint16LE(); + s_hdr[i]._offset = fp.readUint32LE(); } if (fp.err()) error("Wrong sound file format"); has_read_header = true; } - *size = s_hdr[sound].size; + *size = s_hdr[sound]._size; if (*size == 0) error("Wrong sound file format or missing sound %d", sound); // Allocate memory for sound or music, if possible - sound_pt soundPtr = (byte *)malloc(s_hdr[sound].size); // Ptr to sound data + sound_pt soundPtr = (byte *)malloc(s_hdr[sound]._size); // Ptr to sound data assert(soundPtr); // Seek to data and read it - fp.seek(s_hdr[sound].offset, SEEK_SET); - if (fp.read(soundPtr, s_hdr[sound].size) != s_hdr[sound].size) + fp.seek(s_hdr[sound]._offset, SEEK_SET); + if (fp.read(soundPtr, s_hdr[sound]._size) != s_hdr[sound]._size) error("Wrong sound file format"); fp.close(); @@ -391,13 +391,13 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) { out->writeSint16BE(_vm->getScore()); // Save story mode - out->writeByte((gameStatus.storyModeFl) ? 1 : 0); + out->writeByte((gameStatus._storyModeFl) ? 1 : 0); // Save jumpexit mode out->writeByte((_vm->_mouse->getJumpExitFl()) ? 1 : 0); // Save gameover status - out->writeByte((gameStatus.gameOverFl) ? 1 : 0); + out->writeByte((gameStatus._gameOverFl) ? 1 : 0); // Save screen states for (int i = 0; i < _vm->_numStates; i++) @@ -408,17 +408,17 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) { _vm->_screen->savePal(out); // Save maze status - out->writeByte((_vm->_maze.enabledFl) ? 1 : 0); - out->writeByte(_vm->_maze.size); - out->writeSint16BE(_vm->_maze.x1); - out->writeSint16BE(_vm->_maze.y1); - out->writeSint16BE(_vm->_maze.x2); - out->writeSint16BE(_vm->_maze.y2); - out->writeSint16BE(_vm->_maze.x3); - out->writeSint16BE(_vm->_maze.x4); - out->writeByte(_vm->_maze.firstScreenIndex); - - out->writeByte((byte)_vm->getGameStatus().viewState); + out->writeByte((_vm->_maze._enabledFl) ? 1 : 0); + out->writeByte(_vm->_maze._size); + out->writeSint16BE(_vm->_maze._x1); + out->writeSint16BE(_vm->_maze._y1); + out->writeSint16BE(_vm->_maze._x2); + out->writeSint16BE(_vm->_maze._y2); + out->writeSint16BE(_vm->_maze._x3); + out->writeSint16BE(_vm->_maze._x4); + out->writeByte(_vm->_maze._firstScreenIndex); + + out->writeByte((byte)_vm->getGameStatus()._viewState); out->finalize(); @@ -491,9 +491,9 @@ bool FileManager::restoreGame(const int16 slot) { int score = in->readSint16BE(); _vm->setScore(score); - gameStatus.storyModeFl = (in->readByte() == 1); + gameStatus._storyModeFl = (in->readByte() == 1); _vm->_mouse->setJumpExitFl(in->readByte() == 1); - gameStatus.gameOverFl = (in->readByte() == 1); + gameStatus._gameOverFl = (in->readByte() == 1); for (int i = 0; i < _vm->_numStates; i++) _vm->_screenStates[i] = in->readByte(); @@ -503,18 +503,18 @@ bool FileManager::restoreGame(const int16 slot) { _vm->_screen->restorePal(in); // Restore maze status - _vm->_maze.enabledFl = (in->readByte() == 1); - _vm->_maze.size = in->readByte(); - _vm->_maze.x1 = in->readSint16BE(); - _vm->_maze.y1 = in->readSint16BE(); - _vm->_maze.x2 = in->readSint16BE(); - _vm->_maze.y2 = in->readSint16BE(); - _vm->_maze.x3 = in->readSint16BE(); - _vm->_maze.x4 = in->readSint16BE(); - _vm->_maze.firstScreenIndex = in->readByte(); + _vm->_maze._enabledFl = (in->readByte() == 1); + _vm->_maze._size = in->readByte(); + _vm->_maze._x1 = in->readSint16BE(); + _vm->_maze._y1 = in->readSint16BE(); + _vm->_maze._x2 = in->readSint16BE(); + _vm->_maze._y2 = in->readSint16BE(); + _vm->_maze._x3 = in->readSint16BE(); + _vm->_maze._x4 = in->readSint16BE(); + _vm->_maze._firstScreenIndex = in->readByte(); _vm->_scheduler->restoreScreen(*_vm->_screen_p); - if ((_vm->getGameStatus().viewState = (vstate_t) in->readByte()) != kViewPlay) + if ((_vm->getGameStatus()._viewState = (vstate_t) in->readByte()) != kViewPlay) _vm->_screen->hideCursor(); @@ -536,25 +536,25 @@ void FileManager::printBootText() { return; } else { Utils::notifyBox(Common::String::format("Missing startup file '%s'", getBootFilename())); - _vm->getGameStatus().doQuitFl = true; + _vm->getGameStatus()._doQuitFl = true; return; } } // Allocate space for the text and print it - char *buf = (char *)malloc(_vm->_boot.exit_len + 1); + char *buf = (char *)malloc(_vm->_boot._exitLen + 1); if (buf) { // Skip over the boot structure (already read) and read exit text ofp.seek((long)sizeof(_vm->_boot), SEEK_SET); - if (ofp.read(buf, _vm->_boot.exit_len) != (size_t)_vm->_boot.exit_len) { + if (ofp.read(buf, _vm->_boot._exitLen) != (size_t)_vm->_boot._exitLen) { Utils::notifyBox(Common::String::format("Error while reading startup file '%s'", getBootFilename())); - _vm->getGameStatus().doQuitFl = true; + _vm->getGameStatus()._doQuitFl = true; return; } // Decrypt the exit text, using CRYPT substring int i; - for (i = 0; i < _vm->_boot.exit_len; i++) + for (i = 0; i < _vm->_boot._exitLen; i++) buf[i] ^= s_bootCypher[i % s_bootCypherLen]; buf[i] = '\0'; @@ -577,32 +577,32 @@ void FileManager::readBootFile() { if (_vm->_gameVariant == kGameVariantH1Dos) { //TODO initialize properly _boot structure warning("readBootFile - Skipping as H1 Dos may be a freeware"); - memset(_vm->_boot.distrib, '\0', sizeof(_vm->_boot.distrib)); - _vm->_boot.registered = kRegFreeware; + memset(_vm->_boot._distrib, '\0', sizeof(_vm->_boot._distrib)); + _vm->_boot._registered = kRegFreeware; return; } else if (_vm->getPlatform() == Common::kPlatformPC) { warning("readBootFile - Skipping as H2 and H3 Dos may be shareware"); - memset(_vm->_boot.distrib, '\0', sizeof(_vm->_boot.distrib)); - _vm->_boot.registered = kRegShareware; + memset(_vm->_boot._distrib, '\0', sizeof(_vm->_boot._distrib)); + _vm->_boot._registered = kRegShareware; return; } else { Utils::notifyBox(Common::String::format("Missing startup file '%s'", getBootFilename())); - _vm->getGameStatus().doQuitFl = true; + _vm->getGameStatus()._doQuitFl = true; return; } } if (ofp.size() < (int32)sizeof(_vm->_boot)) { Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename())); - _vm->getGameStatus().doQuitFl = true; + _vm->getGameStatus()._doQuitFl = true; return; } - _vm->_boot.checksum = ofp.readByte(); - _vm->_boot.registered = ofp.readByte(); - ofp.read(_vm->_boot.pbswitch, sizeof(_vm->_boot.pbswitch)); - ofp.read(_vm->_boot.distrib, sizeof(_vm->_boot.distrib)); - _vm->_boot.exit_len = ofp.readUint16LE(); + _vm->_boot._checksum = ofp.readByte(); + _vm->_boot._registered = ofp.readByte(); + ofp.read(_vm->_boot._pbswitch, sizeof(_vm->_boot._pbswitch)); + ofp.read(_vm->_boot._distrib, sizeof(_vm->_boot._distrib)); + _vm->_boot._exitLen = ofp.readUint16LE(); byte *p = (byte *)&_vm->_boot; @@ -615,7 +615,7 @@ void FileManager::readBootFile() { if (checksum) { Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename())); - _vm->getGameStatus().doQuitFl = true; + _vm->getGameStatus()._doQuitFl = true; } } diff --git a/engines/hugo/game.h b/engines/hugo/game.h index b1c5f407b3..ab5e2dff56 100644 --- a/engines/hugo/game.h +++ b/engines/hugo/game.h @@ -84,11 +84,11 @@ enum path_t { }; struct hugo_boot_t { // Common HUGO boot file - char checksum; // Checksum for boot structure (not exit text) - char registered; // TRUE if registered version, else FALSE - char pbswitch[8]; // Playback switch string - char distrib[32]; // Distributor branding string - uint16 exit_len; // Length of exit text (next in file) + char _checksum; // Checksum for boot structure (not exit text) + char _registered; // TRUE if registered version, else FALSE + char _pbswitch[8]; // Playback switch string + char _distrib[32]; // Distributor branding string + uint16 _exitLen; // Length of exit text (next in file) } PACKED_STRUCT; /** @@ -101,11 +101,11 @@ typedef byte *sound_pt; // ptr to sound (or music) d * Structure for initializing maze processing */ struct maze_t { - bool enabledFl; // TRUE when maze processing enabled - byte size; // Size of (square) maze matrix - int x1, y1, x2, y2; // maze hotspot bounding box - int x3, x4; // north, south x entry coordinates - byte firstScreenIndex; // index of first screen in maze + bool _enabledFl; // TRUE when maze processing enabled + byte _size; // Size of (square) maze matrix + int _x1, _y1, _x2, _y2; // maze hotspot bounding box + int _x3, _x4; // north, south x entry coordinates + byte _firstScreenIndex; // index of first screen in maze }; /** @@ -113,25 +113,25 @@ struct maze_t { * The image data is in 8-bit DIB format, i.e. 1 byte = 1 pixel */ struct seq_t { // Linked list of images - byte *imagePtr; // ptr to image - uint16 bytesPerLine8; // bytes per line (8bits) - uint16 lines; // lines - uint16 x1, x2, y1, y2; // Offsets from x,y: data bounding box - seq_t *nextSeqPtr; // ptr to next record + byte *_imagePtr; // ptr to image + uint16 _bytesPerLine8; // bytes per line (8bits) + uint16 _lines; // lines + uint16 _x1, _x2, _y1, _y2; // Offsets from x,y: data bounding box + seq_t *_nextSeqPtr; // ptr to next record }; /** * The following is an array of structures of above sequences */ struct seqList_t { - uint16 imageNbr; // Number of images in sequence - seq_t *seqPtr; // Ptr to sequence structure + uint16 _imageNbr; // Number of images in sequence + seq_t *_seqPtr; // Ptr to sequence structure }; #include "common/pack-start.h" // START STRUCT PACKING struct sound_hdr_t { // Sound file lookup entry - uint16 size; // Size of sound data in bytes - uint32 offset; // Offset of sound data in file + uint16 _size; // Size of sound data in bytes + uint32 _offset; // Offset of sound data in file } PACKED_STRUCT; #include "common/pack-end.h" // END STRUCT PACKING @@ -141,37 +141,37 @@ static const int kMaxSeqNumb = 4; // Number of sequences of im * Following is definition of object attributes */ struct object_t { - uint16 nounIndex; // String identifying object - uint16 dataIndex; // String describing the object - uint16 *stateDataIndex; // Added by Strangerke to handle the LOOK_S state-dependant descriptions - path_t pathType; // Describe path object follows - int vxPath, vyPath; // Delta velocities (e.g. for CHASE) - uint16 actIndex; // Action list to do on collision with hero - byte seqNumb; // Number of sequences in list - seq_t *currImagePtr; // Sequence image currently in use - seqList_t seqList[kMaxSeqNumb]; // Array of sequence structure ptrs and lengths - cycle_t cycling; // Whether cycling, forward or backward - byte cycleNumb; // No. of times to cycle - byte frameInterval; // Interval (in ticks) between frames - byte frameTimer; // Decrementing timer for above - int8 radius; // Defines sphere of influence by hero - byte screenIndex; // Screen in which object resides - int x, y; // Current coordinates of object - int oldx, oldy; // Previous coordinates of object - int8 vx, vy; // Velocity - byte objValue; // Value of object - int genericCmd; // Bit mask of 'generic' commands for object - uint16 cmdIndex; // ptr to list of cmd structures for verbs - bool carriedFl; // TRUE if object being carried - byte state; // state referenced in cmd list - bool verbOnlyFl; // TRUE if verb-only cmds allowed e.g. sit,look - byte priority; // Whether object fore, background or floating - int16 viewx, viewy; // Position to view object from (or 0 or -1) - int16 direction; // Direction to view object from - byte curSeqNum; // Save which seq number currently in use - byte curImageNum; // Save which image of sequence currently in use - int8 oldvx; // Previous vx (used in wandering) - int8 oldvy; // Previous vy + uint16 _nounIndex; // String identifying object + uint16 _dataIndex; // String describing the object + uint16 *_stateDataIndex; // Added by Strangerke to handle the LOOK_S state-dependant descriptions + path_t _pathType; // Describe path object follows + int _vxPath, _vyPath; // Delta velocities (e.g. for CHASE) + uint16 _actIndex; // Action list to do on collision with hero + byte _seqNumb; // Number of sequences in list + seq_t *_currImagePtr; // Sequence image currently in use + seqList_t _seqList[kMaxSeqNumb]; // Array of sequence structure ptrs and lengths + cycle_t _cycling; // Whether cycling, forward or backward + byte _cycleNumb; // No. of times to cycle + byte _frameInterval; // Interval (in ticks) between frames + byte _frameTimer; // Decrementing timer for above + int8 _radius; // Defines sphere of influence by hero + byte _screenIndex; // Screen in which object resides + int _x, _y; // Current coordinates of object + int _oldx, _oldy; // Previous coordinates of object + int8 _vx, _vy; // Velocity + byte _objValue; // Value of object + int _genericCmd; // Bit mask of 'generic' commands for object + uint16 _cmdIndex; // ptr to list of cmd structures for verbs + bool _carriedFl; // TRUE if object being carried + byte _state; // state referenced in cmd list + bool _verbOnlyFl; // TRUE if verb-only cmds allowed e.g. sit,look + byte _priority; // Whether object fore, background or floating + int16 _viewx, _viewy; // Position to view object from (or 0 or -1) + int16 _direction; // Direction to view object from + byte _curSeqNum; // Save which seq number currently in use + byte _curImageNum; // Save which image of sequence currently in use + int8 _oldvx; // Previous vx (used in wandering) + int8 _oldvy; // Previous vy }; } // End of namespace Hugo diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index df8abf32eb..450f4ff837 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -249,24 +249,24 @@ Common::Error HugoEngine::run() { initStatus(); // Initialize game status initConfig(); // Initialize user's config - if (!_status.doQuitFl) { + if (!_status._doQuitFl) { initialize(); resetConfig(); // Reset user's config initMachine(); // Start the state machine - _status.viewState = kViewIntroInit; + _status._viewState = kViewIntroInit; int16 loadSlot = Common::ConfigManager::instance().getInt("save_slot"); if (loadSlot >= 0) { - _status.skipIntroFl = true; + _status._skipIntroFl = true; _file->restoreGame(loadSlot); } else { _file->saveGame(0, "New Game"); } } - while (!_status.doQuitFl) { + while (!_status._doQuitFl) { _screen->drawBoundaries(); g_system->updateScreen(); runMachine(); @@ -289,20 +289,20 @@ Common::Error HugoEngine::run() { _mouse->setRightButton(); break; case Common::EVENT_QUIT: - _status.doQuitFl = true; + _status._doQuitFl = true; break; default: break; } } - if (_status.helpFl) { - _status.helpFl = false; + if (_status._helpFl) { + _status._helpFl = false; _file->instructions(); } _mouse->mouseHandler(); // Mouse activity - adds to display list _screen->displayList(kDisplayDisplay); // Blit the display list to screen - _status.doQuitFl |= shouldQuit(); // update game quit flag + _status._doQuitFl |= shouldQuit(); // update game quit flag } return Common::kNoError; } @@ -326,7 +326,7 @@ void HugoEngine::runMachine() { status_t &gameStatus = getGameStatus(); // Don't process if gameover - if (gameStatus.gameOverFl) + if (gameStatus._gameOverFl) return; _curTime = g_system->getMillis(); @@ -338,19 +338,19 @@ void HugoEngine::runMachine() { _lastTime = _curTime; - switch (gameStatus.viewState) { + switch (gameStatus._viewState) { case kViewIdle: // Not processing state machine _screen->hideCursor(); _intro->preNewGame(); // Any processing before New Game selected break; case kViewIntroInit: // Initialization before intro begins _intro->introInit(); - gameStatus.viewState = kViewIntro; + gameStatus._viewState = kViewIntro; break; case kViewIntro: // Do any game-dependant preamble if (_intro->introPlay()) { // Process intro screen _scheduler->newScreen(0); // Initialize first screen - gameStatus.viewState = kViewPlay; + gameStatus._viewState = kViewPlay; } break; case kViewPlay: // Playing game @@ -368,8 +368,8 @@ void HugoEngine::runMachine() { _inventory->runInventory(); // Process Inventory state machine break; case kViewExit: // Game over or user exited - gameStatus.viewState = kViewIdle; - _status.doQuitFl = true; + gameStatus._viewState = kViewIdle; + _status._doQuitFl = true; break; } } @@ -427,7 +427,7 @@ bool HugoEngine::loadHugoDat() { _scheduler->loadActListArr(in); _scheduler->loadAlNewscrIndex(in); _hero = &_object->_objects[kHeroIndex]; // This always points to hero - _screen_p = &(_object->_objects[kHeroIndex].screenIndex); // Current screen is hero's + _screen_p = &(_object->_objects[kHeroIndex]._screenIndex); // Current screen is hero's _heroImage = kHeroIndex; // Current in use hero image for (int varnt = 0; varnt < _numVariant; varnt++) { @@ -527,33 +527,33 @@ void HugoEngine::initPlaylist(bool playlist[kMaxTunes]) { */ void HugoEngine::initStatus() { debugC(1, kDebugEngine, "initStatus"); - _status.storyModeFl = false; // Not in story mode - _status.gameOverFl = false; // Hero not knobbled yet - _status.lookFl = false; // Toolbar "look" button - _status.recallFl = false; // Toolbar "recall" button - _status.newScreenFl = false; // Screen not just loaded - _status.godModeFl = false; // No special cheats allowed - _status.showBoundariesFl = false; // Boundaries hidden by default - _status.doQuitFl = false; - _status.skipIntroFl = false; - _status.helpFl = false; + _status._storyModeFl = false; // Not in story mode + _status._gameOverFl = false; // Hero not knobbled yet + _status._lookFl = false; // Toolbar "look" button + _status._recallFl = false; // Toolbar "recall" button + _status._newScreenFl = false; // Screen not just loaded + _status._godModeFl = false; // No special cheats allowed + _status._showBoundariesFl = false; // Boundaries hidden by default + _status._doQuitFl = false; + _status._skipIntroFl = false; + _status._helpFl = false; // Initialize every start of new game - _status.tick = 0; // Tick count - _status.viewState = kViewIdle; // View state + _status._tick = 0; // Tick count + _status._viewState = kViewIdle; // View state // Strangerke - Suppress as related to playback -// _status.recordFl = false; // Not record mode -// _status.playbackFl = false; // Not playback mode +// _status._recordFl = false; // Not record mode +// _status._playbackFl = false; // Not playback mode // Strangerke - Not used ? -// _status.mmtime = false; // Multimedia timer support -// _status.helpFl = false; // Not calling WinHelp() -// _status.demoFl = false; // Not demo mode -// _status.path[0] = 0; // Path to write files -// _status.screenWidth = 0; // Desktop screen width -// _status.saveTick = 0; // Time of last save -// _status.saveSlot = 0; // Slot to save/restore game -// _status.textBoxFl = false; // Not processing a text box +// _status._mmtime = false; // Multimedia timer support +// _status._helpFl = false; // Not calling WinHelp() +// _status._demoFl = false; // Not demo mode +// _status._path[0] = 0; // Path to write files +// _status._screenWidth = 0; // Desktop screen width +// _status._saveTick = 0; // Time of last save +// _status._saveSlot = 0; // Slot to save/restore game +// _status._textBoxFl = false; // Not processing a text box } /** @@ -587,7 +587,7 @@ void HugoEngine::resetConfig() { void HugoEngine::initialize() { debugC(1, kDebugEngine, "initialize"); - _maze.enabledFl = false; + _maze._enabledFl = false; _line[0] = '\0'; _sound->initSound(); @@ -679,10 +679,10 @@ void HugoEngine::calcMaxScore() { void HugoEngine::endGame() { debugC(1, kDebugEngine, "endGame"); - if (_boot.registered != kRegRegistered) + if (_boot._registered != kRegRegistered) Utils::notifyBox(_text->getTextEngine(kEsAdvertise)); Utils::notifyBox(Common::String::format("%s\n%s", _episode, getCopyrightString())); - _status.viewState = kViewExit; + _status._viewState = kViewExit; } bool HugoEngine::canLoadGameStateCurrently() { @@ -690,7 +690,7 @@ bool HugoEngine::canLoadGameStateCurrently() { } bool HugoEngine::canSaveGameStateCurrently() { - return (_status.viewState == kViewPlay); + return (_status._viewState == kViewPlay); } int8 HugoEngine::getTPS() const { diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h index 125819a39b..3ad6fced24 100644 --- a/engines/hugo/hugo.h +++ b/engines/hugo/hugo.h @@ -171,20 +171,20 @@ enum seqTextEngine { struct HugoGameDescription; struct status_t { // Game status (not saved) - bool storyModeFl; // Game is telling story - no commands - bool gameOverFl; // Game is over - hero knobbled - bool lookFl; // Toolbar "look" button pressed - bool recallFl; // Toolbar "recall" button pressed - bool newScreenFl; // New screen just loaded in dib_a - bool godModeFl; // Allow DEBUG features in live version - bool showBoundariesFl; // Flag used to show and hide boundaries, + bool _storyModeFl; // Game is telling story - no commands + bool _gameOverFl; // Game is over - hero knobbled + bool _lookFl; // Toolbar "look" button pressed + bool _recallFl; // Toolbar "recall" button pressed + bool _newScreenFl; // New screen just loaded in dib_a + bool _godModeFl; // Allow DEBUG features in live version + bool _showBoundariesFl; // Flag used to show and hide boundaries, // used by the console - bool doQuitFl; - bool skipIntroFl; - bool helpFl; - uint32 tick; // Current time in ticks - vstate_t viewState; // View state machine - int16 song; // Current song + bool _doQuitFl; + bool _skipIntroFl; + bool _helpFl; + uint32 _tick; // Current time in ticks + vstate_t _viewState; // View state machine + int16 _song; // Current song // Strangerke - Suppress as related to playback // bool playbackFl; // Game is in playback mode diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp index 72f718fe8e..599d8f21d3 100644 --- a/engines/hugo/intro.cpp +++ b/engines/hugo/intro.cpp @@ -98,7 +98,7 @@ void intro_v1d::introInit() { bool intro_v1d::introPlay() { byte introSize = getIntroSize(); - if (_vm->getGameStatus().skipIntroFl) + if (_vm->getGameStatus()._skipIntroFl) return true; if (introTicks < introSize) { @@ -117,20 +117,20 @@ bool intro_v1d::introPlay() { error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 8"); char buffer[80]; - if (_vm->_boot.registered == kRegRegistered) + if (_vm->_boot._registered == kRegRegistered) strcpy(buffer, "Registered Version"); - else if (_vm->_boot.registered == kRegShareware) + else if (_vm->_boot._registered == kRegShareware) strcpy(buffer, "Shareware Version"); - else if (_vm->_boot.registered == kRegFreeware) + else if (_vm->_boot._registered == kRegFreeware) strcpy(buffer, "Freeware Version"); else - error("Unknown registration flag in hugo.bsf: %d", _vm->_boot.registered); + error("Unknown registration flag in hugo.bsf: %d", _vm->_boot._registered); font.drawString(&surf, buffer, 0, 163, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter); font.drawString(&surf, _vm->getCopyrightString(), 0, 176, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter); - if ((*_vm->_boot.distrib != '\0') && (scumm_stricmp(_vm->_boot.distrib, "David P. Gray"))) { - sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); + if ((*_vm->_boot._distrib != '\0') && (scumm_stricmp(_vm->_boot._distrib, "David P. Gray"))) { + sprintf(buffer, "Distributed by %s.", _vm->_boot._distrib); font.drawString(&surf, buffer, 0, 75, 320, _TMAGENTA, Graphics::kTextAlignCenter); } @@ -253,16 +253,16 @@ void intro_v2d::introInit() { if (!font.loadFromFON("TMSRB.FON", Graphics::WinFontDirEntry("Tms Rmn", 8))) error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 8"); - if (_vm->_boot.registered) + if (_vm->_boot._registered) sprintf(buffer, "%s Registered Version", _vm->getCopyrightString()); else sprintf(buffer, "%s Shareware Version", _vm->getCopyrightString()); font.drawString(&surf, buffer, 0, 186, 320, _TLIGHTRED, Graphics::kTextAlignCenter); - if ((*_vm->_boot.distrib != '\0') && (scumm_stricmp(_vm->_boot.distrib, "David P. Gray"))) { + if ((*_vm->_boot._distrib != '\0') && (scumm_stricmp(_vm->_boot._distrib, "David P. Gray"))) { // TROMAN, size 10-5 - sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); + sprintf(buffer, "Distributed by %s.", _vm->_boot._distrib); font.drawString(&surf, buffer, 0, 1, 320, _TLIGHTRED, Graphics::kTextAlignCenter); } @@ -294,7 +294,7 @@ void intro_v3d::introInit() { surf.format = Graphics::PixelFormat::createFormatCLUT8(); char buffer[128]; - if (_vm->_boot.registered) + if (_vm->_boot._registered) sprintf(buffer, "%s Registered Version", _vm->getCopyrightString()); else sprintf(buffer,"%s Shareware Version", _vm->getCopyrightString()); @@ -305,8 +305,8 @@ void intro_v3d::introInit() { font.drawString(&surf, buffer, 0, 190, 320, _TBROWN, Graphics::kTextAlignCenter); - if ((*_vm->_boot.distrib != '\0') && (scumm_stricmp(_vm->_boot.distrib, "David P. Gray"))) { - sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); + if ((*_vm->_boot._distrib != '\0') && (scumm_stricmp(_vm->_boot._distrib, "David P. Gray"))) { + sprintf(buffer, "Distributed by %s.", _vm->_boot._distrib); font.drawString(&surf, buffer, 0, 0, 320, _TBROWN, Graphics::kTextAlignCenter); } @@ -325,7 +325,7 @@ void intro_v3d::introInit() { * Called every tick. Returns TRUE when complete */ bool intro_v3d::introPlay() { - if (_vm->getGameStatus().skipIntroFl) + if (_vm->getGameStatus()._skipIntroFl) return true; if (introTicks < getIntroSize()) { @@ -356,7 +356,7 @@ intro_v1w::~intro_v1w() { } void intro_v1w::preNewGame() { - _vm->getGameStatus().viewState = kViewIntroInit; + _vm->getGameStatus()._viewState = kViewIntroInit; } void intro_v1w::introInit() { @@ -416,7 +416,7 @@ void intro_v3w::introInit() { * Called every tick. Returns TRUE when complete */ bool intro_v3w::introPlay() { - if (_vm->getGameStatus().skipIntroFl) + if (_vm->getGameStatus()._skipIntroFl) return true; if (introTicks < getIntroSize()) { diff --git a/engines/hugo/inventory.cpp b/engines/hugo/inventory.cpp index 410c4e715c..151fe0ee13 100644 --- a/engines/hugo/inventory.cpp +++ b/engines/hugo/inventory.cpp @@ -231,7 +231,7 @@ void InventoryHandler::runInventory() { _vm->_screen->moveImage(_vm->_screen->getBackBuffer(), 0, 0, kXPix, kYPix, kXPix, _vm->_screen->getFrontBuffer(), 0, 0, kXPix); _vm->_object->updateImages(); // Add objects back into display list for restore _inventoryState = kInventoryOff; - gameStatus.viewState = kViewPlay; + gameStatus._viewState = kViewPlay; } break; case kInventoryDown: // Icon bar moving down diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp index d2d5b59dae..323f362b10 100644 --- a/engines/hugo/mouse.cpp +++ b/engines/hugo/mouse.cpp @@ -154,7 +154,7 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in status_t &gameStatus = _vm->getGameStatus(); - if (gameStatus.storyModeFl || _vm->_hero->pathType == kPathQuiet) // Make sure user has control + if (gameStatus._storyModeFl || _vm->_hero->_pathType == kPathQuiet) // Make sure user has control return; int16 inventObjId = _vm->_inventory->getInventoryObjId(); @@ -170,7 +170,7 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in } else { // Clicked over viewport object object_t *obj = &_vm->_object->_objects[objId]; int16 x, y; - switch (obj->viewx) { // Where to walk to + switch (obj->_viewx) { // Where to walk to case -1: // Walk to object position if (_vm->_object->findObjectSpace(obj, &x, &y)) foundFl = _vm->_route->startRoute(kRouteGet, objId, x, y); @@ -181,8 +181,8 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in _vm->_object->useObject(objId); // Pick up or use object break; default: // Walk to view point if possible - if (!_vm->_route->startRoute(kRouteGet, objId, obj->viewx, obj->viewy)) { - if (_vm->_hero->cycling == kCycleInvisible) // If invisible do + if (!_vm->_route->startRoute(kRouteGet, objId, obj->_viewx, obj->_viewy)) { + if (_vm->_hero->_cycling == kCycleInvisible) // If invisible do _vm->_object->useObject(objId); // immediate use else Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there @@ -207,7 +207,7 @@ void MouseHandler::processLeftClick(const int16 objId, const int16 cx, const int status_t &gameStatus = _vm->getGameStatus(); - if (gameStatus.storyModeFl || _vm->_hero->pathType == kPathQuiet) // Make sure user has control + if (gameStatus._storyModeFl || _vm->_hero->_pathType == kPathQuiet) // Make sure user has control return; switch (objId) { @@ -254,7 +254,7 @@ void MouseHandler::processLeftClick(const int16 objId, const int16 cx, const int _vm->_object->lookObject(obj); } else { bool foundFl = false; // TRUE if route found to object - switch (obj->viewx) { // Clicked over viewport object + switch (obj->_viewx) { // Clicked over viewport object case -1: // Walk to object position if (_vm->_object->findObjectSpace(obj, &x, &y)) foundFl = _vm->_route->startRoute(kRouteLook, objId, x, y); @@ -265,8 +265,8 @@ void MouseHandler::processLeftClick(const int16 objId, const int16 cx, const int _vm->_object->lookObject(obj); break; default: // Walk to view point if possible - if (!_vm->_route->startRoute(kRouteLook, objId, obj->viewx, obj->viewy)) { - if (_vm->_hero->cycling == kCycleInvisible) // If invisible do + if (!_vm->_route->startRoute(kRouteLook, objId, obj->_viewx, obj->_viewy)) { + if (_vm->_hero->_cycling == kCycleInvisible) // If invisible do _vm->_object->lookObject(obj); // immediate decription else Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there @@ -286,14 +286,14 @@ void MouseHandler::mouseHandler() { status_t &gameStatus = _vm->getGameStatus(); istate_t inventState = _vm->_inventory->getInventoryState(); - if ((gameStatus.viewState != kViewPlay) && (inventState != kInventoryActive)) + if ((gameStatus._viewState != kViewPlay) && (inventState != kInventoryActive)) return; int16 cx = getMouseX(); int16 cy = getMouseY(); -// gameStatus.cx = cx; // Save cursor coords -// gameStatus.cy = cy; +// gameStatus._cx = cx; // Save cursor coords +// gameStatus._cy = cy; // Don't process if outside client area if ((cx < 0) || (cx > kXPix) || (cy < kDibOffY) || (cy > kViewSizeY + kDibOffY)) @@ -309,14 +309,14 @@ void MouseHandler::mouseHandler() { } } - if (!gameStatus.gameOverFl) { + if (!gameStatus._gameOverFl) { if (objId == -1) // No match, check rest of view objId = _vm->_object->findObject(cx, cy); if (objId >= 0) { // Got a match // Display object name next to cursor (unless CURSOR_NOCHAR) // Note test for swapped hero name - const char *name = _vm->_text->getNoun(_vm->_object->_objects[(objId == kHeroIndex) ? _vm->_heroImage : objId].nounIndex, kCursorNameIndex); + const char *name = _vm->_text->getNoun(_vm->_object->_objects[(objId == kHeroIndex) ? _vm->_heroImage : objId]._nounIndex, kCursorNameIndex); if (name[0] != kCursorNochar) cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE); @@ -378,7 +378,7 @@ void MouseHandler::loadHotspots(Common::ReadStream &in) { void MouseHandler::drawHotspots() const { for (int i = 0; _hotspots[i].screenIndex >= 0; i++) { hotspot_t *hotspot = &_hotspots[i]; - if (hotspot->screenIndex == _vm->_hero->screenIndex) + if (hotspot->screenIndex == _vm->_hero->_screenIndex) _vm->_screen->drawRectangle(false, hotspot->x1, hotspot->y1, hotspot->x2, hotspot->y2, _TLIGHTRED); } } 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); } } diff --git a/engines/hugo/object.h b/engines/hugo/object.h index 84c20db041..8f8043dbbc 100644 --- a/engines/hugo/object.h +++ b/engines/hugo/object.h @@ -35,14 +35,14 @@ namespace Hugo { struct target_t { // Secondary target for action - uint16 nounIndex; // Secondary object - uint16 verbIndex; // Action on secondary object + uint16 _nounIndex; // Secondary object + uint16 _verbIndex; // Action on secondary object }; struct uses_t { // Define uses of certain objects - int16 objId; // Primary object - uint16 dataIndex; // String if no secondary object matches - target_t *targets; // List of secondary targets + int16 _objId; // Primary object + uint16 _dataIndex; // String if no secondary object matches + target_t *_targets; // List of secondary targets }; class ObjectHandler { diff --git a/engines/hugo/object_v1d.cpp b/engines/hugo/object_v1d.cpp index 831dc88dea..7b8f90e189 100644 --- a/engines/hugo/object_v1d.cpp +++ b/engines/hugo/object_v1d.cpp @@ -64,7 +64,7 @@ void ObjectHandler_v1d::updateImages() { for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= kCycleAlmostInvisible)) + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling >= kCycleAlmostInvisible)) objindex[num_objs++] = i; } @@ -75,27 +75,27 @@ void ObjectHandler_v1d::updateImages() { for (int i = 0; i < num_objs; i++) { object_t *obj = &_objects[objindex[i]]; // Count down inter-frame timer - if (obj->frameTimer) - obj->frameTimer--; + if (obj->_frameTimer) + obj->_frameTimer--; - if (obj->cycling > kCycleAlmostInvisible) { // Only if visible - switch (obj->cycling) { + if (obj->_cycling > kCycleAlmostInvisible) { // Only if visible + switch (obj->_cycling) { case kCycleNotCycling: - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, false); + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, false); break; case kCycleForward: - if (obj->frameTimer) // Not time to see next frame yet - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, false); + if (obj->_frameTimer) // Not time to see next frame yet + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, false); else - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, false); + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr->_nextSeqPtr, false); break; case kCycleBackward: { - seq_t *seqPtr = obj->currImagePtr; - if (!obj->frameTimer) { // Show next frame - while (seqPtr->nextSeqPtr != obj->currImagePtr) - seqPtr = seqPtr->nextSeqPtr; + seq_t *seqPtr = obj->_currImagePtr; + if (!obj->_frameTimer) { // Show next frame + while (seqPtr->_nextSeqPtr != obj->_currImagePtr) + seqPtr = seqPtr->_nextSeqPtr; } - _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, false); + _vm->_screen->displayFrame(obj->_x, obj->_y, seqPtr, false); break; } default: @@ -109,28 +109,28 @@ void ObjectHandler_v1d::updateImages() { // Cycle any animating objects for (int i = 0; i < num_objs; i++) { object_t *obj = &_objects[objindex[i]]; - if (obj->cycling != kCycleInvisible) { + if (obj->_cycling != kCycleInvisible) { // Only if it's visible - if (obj->cycling == kCycleAlmostInvisible) - obj->cycling = kCycleInvisible; + if (obj->_cycling == kCycleAlmostInvisible) + obj->_cycling = kCycleInvisible; // Now Rotate to next picture in sequence - switch (obj->cycling) { + switch (obj->_cycling) { case kCycleNotCycling: break; case kCycleForward: - if (!obj->frameTimer) { + if (!obj->_frameTimer) { // Time to step to next frame - obj->currImagePtr = obj->currImagePtr->nextSeqPtr; + obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr; // Find out if this is last frame of sequence // If so, reset frame_timer and decrement n_cycle - if (obj->frameInterval || obj->cycleNumb) { - obj->frameTimer = obj->frameInterval; - for (int j = 0; j < obj->seqNumb; j++) { - if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) { - if (obj->cycleNumb) { // Decr cycleNumb if Non-continous - if (!--obj->cycleNumb) - obj->cycling = kCycleNotCycling; + if (obj->_frameInterval || obj->_cycleNumb) { + obj->_frameTimer = obj->_frameInterval; + for (int j = 0; j < obj->_seqNumb; j++) { + if (obj->_currImagePtr->_nextSeqPtr == obj->_seqList[j]._seqPtr) { + if (obj->_cycleNumb) { // Decr cycleNumb if Non-continous + if (!--obj->_cycleNumb) + obj->_cycling = kCycleNotCycling; } } } @@ -138,20 +138,20 @@ void ObjectHandler_v1d::updateImages() { } break; case kCycleBackward: { - if (!obj->frameTimer) { + if (!obj->_frameTimer) { // Time to step to prev frame - seq_t *seqPtr = obj->currImagePtr; - while (obj->currImagePtr->nextSeqPtr != seqPtr) - obj->currImagePtr = obj->currImagePtr->nextSeqPtr; + seq_t *seqPtr = obj->_currImagePtr; + while (obj->_currImagePtr->_nextSeqPtr != seqPtr) + obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr; // Find out if this is first frame of sequence // If so, reset frame_timer and decrement n_cycle - if (obj->frameInterval || obj->cycleNumb) { - obj->frameTimer = obj->frameInterval; - for (int j = 0; j < obj->seqNumb; j++) { - if (obj->currImagePtr == obj->seqList[j].seqPtr) { - if (obj->cycleNumb){ // Decr cycleNumb if Non-continous - if (!--obj->cycleNumb) - obj->cycling = kCycleNotCycling; + if (obj->_frameInterval || obj->_cycleNumb) { + obj->_frameTimer = obj->_frameInterval; + for (int j = 0; j < obj->_seqNumb; j++) { + if (obj->_currImagePtr == obj->_seqList[j]._seqPtr) { + if (obj->_cycleNumb){ // Decr cycleNumb if Non-continous + if (!--obj->_cycleNumb) + obj->_cycling = kCycleNotCycling; } } } @@ -162,8 +162,8 @@ void ObjectHandler_v1d::updateImages() { default: break; } - obj->oldx = obj->x; - obj->oldy = obj->y; + obj->_oldx = obj->_x; + obj->_oldy = obj->_y; } } } @@ -184,161 +184,161 @@ void ObjectHandler_v1d::moveObjects() { // Don't store foreground or background objects for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if (obj->screenIndex == *_vm->_screen_p) { - switch (obj->pathType) { + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if (obj->_screenIndex == *_vm->_screen_p) { + switch (obj->_pathType) { case kPathChase: { // Allowable motion wrt boundary - int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; - int dy = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - obj->y - currImage->y2 - 1; + int dx = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1 - obj->_x - currImage->_x1; + int dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1; if (abs(dx) <= 1) - obj->vx = 0; + obj->_vx = 0; else - obj->vx = (dx > 0) ? MIN(dx, obj->vxPath) : MAX(dx, -obj->vxPath); + obj->_vx = (dx > 0) ? MIN(dx, obj->_vxPath) : MAX(dx, -obj->_vxPath); if (abs(dy) <= 1) - obj->vy = 0; + obj->_vy = 0; else - obj->vy = (dy > 0) ? MIN(dy, obj->vyPath) : MAX(dy, -obj->vyPath); + obj->_vy = (dy > 0) ? MIN(dy, obj->_vyPath) : MAX(dy, -obj->_vyPath); // Set first image in sequence (if multi-seq object) - if (obj->seqNumb == 4) { - if (!obj->vx) { // Got 4 directions - if (obj->vx != obj->oldvx) {// vx just stopped + if (obj->_seqNumb == 4) { + if (!obj->_vx) { // Got 4 directions + if (obj->_vx != obj->_oldvx) {// vx just stopped if (dy > 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { + } else if (obj->_vx != obj->_oldvx) { if (dx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } } - if (obj->vx || obj->vy) { - if (obj->seqNumb > 1) - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) { + if (obj->_seqNumb > 1) + obj->_cycling = kCycleForward; } else { - obj->cycling = kCycleNotCycling; + obj->_cycling = kCycleNotCycling; boundaryCollision(obj); // Must have got hero! } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image break; } case kPathWander: if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval - obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; - obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; + obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath; + obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath; // Set first image in sequence (if multi-seq object) - if (obj->seqNumb > 1) { - if (!obj->vx && (obj->seqNumb > 2)) { - if (obj->vx != obj->oldvx) { // vx just stopped - if (obj->vy > 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + if (obj->_seqNumb > 1) { + if (!obj->_vx && (obj->_seqNumb > 2)) { + if (obj->_vx != obj->_oldvx) { // vx just stopped + if (obj->_vy > 0) + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { - if (obj->vx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + } else if (obj->_vx != obj->_oldvx) { + if (obj->_vx > 0) + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } - if (obj->vx || obj->vy) - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) + obj->_cycling = kCycleForward; else - obj->cycling = kCycleNotCycling; + obj->_cycling = kCycleNotCycling; } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image } break; default: ; // Really, nothing } // Store boundaries - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2); } } // Move objects, allowing for boundaries for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - if ((obj->screenIndex == *_vm->_screen_p) && (obj->vx || obj->vy)) { + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_vx || obj->_vy)) { // Only process if it's moving // Do object movement. Delta_x,y return allowed movement in x,y // to move as close to a boundary as possible without crossing it. - seq_t *currImage = obj->currImagePtr; // Get ptr to current image + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image // object coordinates - int x1 = obj->x + currImage->x1; // Left edge of object - int x2 = obj->x + currImage->x2; // Right edge - int y1 = obj->y + currImage->y1; // Top edge - int y2 = obj->y + currImage->y2; // Bottom edge + int x1 = obj->_x + currImage->_x1; // Left edge of object + int x2 = obj->_x + currImage->_x2; // Right edge + int y1 = obj->_y + currImage->_y1; // Top edge + int y2 = obj->_y + currImage->_y2; // Bottom edge - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) clearBoundary(x1, x2, y2); // Clear our own boundary // Allowable motion wrt boundary - int dx = deltaX(x1, x2, obj->vx, y2); - if (dx != obj->vx) { + int dx = deltaX(x1, x2, obj->_vx, y2); + if (dx != obj->_vx) { // An object boundary collision! boundaryCollision(obj); - obj->vx = 0; + obj->_vx = 0; } - int dy = deltaY(x1, x2, obj->vy, y2); - if (dy != obj->vy) { + int dy = deltaY(x1, x2, obj->_vy, y2); + if (dy != obj->_vy) { // An object boundary collision! boundaryCollision(obj); - obj->vy = 0; + obj->_vy = 0; } - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) storeBoundary(x1, x2, y2); // Re-store our own boundary - obj->x += dx; // Update object position - obj->y += dy; + obj->_x += dx; // Update object position + obj->_y += dy; // Don't let object go outside screen if (x1 < kEdge) - obj->x = kEdge2; + obj->_x = kEdge2; if (x2 > (kXPix - kEdge)) - obj->x = kXPix - kEdge2 - (x2 - x1); + obj->_x = kXPix - kEdge2 - (x2 - x1); if (y1 < kEdge) - obj->y = kEdge2; + obj->_y = kEdge2; if (y2 > (kYPix - kEdge)) - obj->y = kYPix - kEdge2 - (y2 - y1); + obj->_y = kYPix - kEdge2 - (y2 - y1); - if ((obj->vx == 0) && (obj->vy == 0)) - obj->cycling = kCycleNotCycling; + if ((obj->_vx == 0) && (obj->_vy == 0)) + obj->_cycling = kCycleNotCycling; } } // Clear all object baselines from the boundary file. for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2); + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2); } // If maze mode is enabled, do special maze processing - if (_vm->_maze.enabledFl) { - seq_t *currImage = _vm->_hero->currImagePtr;// Get ptr to current image + if (_vm->_maze._enabledFl) { + seq_t *currImage = _vm->_hero->_currImagePtr;// Get ptr to current image // hero coordinates - int x1 = _vm->_hero->x + currImage->x1; // Left edge of object - int x2 = _vm->_hero->x + currImage->x2; // Right edge - int y1 = _vm->_hero->y + currImage->y1; // Top edge - int y2 = _vm->_hero->y + currImage->y2; // Bottom edge + int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object + int x2 = _vm->_hero->_x + currImage->_x2; // Right edge + int y1 = _vm->_hero->_y + currImage->_y1; // Top edge + int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge _vm->_scheduler->processMaze(x1, x2, y1, y2); } @@ -355,11 +355,11 @@ void ObjectHandler_v1d::swapImages(int objIndex1, int objIndex2) { seqList_t tmpSeqList[kMaxSeqNumb]; int seqListSize = sizeof(seqList_t) * kMaxSeqNumb; - memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); - memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); - memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); - _objects[objIndex1].currImagePtr = _objects[objIndex1].seqList[0].seqPtr; - _objects[objIndex2].currImagePtr = _objects[objIndex2].seqList[0].seqPtr; + memmove(tmpSeqList, _objects[objIndex1]._seqList, seqListSize); + memmove(_objects[objIndex1]._seqList, _objects[objIndex2]._seqList, seqListSize); + memmove(_objects[objIndex2]._seqList, tmpSeqList, seqListSize); + _objects[objIndex1]._currImagePtr = _objects[objIndex1]._seqList[0]._seqPtr; + _objects[objIndex2]._currImagePtr = _objects[objIndex2]._seqList[0]._seqPtr; _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex; } @@ -367,9 +367,9 @@ void ObjectHandler_v1d::homeIn(int objIndex1, const int objIndex2, const int8 ob // object obj1 will home in on object obj2 object_t *obj1 = &_objects[objIndex1]; object_t *obj2 = &_objects[objIndex2]; - obj1->pathType = kPathAuto; - int dx = obj1->x + obj1->currImagePtr->x1 - obj2->x - obj2->currImagePtr->x1; - int dy = obj1->y + obj1->currImagePtr->y1 - obj2->y - obj2->currImagePtr->y1; + obj1->_pathType = kPathAuto; + int dx = obj1->_x + obj1->_currImagePtr->_x1 - obj2->_x - obj2->_currImagePtr->_x1; + int dy = obj1->_y + obj1->_currImagePtr->_y1 - obj2->_y - obj2->_currImagePtr->_y1; if (dx == 0) // Don't EVER divide by zero! dx = 1; @@ -377,11 +377,11 @@ void ObjectHandler_v1d::homeIn(int objIndex1, const int objIndex2, const int8 ob dy = 1; if (abs(dx) > abs(dy)) { - obj1->vx = objDx * -sign<int8>(dx); - obj1->vy = abs((objDy * dy) / dx) * -sign<int8>(dy); + obj1->_vx = objDx * -sign<int8>(dx); + obj1->_vy = abs((objDy * dy) / dx) * -sign<int8>(dy); } else { - obj1->vy = objDy * sign<int8>(dy); - obj1->vx = abs((objDx * dx) / dy) * sign<int8>(dx); + obj1->_vy = objDy * sign<int8>(dy); + obj1->_vx = abs((objDx * dx) / dy) * sign<int8>(dx); } } } // End of namespace Hugo diff --git a/engines/hugo/object_v1w.cpp b/engines/hugo/object_v1w.cpp index 4388ef5520..dd3de5fe40 100644 --- a/engines/hugo/object_v1w.cpp +++ b/engines/hugo/object_v1w.cpp @@ -64,7 +64,7 @@ void ObjectHandler_v1w::updateImages() { for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= kCycleAlmostInvisible)) + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling >= kCycleAlmostInvisible)) objindex[num_objs++] = i; } @@ -75,27 +75,27 @@ void ObjectHandler_v1w::updateImages() { for (int i = 0; i < num_objs; i++) { object_t *obj = &_objects[objindex[i]]; // Count down inter-frame timer - if (obj->frameTimer) - obj->frameTimer--; + if (obj->_frameTimer) + obj->_frameTimer--; - if (obj->cycling > kCycleAlmostInvisible) { // Only if visible - switch (obj->cycling) { + if (obj->_cycling > kCycleAlmostInvisible) { // Only if visible + switch (obj->_cycling) { case kCycleNotCycling: - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, obj->_priority == kPriorityOverOverlay); break; case kCycleForward: - if (obj->frameTimer) // Not time to see next frame yet - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); + if (obj->_frameTimer) // Not time to see next frame yet + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, obj->_priority == kPriorityOverOverlay); else - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == kPriorityOverOverlay); + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr->_nextSeqPtr, obj->_priority == kPriorityOverOverlay); break; case kCycleBackward: { - seq_t *seqPtr = obj->currImagePtr; - if (!obj->frameTimer) { // Show next frame - while (seqPtr->nextSeqPtr != obj->currImagePtr) - seqPtr = seqPtr->nextSeqPtr; + seq_t *seqPtr = obj->_currImagePtr; + if (!obj->_frameTimer) { // Show next frame + while (seqPtr->_nextSeqPtr != obj->_currImagePtr) + seqPtr = seqPtr->_nextSeqPtr; } - _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == kPriorityOverOverlay); + _vm->_screen->displayFrame(obj->_x, obj->_y, seqPtr, obj->_priority == kPriorityOverOverlay); break; } default: @@ -107,28 +107,28 @@ void ObjectHandler_v1w::updateImages() { // Cycle any animating objects for (int i = 0; i < num_objs; i++) { object_t *obj = &_objects[objindex[i]]; - if (obj->cycling != kCycleInvisible) { + if (obj->_cycling != kCycleInvisible) { // Only if it's visible - if (obj->cycling == kCycleAlmostInvisible) - obj->cycling = kCycleInvisible; + if (obj->_cycling == kCycleAlmostInvisible) + obj->_cycling = kCycleInvisible; // Now Rotate to next picture in sequence - switch (obj->cycling) { + switch (obj->_cycling) { case kCycleNotCycling: break; case kCycleForward: - if (!obj->frameTimer) { + if (!obj->_frameTimer) { // Time to step to next frame - obj->currImagePtr = obj->currImagePtr->nextSeqPtr; + obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr; // Find out if this is last frame of sequence // If so, reset frame_timer and decrement n_cycle - if (obj->frameInterval || obj->cycleNumb) { - obj->frameTimer = obj->frameInterval; - for (int j = 0; j < obj->seqNumb; j++) { - if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) { - if (obj->cycleNumb) { // Decr cycleNumb if Non-continous - if (!--obj->cycleNumb) - obj->cycling = kCycleNotCycling; + if (obj->_frameInterval || obj->_cycleNumb) { + obj->_frameTimer = obj->_frameInterval; + for (int j = 0; j < obj->_seqNumb; j++) { + if (obj->_currImagePtr->_nextSeqPtr == obj->_seqList[j]._seqPtr) { + if (obj->_cycleNumb) { // Decr cycleNumb if Non-continous + if (!--obj->_cycleNumb) + obj->_cycling = kCycleNotCycling; } } } @@ -136,20 +136,20 @@ void ObjectHandler_v1w::updateImages() { } break; case kCycleBackward: { - if (!obj->frameTimer) { + if (!obj->_frameTimer) { // Time to step to prev frame - seq_t *seqPtr = obj->currImagePtr; - while (obj->currImagePtr->nextSeqPtr != seqPtr) - obj->currImagePtr = obj->currImagePtr->nextSeqPtr; + seq_t *seqPtr = obj->_currImagePtr; + while (obj->_currImagePtr->_nextSeqPtr != seqPtr) + obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr; // Find out if this is first frame of sequence // If so, reset frame_timer and decrement n_cycle - if (obj->frameInterval || obj->cycleNumb) { - obj->frameTimer = obj->frameInterval; - for (int j = 0; j < obj->seqNumb; j++) { - if (obj->currImagePtr == obj->seqList[j].seqPtr) { - if (obj->cycleNumb){ // Decr cycleNumb if Non-continous - if (!--obj->cycleNumb) - obj->cycling = kCycleNotCycling; + if (obj->_frameInterval || obj->_cycleNumb) { + obj->_frameTimer = obj->_frameInterval; + for (int j = 0; j < obj->_seqNumb; j++) { + if (obj->_currImagePtr == obj->_seqList[j]._seqPtr) { + if (obj->_cycleNumb){ // Decr cycleNumb if Non-continous + if (!--obj->_cycleNumb) + obj->_cycling = kCycleNotCycling; } } } @@ -160,8 +160,8 @@ void ObjectHandler_v1w::updateImages() { default: break; } - obj->oldx = obj->x; - obj->oldy = obj->y; + obj->_oldx = obj->_x; + obj->_oldy = obj->_y; } } } @@ -181,174 +181,174 @@ void ObjectHandler_v1w::moveObjects() { // Don't store foreground or background objects for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if (obj->screenIndex == *_vm->_screen_p) { - switch (obj->pathType) { + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if (obj->_screenIndex == *_vm->_screen_p) { + switch (obj->_pathType) { case kPathChase: case kPathChase2: { - int8 radius = obj->radius; // Default to object's radius + int8 radius = obj->_radius; // Default to object's radius if (radius < 0) // If radius infinity, use closer value radius = kStepDx; // Allowable motion wrt boundary - int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; - int dy = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - obj->y - currImage->y2 - 1; + int dx = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1 - obj->_x - currImage->_x1; + int dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1; if (abs(dx) <= radius) - obj->vx = 0; + obj->_vx = 0; else - obj->vx = (dx > 0) ? MIN(dx, obj->vxPath) : MAX(dx, -obj->vxPath); + obj->_vx = (dx > 0) ? MIN(dx, obj->_vxPath) : MAX(dx, -obj->_vxPath); if (abs(dy) <= radius) - obj->vy = 0; + obj->_vy = 0; else - obj->vy = (dy > 0) ? MIN(dy, obj->vyPath) : MAX(dy, -obj->vyPath); + obj->_vy = (dy > 0) ? MIN(dy, obj->_vyPath) : MAX(dy, -obj->_vyPath); // Set first image in sequence (if multi-seq object) - switch (obj->seqNumb) { + switch (obj->_seqNumb) { case 4: - if (!obj->vx) { // Got 4 directions - if (obj->vx != obj->oldvx) { // vx just stopped + if (!obj->_vx) { // Got 4 directions + if (obj->_vx != obj->_oldvx) { // vx just stopped if (dy >= 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { + } else if (obj->_vx != obj->_oldvx) { if (dx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } break; case 3: case 2: - if (obj->vx != obj->oldvx) { // vx just stopped + if (obj->_vx != obj->_oldvx) { // vx just stopped if (dx > 0) // Left & right only - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } break; } - if (obj->vx || obj->vy) { - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) { + obj->_cycling = kCycleForward; } else { - obj->cycling = kCycleNotCycling; + obj->_cycling = kCycleNotCycling; boundaryCollision(obj); // Must have got hero! } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image break; } case kPathWander2: case kPathWander: if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval - obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; - obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; + obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath; + obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath; // Set first image in sequence (if multi-seq object) - if (obj->seqNumb > 1) { - if (!obj->vx && (obj->seqNumb >= 4)) { - if (obj->vx != obj->oldvx) { // vx just stopped - if (obj->vy > 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + if (obj->_seqNumb > 1) { + if (!obj->_vx && (obj->_seqNumb >= 4)) { + if (obj->_vx != obj->_oldvx) { // vx just stopped + if (obj->_vy > 0) + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { - if (obj->vx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + } else if (obj->_vx != obj->_oldvx) { + if (obj->_vx > 0) + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image } - if (obj->vx || obj->vy) - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) + obj->_cycling = kCycleForward; break; default: ; // Really, nothing } // Store boundaries - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2); } } // Move objects, allowing for boundaries for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - if ((obj->screenIndex == *_vm->_screen_p) && (obj->vx || obj->vy)) { + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_vx || obj->_vy)) { // Only process if it's moving // Do object movement. Delta_x,y return allowed movement in x,y // to move as close to a boundary as possible without crossing it. - seq_t *currImage = obj->currImagePtr; // Get ptr to current image + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image // object coordinates - int x1 = obj->x + currImage->x1; // Left edge of object - int x2 = obj->x + currImage->x2; // Right edge - int y1 = obj->y + currImage->y1; // Top edge - int y2 = obj->y + currImage->y2; // Bottom edge + int x1 = obj->_x + currImage->_x1; // Left edge of object + int x2 = obj->_x + currImage->_x2; // Right edge + int y1 = obj->_y + currImage->_y1; // Top edge + int y2 = obj->_y + currImage->_y2; // Bottom edge - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) clearBoundary(x1, x2, y2); // Clear our own boundary // Allowable motion wrt boundary - int dx = deltaX(x1, x2, obj->vx, y2); - if (dx != obj->vx) { + int dx = deltaX(x1, x2, obj->_vx, y2); + if (dx != obj->_vx) { // An object boundary collision! boundaryCollision(obj); - obj->vx = 0; + obj->_vx = 0; } - int dy = deltaY(x1, x2, obj->vy, y2); - if (dy != obj->vy) { + int dy = deltaY(x1, x2, obj->_vy, y2); + if (dy != obj->_vy) { // An object boundary collision! boundaryCollision(obj); - obj->vy = 0; + obj->_vy = 0; } - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) storeBoundary(x1, x2, y2); // Re-store our own boundary - obj->x += dx; // Update object position - obj->y += dy; + obj->_x += dx; // Update object position + obj->_y += dy; // Don't let object go outside screen if (x1 < kEdge) - obj->x = kEdge2; + obj->_x = kEdge2; if (x2 > (kXPix - kEdge)) - obj->x = kXPix - kEdge2 - (x2 - x1); + obj->_x = kXPix - kEdge2 - (x2 - x1); if (y1 < kEdge) - obj->y = kEdge2; + obj->_y = kEdge2; if (y2 > (kYPix - kEdge)) - obj->y = kYPix - kEdge2 - (y2 - y1); + obj->_y = kYPix - kEdge2 - (y2 - y1); - if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != kPathWander2) && (obj->pathType != kPathChase2)) - obj->cycling = kCycleNotCycling; + if ((obj->_vx == 0) && (obj->_vy == 0) && (obj->_pathType != kPathWander2) && (obj->_pathType != kPathChase2)) + obj->_cycling = kCycleNotCycling; } } // Clear all object baselines from the boundary file. for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2); + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2); } // If maze mode is enabled, do special maze processing - if (_vm->_maze.enabledFl) { - seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image + if (_vm->_maze._enabledFl) { + seq_t *currImage = _vm->_hero->_currImagePtr; // Get ptr to current image // hero coordinates - int x1 = _vm->_hero->x + currImage->x1; // Left edge of object - int x2 = _vm->_hero->x + currImage->x2; // Right edge - int y1 = _vm->_hero->y + currImage->y1; // Top edge - int y2 = _vm->_hero->y + currImage->y2; // Bottom edge + int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object + int x2 = _vm->_hero->_x + currImage->_x2; // Right edge + int y1 = _vm->_hero->_y + currImage->_y1; // Top edge + int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge _vm->_scheduler->processMaze(x1, x2, y1, y2); } @@ -367,15 +367,15 @@ void ObjectHandler_v1w::swapImages(int objIndex1, int objIndex2) { seqList_t tmpSeqList[kMaxSeqNumb]; int seqListSize = sizeof(seqList_t) * kMaxSeqNumb; - memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); - memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); - memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); + 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; + _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; + _objects[objIndex1]._y += _objects[objIndex2]._currImagePtr->_y2 - _objects[objIndex1]._currImagePtr->_y2; } } // End of namespace Hugo diff --git a/engines/hugo/object_v2d.cpp b/engines/hugo/object_v2d.cpp index 4a22fab2c0..025374521c 100644 --- a/engines/hugo/object_v2d.cpp +++ b/engines/hugo/object_v2d.cpp @@ -64,7 +64,7 @@ void ObjectHandler_v2d::updateImages() { for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= kCycleAlmostInvisible)) + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling >= kCycleAlmostInvisible)) objindex[num_objs++] = i; } @@ -75,27 +75,27 @@ void ObjectHandler_v2d::updateImages() { for (int i = 0; i < num_objs; i++) { object_t *obj = &_objects[objindex[i]]; // Count down inter-frame timer - if (obj->frameTimer) - obj->frameTimer--; + if (obj->_frameTimer) + obj->_frameTimer--; - if (obj->cycling > kCycleAlmostInvisible) { // Only if visible - switch (obj->cycling) { + if (obj->_cycling > kCycleAlmostInvisible) { // Only if visible + switch (obj->_cycling) { case kCycleNotCycling: - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, obj->_priority == kPriorityOverOverlay); break; case kCycleForward: - if (obj->frameTimer) // Not time to see next frame yet - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); + if (obj->_frameTimer) // Not time to see next frame yet + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, obj->_priority == kPriorityOverOverlay); else - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == kPriorityOverOverlay); + _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr->_nextSeqPtr, obj->_priority == kPriorityOverOverlay); break; case kCycleBackward: { - seq_t *seqPtr = obj->currImagePtr; - if (!obj->frameTimer) { // Show next frame - while (seqPtr->nextSeqPtr != obj->currImagePtr) - seqPtr = seqPtr->nextSeqPtr; + seq_t *seqPtr = obj->_currImagePtr; + if (!obj->_frameTimer) { // Show next frame + while (seqPtr->_nextSeqPtr != obj->_currImagePtr) + seqPtr = seqPtr->_nextSeqPtr; } - _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == kPriorityOverOverlay); + _vm->_screen->displayFrame(obj->_x, obj->_y, seqPtr, obj->_priority == kPriorityOverOverlay); break; } default: @@ -109,28 +109,28 @@ void ObjectHandler_v2d::updateImages() { // Cycle any animating objects for (int i = 0; i < num_objs; i++) { object_t *obj = &_objects[objindex[i]]; - if (obj->cycling != kCycleInvisible) { + if (obj->_cycling != kCycleInvisible) { // Only if it's visible - if (obj->cycling == kCycleAlmostInvisible) - obj->cycling = kCycleInvisible; + if (obj->_cycling == kCycleAlmostInvisible) + obj->_cycling = kCycleInvisible; // Now Rotate to next picture in sequence - switch (obj->cycling) { + switch (obj->_cycling) { case kCycleNotCycling: break; case kCycleForward: - if (!obj->frameTimer) { + if (!obj->_frameTimer) { // Time to step to next frame - obj->currImagePtr = obj->currImagePtr->nextSeqPtr; + obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr; // Find out if this is last frame of sequence // If so, reset frame_timer and decrement n_cycle - if (obj->frameInterval || obj->cycleNumb) { - obj->frameTimer = obj->frameInterval; - for (int j = 0; j < obj->seqNumb; j++) { - if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) { - if (obj->cycleNumb) { // Decr cycleNumb if Non-continous - if (!--obj->cycleNumb) - obj->cycling = kCycleNotCycling; + if (obj->_frameInterval || obj->_cycleNumb) { + obj->_frameTimer = obj->_frameInterval; + for (int j = 0; j < obj->_seqNumb; j++) { + if (obj->_currImagePtr->_nextSeqPtr == obj->_seqList[j]._seqPtr) { + if (obj->_cycleNumb) { // Decr cycleNumb if Non-continous + if (!--obj->_cycleNumb) + obj->_cycling = kCycleNotCycling; } } } @@ -138,20 +138,20 @@ void ObjectHandler_v2d::updateImages() { } break; case kCycleBackward: { - if (!obj->frameTimer) { + if (!obj->_frameTimer) { // Time to step to prev frame - seq_t *seqPtr = obj->currImagePtr; - while (obj->currImagePtr->nextSeqPtr != seqPtr) - obj->currImagePtr = obj->currImagePtr->nextSeqPtr; + seq_t *seqPtr = obj->_currImagePtr; + while (obj->_currImagePtr->_nextSeqPtr != seqPtr) + obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr; // Find out if this is first frame of sequence // If so, reset frame_timer and decrement n_cycle - if (obj->frameInterval || obj->cycleNumb) { - obj->frameTimer = obj->frameInterval; - for (int j = 0; j < obj->seqNumb; j++) { - if (obj->currImagePtr == obj->seqList[j].seqPtr) { - if (obj->cycleNumb){ // Decr cycleNumb if Non-continous - if (!--obj->cycleNumb) - obj->cycling = kCycleNotCycling; + if (obj->_frameInterval || obj->_cycleNumb) { + obj->_frameTimer = obj->_frameInterval; + for (int j = 0; j < obj->_seqNumb; j++) { + if (obj->_currImagePtr == obj->_seqList[j]._seqPtr) { + if (obj->_cycleNumb){ // Decr cycleNumb if Non-continous + if (!--obj->_cycleNumb) + obj->_cycling = kCycleNotCycling; } } } @@ -162,8 +162,8 @@ void ObjectHandler_v2d::updateImages() { default: break; } - obj->oldx = obj->x; - obj->oldy = obj->y; + obj->_oldx = obj->_x; + obj->_oldy = obj->_y; } } } @@ -184,174 +184,174 @@ void ObjectHandler_v2d::moveObjects() { // Don't store foreground or background objects for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if (obj->screenIndex == *_vm->_screen_p) { - switch (obj->pathType) { + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if (obj->_screenIndex == *_vm->_screen_p) { + switch (obj->_pathType) { case kPathChase: case kPathChase2: { - int8 radius = obj->radius; // Default to object's radius + int8 radius = obj->_radius; // Default to object's radius if (radius < 0) // If radius infinity, use closer value radius = kStepDx; // Allowable motion wrt boundary - int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; - int dy = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - obj->y - currImage->y2 - 1; + int dx = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1 - obj->_x - currImage->_x1; + int dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1; if (abs(dx) <= radius) - obj->vx = 0; + obj->_vx = 0; else - obj->vx = (dx > 0) ? MIN(dx, obj->vxPath) : MAX(dx, -obj->vxPath); + obj->_vx = (dx > 0) ? MIN(dx, obj->_vxPath) : MAX(dx, -obj->_vxPath); if (abs(dy) <= radius) - obj->vy = 0; + obj->_vy = 0; else - obj->vy = (dy > 0) ? MIN(dy, obj->vyPath) : MAX(dy, -obj->vyPath); + obj->_vy = (dy > 0) ? MIN(dy, obj->_vyPath) : MAX(dy, -obj->_vyPath); // Set first image in sequence (if multi-seq object) - switch (obj->seqNumb) { + switch (obj->_seqNumb) { case 4: - if (!obj->vx) { // Got 4 directions - if (obj->vx != obj->oldvx) { // vx just stopped + if (!obj->_vx) { // Got 4 directions + if (obj->_vx != obj->_oldvx) { // vx just stopped if (dy > 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { + } else if (obj->_vx != obj->_oldvx) { if (dx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } break; case 3: case 2: - if (obj->vx != obj->oldvx) { // vx just stopped + if (obj->_vx != obj->_oldvx) { // vx just stopped if (dx > 0) // Left & right only - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } break; } - if (obj->vx || obj->vy) { - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) { + obj->_cycling = kCycleForward; } else { - obj->cycling = kCycleNotCycling; + obj->_cycling = kCycleNotCycling; boundaryCollision(obj); // Must have got hero! } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image break; } case kPathWander2: case kPathWander: if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval - obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; - obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; + obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath; + obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath; // Set first image in sequence (if multi-seq object) - if (obj->seqNumb > 1) { - if (!obj->vx && (obj->seqNumb >= 4)) { - if (obj->vx != obj->oldvx) { // vx just stopped - if (obj->vy > 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + if (obj->_seqNumb > 1) { + if (!obj->_vx && (obj->_seqNumb >= 4)) { + if (obj->_vx != obj->_oldvx) { // vx just stopped + if (obj->_vy > 0) + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { - if (obj->vx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + } else if (obj->_vx != obj->_oldvx) { + if (obj->_vx > 0) + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image } - if (obj->vx || obj->vy) - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) + obj->_cycling = kCycleForward; break; default: ; // Really, nothing } // Store boundaries - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2); } } // Move objects, allowing for boundaries for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - if ((obj->screenIndex == *_vm->_screen_p) && (obj->vx || obj->vy)) { + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_vx || obj->_vy)) { // Only process if it's moving // Do object movement. Delta_x,y return allowed movement in x,y // to move as close to a boundary as possible without crossing it. - seq_t *currImage = obj->currImagePtr; // Get ptr to current image + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image // object coordinates - int x1 = obj->x + currImage->x1; // Left edge of object - int x2 = obj->x + currImage->x2; // Right edge - int y1 = obj->y + currImage->y1; // Top edge - int y2 = obj->y + currImage->y2; // Bottom edge + int x1 = obj->_x + currImage->_x1; // Left edge of object + int x2 = obj->_x + currImage->_x2; // Right edge + int y1 = obj->_y + currImage->_y1; // Top edge + int y2 = obj->_y + currImage->_y2; // Bottom edge - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) clearBoundary(x1, x2, y2); // Clear our own boundary // Allowable motion wrt boundary - int dx = deltaX(x1, x2, obj->vx, y2); - if (dx != obj->vx) { + int dx = deltaX(x1, x2, obj->_vx, y2); + if (dx != obj->_vx) { // An object boundary collision! boundaryCollision(obj); - obj->vx = 0; + obj->_vx = 0; } - int dy = deltaY(x1, x2, obj->vy, y2); - if (dy != obj->vy) { + int dy = deltaY(x1, x2, obj->_vy, y2); + if (dy != obj->_vy) { // An object boundary collision! boundaryCollision(obj); - obj->vy = 0; + obj->_vy = 0; } - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) storeBoundary(x1, x2, y2); // Re-store our own boundary - obj->x += dx; // Update object position - obj->y += dy; + obj->_x += dx; // Update object position + obj->_y += dy; // Don't let object go outside screen if (x1 < kEdge) - obj->x = kEdge2; + obj->_x = kEdge2; if (x2 > (kXPix - kEdge)) - obj->x = kXPix - kEdge2 - (x2 - x1); + obj->_x = kXPix - kEdge2 - (x2 - x1); if (y1 < kEdge) - obj->y = kEdge2; + obj->_y = kEdge2; if (y2 > (kYPix - kEdge)) - obj->y = kYPix - kEdge2 - (y2 - y1); + obj->_y = kYPix - kEdge2 - (y2 - y1); - if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != kPathWander2) && (obj->pathType != kPathChase2)) - obj->cycling = kCycleNotCycling; + if ((obj->_vx == 0) && (obj->_vy == 0) && (obj->_pathType != kPathWander2) && (obj->_pathType != kPathChase2)) + obj->_cycling = kCycleNotCycling; } } // Clear all object baselines from the boundary file. for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2); + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2); } // If maze mode is enabled, do special maze processing - if (_vm->_maze.enabledFl) { - seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image + if (_vm->_maze._enabledFl) { + seq_t *currImage = _vm->_hero->_currImagePtr; // Get ptr to current image // hero coordinates - int x1 = _vm->_hero->x + currImage->x1; // Left edge of object - int x2 = _vm->_hero->x + currImage->x2; // Right edge - int y1 = _vm->_hero->y + currImage->y1; // Top edge - int y2 = _vm->_hero->y + currImage->y2; // Bottom edge + int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object + int x2 = _vm->_hero->_x + currImage->_x2; // Right edge + int y1 = _vm->_hero->_y + currImage->_y1; // Top edge + int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge _vm->_scheduler->processMaze(x1, x2, y1, y2); } @@ -361,9 +361,9 @@ void ObjectHandler_v2d::homeIn(const int objIndex1, const int objIndex2, const i // object obj1 will home in on object obj2 object_t *obj1 = &_objects[objIndex1]; object_t *obj2 = &_objects[objIndex2]; - obj1->pathType = kPathAuto; - int dx = obj1->x + obj1->currImagePtr->x1 - obj2->x - obj2->currImagePtr->x1; - int dy = obj1->y + obj1->currImagePtr->y1 - obj2->y - obj2->currImagePtr->y1; + obj1->_pathType = kPathAuto; + int dx = obj1->_x + obj1->_currImagePtr->_x1 - obj2->_x - obj2->_currImagePtr->_x1; + int dy = obj1->_y + obj1->_currImagePtr->_y1 - obj2->_y - obj2->_currImagePtr->_y1; if (dx == 0) // Don't EVER divide by zero! dx = 1; @@ -371,11 +371,11 @@ void ObjectHandler_v2d::homeIn(const int objIndex1, const int objIndex2, const i dy = 1; if (abs(dx) > abs(dy)) { - obj1->vx = objDx * -sign<int8>(dx); - obj1->vy = abs((objDy * dy) / dx) * -sign<int8>(dy); + obj1->_vx = objDx * -sign<int8>(dx); + obj1->_vy = abs((objDy * dy) / dx) * -sign<int8>(dy); } else { - obj1->vy = objDy * -sign<int8>(dy); - obj1->vx = abs((objDx * dx) / dy) * -sign<int8>(dx); + obj1->_vy = objDy * -sign<int8>(dy); + obj1->_vx = abs((objDx * dx) / dy) * -sign<int8>(dx); } } } // End of namespace Hugo diff --git a/engines/hugo/object_v3d.cpp b/engines/hugo/object_v3d.cpp index cde7f5fd62..15d5fcd936 100644 --- a/engines/hugo/object_v3d.cpp +++ b/engines/hugo/object_v3d.cpp @@ -65,175 +65,175 @@ void ObjectHandler_v3d::moveObjects() { // Don't store foreground or background objects for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if (obj->screenIndex == *_vm->_screen_p) { - switch (obj->pathType) { + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if (obj->_screenIndex == *_vm->_screen_p) { + switch (obj->_pathType) { case kPathChase: case kPathChase2: { - int8 radius = obj->radius; // Default to object's radius + int8 radius = obj->_radius; // Default to object's radius if (radius < 0) // If radius infinity, use closer value radius = kStepDx; // Allowable motion wrt boundary - int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; - int dy = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - obj->y - currImage->y2 - 1; + int dx = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1 - obj->_x - currImage->_x1; + int dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1; if (abs(dx) <= radius) - obj->vx = 0; + obj->_vx = 0; else - obj->vx = (dx > 0) ? MIN(dx, obj->vxPath) : MAX(dx, -obj->vxPath); + obj->_vx = (dx > 0) ? MIN(dx, obj->_vxPath) : MAX(dx, -obj->_vxPath); if (abs(dy) <= radius) - obj->vy = 0; + obj->_vy = 0; else - obj->vy = (dy > 0) ? MIN(dy, obj->vyPath) : MAX(dy, -obj->vyPath); + obj->_vy = (dy > 0) ? MIN(dy, obj->_vyPath) : MAX(dy, -obj->_vyPath); // Set first image in sequence (if multi-seq object) - switch (obj->seqNumb) { + switch (obj->_seqNumb) { case 4: - if (!obj->vx) { // Got 4 directions - if (obj->vx != obj->oldvx) { // vx just stopped + if (!obj->_vx) { // Got 4 directions + if (obj->_vx != obj->_oldvx) { // vx just stopped if (dy >= 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { + } else if (obj->_vx != obj->_oldvx) { if (dx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } break; case 3: case 2: - if (obj->vx != obj->oldvx) { // vx just stopped + if (obj->_vx != obj->_oldvx) { // vx just stopped if (dx > 0) // Left & right only - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } break; } - if (obj->vx || obj->vy) { - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) { + obj->_cycling = kCycleForward; } else { - obj->cycling = kCycleNotCycling; + obj->_cycling = kCycleNotCycling; boundaryCollision(obj); // Must have got hero! } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image break; } case kPathWander2: case kPathWander: if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval - obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; - obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; + obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath; + obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath; // Set first image in sequence (if multi-seq object) - if (obj->seqNumb > 1) { - if (!obj->vx && (obj->seqNumb >= 4)) { - if (obj->vx != obj->oldvx) { // vx just stopped - if (obj->vy > 0) - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + if (obj->_seqNumb > 1) { + if (!obj->_vx && (obj->_seqNumb >= 4)) { + if (obj->_vx != obj->_oldvx) { // vx just stopped + if (obj->_vy > 0) + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; } - } else if (obj->vx != obj->oldvx) { - if (obj->vx > 0) - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + } else if (obj->_vx != obj->_oldvx) { + if (obj->_vx > 0) + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; else - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; } } - obj->oldvx = obj->vx; - obj->oldvy = obj->vy; - currImage = obj->currImagePtr; // Get (new) ptr to current image + obj->_oldvx = obj->_vx; + obj->_oldvy = obj->_vy; + currImage = obj->_currImagePtr; // Get (new) ptr to current image } - if (obj->vx || obj->vy) - obj->cycling = kCycleForward; + if (obj->_vx || obj->_vy) + obj->_cycling = kCycleForward; break; default: ; // Really, nothing } // Store boundaries - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2); } } // Move objects, allowing for boundaries for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - if ((obj->screenIndex == *_vm->_screen_p) && (obj->vx || obj->vy)) { + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_vx || obj->_vy)) { // Only process if it's moving // Do object movement. Delta_x,y return allowed movement in x,y // to move as close to a boundary as possible without crossing it. - seq_t *currImage = obj->currImagePtr; // Get ptr to current image + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image // object coordinates - int x1 = obj->x + currImage->x1; // Left edge of object - int x2 = obj->x + currImage->x2; // Right edge - int y1 = obj->y + currImage->y1; // Top edge - int y2 = obj->y + currImage->y2; // Bottom edge + int x1 = obj->_x + currImage->_x1; // Left edge of object + int x2 = obj->_x + currImage->_x2; // Right edge + int y1 = obj->_y + currImage->_y1; // Top edge + int y2 = obj->_y + currImage->_y2; // Bottom edge - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) clearBoundary(x1, x2, y2); // Clear our own boundary // Allowable motion wrt boundary - int dx = deltaX(x1, x2, obj->vx, y2); - if (dx != obj->vx) { + int dx = deltaX(x1, x2, obj->_vx, y2); + if (dx != obj->_vx) { // An object boundary collision! boundaryCollision(obj); - obj->vx = 0; + obj->_vx = 0; } - int dy = deltaY(x1, x2, obj->vy, y2); - if (dy != obj->vy) { + int dy = deltaY(x1, x2, obj->_vy, y2); + if (dy != obj->_vy) { // An object boundary collision! boundaryCollision(obj); - obj->vy = 0; + obj->_vy = 0; } - if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) + if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) storeBoundary(x1, x2, y2); // Re-store our own boundary - obj->x += dx; // Update object position - obj->y += dy; + obj->_x += dx; // Update object position + obj->_y += dy; // Don't let object go outside screen if (x1 < kEdge) - obj->x = kEdge2; + obj->_x = kEdge2; if (x2 > (kXPix - kEdge)) - obj->x = kXPix - kEdge2 - (x2 - x1); + obj->_x = kXPix - kEdge2 - (x2 - x1); if (y1 < kEdge) - obj->y = kEdge2; + obj->_y = kEdge2; if (y2 > (kYPix - kEdge)) - obj->y = kYPix - kEdge2 - (y2 - y1); + obj->_y = kYPix - kEdge2 - (y2 - y1); - if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != kPathWander2) && (obj->pathType != kPathChase2)) - obj->cycling = kCycleNotCycling; + if ((obj->_vx == 0) && (obj->_vy == 0) && (obj->_pathType != kPathWander2) && (obj->_pathType != kPathChase2)) + obj->_cycling = kCycleNotCycling; } } // Clear all object baselines from the boundary file. for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object - seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) - clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2); + seq_t *currImage = obj->_currImagePtr; // Get ptr to current image + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating)) + clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2); } // If maze mode is enabled, do special maze processing - if (_vm->_maze.enabledFl) { - seq_t *currImage = _vm->_hero->currImagePtr;// Get ptr to current image + if (_vm->_maze._enabledFl) { + seq_t *currImage = _vm->_hero->_currImagePtr;// Get ptr to current image // hero coordinates - int x1 = _vm->_hero->x + currImage->x1; // Left edge of object - int x2 = _vm->_hero->x + currImage->x2; // Right edge - int y1 = _vm->_hero->y + currImage->y1; // Top edge - int y2 = _vm->_hero->y + currImage->y2; // Bottom edge + int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object + int x2 = _vm->_hero->_x + currImage->_x2; // Right edge + int y1 = _vm->_hero->_y + currImage->_y1; // Top edge + int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge _vm->_scheduler->processMaze(x1, x2, y1, y2); } @@ -252,15 +252,15 @@ void ObjectHandler_v3d::swapImages(int objIndex1, int objIndex2) { seqList_t tmpSeqList[kMaxSeqNumb]; int seqListSize = sizeof(seqList_t) * kMaxSeqNumb; - memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); - memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); - memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); + 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; + _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; + _objects[objIndex1]._y += _objects[objIndex2]._currImagePtr->_y2 - _objects[objIndex1]._currImagePtr->_y2; } } // End of namespace Hugo diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp index 4eaed6fecf..b4255e607b 100644 --- a/engines/hugo/parser.cpp +++ b/engines/hugo/parser.cpp @@ -58,21 +58,21 @@ Parser::~Parser() { } uint16 Parser::getCmdDefaultVerbIdx(const uint16 index) const { - return _cmdList[index][0].verbIndex; + return _cmdList[index][0]._verbIndex; } /** * Read a cmd structure from Hugo.dat */ void Parser::readCmd(Common::ReadStream &in, cmd &curCmd) { - curCmd.verbIndex = in.readUint16BE(); - curCmd.reqIndex = in.readUint16BE(); - curCmd.textDataNoCarryIndex = in.readUint16BE(); - curCmd.reqState = in.readByte(); - curCmd.newState = in.readByte(); - curCmd.textDataWrongIndex = in.readUint16BE(); - curCmd.textDataDoneIndex = in.readUint16BE(); - curCmd.actIndex = in.readUint16BE(); + curCmd._verbIndex = in.readUint16BE(); + curCmd._reqIndex = in.readUint16BE(); + curCmd._textDataNoCarryIndex = in.readUint16BE(); + curCmd._reqState = in.readByte(); + curCmd._newState = in.readByte(); + curCmd._textDataWrongIndex = in.readUint16BE(); + curCmd._textDataDoneIndex = in.readUint16BE(); + curCmd._actIndex = in.readUint16BE(); } /** @@ -100,12 +100,12 @@ void Parser::loadCmdList(Common::ReadStream &in) { void Parser::readBG(Common::ReadStream &in, background_t &curBG) { - curBG.verbIndex = in.readUint16BE(); - curBG.nounIndex = in.readUint16BE(); - curBG.commentIndex = in.readSint16BE(); - curBG.matchFl = (in.readByte() != 0); - curBG.roomState = in.readByte(); - curBG.bonusIndex = in.readByte(); + curBG._verbIndex = in.readUint16BE(); + curBG._nounIndex = in.readUint16BE(); + curBG._commentIndex = in.readSint16BE(); + curBG._matchFl = (in.readByte() != 0); + curBG._roomState = in.readByte(); + curBG._bonusIndex = in.readByte(); } /** @@ -165,11 +165,11 @@ const char *Parser::useBG(const char *name) { debugC(1, kDebugEngine, "useBG(%s)", name); objectList_t p = _backgroundObjects[*_vm->_screen_p]; - for (int i = 0; p[i].verbIndex != 0; i++) { - if ((name == _vm->_text->getNoun(p[i].nounIndex, 0) && - p[i].verbIndex != _vm->_look) && - ((p[i].roomState == kStateDontCare) || (p[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) - return _vm->_text->getVerb(p[i].verbIndex, 0); + for (int i = 0; p[i]._verbIndex != 0; i++) { + if ((name == _vm->_text->getNoun(p[i]._nounIndex, 0) && + p[i]._verbIndex != _vm->_look) && + ((p[i]._roomState == kStateDontCare) || (p[i]._roomState == _vm->_screenStates[*_vm->_screen_p]))) + return _vm->_text->getVerb(p[i]._verbIndex, 0); } return 0; @@ -222,7 +222,7 @@ void Parser::charHandler() { _cmdLine[--_cmdLineIndex] = '\0'; break; case Common::KEYCODE_RETURN: // EOL, pass line to line handler - if (_cmdLineIndex && (_vm->_hero->pathType != kPathQuiet)) { + if (_cmdLineIndex && (_vm->_hero->_pathType != kPathQuiet)) { // Remove inventory bar if active if (_vm->_inventory->getInventoryState() == kInventoryActive) _vm->_inventory->setInventoryState(kInventoryUp); @@ -248,9 +248,9 @@ void Parser::charHandler() { _cmdLineCursor = (_cmdLineCursor == '_') ? ' ' : '_'; // See if recall button pressed - if (gameStatus.recallFl) { + if (gameStatus._recallFl) { // Copy previous line to current cmdline - gameStatus.recallFl = false; + gameStatus._recallFl = false; strcpy(_cmdLine, _vm->_line); _cmdLineIndex = strlen(_cmdLine); } @@ -259,9 +259,9 @@ void Parser::charHandler() { sprintf(_vm->_scoreLine, "F1-Help %s Score: %d of %d Sound %s", (_vm->_config.turboFl) ? "T" : " ", _vm->getScore(), _vm->getMaxScore(), (_vm->_config.soundFl) ? "On" : "Off"); // See if "look" button pressed - if (gameStatus.lookFl) { + if (gameStatus._lookFl) { command("look around"); - gameStatus.lookFl = false; + gameStatus._lookFl = false; } } @@ -288,8 +288,8 @@ void Parser::keyHandler(Common::Event event) { _vm->_file->restoreGame(0); break; case Common::KEYCODE_s: - if (gameStatus.viewState == kViewPlay) { - if (gameStatus.gameOverFl) + if (gameStatus._viewState == kViewPlay) { + if (gameStatus._gameOverFl) _vm->gameOverMsg(); else _vm->_file->saveGame(-1, Common::String()); @@ -304,8 +304,8 @@ void Parser::keyHandler(Common::Event event) { // Process key down event - called from OnKeyDown() switch (nChar) { // Set various toggle states case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT - if (gameStatus.viewState == kViewIntro) - gameStatus.skipIntroFl = true; + if (gameStatus._viewState == kViewIntro) + gameStatus._skipIntroFl = true; else { if (_vm->_inventory->getInventoryState() == kInventoryActive) // Remove inventory, if displayed _vm->_inventory->setInventoryState(kInventoryUp); @@ -333,7 +333,7 @@ void Parser::keyHandler(Common::Event event) { break; case Common::KEYCODE_F1: // User Help (DOS) if (_checkDoubleF1Fl) - gameStatus.helpFl = true; + gameStatus._helpFl = true; else _vm->_screen->userHelp(); _checkDoubleF1Fl = !_checkDoubleF1Fl; @@ -343,11 +343,11 @@ void Parser::keyHandler(Common::Event event) { _vm->_sound->toggleMusic(); break; case Common::KEYCODE_F3: // Repeat last line - gameStatus.recallFl = true; + gameStatus._recallFl = true; break; case Common::KEYCODE_F4: // Save game - if (gameStatus.viewState == kViewPlay) { - if (gameStatus.gameOverFl) + if (gameStatus._viewState == kViewPlay) { + if (gameStatus._gameOverFl) _vm->gameOverMsg(); else _vm->_file->saveGame(-1, Common::String()); @@ -366,7 +366,7 @@ void Parser::keyHandler(Common::Event event) { warning("STUB: F9 (DOS) - BossKey"); break; default: // Any other key - if (!gameStatus.storyModeFl) { // Keyboard disabled + if (!gameStatus._storyModeFl) { // Keyboard disabled // Add printable keys to ring buffer uint16 bnext = _putIndex + 1; if (bnext >= sizeof(_ringBuffer)) @@ -452,7 +452,7 @@ void Parser::showDosInventory() const { for (int i = 0; i < _vm->_object->_numObj; i++) { // Find widths of 2 columns if (_vm->_object->isCarried(i)) { - uint16 len = strlen(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)); + uint16 len = strlen(_vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 2)); if (index++ & 1) // Right hand column len2 = (len > len2) ? len : len2; else @@ -473,9 +473,9 @@ void Parser::showDosInventory() const { for (int i = 0; i < _vm->_object->_numObj; i++) { // Assign strings if (_vm->_object->isCarried(i)) { if (index++ & 1) - buffer += Common::String(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)) + "\n"; + buffer += Common::String(_vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 2)) + "\n"; else - buffer += Common::String(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)) + Common::String(blanks, len1 - strlen(_vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2))); + buffer += Common::String(_vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 2)) + Common::String(blanks, len1 - strlen(_vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 2))); } } if (index & 1) diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h index f8b9d9f13b..18f4916b1e 100644 --- a/engines/hugo/parser.h +++ b/engines/hugo/parser.h @@ -48,14 +48,14 @@ enum seqTextParser { * The following determines how a verb is acted on, for an object */ struct cmd { - uint16 verbIndex; // the verb - uint16 reqIndex; // ptr to list of required objects - uint16 textDataNoCarryIndex; // ptr to string if any of above not carried - byte reqState; // required state for verb to be done - byte newState; // new states if verb done - uint16 textDataWrongIndex; // ptr to string if wrong state - uint16 textDataDoneIndex; // ptr to string if verb done - uint16 actIndex; // Ptr to action list if verb done + uint16 _verbIndex; // the verb + uint16 _reqIndex; // ptr to list of required objects + uint16 _textDataNoCarryIndex; // ptr to string if any of above not carried + byte _reqState; // required state for verb to be done + byte _newState; // new states if verb done + uint16 _textDataWrongIndex; // ptr to string if wrong state + uint16 _textDataDoneIndex; // ptr to string if verb done + uint16 _actIndex; // Ptr to action list if verb done }; /** @@ -65,12 +65,12 @@ struct cmd { * "don't understand" we produce an interesting msg to keep user sane. */ struct background_t { - uint16 verbIndex; - uint16 nounIndex; - int commentIndex; // Index of comment produced on match - bool matchFl; // TRUE if noun must match when present - byte roomState; // "State" of room. Comments might differ. - byte bonusIndex; // Index of bonus score (0 = no bonus) + uint16 _verbIndex; + uint16 _nounIndex; + int _commentIndex; // Index of comment produced on match + bool _matchFl; // TRUE if noun must match when present + byte _roomState; // "State" of room. Comments might differ. + byte _bonusIndex; // Index of bonus score (0 = no bonus) }; typedef background_t *objectList_t; diff --git a/engines/hugo/parser_v1d.cpp b/engines/hugo/parser_v1d.cpp index ccd428311b..aa43cce536 100644 --- a/engines/hugo/parser_v1d.cpp +++ b/engines/hugo/parser_v1d.cpp @@ -81,32 +81,32 @@ const char *Parser_v1d::findNextNoun(const char *noun) const { bool Parser_v1d::isNear_v1(const char *verb, const char *noun, object_t *obj, char *comment) const { debugC(1, kDebugParser, "isNear(%s, %s, obj, %s)", verb, noun, comment); - if (!noun && !obj->verbOnlyFl) { // No noun specified & object not context senesitive + if (!noun && !obj->_verbOnlyFl) { // No noun specified & object not context senesitive return false; - } else if (noun && (noun != _vm->_text->getNoun(obj->nounIndex, 0))) { // Noun specified & not same as object + } else if (noun && (noun != _vm->_text->getNoun(obj->_nounIndex, 0))) { // Noun specified & not same as object return false; - } else if (obj->carriedFl) { // Object is being carried + } else if (obj->_carriedFl) { // Object is being carried return true; - } else if (obj->screenIndex != *_vm->_screen_p) { // Not in same screen - if (obj->objValue) + } else if (obj->_screenIndex != *_vm->_screen_p) { // Not in same screen + if (obj->_objValue) strcpy (comment, _vm->_text->getTextParser(kCmtAny4)); return false; } - if (obj->cycling == kCycleInvisible) { - if (obj->seqNumb) { // There is an image + if (obj->_cycling == kCycleInvisible) { + if (obj->_seqNumb) { // There is an image strcpy(comment, _vm->_text->getTextParser(kCmtAny5)); return false; } else { // No image, assume visible - if ((obj->radius < 0) || - ((abs(obj->x - _vm->_hero->x) <= obj->radius) && - (abs(obj->y - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { + if ((obj->_radius < 0) || + ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) && + (abs(obj->_y - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) { return true; } else { // User is either not close enough (stationary, valueless objects) // or is not carrying it (small, portable objects of value) if (noun) { // Don't say unless object specified - if (obj->objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) + if (obj->_objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) strcpy(comment, _vm->_text->getTextParser(kCmtAny4)); else strcpy(comment, _vm->_text->getTextParser(kCmtClose)); @@ -116,15 +116,15 @@ bool Parser_v1d::isNear_v1(const char *verb, const char *noun, object_t *obj, ch } } - if ((obj->radius < 0) || - ((abs(obj->x - _vm->_hero->x) <= obj->radius) && - (abs(obj->y + obj->currImagePtr->y2 - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { + if ((obj->_radius < 0) || + ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) && + (abs(obj->_y + obj->_currImagePtr->_y2 - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) { return true; } else { // User is either not close enough (stationary, valueless objects) // or is not carrying it (small, portable objects of value) if (noun) { // Don't say unless object specified - if (obj->objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) + if (obj->_objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) strcpy(comment, _vm->_text->getTextParser(kCmtAny4)); else strcpy(comment, _vm->_text->getTextParser(kCmtClose)); @@ -143,28 +143,28 @@ bool Parser_v1d::isNear_v1(const char *verb, const char *noun, object_t *obj, ch bool Parser_v1d::isGenericVerb_v1(const char *word, object_t *obj) { debugC(1, kDebugParser, "isGenericVerb(%s, object_t *obj)", word); - if (!obj->genericCmd) + if (!obj->_genericCmd) return false; // Following is equivalent to switch, but couldn't do one if (word == _vm->_text->getVerb(_vm->_look, 0)) { - if ((LOOK & obj->genericCmd) == LOOK) - Utils::notifyBox(_vm->_text->getTextData(obj->dataIndex)); + if ((LOOK & obj->_genericCmd) == LOOK) + Utils::notifyBox(_vm->_text->getTextData(obj->_dataIndex)); else Utils::notifyBox(_vm->_text->getTextParser(kTBUnusual_1d)); } else if (word == _vm->_text->getVerb(_vm->_take, 0)) { - if (obj->carriedFl) + if (obj->_carriedFl) Utils::notifyBox(_vm->_text->getTextParser(kTBHave)); - else if ((TAKE & obj->genericCmd) == TAKE) + else if ((TAKE & obj->_genericCmd) == TAKE) takeObject(obj); - else if (!obj->verbOnlyFl) // Make sure not taking object in context! + else if (!obj->_verbOnlyFl) // Make sure not taking object in context! Utils::notifyBox(_vm->_text->getTextParser(kTBNoUse)); else return false; } else if (word == _vm->_text->getVerb(_vm->_drop, 0)) { - if (!obj->carriedFl) + if (!obj->_carriedFl) Utils::notifyBox(_vm->_text->getTextParser(kTBDontHave)); - else if ((DROP & obj->genericCmd) == DROP) + else if ((DROP & obj->_genericCmd) == DROP) dropObject(obj); else Utils::notifyBox(_vm->_text->getTextParser(kTBNeed)); @@ -185,42 +185,42 @@ bool Parser_v1d::isObjectVerb_v1(const char *word, object_t *obj) { debugC(1, kDebugParser, "isObjectVerb(%s, object_t *obj)", word); // First, find matching verb in cmd list - uint16 cmdIndex = obj->cmdIndex; // ptr to list of commands + uint16 cmdIndex = obj->_cmdIndex; // ptr to list of commands if (!cmdIndex) // No commands for this obj return false; int i; - for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd - if (!strcmp(word, _vm->_text->getVerb(_cmdList[cmdIndex][i].verbIndex, 0))) // Is this verb catered for? + for (i = 0; _cmdList[cmdIndex][i]._verbIndex != 0; i++) { // For each cmd + if (!strcmp(word, _vm->_text->getVerb(_cmdList[cmdIndex][i]._verbIndex, 0))) // Is this verb catered for? break; } - if (_cmdList[cmdIndex][i].verbIndex == 0) // No + if (_cmdList[cmdIndex][i]._verbIndex == 0) // No return false; // Verb match found, check all required objects are being carried cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd - if (cmnd->reqIndex) { // At least 1 thing in list - uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects + if (cmnd->_reqIndex) { // At least 1 thing in list + uint16 *reqs = _arrayReqs[cmnd->_reqIndex]; // ptr to list of required objects for (i = 0; reqs[i]; i++) { // for each obj if (!_vm->_object->isCarrying(reqs[i])) { - Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataNoCarryIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataNoCarryIndex)); return true; } } } // Required objects are present, now check state is correct - if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)){ - Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataWrongIndex)); + if ((obj->_state != cmnd->_reqState) && (cmnd->_reqState != kStateDontCare)){ + Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataWrongIndex)); return true; } // Everything checked. Change the state and carry out any actions - if (cmnd->reqState != kStateDontCare) // Don't change new state if required state didn't care - obj->state = cmnd->newState; - Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataDoneIndex)); - _vm->_scheduler->insertActionList(cmnd->actIndex); + if (cmnd->_reqState != kStateDontCare) // Don't change new state if required state didn't care + obj->_state = cmnd->_newState; + Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataDoneIndex)); + _vm->_scheduler->insertActionList(cmnd->_actIndex); // Special case if verb is Take or Drop. Assume additional generic actions if ((word == _vm->_text->getVerb(_vm->_take, 0)) || (word == _vm->_text->getVerb(_vm->_drop, 0))) isGenericVerb_v1(word, obj); @@ -237,9 +237,9 @@ bool Parser_v1d::isBackgroundWord_v1(const char *noun, const char *verb, objectL if (!noun) return false; - for (int i = 0; obj[i].verbIndex; i++) { - if ((verb == _vm->_text->getVerb(obj[i].verbIndex, 0)) && (noun == _vm->_text->getNoun(obj[i].nounIndex, 0))) { - Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); + for (int i = 0; obj[i]._verbIndex; i++) { + if ((verb == _vm->_text->getVerb(obj[i]._verbIndex, 0)) && (noun == _vm->_text->getNoun(obj[i]._nounIndex, 0))) { + Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex)); return true; } } @@ -252,13 +252,13 @@ bool Parser_v1d::isBackgroundWord_v1(const char *noun, const char *verb, objectL void Parser_v1d::takeObject(object_t *obj) { debugC(1, kDebugParser, "takeObject(object_t *obj)"); - obj->carriedFl = true; - if (obj->seqNumb) // Don't change if no image to display - obj->cycling = kCycleAlmostInvisible; + obj->_carriedFl = true; + if (obj->_seqNumb) // Don't change if no image to display + obj->_cycling = kCycleAlmostInvisible; - _vm->adjustScore(obj->objValue); + _vm->adjustScore(obj->_objValue); - Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(obj->nounIndex, TAKE_NAME))); + Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(obj->_nounIndex, TAKE_NAME))); } /** @@ -267,13 +267,13 @@ void Parser_v1d::takeObject(object_t *obj) { void Parser_v1d::dropObject(object_t *obj) { debugC(1, kDebugParser, "dropObject(object_t *obj)"); - obj->carriedFl = false; - obj->screenIndex = *_vm->_screen_p; - if (obj->seqNumb) // Don't change if no image to display - obj->cycling = kCycleNotCycling; - obj->x = _vm->_hero->x - 1; - obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1; - _vm->adjustScore(-obj->objValue); + obj->_carriedFl = false; + obj->_screenIndex = *_vm->_screen_p; + if (obj->_seqNumb) // Don't change if no image to display + obj->_cycling = kCycleNotCycling; + obj->_x = _vm->_hero->_x - 1; + obj->_y = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - 1; + _vm->adjustScore(-obj->_objValue); Utils::notifyBox(_vm->_text->getTextParser(kTBOk)); } @@ -284,15 +284,15 @@ void Parser_v1d::dropObject(object_t *obj) { bool Parser_v1d::isCatchallVerb_v1(bool testNounFl, const char *noun, const char *verb, objectList_t obj) const { debugC(1, kDebugParser, "isCatchallVerb(%d, %s, %s, object_list_t obj)", (testNounFl) ? 1 : 0, noun, verb); - if (_vm->_maze.enabledFl) + if (_vm->_maze._enabledFl) return false; if (testNounFl && !noun) return false; - for (int i = 0; obj[i].verbIndex; i++) { - if ((verb == _vm->_text->getVerb(obj[i].verbIndex, 0)) && ((noun == _vm->_text->getNoun(obj[i].nounIndex, 0)) || (obj[i].nounIndex == 0))) { - Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); + for (int i = 0; obj[i]._verbIndex; i++) { + if ((verb == _vm->_text->getVerb(obj[i]._verbIndex, 0)) && ((noun == _vm->_text->getNoun(obj[i]._nounIndex, 0)) || (obj[i]._nounIndex == 0))) { + Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex)); return true; } } @@ -310,7 +310,7 @@ void Parser_v1d::lineHandler() { // Toggle God Mode if (!strncmp(_vm->_line, "PPG", 3)) { _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); - gameStatus.godModeFl = !gameStatus.godModeFl; + gameStatus._godModeFl = !gameStatus._godModeFl; return; } @@ -321,7 +321,7 @@ void Parser_v1d::lineHandler() { // fetch <object name> Hero carries named object // fetch all Hero carries all possible objects // find <object name> Takes hero to screen containing named object - if (gameStatus.godModeFl) { + if (gameStatus._godModeFl) { // Special code to allow me to go straight to any screen if (strstr(_vm->_line, "goto")) { for (int i = 0; i < _vm->_numScreens; i++) { @@ -335,7 +335,7 @@ void Parser_v1d::lineHandler() { // Special code to allow me to get objects from anywhere if (strstr(_vm->_line, "fetch all")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (_vm->_object->_objects[i].genericCmd & TAKE) + if (_vm->_object->_objects[i]._genericCmd & TAKE) takeObject(&_vm->_object->_objects[i]); } return; @@ -343,7 +343,7 @@ void Parser_v1d::lineHandler() { if (strstr(_vm->_line, "fetch")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { + if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { takeObject(&_vm->_object->_objects[i]); return; } @@ -353,8 +353,8 @@ void Parser_v1d::lineHandler() { // Special code to allow me to goto objects if (strstr(_vm->_line, "find")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { - _vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex); + if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { + _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex); return; } } @@ -369,7 +369,7 @@ void Parser_v1d::lineHandler() { // SAVE/RESTORE if (!strcmp("save", _vm->_line)) { - if (gameStatus.gameOverFl) + if (gameStatus._gameOverFl) _vm->gameOverMsg(); else _vm->_file->saveGame(-1, Common::String()); @@ -387,7 +387,7 @@ void Parser_v1d::lineHandler() { if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! return; - if (gameStatus.gameOverFl) { + if (gameStatus._gameOverFl) { // No commands allowed! _vm->gameOverMsg(); return; @@ -425,8 +425,8 @@ void Parser_v1d::lineHandler() { void Parser_v1d::showInventory() const { status_t &gameStatus = _vm->getGameStatus(); - if (gameStatus.viewState == kViewPlay) { - if (gameStatus.gameOverFl) + if (gameStatus._viewState == kViewPlay) { + if (gameStatus._gameOverFl) _vm->gameOverMsg(); else showDosInventory(); diff --git a/engines/hugo/parser_v1w.cpp b/engines/hugo/parser_v1w.cpp index b1657c3bf4..832e6fd1b0 100644 --- a/engines/hugo/parser_v1w.cpp +++ b/engines/hugo/parser_v1w.cpp @@ -61,7 +61,7 @@ void Parser_v1w::lineHandler() { // Toggle God Mode if (!strncmp(_vm->_line, "PPG", 3)) { _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); - gameStatus.godModeFl = !gameStatus.godModeFl; + gameStatus._godModeFl = !gameStatus._godModeFl; return; } @@ -72,7 +72,7 @@ void Parser_v1w::lineHandler() { // fetch <object name> Hero carries named object // fetch all Hero carries all possible objects // find <object name> Takes hero to screen containing named object - if (gameStatus.godModeFl) { + if (gameStatus._godModeFl) { // Special code to allow me to go straight to any screen if (strstr(_vm->_line, "goto")) { for (int i = 0; i < _vm->_numScreens; i++) { @@ -86,7 +86,7 @@ void Parser_v1w::lineHandler() { // Special code to allow me to get objects from anywhere if (strstr(_vm->_line, "fetch all")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (_vm->_object->_objects[i].genericCmd & TAKE) + if (_vm->_object->_objects[i]._genericCmd & TAKE) takeObject(&_vm->_object->_objects[i]); } return; @@ -94,7 +94,7 @@ void Parser_v1w::lineHandler() { if (strstr(_vm->_line, "fetch")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { + if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { takeObject(&_vm->_object->_objects[i]); return; } @@ -104,8 +104,8 @@ void Parser_v1w::lineHandler() { // Special code to allow me to goto objects if (strstr(_vm->_line, "find")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { - _vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex); + if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { + _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex); return; } } @@ -121,12 +121,12 @@ void Parser_v1w::lineHandler() { } // SAVE/RESTORE - if (!strcmp("save", _vm->_line) && gameStatus.viewState == kViewPlay) { + if (!strcmp("save", _vm->_line) && gameStatus._viewState == kViewPlay) { _vm->_file->saveGame(-1, Common::String()); return; } - if (!strcmp("restore", _vm->_line) && (gameStatus.viewState == kViewPlay || gameStatus.viewState == kViewIdle)) { + if (!strcmp("restore", _vm->_line) && (gameStatus._viewState == kViewPlay || gameStatus._viewState == kViewIdle)) { _vm->_file->restoreGame(-1); return; } @@ -137,7 +137,7 @@ void Parser_v1w::lineHandler() { if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! return; - if (gameStatus.gameOverFl) { + if (gameStatus._gameOverFl) { // No commands allowed! _vm->gameOverMsg(); return; @@ -148,7 +148,7 @@ void Parser_v1w::lineHandler() { // Test for nearby objects referenced explicitly for (int i = 0; i < _vm->_object->_numObj; i++) { object_t *obj = &_vm->_object->_objects[i]; - if (isWordPresent(_vm->_text->getNounArray(obj->nounIndex))) { + if (isWordPresent(_vm->_text->getNounArray(obj->_nounIndex))) { if (isObjectVerb_v3(obj, farComment) || isGenericVerb_v3(obj, farComment)) return; } @@ -158,7 +158,7 @@ void Parser_v1w::lineHandler() { // Note comment is unused if not near. for (int i = 0; i < _vm->_object->_numObj; i++) { object_t *obj = &_vm->_object->_objects[i]; - if (obj->verbOnlyFl) { + if (obj->_verbOnlyFl) { char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects if (isObjectVerb_v3(obj, contextComment) || isGenericVerb_v3(obj, contextComment)) return; @@ -185,7 +185,7 @@ void Parser_v1w::lineHandler() { // Nothing matches. Report recognition success to user. const char *verb = findVerb(); const char *noun = findNoun(); - if (verb == _vm->_text->getVerb(_vm->_look, 0) && _vm->_maze.enabledFl) { + if (verb == _vm->_text->getVerb(_vm->_look, 0) && _vm->_maze._enabledFl) { Utils::notifyBox(_vm->_text->getTextParser(kTBMaze)); _vm->_object->showTakeables(); } else if (verb && noun) { // A combination I didn't think of @@ -202,14 +202,14 @@ void Parser_v1w::lineHandler() { void Parser_v1w::showInventory() const { status_t &gameStatus = _vm->getGameStatus(); istate_t inventState = _vm->_inventory->getInventoryState(); - if (gameStatus.gameOverFl) { + if (gameStatus._gameOverFl) { _vm->gameOverMsg(); - } else if ((inventState == kInventoryOff) && (gameStatus.viewState == kViewPlay)) { + } else if ((inventState == kInventoryOff) && (gameStatus._viewState == kViewPlay)) { _vm->_inventory->setInventoryState(kInventoryDown); - gameStatus.viewState = kViewInvent; + gameStatus._viewState = kViewInvent; } else if (inventState == kInventoryActive) { _vm->_inventory->setInventoryState(kInventoryUp); - gameStatus.viewState = kViewInvent; + gameStatus._viewState = kViewInvent; } } diff --git a/engines/hugo/parser_v2d.cpp b/engines/hugo/parser_v2d.cpp index 0095c4d726..2daf3c5e9f 100644 --- a/engines/hugo/parser_v2d.cpp +++ b/engines/hugo/parser_v2d.cpp @@ -60,7 +60,7 @@ void Parser_v2d::lineHandler() { // Toggle God Mode if (!strncmp(_vm->_line, "PPG", 3)) { _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); - gameStatus.godModeFl = !gameStatus.godModeFl; + gameStatus._godModeFl = !gameStatus._godModeFl; return; } @@ -71,7 +71,7 @@ void Parser_v2d::lineHandler() { // fetch <object name> Hero carries named object // fetch all Hero carries all possible objects // find <object name> Takes hero to screen containing named object - if (gameStatus.godModeFl) { + if (gameStatus._godModeFl) { // Special code to allow me to go straight to any screen if (strstr(_vm->_line, "goto")) { for (int i = 0; i < _vm->_numScreens; i++) { @@ -85,7 +85,7 @@ void Parser_v2d::lineHandler() { // Special code to allow me to get objects from anywhere if (strstr(_vm->_line, "fetch all")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (_vm->_object->_objects[i].genericCmd & TAKE) + if (_vm->_object->_objects[i]._genericCmd & TAKE) takeObject(&_vm->_object->_objects[i]); } return; @@ -93,7 +93,7 @@ void Parser_v2d::lineHandler() { if (strstr(_vm->_line, "fetch")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { + if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { takeObject(&_vm->_object->_objects[i]); return; } @@ -103,8 +103,8 @@ void Parser_v2d::lineHandler() { // Special code to allow me to goto objects if (strstr(_vm->_line, "find")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { - _vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex); + if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { + _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex); return; } } @@ -119,7 +119,7 @@ void Parser_v2d::lineHandler() { // SAVE/RESTORE if (!strcmp("save", _vm->_line)) { - if (gameStatus.gameOverFl) + if (gameStatus._gameOverFl) _vm->gameOverMsg(); else _vm->_file->saveGame(-1, Common::String()); @@ -137,7 +137,7 @@ void Parser_v2d::lineHandler() { if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! return; - if (gameStatus.gameOverFl) { + if (gameStatus._gameOverFl) { // No commands allowed! _vm->gameOverMsg(); return; @@ -172,7 +172,7 @@ void Parser_v2d::lineHandler() { && !isCatchallVerb_v1(false, noun, verb, _catchallList)) { if (*farComment != '\0') { // An object matched but not near enough Utils::notifyBox(farComment); - } else if (_vm->_maze.enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) { + } else if (_vm->_maze._enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) { Utils::notifyBox(_vm->_text->getTextParser(kTBMaze)); _vm->_object->showTakeables(); } else if (verb && noun) { // A combination I didn't think of diff --git a/engines/hugo/parser_v3d.cpp b/engines/hugo/parser_v3d.cpp index b45e9186b3..abfe263f6e 100644 --- a/engines/hugo/parser_v3d.cpp +++ b/engines/hugo/parser_v3d.cpp @@ -60,7 +60,7 @@ void Parser_v3d::lineHandler() { // Toggle God Mode if (!strncmp(_vm->_line, "PPG", 3)) { _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); - gameStatus.godModeFl = !gameStatus.godModeFl; + gameStatus._godModeFl = !gameStatus._godModeFl; return; } @@ -71,7 +71,7 @@ void Parser_v3d::lineHandler() { // fetch <object name> Hero carries named object // fetch all Hero carries all possible objects // find <object name> Takes hero to screen containing named object - if (gameStatus.godModeFl) { + if (gameStatus._godModeFl) { // Special code to allow me to go straight to any screen if (strstr(_vm->_line, "goto")) { for (int i = 0; i < _vm->_numScreens; i++) { @@ -85,7 +85,7 @@ void Parser_v3d::lineHandler() { // Special code to allow me to get objects from anywhere if (strstr(_vm->_line, "fetch all")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (_vm->_object->_objects[i].genericCmd & TAKE) + if (_vm->_object->_objects[i]._genericCmd & TAKE) takeObject(&_vm->_object->_objects[i]); } return; @@ -93,7 +93,7 @@ void Parser_v3d::lineHandler() { if (strstr(_vm->_line, "fetch")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { + if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { takeObject(&_vm->_object->_objects[i]); return; } @@ -103,8 +103,8 @@ void Parser_v3d::lineHandler() { // Special code to allow me to goto objects if (strstr(_vm->_line, "find")) { for (int i = 0; i < _vm->_object->_numObj; i++) { - if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) { - _vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex); + if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 0))) { + _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex); return; } } @@ -121,7 +121,7 @@ void Parser_v3d::lineHandler() { // SAVE/RESTORE if (!strcmp("save", _vm->_line)) { - if (gameStatus.gameOverFl) + if (gameStatus._gameOverFl) _vm->gameOverMsg(); else _vm->_file->saveGame(-1, Common::String()); @@ -139,7 +139,7 @@ void Parser_v3d::lineHandler() { if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! return; - if (gameStatus.gameOverFl) { + if (gameStatus._gameOverFl) { // No commands allowed! _vm->gameOverMsg(); return; @@ -150,7 +150,7 @@ void Parser_v3d::lineHandler() { // Test for nearby objects referenced explicitly for (int i = 0; i < _vm->_object->_numObj; i++) { object_t *obj = &_vm->_object->_objects[i]; - if (isWordPresent(_vm->_text->getNounArray(obj->nounIndex))) { + if (isWordPresent(_vm->_text->getNounArray(obj->_nounIndex))) { if (isObjectVerb_v3(obj, farComment) || isGenericVerb_v3(obj, farComment)) return; } @@ -160,7 +160,7 @@ void Parser_v3d::lineHandler() { // Note comment is unused if not near. for (int i = 0; i < _vm->_object->_numObj; i++) { object_t *obj = &_vm->_object->_objects[i]; - if (obj->verbOnlyFl) { + if (obj->_verbOnlyFl) { char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects if (isObjectVerb_v3(obj, contextComment) || isGenericVerb_v3(obj, contextComment)) return; @@ -208,47 +208,47 @@ bool Parser_v3d::isObjectVerb_v3(object_t *obj, char *comment) { debugC(1, kDebugParser, "isObjectVerb(object_t *obj, %s)", comment); // First, find matching verb in cmd list - uint16 cmdIndex = obj->cmdIndex; // ptr to list of commands + uint16 cmdIndex = obj->_cmdIndex; // ptr to list of commands if (cmdIndex == 0) // No commands for this obj return false; int i; - for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd - if (isWordPresent(_vm->_text->getVerbArray(_cmdList[cmdIndex][i].verbIndex))) // Was this verb used? + for (i = 0; _cmdList[cmdIndex][i]._verbIndex != 0; i++) { // For each cmd + if (isWordPresent(_vm->_text->getVerbArray(_cmdList[cmdIndex][i]._verbIndex))) // Was this verb used? break; } - if (_cmdList[cmdIndex][i].verbIndex == 0) // No verbs used. + if (_cmdList[cmdIndex][i]._verbIndex == 0) // No verbs used. return false; // Verb match found. Check if object is Near - char *verb = *_vm->_text->getVerbArray(_cmdList[cmdIndex][i].verbIndex); + char *verb = *_vm->_text->getVerbArray(_cmdList[cmdIndex][i]._verbIndex); if (!isNear_v3(obj, verb, comment)) return false; // Check all required objects are being carried cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd - if (cmnd->reqIndex) { // At least 1 thing in list - uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects + if (cmnd->_reqIndex) { // At least 1 thing in list + uint16 *reqs = _arrayReqs[cmnd->_reqIndex]; // ptr to list of required objects for (i = 0; reqs[i]; i++) { // for each obj if (!_vm->_object->isCarrying(reqs[i])) { - Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataNoCarryIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataNoCarryIndex)); return true; } } } // Required objects are present, now check state is correct - if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)) { - Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataWrongIndex)); + if ((obj->_state != cmnd->_reqState) && (cmnd->_reqState != kStateDontCare)) { + Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataWrongIndex)); return true; } // Everything checked. Change the state and carry out any actions - if (cmnd->reqState != kStateDontCare) // Don't change new state if required state didn't care - obj->state = cmnd->newState; - Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataDoneIndex)); - _vm->_scheduler->insertActionList(cmnd->actIndex); + if (cmnd->_reqState != kStateDontCare) // Don't change new state if required state didn't care + obj->_state = cmnd->_newState; + Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataDoneIndex)); + _vm->_scheduler->insertActionList(cmnd->_actIndex); // See if any additional generic actions if ((verb == _vm->_text->getVerb(_vm->_look, 0)) || (verb == _vm->_text->getVerb(_vm->_take, 0)) || (verb == _vm->_text->getVerb(_vm->_drop, 0))) @@ -262,18 +262,18 @@ bool Parser_v3d::isObjectVerb_v3(object_t *obj, char *comment) { bool Parser_v3d::isGenericVerb_v3(object_t *obj, char *comment) { debugC(1, kDebugParser, "isGenericVerb(object_t *obj, %s)", comment); - if (!obj->genericCmd) + if (!obj->_genericCmd) return false; // Following is equivalent to switch, but couldn't do one if (isWordPresent(_vm->_text->getVerbArray(_vm->_look)) && isNear_v3(obj, _vm->_text->getVerb(_vm->_look, 0), comment)) { // Test state-dependent look before general look - if ((obj->genericCmd & LOOK_S) == LOOK_S) { - Utils::notifyBox(_vm->_text->getTextData(obj->stateDataIndex[obj->state])); + if ((obj->_genericCmd & LOOK_S) == LOOK_S) { + Utils::notifyBox(_vm->_text->getTextData(obj->_stateDataIndex[obj->_state])); } else { - if ((LOOK & obj->genericCmd) == LOOK) { - if (obj->dataIndex != 0) - Utils::notifyBox(_vm->_text->getTextData(obj->dataIndex)); + if ((LOOK & obj->_genericCmd) == LOOK) { + if (obj->_dataIndex != 0) + Utils::notifyBox(_vm->_text->getTextData(obj->_dataIndex)); else return false; } else { @@ -281,22 +281,22 @@ bool Parser_v3d::isGenericVerb_v3(object_t *obj, char *comment) { } } } else if (isWordPresent(_vm->_text->getVerbArray(_vm->_take)) && isNear_v3(obj, _vm->_text->getVerb(_vm->_take, 0), comment)) { - if (obj->carriedFl) + if (obj->_carriedFl) Utils::notifyBox(_vm->_text->getTextParser(kTBHave)); - else if ((TAKE & obj->genericCmd) == TAKE) + else if ((TAKE & obj->_genericCmd) == TAKE) takeObject(obj); - else if (obj->cmdIndex) // No comment if possible commands + else if (obj->_cmdIndex) // No comment if possible commands return false; - else if (!obj->verbOnlyFl && (TAKE & obj->genericCmd) == TAKE) // Make sure not taking object in context! + else if (!obj->_verbOnlyFl && (TAKE & obj->_genericCmd) == TAKE) // Make sure not taking object in context! Utils::notifyBox(_vm->_text->getTextParser(kTBNoUse)); else return false; } else if (isWordPresent(_vm->_text->getVerbArray(_vm->_drop))) { - if (!obj->carriedFl && ((DROP & obj->genericCmd) == DROP)) + if (!obj->_carriedFl && ((DROP & obj->_genericCmd) == DROP)) Utils::notifyBox(_vm->_text->getTextParser(kTBDontHave)); - else if (obj->carriedFl && ((DROP & obj->genericCmd) == DROP)) + else if (obj->_carriedFl && ((DROP & obj->_genericCmd) == DROP)) dropObject(obj); - else if (obj->cmdIndex == 0) + else if (obj->_cmdIndex == 0) Utils::notifyBox(_vm->_text->getTextParser(kTBNeed)); else return false; @@ -316,32 +316,32 @@ bool Parser_v3d::isGenericVerb_v3(object_t *obj, char *comment) { bool Parser_v3d::isNear_v3(object_t *obj, const char *verb, char *comment) const { debugC(1, kDebugParser, "isNear(object_t *obj, %s, %s)", verb, comment); - if (obj->carriedFl) // Object is being carried + if (obj->_carriedFl) // Object is being carried return true; - if (obj->screenIndex != *_vm->_screen_p) { + if (obj->_screenIndex != *_vm->_screen_p) { // Not in same screen - if (obj->objValue) + if (obj->_objValue) strcpy(comment, _vm->_text->getTextParser(kCmtAny1)); else strcpy(comment, _vm->_text->getTextParser(kCmtAny2)); return false; } - if (obj->cycling == kCycleInvisible) { - if (obj->seqNumb) { + if (obj->_cycling == kCycleInvisible) { + if (obj->_seqNumb) { // There is an image strcpy(comment, _vm->_text->getTextParser(kCmtAny3)); return false; } else { // No image, assume visible - if ((obj->radius < 0) || - ((abs(obj->x - _vm->_hero->x) <= obj->radius) && - (abs(obj->y - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { + if ((obj->_radius < 0) || + ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) && + (abs(obj->_y - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) { return true; } else { // User is not close enough - if (obj->objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) + if (obj->_objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) strcpy(comment, _vm->_text->getTextParser(kCmtAny1)); else strcpy(comment, _vm->_text->getTextParser(kCmtClose)); @@ -350,13 +350,13 @@ bool Parser_v3d::isNear_v3(object_t *obj, const char *verb, char *comment) const } } - if ((obj->radius < 0) || - ((abs(obj->x - _vm->_hero->x) <= obj->radius) && - (abs(obj->y + obj->currImagePtr->y2 - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { + if ((obj->_radius < 0) || + ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) && + (abs(obj->_y + obj->_currImagePtr->_y2 - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) { return true; } else { // User is not close enough - if (obj->objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) + if (obj->_objValue && (verb != _vm->_text->getVerb(_vm->_take, 0))) strcpy(comment, _vm->_text->getTextParser(kCmtAny1)); else strcpy(comment, _vm->_text->getTextParser(kCmtClose)); @@ -371,15 +371,15 @@ bool Parser_v3d::isNear_v3(object_t *obj, const char *verb, char *comment) const void Parser_v3d::takeObject(object_t *obj) { debugC(1, kDebugParser, "takeObject(object_t *obj)"); - obj->carriedFl = true; - if (obj->seqNumb) { // Don't change if no image to display - obj->cycling = kCycleInvisible; + obj->_carriedFl = true; + if (obj->_seqNumb) { // Don't change if no image to display + obj->_cycling = kCycleInvisible; } - _vm->adjustScore(obj->objValue); + _vm->adjustScore(obj->_objValue); - if (obj->seqNumb > 0) // If object has an image, force walk to dropped - obj->viewx = -1; // (possibly moved) object next time taken! - Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(obj->nounIndex, TAKE_NAME))); + if (obj->_seqNumb > 0) // If object has an image, force walk to dropped + obj->_viewx = -1; // (possibly moved) object next time taken! + Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(obj->_nounIndex, TAKE_NAME))); } /** @@ -388,16 +388,16 @@ void Parser_v3d::takeObject(object_t *obj) { void Parser_v3d::dropObject(object_t *obj) { debugC(1, kDebugParser, "dropObject(object_t *obj)"); - obj->carriedFl = false; - obj->screenIndex = *_vm->_screen_p; - if ((obj->seqNumb > 1) || (obj->seqList[0].imageNbr > 1)) - obj->cycling = kCycleForward; + obj->_carriedFl = false; + obj->_screenIndex = *_vm->_screen_p; + if ((obj->_seqNumb > 1) || (obj->_seqList[0]._imageNbr > 1)) + obj->_cycling = kCycleForward; else - obj->cycling = kCycleNotCycling; - obj->x = _vm->_hero->x - 1; - obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1; - obj->y = (obj->y + obj->currImagePtr->y2 < kYPix) ? obj->y : kYPix - obj->currImagePtr->y2 - 10; - _vm->adjustScore(-obj->objValue); + obj->_cycling = kCycleNotCycling; + obj->_x = _vm->_hero->_x - 1; + obj->_y = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - 1; + obj->_y = (obj->_y + obj->_currImagePtr->_y2 < kYPix) ? obj->_y : kYPix - obj->_currImagePtr->_y2 - 10; + _vm->adjustScore(-obj->_objValue); Utils::notifyBox(_vm->_text->getTextParser(kTBOk)); } @@ -410,19 +410,19 @@ void Parser_v3d::dropObject(object_t *obj) { bool Parser_v3d::isCatchallVerb_v3(objectList_t obj) const { debugC(1, kDebugParser, "isCatchallVerb(object_list_t obj)"); - if (_vm->_maze.enabledFl) + if (_vm->_maze._enabledFl) return false; - for (int i = 0; obj[i].verbIndex != 0; i++) { - if (isWordPresent(_vm->_text->getVerbArray(obj[i].verbIndex)) && obj[i].nounIndex == 0 && - (!obj[i].matchFl || !findNoun()) && - ((obj[i].roomState == kStateDontCare) || - (obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) { - Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); - _vm->_scheduler->processBonus(obj[i].bonusIndex); + for (int i = 0; obj[i]._verbIndex != 0; i++) { + if (isWordPresent(_vm->_text->getVerbArray(obj[i]._verbIndex)) && obj[i]._nounIndex == 0 && + (!obj[i]._matchFl || !findNoun()) && + ((obj[i]._roomState == kStateDontCare) || + (obj[i]._roomState == _vm->_screenStates[*_vm->_screen_p]))) { + Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex)); + _vm->_scheduler->processBonus(obj[i]._bonusIndex); // If this is LOOK (without a noun), show any takeable objects - if (*(_vm->_text->getVerbArray(obj[i].verbIndex)) == _vm->_text->getVerb(_vm->_look, 0)) + if (*(_vm->_text->getVerbArray(obj[i]._verbIndex)) == _vm->_text->getVerb(_vm->_look, 0)) _vm->_object->showTakeables(); return true; @@ -438,16 +438,16 @@ bool Parser_v3d::isCatchallVerb_v3(objectList_t obj) const { bool Parser_v3d::isBackgroundWord_v3(objectList_t obj) const { debugC(1, kDebugParser, "isBackgroundWord(object_list_t obj)"); - if (_vm->_maze.enabledFl) + if (_vm->_maze._enabledFl) return false; - for (int i = 0; obj[i].verbIndex != 0; i++) { - if (isWordPresent(_vm->_text->getVerbArray(obj[i].verbIndex)) && - isWordPresent(_vm->_text->getNounArray(obj[i].nounIndex)) && - ((obj[i].roomState == kStateDontCare) || - (obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) { - Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); - _vm->_scheduler->processBonus(obj[i].bonusIndex); + for (int i = 0; obj[i]._verbIndex != 0; i++) { + if (isWordPresent(_vm->_text->getVerbArray(obj[i]._verbIndex)) && + isWordPresent(_vm->_text->getNounArray(obj[i]._nounIndex)) && + ((obj[i]._roomState == kStateDontCare) || + (obj[i]._roomState == _vm->_screenStates[*_vm->_screen_p]))) { + Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex)); + _vm->_scheduler->processBonus(obj[i]._bonusIndex); return true; } } diff --git a/engines/hugo/route.cpp b/engines/hugo/route.cpp index 281aacf031..552ddaf5c9 100644 --- a/engines/hugo/route.cpp +++ b/engines/hugo/route.cpp @@ -67,35 +67,35 @@ void Route::setDirection(const uint16 keyCode) { switch (keyCode) { case Common::KEYCODE_UP: case Common::KEYCODE_KP8: - obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr; break; case Common::KEYCODE_DOWN: case Common::KEYCODE_KP2: - obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr; break; case Common::KEYCODE_LEFT: case Common::KEYCODE_KP4: - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; break; case Common::KEYCODE_RIGHT: case Common::KEYCODE_KP6: - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; break; case Common::KEYCODE_HOME: case Common::KEYCODE_KP7: - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; break; case Common::KEYCODE_END: case Common::KEYCODE_KP1: - obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr; break; case Common::KEYCODE_PAGEUP: case Common::KEYCODE_KP9: - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; break; case Common::KEYCODE_PAGEDOWN: case Common::KEYCODE_KP3: - obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; + obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr; break; } } @@ -109,66 +109,66 @@ void Route::setWalk(const uint16 direction) { object_t *obj = _vm->_hero; // Pointer to hero object - if (_vm->getGameStatus().storyModeFl || obj->pathType != kPathUser) // Make sure user has control + if (_vm->getGameStatus()._storyModeFl || obj->_pathType != kPathUser) // Make sure user has control return; - if (!obj->vx && !obj->vy) + if (!obj->_vx && !obj->_vy) _oldWalkDirection = 0; // Fix for consistant restarts if (direction != _oldWalkDirection) { // Direction has changed setDirection(direction); // Face new direction - obj->vx = obj->vy = 0; + obj->_vx = obj->_vy = 0; switch (direction) { // And set correct velocity case Common::KEYCODE_UP: case Common::KEYCODE_KP8: - obj->vy = -kStepDy; + obj->_vy = -kStepDy; break; case Common::KEYCODE_DOWN: case Common::KEYCODE_KP2: - obj->vy = kStepDy; + obj->_vy = kStepDy; break; case Common::KEYCODE_LEFT: case Common::KEYCODE_KP4: - obj->vx = -kStepDx; + obj->_vx = -kStepDx; break; case Common::KEYCODE_RIGHT: case Common::KEYCODE_KP6: - obj->vx = kStepDx; + obj->_vx = kStepDx; break; case Common::KEYCODE_HOME: case Common::KEYCODE_KP7: - obj->vx = -kStepDx; + obj->_vx = -kStepDx; // Note: in v1 Dos and v2 Dos, obj->vy is set to DY - obj->vy = -kStepDy / 2; + obj->_vy = -kStepDy / 2; break; case Common::KEYCODE_END: case Common::KEYCODE_KP1: - obj->vx = -kStepDx; + obj->_vx = -kStepDx; // Note: in v1 Dos and v2 Dos, obj->vy is set to -DY - obj->vy = kStepDy / 2; + obj->_vy = kStepDy / 2; break; case Common::KEYCODE_PAGEUP: case Common::KEYCODE_KP9: - obj->vx = kStepDx; + obj->_vx = kStepDx; // Note: in v1 Dos and v2 Dos, obj->vy is set to -DY - obj->vy = -kStepDy / 2; + obj->_vy = -kStepDy / 2; break; case Common::KEYCODE_PAGEDOWN: case Common::KEYCODE_KP3: - obj->vx = kStepDx; + obj->_vx = kStepDx; // Note: in v1 Dos and v2 Dos, obj->vy is set to DY - obj->vy = kStepDy / 2; + obj->_vy = kStepDy / 2; break; } _oldWalkDirection = direction; - obj->cycling = kCycleForward; + obj->_cycling = kCycleForward; } else { // Same key twice - halt hero - obj->vy = 0; - obj->vx = 0; + obj->_vy = 0; + obj->_vx = 0; _oldWalkDirection = 0; - obj->cycling = kCycleNotCycling; + obj->_cycling = kCycleNotCycling; } } @@ -228,7 +228,7 @@ void Route::segment(int16 x, int16 y) { if (y <= 0 || y >= kYPix - 1) return; - if (_vm->_hero->x < x1) { + if (_vm->_hero->_x < x1) { // Hero x not in segment, search x1..x2 // Find all segments above current for (x = x1; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x <= x2; x++) { @@ -241,7 +241,7 @@ void Route::segment(int16 x, int16 y) { if (_boundaryMap[y + 1][x] == 0) segment(x, y + 1); } - } else if (_vm->_hero->x + kHeroMaxWidth > x2) { + } else if (_vm->_hero->_x + kHeroMaxWidth > x2) { // Hero x not in segment, search x1..x2 // Find all segments above current for (x = x2; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x >= x1; x--) { @@ -257,22 +257,22 @@ void Route::segment(int16 x, int16 y) { } else { // Organize search around hero x position - this gives // better chance for more direct route. - for (x = _vm->_hero->x; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x <= x2; x++) { + for (x = _vm->_hero->_x; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x <= x2; x++) { if (_boundaryMap[y - 1][x] == 0) segment(x, y - 1); } - for (x = x1; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x < _vm->_hero->x; x++) { + for (x = x1; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x < _vm->_hero->_x; x++) { if (_boundaryMap[y - 1][x] == 0) segment(x, y - 1); } - for (x = _vm->_hero->x; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x <= x2; x++) { + for (x = _vm->_hero->_x; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x <= x2; x++) { if (_boundaryMap[y + 1][x] == 0) segment(x, y + 1); } - for (x = x1; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x < _vm->_hero->x; x++) { + for (x = x1; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x < _vm->_hero->_x; x++) { if (_boundaryMap[y + 1][x] == 0) segment(x, y + 1); } @@ -327,16 +327,16 @@ bool Route::findRoute(const int16 cx, const int16 cy) { _destY = cy; // Destination coords _destX = cx; // Destination coords - int16 herox1 = _vm->_hero->x + _vm->_hero->currImagePtr->x1; // Hero baseline - int16 herox2 = _vm->_hero->x + _vm->_hero->currImagePtr->x2; // Hero baseline - int16 heroy = _vm->_hero->y + _vm->_hero->currImagePtr->y2; // Hero baseline + int16 herox1 = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1; // Hero baseline + int16 herox2 = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x2; // Hero baseline + int16 heroy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2; // Hero baseline // Store all object baselines into objbound (except hero's = [0]) object_t *obj; // Ptr to object int i; for (i = 1, obj = &_vm->_object->_objects[i]; i < _vm->_object->_numObj; i++, obj++) { - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling != kCycleInvisible) && (obj->priority == kPriorityFloating)) - _vm->_object->storeBoundary(obj->oldx + obj->currImagePtr->x1, obj->oldx + obj->currImagePtr->x2, obj->oldy + obj->currImagePtr->y2); + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling != kCycleInvisible) && (obj->_priority == kPriorityFloating)) + _vm->_object->storeBoundary(obj->_oldx + obj->_currImagePtr->_x1, obj->_oldx + obj->_currImagePtr->_x2, obj->_oldy + obj->_currImagePtr->_y2); } // Combine objbound and boundary bitmaps to local byte map @@ -350,8 +350,8 @@ bool Route::findRoute(const int16 cx, const int16 cy) { // Clear all object baselines from objbound for (i = 0, obj = _vm->_object->_objects; i < _vm->_object->_numObj; i++, obj++) { - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling != kCycleInvisible) && (obj->priority == kPriorityFloating)) - _vm->_object->clearBoundary(obj->oldx + obj->currImagePtr->x1, obj->oldx + obj->currImagePtr->x2, obj->oldy + obj->currImagePtr->y2); + if ((obj->_screenIndex == *_vm->_screen_p) && (obj->_cycling != kCycleInvisible) && (obj->_priority == kPriorityFloating)) + _vm->_object->clearBoundary(obj->_oldx + obj->_currImagePtr->_x1, obj->_oldx + obj->_currImagePtr->_x2, obj->_oldy + obj->_currImagePtr->_y2); } // Search from hero to destination @@ -433,18 +433,18 @@ void Route::processRoute() { return; // Current hero position - int16 herox = _vm->_hero->x + _vm->_hero->currImagePtr->x1; - int16 heroy = _vm->_hero->y + _vm->_hero->currImagePtr->y2; + int16 herox = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1; + int16 heroy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2; Point *routeNode = &_route[_routeIndex]; // Arrived at node? if (abs(herox - routeNode->x) < kStepDx + 1 && abs(heroy - routeNode->y) < kStepDy) { // kStepDx too low // Close enough - position hero exactly - _vm->_hero->x = _vm->_hero->oldx = routeNode->x - _vm->_hero->currImagePtr->x1; - _vm->_hero->y = _vm->_hero->oldy = routeNode->y - _vm->_hero->currImagePtr->y2; - _vm->_hero->vx = _vm->_hero->vy = 0; - _vm->_hero->cycling = kCycleNotCycling; + _vm->_hero->_x = _vm->_hero->_oldx = routeNode->x - _vm->_hero->_currImagePtr->_x1; + _vm->_hero->_y = _vm->_hero->_oldy = routeNode->y - _vm->_hero->_currImagePtr->_y2; + _vm->_hero->_vx = _vm->_hero->_vy = 0; + _vm->_hero->_cycling = kCycleNotCycling; // Arrived at final node? if (--_routeIndex < 0) { @@ -458,7 +458,7 @@ void Route::processRoute() { _vm->_object->lookObject(&_vm->_object->_objects[_routeObjId]); turnedFl = false; } else { - setDirection(_vm->_object->_objects[_routeObjId].direction); + setDirection(_vm->_object->_objects[_routeObjId]._direction); _routeIndex++; // Come round again turnedFl = true; } @@ -468,7 +468,7 @@ void Route::processRoute() { _vm->_object->useObject(_routeObjId); turnedFl = false; } else { - setDirection(_vm->_object->_objects[_routeObjId].direction); + setDirection(_vm->_object->_objects[_routeObjId]._direction); _routeIndex++; // Come round again turnedFl = true; } @@ -477,7 +477,7 @@ void Route::processRoute() { break; } } - } else if (_vm->_hero->vx == 0 && _vm->_hero->vy == 0) { + } else if (_vm->_hero->_vx == 0 && _vm->_hero->_vy == 0) { // Set direction of travel if at a node // Note realignment when changing to (thinner) up/down sprite, // otherwise hero could bump into boundaries along route. @@ -487,10 +487,10 @@ void Route::processRoute() { setWalk(Common::KEYCODE_LEFT); } else if (heroy < routeNode->y) { setWalk(Common::KEYCODE_DOWN); - _vm->_hero->x = _vm->_hero->oldx = routeNode->x - _vm->_hero->currImagePtr->x1; + _vm->_hero->_x = _vm->_hero->_oldx = routeNode->x - _vm->_hero->_currImagePtr->_x1; } else if (heroy > routeNode->y) { setWalk(Common::KEYCODE_UP); - _vm->_hero->x = _vm->_hero->oldx = routeNode->x - _vm->_hero->currImagePtr->x1; + _vm->_hero->_x = _vm->_hero->_oldx = routeNode->x - _vm->_hero->_currImagePtr->_x1; } } } @@ -504,7 +504,7 @@ bool Route::startRoute(const go_t routeType, const int16 objId, int16 cx, int16 debugC(1, kDebugRoute, "startRoute(%d, %d, %d, %d)", routeType, objId, cx, cy); // Don't attempt to walk if user does not have control - if (_vm->_hero->pathType != kPathUser) + if (_vm->_hero->_pathType != kPathUser) return false; // if inventory showing, make it go away @@ -521,7 +521,7 @@ bool Route::startRoute(const go_t routeType, const int16 objId, int16 cx, int16 bool foundFl = false; // TRUE if route found ok if ((foundFl = findRoute(cx, cy))) { // Found a route? _routeIndex = _routeListIndex; // Node index - _vm->_hero->vx = _vm->_hero->vy = 0; // Stop manual motion + _vm->_hero->_vx = _vm->_hero->_vy = 0; // Stop manual motion } return foundFl; diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp index 896e8fa2ce..18e414420a 100644 --- a/engines/hugo/schedule.cpp +++ b/engines/hugo/schedule.cpp @@ -112,7 +112,7 @@ void Scheduler::insertActionList(const uint16 actIndex) { uint32 Scheduler::getWinTicks() const { debugC(5, kDebugSchedule, "getWinTicks()"); - return _vm->getGameStatus().tick; + return _vm->getGameStatus()._tick; } /** @@ -656,32 +656,32 @@ void Scheduler::screenActions(const int screenNum) { void Scheduler::processMaze(const int x1, const int x2, const int y1, const int y2) { debugC(1, kDebugSchedule, "processMaze"); - if (x1 < _vm->_maze.x1) { + if (x1 < _vm->_maze._x1) { // Exit west _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - 1; - _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x2 - kShiftSize - (x2 - x1); - _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y; + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x2 - kShiftSize - (x2 - x1); + _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->_y; _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); - } else if (x2 > _vm->_maze.x2) { + } else if (x2 > _vm->_maze._x2) { // Exit east _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + 1; - _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x1 + kShiftSize; - _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y; + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x1 + kShiftSize; + _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->_y; _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); - } else if (y1 < _vm->_maze.y1 - kShiftSize) { + } else if (y1 < _vm->_maze._y1 - kShiftSize) { // Exit north - _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _vm->_maze.size; - _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x3; - _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze.y2 - kShiftSize - (y2 - y1); + _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _vm->_maze._size; + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x3; + _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze._y2 - kShiftSize - (y2 - y1); _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); - } else if (y2 > _vm->_maze.y2 - kShiftSize / 2) { + } else if (y2 > _vm->_maze._y2 - kShiftSize / 2) { // Exit south - _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _vm->_maze.size; - _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x4; - _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze.y1 + kShiftSize; + _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _vm->_maze._size; + _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x4; + _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze._y1 + kShiftSize; _vm->_route->resetRoute(); insertActionList(_alNewscrIndex); } @@ -1144,7 +1144,7 @@ void Scheduler::insertAction(act *action) { break; // Workaround: When dying, switch to storyMode in order to block the keyboard. case GAMEOVER: - _vm->getGameStatus().storyModeFl = true; + _vm->getGameStatus()._storyModeFl = true; // No break on purpose default: curEvent->localActionFl = true; // Rest are for current screen only @@ -1205,12 +1205,12 @@ event_t *Scheduler::doAction(event_t *curEvent) { insertActionList(action->a0.actIndex); break; case START_OBJ: // act1: Start an object cycling - _vm->_object->_objects[action->a1.objIndex].cycleNumb = action->a1.cycleNumb; - _vm->_object->_objects[action->a1.objIndex].cycling = action->a1.cycle; + _vm->_object->_objects[action->a1.objIndex]._cycleNumb = action->a1.cycleNumb; + _vm->_object->_objects[action->a1.objIndex]._cycling = action->a1.cycle; break; case INIT_OBJXY: // act2: Initialize an object - _vm->_object->_objects[action->a2.objIndex].x = action->a2.x; // Coordinates - _vm->_object->_objects[action->a2.objIndex].y = action->a2.y; + _vm->_object->_objects[action->a2.objIndex]._x = action->a2.x; // Coordinates + _vm->_object->_objects[action->a2.objIndex]._y = action->a2.y; break; case PROMPT: // act3: Prompt user for key phrase promptAction(action); @@ -1225,21 +1225,21 @@ event_t *Scheduler::doAction(event_t *curEvent) { _vm->_object->setCarry(action->a6.objIndex, action->a6.carriedFl); // carried status break; case INIT_HF_COORD: // act7: Initialize an object to hero's "feet" coords - _vm->_object->_objects[action->a7.objIndex].x = _vm->_hero->x - 1; - _vm->_object->_objects[action->a7.objIndex].y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1; - _vm->_object->_objects[action->a7.objIndex].screenIndex = *_vm->_screen_p; // Don't forget screen! + _vm->_object->_objects[action->a7.objIndex]._x = _vm->_hero->_x - 1; + _vm->_object->_objects[action->a7.objIndex]._y = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - 1; + _vm->_object->_objects[action->a7.objIndex]._screenIndex = *_vm->_screen_p; // Don't forget screen! break; case NEW_SCREEN: // act8: Start new screen newScreen(action->a8.screenIndex); break; case INIT_OBJSTATE: // act9: Initialize an object state - _vm->_object->_objects[action->a9.objIndex].state = action->a9.newState; + _vm->_object->_objects[action->a9.objIndex]._state = action->a9.newState; break; case INIT_PATH: // act10: Initialize an object path and velocity _vm->_object->setPath(action->a10.objIndex, (path_t) action->a10.newPathType, action->a10.vxPath, action->a10.vyPath); break; case COND_R: // act11: action lists conditional on object state - if (_vm->_object->_objects[action->a11.objIndex].state == action->a11.stateReq) + if (_vm->_object->_objects[action->a11.objIndex]._state == action->a11.stateReq) insertActionList(action->a11.actPassIndex); else insertActionList(action->a11.actFailIndex); @@ -1251,7 +1251,7 @@ event_t *Scheduler::doAction(event_t *curEvent) { _vm->_object->swapImages(action->a13.objIndex1, action->a13.objIndex2); break; case COND_SCR: // act14: Conditional on current screen - if (_vm->_object->_objects[action->a14.objIndex].screenIndex == action->a14.screenReq) + if (_vm->_object->_objects[action->a14.objIndex]._screenIndex == action->a14.screenReq) insertActionList(action->a14.actPassIndex); else insertActionList(action->a14.actFailIndex); @@ -1262,16 +1262,16 @@ event_t *Scheduler::doAction(event_t *curEvent) { case INIT_OBJ_SEQ: // act16: Set sequence number to use // Note: Don't set a sequence at time 0 of a new screen, it causes // problems clearing the boundary bits of the object! t>0 is safe - _vm->_object->_objects[action->a16.objIndex].currImagePtr = _vm->_object->_objects[action->a16.objIndex].seqList[action->a16.seqIndex].seqPtr; + _vm->_object->_objects[action->a16.objIndex]._currImagePtr = _vm->_object->_objects[action->a16.objIndex]._seqList[action->a16.seqIndex]._seqPtr; break; case SET_STATE_BITS: // act17: OR mask with curr obj state - _vm->_object->_objects[action->a17.objIndex].state |= action->a17.stateMask; + _vm->_object->_objects[action->a17.objIndex]._state |= action->a17.stateMask; break; case CLEAR_STATE_BITS: // act18: AND ~mask with curr obj state - _vm->_object->_objects[action->a18.objIndex].state &= ~action->a18.stateMask; + _vm->_object->_objects[action->a18.objIndex]._state &= ~action->a18.stateMask; break; case TEST_STATE_BITS: // act19: If all bits set, do apass else afail - if ((_vm->_object->_objects[action->a19.objIndex].state & action->a19.stateMask) == action->a19.stateMask) + if ((_vm->_object->_objects[action->a19.objIndex]._state & action->a19.stateMask) == action->a19.stateMask) insertActionList(action->a19.actPassIndex); else insertActionList(action->a19.actFailIndex); @@ -1282,12 +1282,12 @@ event_t *Scheduler::doAction(event_t *curEvent) { case GAMEOVER: // act21: Game over! // NOTE: Must wait at least 1 tick before issuing this action if // any objects are to be made invisible! - gameStatus.gameOverFl = true; + gameStatus._gameOverFl = true; break; case INIT_HH_COORD: // act22: Initialize an object to hero's actual coords - _vm->_object->_objects[action->a22.objIndex].x = _vm->_hero->x; - _vm->_object->_objects[action->a22.objIndex].y = _vm->_hero->y; - _vm->_object->_objects[action->a22.objIndex].screenIndex = *_vm->_screen_p;// Don't forget screen! + _vm->_object->_objects[action->a22.objIndex]._x = _vm->_hero->_x; + _vm->_object->_objects[action->a22.objIndex]._y = _vm->_hero->_y; + _vm->_object->_objects[action->a22.objIndex]._screenIndex = *_vm->_screen_p;// Don't forget screen! break; case EXIT: // act23: Exit game back to DOS _vm->endGame(); @@ -1297,8 +1297,8 @@ event_t *Scheduler::doAction(event_t *curEvent) { break; case COND_BOX: // act25: Conditional on bounding box obj1 = &_vm->_object->_objects[action->a25.objIndex]; - dx = obj1->x + obj1->currImagePtr->x1; - dy = obj1->y + obj1->currImagePtr->y2; + dx = obj1->_x + obj1->_currImagePtr->_x1; + dy = obj1->_y + obj1->_currImagePtr->_y2; if ((dx >= action->a25.x1) && (dx <= action->a25.x2) && (dy >= action->a25.y1) && (dy <= action->a25.y2)) insertActionList(action->a25.actPassIndex); @@ -1312,10 +1312,10 @@ event_t *Scheduler::doAction(event_t *curEvent) { _vm->_sound->playSound(action->a26.soundIndex, kSoundPriorityMedium); break; case ADD_SCORE: // act27: Add object's value to score - _vm->adjustScore(_vm->_object->_objects[action->a27.objIndex].objValue); + _vm->adjustScore(_vm->_object->_objects[action->a27.objIndex]._objValue); break; case SUB_SCORE: // act28: Subtract object's value from score - _vm->adjustScore(-_vm->_object->_objects[action->a28.objIndex].objValue); + _vm->adjustScore(-_vm->_object->_objects[action->a28.objIndex]._objValue); break; case COND_CARRY: // act29: Conditional on object being carried if (_vm->_object->isCarried(action->a29.objIndex)) @@ -1324,24 +1324,24 @@ event_t *Scheduler::doAction(event_t *curEvent) { insertActionList(action->a29.actFailIndex); break; case INIT_MAZE: // act30: Enable and init maze structure - _vm->_maze.enabledFl = true; - _vm->_maze.size = action->a30.mazeSize; - _vm->_maze.x1 = action->a30.x1; - _vm->_maze.y1 = action->a30.y1; - _vm->_maze.x2 = action->a30.x2; - _vm->_maze.y2 = action->a30.y2; - _vm->_maze.x3 = action->a30.x3; - _vm->_maze.x4 = action->a30.x4; - _vm->_maze.firstScreenIndex = action->a30.firstScreenIndex; + _vm->_maze._enabledFl = true; + _vm->_maze._size = action->a30.mazeSize; + _vm->_maze._x1 = action->a30.x1; + _vm->_maze._y1 = action->a30.y1; + _vm->_maze._x2 = action->a30.x2; + _vm->_maze._y2 = action->a30.y2; + _vm->_maze._x3 = action->a30.x3; + _vm->_maze._x4 = action->a30.x4; + _vm->_maze._firstScreenIndex = action->a30.firstScreenIndex; break; case EXIT_MAZE: // act31: Disable maze mode - _vm->_maze.enabledFl = false; + _vm->_maze._enabledFl = false; break; case INIT_PRIORITY: - _vm->_object->_objects[action->a32.objIndex].priority = action->a32.priority; + _vm->_object->_objects[action->a32.objIndex]._priority = action->a32.priority; break; case INIT_SCREEN: - _vm->_object->_objects[action->a33.objIndex].screenIndex = action->a33.screenIndex; + _vm->_object->_objects[action->a33.objIndex]._screenIndex = action->a33.screenIndex; break; case AGSCHEDULE: // act34: Schedule a (global) action list insertActionList(action->a34.actIndex); @@ -1359,15 +1359,15 @@ event_t *Scheduler::doAction(event_t *curEvent) { _vm->_screenStates[action->a37.screenIndex] = action->a37.newState; break; case INIT_LIPS: // act38: Position lips on object - _vm->_object->_objects[action->a38.lipsObjIndex].x = _vm->_object->_objects[action->a38.objIndex].x + action->a38.dxLips; - _vm->_object->_objects[action->a38.lipsObjIndex].y = _vm->_object->_objects[action->a38.objIndex].y + action->a38.dyLips; - _vm->_object->_objects[action->a38.lipsObjIndex].screenIndex = *_vm->_screen_p; // Don't forget screen! - _vm->_object->_objects[action->a38.lipsObjIndex].cycling = kCycleForward; + _vm->_object->_objects[action->a38.lipsObjIndex]._x = _vm->_object->_objects[action->a38.objIndex]._x + action->a38.dxLips; + _vm->_object->_objects[action->a38.lipsObjIndex]._y = _vm->_object->_objects[action->a38.objIndex]._y + action->a38.dyLips; + _vm->_object->_objects[action->a38.lipsObjIndex]._screenIndex = *_vm->_screen_p; // Don't forget screen! + _vm->_object->_objects[action->a38.lipsObjIndex]._cycling = kCycleForward; break; case INIT_STORY_MODE: // act39: Init story_mode flag // This is similar to the QUIET path mode, except that it is // independant of it and it additionally disables the ">" prompt - gameStatus.storyModeFl = action->a39.storyModeFl; + gameStatus._storyModeFl = action->a39.storyModeFl; break; case WARN: // act40: Text box (CF TEXT) Utils::notifyBox(_vm->_file->fetchString(action->a40.stringIndex)); @@ -1379,7 +1379,7 @@ event_t *Scheduler::doAction(event_t *curEvent) { insertActionList(action->a41.actFailIndex); break; case TEXT_TAKE: // act42: Text box with "take" message - Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(_vm->_object->_objects[action->a42.objIndex].nounIndex, TAKE_NAME))); + Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(_vm->_object->_objects[action->a42.objIndex]._nounIndex, TAKE_NAME))); break; case YESNO: // act43: Prompt user for Yes or No if (Utils::yesNoBox(_vm->_file->fetchString(action->a43.promptIndex))) @@ -1403,16 +1403,16 @@ event_t *Scheduler::doAction(event_t *curEvent) { _vm->_mouse->setJumpExitFl(action->a46.jumpExitFl); break; case INIT_VIEW: // act47: Init object.viewx, viewy, dir - _vm->_object->_objects[action->a47.objIndex].viewx = action->a47.viewx; - _vm->_object->_objects[action->a47.objIndex].viewy = action->a47.viewy; - _vm->_object->_objects[action->a47.objIndex].direction = action->a47.direction; + _vm->_object->_objects[action->a47.objIndex]._viewx = action->a47.viewx; + _vm->_object->_objects[action->a47.objIndex]._viewy = action->a47.viewy; + _vm->_object->_objects[action->a47.objIndex]._direction = action->a47.direction; break; case INIT_OBJ_FRAME: // act48: Set seq,frame number to use // Note: Don't set a sequence at time 0 of a new screen, it causes // problems clearing the boundary bits of the object! t>0 is safe - _vm->_object->_objects[action->a48.objIndex].currImagePtr = _vm->_object->_objects[action->a48.objIndex].seqList[action->a48.seqIndex].seqPtr; + _vm->_object->_objects[action->a48.objIndex]._currImagePtr = _vm->_object->_objects[action->a48.objIndex]._seqList[action->a48.seqIndex]._seqPtr; for (dx = 0; dx < action->a48.frameIndex; dx++) - _vm->_object->_objects[action->a48.objIndex].currImagePtr = _vm->_object->_objects[action->a48.objIndex].currImagePtr->nextSeqPtr; + _vm->_object->_objects[action->a48.objIndex]._currImagePtr = _vm->_object->_objects[action->a48.objIndex]._currImagePtr->_nextSeqPtr; break; case OLD_SONG: // Replaces ACT26 for DOS games. @@ -1644,6 +1644,6 @@ void Scheduler_v1w::runScheduler() { while (curEvent && (curEvent->time <= ticker)) // While mature events found curEvent = doAction(curEvent); // Perform the action (returns next_p) - _vm->getGameStatus().tick++; // Accessed elsewhere via getTicks() + _vm->getGameStatus()._tick++; // Accessed elsewhere via getTicks() } } // End of namespace Hugo diff --git a/engines/hugo/sound.cpp b/engines/hugo/sound.cpp index d0b4e3dfe8..eed4164d5e 100644 --- a/engines/hugo/sound.cpp +++ b/engines/hugo/sound.cpp @@ -186,7 +186,7 @@ void SoundHandler::playMusic(int16 tune) { uint16 size; // Size of sequence data if (_vm->_config.musicFl) { - _vm->getGameStatus().song = tune; + _vm->getGameStatus()._song = tune; seqPtr = _vm->_file->getSound(tune, &size); playMIDI(seqPtr, size); free(seqPtr); @@ -245,7 +245,7 @@ void SoundHandler::checkMusic() { return; for (int i = 0; _vm->_defltTunes[i] != -1; i++) { - if (_vm->_defltTunes[i] == _vm->getGameStatus().song) { + if (_vm->_defltTunes[i] == _vm->getGameStatus()._song) { if (_vm->_defltTunes[i + 1] != -1) playMusic(_vm->_defltTunes[i + 1]); else diff --git a/engines/sword25/gfx/image/art.cpp b/engines/sword25/gfx/image/art.cpp index 3944a207c8..9c4b9fe8bd 100644 --- a/engines/sword25/gfx/image/art.cpp +++ b/engines/sword25/gfx/image/art.cpp @@ -2367,38 +2367,30 @@ ArtSVPRenderAAIter *art_svp_render_aa_iter(const ArtSVP *svp, return iter; } -#define ADD_STEP(xpos, xdelta) \ +#define ADD_STEP(xpos, xdelta) \ /* stereotype code fragment for adding a step */ \ - if (n_steps == 0 || steps[n_steps - 1].x < xpos) \ - { \ + if (n_steps == 0 || steps[n_steps - 1].x < xpos) { \ sx = n_steps; \ steps[sx].x = xpos; \ steps[sx].delta = xdelta; \ n_steps++; \ - } \ - else \ - { \ - for (sx = n_steps; sx > 0; sx--) \ - { \ - if (steps[sx - 1].x == xpos) \ - { \ + } else { \ + for (sx = n_steps; sx > 0; sx--) { \ + if (steps[sx - 1].x == xpos) { \ steps[sx - 1].delta += xdelta; \ sx = n_steps; \ break; \ - } \ - else if (steps[sx - 1].x < xpos) \ - { \ + } else if (steps[sx - 1].x < xpos) { \ break; \ - } \ - } \ - if (sx < n_steps) \ - { \ + } \ + } \ + if (sx < n_steps) { \ memmove (&steps[sx + 1], &steps[sx], \ (n_steps - sx) * sizeof(steps[0])); \ steps[sx].x = xpos; \ steps[sx].delta = xdelta; \ n_steps++; \ - } \ + } \ } void art_svp_render_aa_iter_step(ArtSVPRenderAAIter *iter, int *p_start, diff --git a/engines/sword25/gfx/image/art.h b/engines/sword25/gfx/image/art.h index 8c9c97bc57..40bcb55aa7 100644 --- a/engines/sword25/gfx/image/art.h +++ b/engines/sword25/gfx/image/art.h @@ -50,7 +50,7 @@ namespace Sword25 { be variables. They can also be pstruct->el lvalues. */ #define art_expand(p, type, max) \ do { \ - if(max) {\ + if (max) {\ type *tmp = art_renew(p, type, max <<= 1); \ if (!tmp) error("Cannot reallocate memory for art data"); \ p = tmp; \ |