HUGO: Apply coding convention (in progress)

This commit is contained in:
Strangerke 2012-06-13 11:28:25 +02:00
parent 04b6af9176
commit 2e7b16a8bd
26 changed files with 1274 additions and 1274 deletions

View file

@ -96,8 +96,8 @@ bool HugoConsole::Cmd_listObjects(int argc, const char **argv) {
DebugPrintf("Available objects for this game are:\n"); DebugPrintf("Available objects for this game are:\n");
for (int i = 0; i < _vm->_object->_numObj; i++) { for (int i = 0; i < _vm->_object->_numObj; i++) {
if (_vm->_object->_objects[i].genericCmd & TAKE) if (_vm->_object->_objects[i]._genericCmd & TAKE)
DebugPrintf("%2d - %s\n", i, _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)); DebugPrintf("%2d - %s\n", i, _vm->_text->getNoun(_vm->_object->_objects[i]._nounIndex, 2));
} }
return true; return true;
} }
@ -111,7 +111,7 @@ bool HugoConsole::Cmd_getObject(int argc, const char **argv) {
return true; 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])]); _vm->_parser->takeObject(&_vm->_object->_objects[strToInt(argv[1])]);
else else
DebugPrintf("Object not available\n"); 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++) { 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]); _vm->_parser->takeObject(&_vm->_object->_objects[i]);
} }
@ -145,7 +145,7 @@ bool HugoConsole::Cmd_boundaries(int argc, const char **argv) {
return true; return true;
} }
_vm->getGameStatus().showBoundariesFl = !_vm->getGameStatus().showBoundariesFl; _vm->getGameStatus()._showBoundariesFl = !_vm->getGameStatus()._showBoundariesFl;
return false; return false;
} }

View file

@ -34,19 +34,19 @@
namespace Hugo { 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) { _vm(vm) {
init(); init();
} }
TopMenu::~TopMenu() { TopMenu::~TopMenu() {
for (int i = 0; i < arraySize; i++) { for (int i = 0; i < _arraySize; i++) {
arrayBmp[i * 2]->free(); _arrayBmp[i * 2]->free();
delete arrayBmp[i * 2]; delete _arrayBmp[i * 2];
arrayBmp[i * 2 + 1]->free(); _arrayBmp[i * 2 + 1]->free();
delete arrayBmp[i * 2 + 1]; delete _arrayBmp[i * 2 + 1];
} }
delete[] arrayBmp; delete[] _arrayBmp;
} }
void TopMenu::init() { void TopMenu::init() {
@ -108,23 +108,23 @@ void TopMenu::reflowLayout() {
x += kButtonWidth + kButtonPad; x += kButtonWidth + kButtonPad;
// Set the graphics to the 'on' buttons, except for the variable ones // Set the graphics to the 'on' buttons, except for the variable ones
_whatButton->setGfx(arrayBmp[4 * kMenuWhat + scale - 1]); _whatButton->setGfx(_arrayBmp[4 * kMenuWhat + scale - 1]);
_musicButton->setGfx(arrayBmp[4 * kMenuMusic + scale - 1 + ((_vm->_config.musicFl) ? 0 : 2)]); _musicButton->setGfx(_arrayBmp[4 * kMenuMusic + scale - 1 + ((_vm->_config.musicFl) ? 0 : 2)]);
_soundFXButton->setGfx(arrayBmp[4 * kMenuSoundFX + scale - 1 + ((_vm->_config.soundFl) ? 0 : 2)]); _soundFXButton->setGfx(_arrayBmp[4 * kMenuSoundFX + scale - 1 + ((_vm->_config.soundFl) ? 0 : 2)]);
_saveButton->setGfx(arrayBmp[4 * kMenuSave + scale - 1]); _saveButton->setGfx(_arrayBmp[4 * kMenuSave + scale - 1]);
_loadButton->setGfx(arrayBmp[4 * kMenuLoad + scale - 1]); _loadButton->setGfx(_arrayBmp[4 * kMenuLoad + scale - 1]);
_recallButton->setGfx(arrayBmp[4 * kMenuRecall + scale - 1]); _recallButton->setGfx(_arrayBmp[4 * kMenuRecall + scale - 1]);
_turboButton->setGfx(arrayBmp[4 * kMenuTurbo + scale - 1 + ((_vm->_config.turboFl) ? 0 : 2)]); _turboButton->setGfx(_arrayBmp[4 * kMenuTurbo + scale - 1 + ((_vm->_config.turboFl) ? 0 : 2)]);
_lookButton->setGfx(arrayBmp[4 * kMenuLook + scale - 1]); _lookButton->setGfx(_arrayBmp[4 * kMenuLook + scale - 1]);
_inventButton->setGfx(arrayBmp[4 * kMenuInventory + scale - 1]); _inventButton->setGfx(_arrayBmp[4 * kMenuInventory + scale - 1]);
} }
void TopMenu::loadBmpArr(Common::SeekableReadStream &in) { void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
arraySize = in.readUint16BE(); _arraySize = in.readUint16BE();
delete arrayBmp; delete _arrayBmp;
arrayBmp = new Graphics::Surface *[arraySize * 2]; _arrayBmp = new Graphics::Surface *[_arraySize * 2];
for (int i = 0; i < arraySize; i++) { for (int i = 0; i < _arraySize; i++) {
uint16 bmpSize = in.readUint16BE(); uint16 bmpSize = in.readUint16BE();
uint32 filPos = in.pos(); uint32 filPos = in.pos();
Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize); Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize);
@ -137,28 +137,28 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
if (bitmapSrc->format.bytesPerPixel == 1) if (bitmapSrc->format.bytesPerPixel == 1)
error("TopMenu::loadBmpArr(): Unhandled paletted image"); error("TopMenu::loadBmpArr(): Unhandled paletted image");
arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat()); _arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat());
arrayBmp[i * 2 + 1] = new Graphics::Surface(); _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()); _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 *src = (byte *)_arrayBmp[i * 2]->pixels;
byte *dst = (byte *)arrayBmp[i * 2 + 1]->pixels; byte *dst = (byte *)_arrayBmp[i * 2 + 1]->pixels;
for (int j = 0; j < arrayBmp[i * 2]->h; j++) { for (int j = 0; j < _arrayBmp[i * 2]->h; j++) {
src = (byte *)arrayBmp[i * 2]->getBasePtr(0, j); src = (byte *)_arrayBmp[i * 2]->getBasePtr(0, j);
dst = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2); dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2);
for (int k = arrayBmp[i * 2]->w; k > 0; k--) { for (int k = _arrayBmp[i * 2]->w; k > 0; k--) {
for (int m = arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) { for (int m = _arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) {
*dst++ = *src++; *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++; *dst++ = *src++;
} }
} }
src = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2); src = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2);
dst = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2 + 1); dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2 + 1);
for (int k = arrayBmp[i * 2 + 1]->pitch; k > 0; k--) { for (int k = _arrayBmp[i * 2 + 1]->pitch; k > 0; k--) {
*dst++ = *src++; *dst++ = *src++;
} }
} }
@ -171,12 +171,12 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d
switch (command) { switch (command) {
case kCmdWhat: case kCmdWhat:
close(); close();
_vm->getGameStatus().helpFl = true; _vm->getGameStatus()._helpFl = true;
break; break;
case kCmdMusic: case kCmdMusic:
_vm->_sound->toggleMusic(); _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(); _musicButton->draw();
g_gui.theme()->updateScreen(); g_gui.theme()->updateScreen();
g_system->updateScreen(); g_system->updateScreen();
@ -194,8 +194,8 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d
break; break;
case kCmdSave: case kCmdSave:
close(); close();
if (_vm->getGameStatus().viewState == kViewPlay) { if (_vm->getGameStatus()._viewState == kViewPlay) {
if (_vm->getGameStatus().gameOverFl) if (_vm->getGameStatus()._gameOverFl)
_vm->gameOverMsg(); _vm->gameOverMsg();
else else
_vm->_file->saveGame(-1, Common::String()); _vm->_file->saveGame(-1, Common::String());
@ -207,7 +207,7 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d
break; break;
case kCmdRecall: case kCmdRecall:
close(); close();
_vm->getGameStatus().recallFl = true; _vm->getGameStatus()._recallFl = true;
break; break;
case kCmdTurbo: case kCmdTurbo:
_vm->_parser->switchTurbo(); _vm->_parser->switchTurbo();

View file

@ -94,8 +94,8 @@ protected:
GUI::PicButtonWidget *_lookButton; GUI::PicButtonWidget *_lookButton;
GUI::PicButtonWidget *_inventButton; GUI::PicButtonWidget *_inventButton;
Graphics::Surface **arrayBmp; Graphics::Surface **_arrayBmp;
uint16 arraySize; uint16 _arraySize;
}; };
class EntryDialog : public GUI::Dialog { class EntryDialog : public GUI::Dialog {

View file

@ -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) { 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); 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 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 frontBufferwrap = kXPix - seq->_x2 - 1; // Wraps dest_p after each line
int16 imageWrap = seq->bytesPerLine8 - seq->x2 - 1; int16 imageWrap = seq->_bytesPerLine8 - seq->_x2 - 1;
overlayState_t overlayState = (foreFl) ? kOvlForeground : kOvlUndef; // Overlay state of object overlayState_t overlayState = (foreFl) ? kOvlForeground : kOvlUndef; // Overlay state of object
for (uint16 y = 0; y < seq->lines; y++) { // Each line in object for (uint16 y = 0; y < seq->_lines; y++) { // Each line in object
for (uint16 x = 0; x <= seq->x2; x++) { for (uint16 x = 0; x <= seq->_x2; x++) {
if (*image) { // Non-transparent if (*image) { // Non-transparent
byte ovlBound = _vm->_object->getFirstOverlay((uint16)(subFrontBuffer - _frontBuffer) >> 3); // Ptr into overlay bits byte ovlBound = _vm->_object->getFirstOverlay((uint16)(subFrontBuffer - _frontBuffer) >> 3); // Ptr into overlay bits
if (ovlBound & (0x80 >> ((uint16)(subFrontBuffer - _frontBuffer) & 7))) { // Overlay bit is set 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 // 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 // Don't blit if newscreen just loaded because _frontBuffer will
// get blitted via InvalidateRect() at end of this cycle // get blitted via InvalidateRect() at end of this cycle
// and blitting here causes objects to appear too soon. // and blitting here causes objects to appear too soon.
if (_vm->getGameStatus().newScreenFl) { if (_vm->getGameStatus()._newScreenFl) {
_vm->getGameStatus().newScreenFl = false; _vm->getGameStatus()._newScreenFl = false;
break; break;
} }
@ -563,7 +563,7 @@ void Screen::initNewScreenDisplay() {
displayBackground(); displayBackground();
// Stop premature object display in Display_list(D_DISPLAY) // 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 * White = Fix objects, parts of background
*/ */
void Screen::drawBoundaries() { void Screen::drawBoundaries() {
if (!_vm->getGameStatus().showBoundariesFl) if (!_vm->getGameStatus()._showBoundariesFl)
return; return;
_vm->_mouse->drawHotspots(); _vm->_mouse->drawHotspots();
for (int i = 0; i < _vm->_object->_numObj; i++) { for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[i]; // Get pointer to object object_t *obj = &_vm->_object->_objects[i]; // Get pointer to object
if (obj->screenIndex == *_vm->_screen_p) { if (obj->_screenIndex == *_vm->_screen_p) {
if ((obj->currImagePtr != 0) && (obj->cycling != kCycleInvisible)) if ((obj->_currImagePtr != 0) && (obj->_cycling != kCycleInvisible))
drawRectangle(false, obj->x + obj->currImagePtr->x1, obj->y + obj->currImagePtr->y1, drawRectangle(false, obj->_x + obj->_currImagePtr->_x1, obj->_y + obj->_currImagePtr->_y1,
obj->x + obj->currImagePtr->x2, obj->y + obj->currImagePtr->y2, _TLIGHTGREEN); obj->_x + obj->_currImagePtr->_x2, obj->_y + obj->_currImagePtr->_y2, _TLIGHTGREEN);
else if ((obj->currImagePtr == 0) && (obj->vxPath != 0) && !obj->carriedFl) 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); drawRectangle(false, obj->_oldx, obj->_oldy, obj->_oldx + obj->_vxPath, obj->_oldy + obj->_vyPath, _TBRIGHTWHITE);
} }
} }
g_system->copyRectToScreen(_frontBuffer, 320, 0, 0, 320, 200); 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; 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. if (_vm->_object->getBaseBoundary(index)) // If any overlay base byte is non-zero then the object is foreground, else back.
return kOvlForeground; return kOvlForeground;
index += kCompLineSize; 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) { overlayState_t Screen_v1w::findOvl(seq_t *seq_p, image_pt dst_p, uint16 y) {
debugC(4, kDebugDisplay, "findOvl()"); 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 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 if (ovb & (0x80 >> ((uint16)(dst_p - _frontBuffer) & 7))) // Overlay bit is set
return kOvlForeground; // Found a bit - must be foreground return kOvlForeground; // Found a bit - must be foreground

View file

@ -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 // Find size of image data in 8-bit DIB format
// Note save of x2 - marks end of valid data before garbage // Note save of x2 - marks end of valid data before garbage
uint16 bytesPerLine4 = PCC_header.bytesPerLine * 4; // 4-bit bpl uint16 bytesPerLine4 = PCC_header.bytesPerLine * 4; // 4-bit bpl
seqPtr->bytesPerLine8 = bytesPerLine4 * 2; // 8-bit bpl seqPtr->_bytesPerLine8 = bytesPerLine4 * 2; // 8-bit bpl
seqPtr->lines = PCC_header.y2 - PCC_header.y1 + 1; seqPtr->_lines = PCC_header.y2 - PCC_header.y1 + 1;
seqPtr->x2 = PCC_header.x2 - PCC_header.x1 + 1; seqPtr->_x2 = PCC_header.x2 - PCC_header.x1 + 1;
// Size of the image // Size of the image
uint16 size = seqPtr->lines * seqPtr->bytesPerLine8; uint16 size = seqPtr->_lines * seqPtr->_bytesPerLine8;
// Allocate memory for image data if NULL // Allocate memory for image data if NULL
if (imagePtr == 0) if (imagePtr == 0)
@ -155,13 +155,13 @@ seq_t *FileManager::readPCX(Common::ReadStream &f, seq_t *seqPtr, byte *imagePtr
assert(imagePtr); assert(imagePtr);
seqPtr->imagePtr = imagePtr; seqPtr->_imagePtr = imagePtr;
// Process the image data, converting to 8-bit DIB format // Process the image data, converting to 8-bit DIB format
uint16 y = 0; // Current line index uint16 y = 0; // Current line index
byte pline[kXPix]; // Hold 4 planes of data byte pline[kXPix]; // Hold 4 planes of data
byte *p = pline; // Ptr to above byte *p = pline; // Ptr to above
while (y < seqPtr->lines) { while (y < seqPtr->_lines) {
byte c = f.readByte(); byte c = f.readByte();
if ((c & kRepeatMask) == kRepeatMask) { if ((c & kRepeatMask) == kRepeatMask) {
byte d = f.readByte(); // Read data byte byte d = f.readByte(); // Read data byte
@ -193,7 +193,7 @@ void FileManager::readImage(const int objNum, object_t *objPtr) {
uint32 objLength; uint32 objLength;
}; };
if (!objPtr->seqNumb) // This object has no images if (!objPtr->_seqNumb) // This object has no images
return; return;
if (_vm->isPacked()) { if (_vm->isPacked()) {
@ -206,9 +206,9 @@ void FileManager::readImage(const int objNum, object_t *objPtr) {
_objectsArchive.seek(objBlock.objOffset, SEEK_SET); _objectsArchive.seek(objBlock.objOffset, SEEK_SET);
} else { } else {
Common::String buf; 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)) { 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)) if (!_objectsArchive.open(buf))
error("File not found: %s", buf.c_str()); 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 seq_t *seqPtr = 0; // Ptr to sequence structure
// Now read the images into an images list // Now read the images into an images list
for (int j = 0; j < objPtr->seqNumb; j++) { // for each sequence 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 k = 0; k < objPtr->_seqList[j]._imageNbr; k++) { // each image
if (k == 0) { // First image if (k == 0) { // First image
// Read this image - allocate both seq and image memory // Read this image - allocate both seq and image memory
seqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->nounIndex, 0)); seqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->_nounIndex, 0));
objPtr->seqList[j].seqPtr = seqPtr; objPtr->_seqList[j]._seqPtr = seqPtr;
firstImgFl = false; firstImgFl = false;
} else { // Subsequent image } else { // Subsequent image
// Read this image - allocate both seq and image memory // Read this image - allocate both seq and image memory
seqPtr->nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->nounIndex, 0)); seqPtr->_nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->_nounIndex, 0));
seqPtr = seqPtr->nextSeqPtr; seqPtr = seqPtr->_nextSeqPtr;
} }
// Compute the bounding box - x1, x2, y1, y2 // Compute the bounding box - x1, x2, y1, y2
// Note use of x2 - marks end of valid data in row // Note use of x2 - marks end of valid data in row
uint16 x2 = seqPtr->x2; uint16 x2 = seqPtr->_x2;
seqPtr->x1 = seqPtr->x2; seqPtr->_x1 = seqPtr->_x2;
seqPtr->x2 = 0; seqPtr->_x2 = 0;
seqPtr->y1 = seqPtr->lines; seqPtr->_y1 = seqPtr->_lines;
seqPtr->y2 = 0; seqPtr->_y2 = 0;
image_pt dibPtr = seqPtr->imagePtr; image_pt dibPtr = seqPtr->_imagePtr;
for (int y = 0; y < seqPtr->lines; y++, dibPtr += seqPtr->bytesPerLine8 - x2) { for (int y = 0; y < seqPtr->_lines; y++, dibPtr += seqPtr->_bytesPerLine8 - x2) {
for (int x = 0; x < x2; x++) { for (int x = 0; x < x2; x++) {
if (*dibPtr++) { // Some data found if (*dibPtr++) { // Some data found
if (x < seqPtr->x1) if (x < seqPtr->_x1)
seqPtr->x1 = x; seqPtr->_x1 = x;
if (x > seqPtr->x2) if (x > seqPtr->_x2)
seqPtr->x2 = x; seqPtr->_x2 = x;
if (y < seqPtr->y1) if (y < seqPtr->_y1)
seqPtr->y1 = y; seqPtr->_y1 = y;
if (y > seqPtr->y2) if (y > seqPtr->_y2)
seqPtr->y2 = y; seqPtr->_y2 = y;
} }
} }
} }
} }
assert(seqPtr); 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 // Set the current image sequence to first or last
switch (objPtr->cycling) { switch (objPtr->_cycling) {
case kCycleInvisible: // (May become visible later) case kCycleInvisible: // (May become visible later)
case kCycleAlmostInvisible: case kCycleAlmostInvisible:
case kCycleNotCycling: case kCycleNotCycling:
case kCycleForward: case kCycleForward:
objPtr->currImagePtr = objPtr->seqList[0].seqPtr; objPtr->_currImagePtr = objPtr->_seqList[0]._seqPtr;
break; break;
case kCycleBackward: case kCycleBackward:
objPtr->currImagePtr = seqPtr; objPtr->_currImagePtr = seqPtr;
break; break;
default: default:
warning("Unexpected cycling: %d", objPtr->cycling); warning("Unexpected cycling: %d", objPtr->_cycling);
} }
if (!_vm->isPacked()) if (!_vm->isPacked())
@ -298,25 +298,25 @@ sound_pt FileManager::getSound(const int16 sound, uint16 *size) {
if (!has_read_header) { if (!has_read_header) {
for (int i = 0; i < kMaxSounds; i++) { for (int i = 0; i < kMaxSounds; i++) {
s_hdr[i].size = fp.readUint16LE(); s_hdr[i]._size = fp.readUint16LE();
s_hdr[i].offset = fp.readUint32LE(); s_hdr[i]._offset = fp.readUint32LE();
} }
if (fp.err()) if (fp.err())
error("Wrong sound file format"); error("Wrong sound file format");
has_read_header = true; has_read_header = true;
} }
*size = s_hdr[sound].size; *size = s_hdr[sound]._size;
if (*size == 0) if (*size == 0)
error("Wrong sound file format or missing sound %d", sound); error("Wrong sound file format or missing sound %d", sound);
// Allocate memory for sound or music, if possible // 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); assert(soundPtr);
// Seek to data and read it // Seek to data and read it
fp.seek(s_hdr[sound].offset, SEEK_SET); fp.seek(s_hdr[sound]._offset, SEEK_SET);
if (fp.read(soundPtr, s_hdr[sound].size) != s_hdr[sound].size) if (fp.read(soundPtr, s_hdr[sound]._size) != s_hdr[sound]._size)
error("Wrong sound file format"); error("Wrong sound file format");
fp.close(); fp.close();
@ -391,13 +391,13 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) {
out->writeSint16BE(_vm->getScore()); out->writeSint16BE(_vm->getScore());
// Save story mode // Save story mode
out->writeByte((gameStatus.storyModeFl) ? 1 : 0); out->writeByte((gameStatus._storyModeFl) ? 1 : 0);
// Save jumpexit mode // Save jumpexit mode
out->writeByte((_vm->_mouse->getJumpExitFl()) ? 1 : 0); out->writeByte((_vm->_mouse->getJumpExitFl()) ? 1 : 0);
// Save gameover status // Save gameover status
out->writeByte((gameStatus.gameOverFl) ? 1 : 0); out->writeByte((gameStatus._gameOverFl) ? 1 : 0);
// Save screen states // Save screen states
for (int i = 0; i < _vm->_numStates; i++) 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); _vm->_screen->savePal(out);
// Save maze status // Save maze status
out->writeByte((_vm->_maze.enabledFl) ? 1 : 0); out->writeByte((_vm->_maze._enabledFl) ? 1 : 0);
out->writeByte(_vm->_maze.size); out->writeByte(_vm->_maze._size);
out->writeSint16BE(_vm->_maze.x1); out->writeSint16BE(_vm->_maze._x1);
out->writeSint16BE(_vm->_maze.y1); out->writeSint16BE(_vm->_maze._y1);
out->writeSint16BE(_vm->_maze.x2); out->writeSint16BE(_vm->_maze._x2);
out->writeSint16BE(_vm->_maze.y2); out->writeSint16BE(_vm->_maze._y2);
out->writeSint16BE(_vm->_maze.x3); out->writeSint16BE(_vm->_maze._x3);
out->writeSint16BE(_vm->_maze.x4); out->writeSint16BE(_vm->_maze._x4);
out->writeByte(_vm->_maze.firstScreenIndex); out->writeByte(_vm->_maze._firstScreenIndex);
out->writeByte((byte)_vm->getGameStatus().viewState); out->writeByte((byte)_vm->getGameStatus()._viewState);
out->finalize(); out->finalize();
@ -491,9 +491,9 @@ bool FileManager::restoreGame(const int16 slot) {
int score = in->readSint16BE(); int score = in->readSint16BE();
_vm->setScore(score); _vm->setScore(score);
gameStatus.storyModeFl = (in->readByte() == 1); gameStatus._storyModeFl = (in->readByte() == 1);
_vm->_mouse->setJumpExitFl(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++) for (int i = 0; i < _vm->_numStates; i++)
_vm->_screenStates[i] = in->readByte(); _vm->_screenStates[i] = in->readByte();
@ -503,18 +503,18 @@ bool FileManager::restoreGame(const int16 slot) {
_vm->_screen->restorePal(in); _vm->_screen->restorePal(in);
// Restore maze status // Restore maze status
_vm->_maze.enabledFl = (in->readByte() == 1); _vm->_maze._enabledFl = (in->readByte() == 1);
_vm->_maze.size = in->readByte(); _vm->_maze._size = in->readByte();
_vm->_maze.x1 = in->readSint16BE(); _vm->_maze._x1 = in->readSint16BE();
_vm->_maze.y1 = in->readSint16BE(); _vm->_maze._y1 = in->readSint16BE();
_vm->_maze.x2 = in->readSint16BE(); _vm->_maze._x2 = in->readSint16BE();
_vm->_maze.y2 = in->readSint16BE(); _vm->_maze._y2 = in->readSint16BE();
_vm->_maze.x3 = in->readSint16BE(); _vm->_maze._x3 = in->readSint16BE();
_vm->_maze.x4 = in->readSint16BE(); _vm->_maze._x4 = in->readSint16BE();
_vm->_maze.firstScreenIndex = in->readByte(); _vm->_maze._firstScreenIndex = in->readByte();
_vm->_scheduler->restoreScreen(*_vm->_screen_p); _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(); _vm->_screen->hideCursor();
@ -536,25 +536,25 @@ void FileManager::printBootText() {
return; return;
} else { } else {
Utils::notifyBox(Common::String::format("Missing startup file '%s'", getBootFilename())); Utils::notifyBox(Common::String::format("Missing startup file '%s'", getBootFilename()));
_vm->getGameStatus().doQuitFl = true; _vm->getGameStatus()._doQuitFl = true;
return; return;
} }
} }
// Allocate space for the text and print it // 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) { if (buf) {
// Skip over the boot structure (already read) and read exit text // Skip over the boot structure (already read) and read exit text
ofp.seek((long)sizeof(_vm->_boot), SEEK_SET); 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())); Utils::notifyBox(Common::String::format("Error while reading startup file '%s'", getBootFilename()));
_vm->getGameStatus().doQuitFl = true; _vm->getGameStatus()._doQuitFl = true;
return; return;
} }
// Decrypt the exit text, using CRYPT substring // Decrypt the exit text, using CRYPT substring
int i; 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] ^= s_bootCypher[i % s_bootCypherLen];
buf[i] = '\0'; buf[i] = '\0';
@ -577,32 +577,32 @@ void FileManager::readBootFile() {
if (_vm->_gameVariant == kGameVariantH1Dos) { if (_vm->_gameVariant == kGameVariantH1Dos) {
//TODO initialize properly _boot structure //TODO initialize properly _boot structure
warning("readBootFile - Skipping as H1 Dos may be a freeware"); warning("readBootFile - Skipping as H1 Dos may be a freeware");
memset(_vm->_boot.distrib, '\0', sizeof(_vm->_boot.distrib)); memset(_vm->_boot._distrib, '\0', sizeof(_vm->_boot._distrib));
_vm->_boot.registered = kRegFreeware; _vm->_boot._registered = kRegFreeware;
return; return;
} else if (_vm->getPlatform() == Common::kPlatformPC) { } else if (_vm->getPlatform() == Common::kPlatformPC) {
warning("readBootFile - Skipping as H2 and H3 Dos may be shareware"); warning("readBootFile - Skipping as H2 and H3 Dos may be shareware");
memset(_vm->_boot.distrib, '\0', sizeof(_vm->_boot.distrib)); memset(_vm->_boot._distrib, '\0', sizeof(_vm->_boot._distrib));
_vm->_boot.registered = kRegShareware; _vm->_boot._registered = kRegShareware;
return; return;
} else { } else {
Utils::notifyBox(Common::String::format("Missing startup file '%s'", getBootFilename())); Utils::notifyBox(Common::String::format("Missing startup file '%s'", getBootFilename()));
_vm->getGameStatus().doQuitFl = true; _vm->getGameStatus()._doQuitFl = true;
return; return;
} }
} }
if (ofp.size() < (int32)sizeof(_vm->_boot)) { if (ofp.size() < (int32)sizeof(_vm->_boot)) {
Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename())); Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename()));
_vm->getGameStatus().doQuitFl = true; _vm->getGameStatus()._doQuitFl = true;
return; return;
} }
_vm->_boot.checksum = ofp.readByte(); _vm->_boot._checksum = ofp.readByte();
_vm->_boot.registered = ofp.readByte(); _vm->_boot._registered = ofp.readByte();
ofp.read(_vm->_boot.pbswitch, sizeof(_vm->_boot.pbswitch)); ofp.read(_vm->_boot._pbswitch, sizeof(_vm->_boot._pbswitch));
ofp.read(_vm->_boot.distrib, sizeof(_vm->_boot.distrib)); ofp.read(_vm->_boot._distrib, sizeof(_vm->_boot._distrib));
_vm->_boot.exit_len = ofp.readUint16LE(); _vm->_boot._exitLen = ofp.readUint16LE();
byte *p = (byte *)&_vm->_boot; byte *p = (byte *)&_vm->_boot;
@ -615,7 +615,7 @@ void FileManager::readBootFile() {
if (checksum) { if (checksum) {
Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename())); Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename()));
_vm->getGameStatus().doQuitFl = true; _vm->getGameStatus()._doQuitFl = true;
} }
} }

View file

@ -84,11 +84,11 @@ enum path_t {
}; };
struct hugo_boot_t { // Common HUGO boot file struct hugo_boot_t { // Common HUGO boot file
char checksum; // Checksum for boot structure (not exit text) char _checksum; // Checksum for boot structure (not exit text)
char registered; // TRUE if registered version, else FALSE char _registered; // TRUE if registered version, else FALSE
char pbswitch[8]; // Playback switch string char _pbswitch[8]; // Playback switch string
char distrib[32]; // Distributor branding string char _distrib[32]; // Distributor branding string
uint16 exit_len; // Length of exit text (next in file) uint16 _exitLen; // Length of exit text (next in file)
} PACKED_STRUCT; } PACKED_STRUCT;
/** /**
@ -101,11 +101,11 @@ typedef byte *sound_pt; // ptr to sound (or music) d
* Structure for initializing maze processing * Structure for initializing maze processing
*/ */
struct maze_t { struct maze_t {
bool enabledFl; // TRUE when maze processing enabled bool _enabledFl; // TRUE when maze processing enabled
byte size; // Size of (square) maze matrix byte _size; // Size of (square) maze matrix
int x1, y1, x2, y2; // maze hotspot bounding box int _x1, _y1, _x2, _y2; // maze hotspot bounding box
int x3, x4; // north, south x entry coordinates int _x3, _x4; // north, south x entry coordinates
byte firstScreenIndex; // index of first screen in maze 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 * The image data is in 8-bit DIB format, i.e. 1 byte = 1 pixel
*/ */
struct seq_t { // Linked list of images struct seq_t { // Linked list of images
byte *imagePtr; // ptr to image byte *_imagePtr; // ptr to image
uint16 bytesPerLine8; // bytes per line (8bits) uint16 _bytesPerLine8; // bytes per line (8bits)
uint16 lines; // lines uint16 _lines; // lines
uint16 x1, x2, y1, y2; // Offsets from x,y: data bounding box uint16 _x1, _x2, _y1, _y2; // Offsets from x,y: data bounding box
seq_t *nextSeqPtr; // ptr to next record seq_t *_nextSeqPtr; // ptr to next record
}; };
/** /**
* The following is an array of structures of above sequences * The following is an array of structures of above sequences
*/ */
struct seqList_t { struct seqList_t {
uint16 imageNbr; // Number of images in sequence uint16 _imageNbr; // Number of images in sequence
seq_t *seqPtr; // Ptr to sequence structure seq_t *_seqPtr; // Ptr to sequence structure
}; };
#include "common/pack-start.h" // START STRUCT PACKING #include "common/pack-start.h" // START STRUCT PACKING
struct sound_hdr_t { // Sound file lookup entry struct sound_hdr_t { // Sound file lookup entry
uint16 size; // Size of sound data in bytes uint16 _size; // Size of sound data in bytes
uint32 offset; // Offset of sound data in file uint32 _offset; // Offset of sound data in file
} PACKED_STRUCT; } PACKED_STRUCT;
#include "common/pack-end.h" // END STRUCT PACKING #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 * Following is definition of object attributes
*/ */
struct object_t { struct object_t {
uint16 nounIndex; // String identifying object uint16 _nounIndex; // String identifying object
uint16 dataIndex; // String describing the object uint16 _dataIndex; // String describing the object
uint16 *stateDataIndex; // Added by Strangerke to handle the LOOK_S state-dependant descriptions uint16 *_stateDataIndex; // Added by Strangerke to handle the LOOK_S state-dependant descriptions
path_t pathType; // Describe path object follows path_t _pathType; // Describe path object follows
int vxPath, vyPath; // Delta velocities (e.g. for CHASE) int _vxPath, _vyPath; // Delta velocities (e.g. for CHASE)
uint16 actIndex; // Action list to do on collision with hero uint16 _actIndex; // Action list to do on collision with hero
byte seqNumb; // Number of sequences in list byte _seqNumb; // Number of sequences in list
seq_t *currImagePtr; // Sequence image currently in use seq_t *_currImagePtr; // Sequence image currently in use
seqList_t seqList[kMaxSeqNumb]; // Array of sequence structure ptrs and lengths seqList_t _seqList[kMaxSeqNumb]; // Array of sequence structure ptrs and lengths
cycle_t cycling; // Whether cycling, forward or backward cycle_t _cycling; // Whether cycling, forward or backward
byte cycleNumb; // No. of times to cycle byte _cycleNumb; // No. of times to cycle
byte frameInterval; // Interval (in ticks) between frames byte _frameInterval; // Interval (in ticks) between frames
byte frameTimer; // Decrementing timer for above byte _frameTimer; // Decrementing timer for above
int8 radius; // Defines sphere of influence by hero int8 _radius; // Defines sphere of influence by hero
byte screenIndex; // Screen in which object resides byte _screenIndex; // Screen in which object resides
int x, y; // Current coordinates of object int _x, _y; // Current coordinates of object
int oldx, oldy; // Previous coordinates of object int _oldx, _oldy; // Previous coordinates of object
int8 vx, vy; // Velocity int8 _vx, _vy; // Velocity
byte objValue; // Value of object byte _objValue; // Value of object
int genericCmd; // Bit mask of 'generic' commands for object int _genericCmd; // Bit mask of 'generic' commands for object
uint16 cmdIndex; // ptr to list of cmd structures for verbs uint16 _cmdIndex; // ptr to list of cmd structures for verbs
bool carriedFl; // TRUE if object being carried bool _carriedFl; // TRUE if object being carried
byte state; // state referenced in cmd list byte _state; // state referenced in cmd list
bool verbOnlyFl; // TRUE if verb-only cmds allowed e.g. sit,look bool _verbOnlyFl; // TRUE if verb-only cmds allowed e.g. sit,look
byte priority; // Whether object fore, background or floating byte _priority; // Whether object fore, background or floating
int16 viewx, viewy; // Position to view object from (or 0 or -1) int16 _viewx, _viewy; // Position to view object from (or 0 or -1)
int16 direction; // Direction to view object from int16 _direction; // Direction to view object from
byte curSeqNum; // Save which seq number currently in use byte _curSeqNum; // Save which seq number currently in use
byte curImageNum; // Save which image of sequence currently in use byte _curImageNum; // Save which image of sequence currently in use
int8 oldvx; // Previous vx (used in wandering) int8 _oldvx; // Previous vx (used in wandering)
int8 oldvy; // Previous vy int8 _oldvy; // Previous vy
}; };
} // End of namespace Hugo } // End of namespace Hugo

View file

@ -249,24 +249,24 @@ Common::Error HugoEngine::run() {
initStatus(); // Initialize game status initStatus(); // Initialize game status
initConfig(); // Initialize user's config initConfig(); // Initialize user's config
if (!_status.doQuitFl) { if (!_status._doQuitFl) {
initialize(); initialize();
resetConfig(); // Reset user's config resetConfig(); // Reset user's config
initMachine(); initMachine();
// Start the state machine // Start the state machine
_status.viewState = kViewIntroInit; _status._viewState = kViewIntroInit;
int16 loadSlot = Common::ConfigManager::instance().getInt("save_slot"); int16 loadSlot = Common::ConfigManager::instance().getInt("save_slot");
if (loadSlot >= 0) { if (loadSlot >= 0) {
_status.skipIntroFl = true; _status._skipIntroFl = true;
_file->restoreGame(loadSlot); _file->restoreGame(loadSlot);
} else { } else {
_file->saveGame(0, "New Game"); _file->saveGame(0, "New Game");
} }
} }
while (!_status.doQuitFl) { while (!_status._doQuitFl) {
_screen->drawBoundaries(); _screen->drawBoundaries();
g_system->updateScreen(); g_system->updateScreen();
runMachine(); runMachine();
@ -289,20 +289,20 @@ Common::Error HugoEngine::run() {
_mouse->setRightButton(); _mouse->setRightButton();
break; break;
case Common::EVENT_QUIT: case Common::EVENT_QUIT:
_status.doQuitFl = true; _status._doQuitFl = true;
break; break;
default: default:
break; break;
} }
} }
if (_status.helpFl) { if (_status._helpFl) {
_status.helpFl = false; _status._helpFl = false;
_file->instructions(); _file->instructions();
} }
_mouse->mouseHandler(); // Mouse activity - adds to display list _mouse->mouseHandler(); // Mouse activity - adds to display list
_screen->displayList(kDisplayDisplay); // Blit the display list to screen _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; return Common::kNoError;
} }
@ -326,7 +326,7 @@ void HugoEngine::runMachine() {
status_t &gameStatus = getGameStatus(); status_t &gameStatus = getGameStatus();
// Don't process if gameover // Don't process if gameover
if (gameStatus.gameOverFl) if (gameStatus._gameOverFl)
return; return;
_curTime = g_system->getMillis(); _curTime = g_system->getMillis();
@ -338,19 +338,19 @@ void HugoEngine::runMachine() {
_lastTime = _curTime; _lastTime = _curTime;
switch (gameStatus.viewState) { switch (gameStatus._viewState) {
case kViewIdle: // Not processing state machine case kViewIdle: // Not processing state machine
_screen->hideCursor(); _screen->hideCursor();
_intro->preNewGame(); // Any processing before New Game selected _intro->preNewGame(); // Any processing before New Game selected
break; break;
case kViewIntroInit: // Initialization before intro begins case kViewIntroInit: // Initialization before intro begins
_intro->introInit(); _intro->introInit();
gameStatus.viewState = kViewIntro; gameStatus._viewState = kViewIntro;
break; break;
case kViewIntro: // Do any game-dependant preamble case kViewIntro: // Do any game-dependant preamble
if (_intro->introPlay()) { // Process intro screen if (_intro->introPlay()) { // Process intro screen
_scheduler->newScreen(0); // Initialize first screen _scheduler->newScreen(0); // Initialize first screen
gameStatus.viewState = kViewPlay; gameStatus._viewState = kViewPlay;
} }
break; break;
case kViewPlay: // Playing game case kViewPlay: // Playing game
@ -368,8 +368,8 @@ void HugoEngine::runMachine() {
_inventory->runInventory(); // Process Inventory state machine _inventory->runInventory(); // Process Inventory state machine
break; break;
case kViewExit: // Game over or user exited case kViewExit: // Game over or user exited
gameStatus.viewState = kViewIdle; gameStatus._viewState = kViewIdle;
_status.doQuitFl = true; _status._doQuitFl = true;
break; break;
} }
} }
@ -427,7 +427,7 @@ bool HugoEngine::loadHugoDat() {
_scheduler->loadActListArr(in); _scheduler->loadActListArr(in);
_scheduler->loadAlNewscrIndex(in); _scheduler->loadAlNewscrIndex(in);
_hero = &_object->_objects[kHeroIndex]; // This always points to hero _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 _heroImage = kHeroIndex; // Current in use hero image
for (int varnt = 0; varnt < _numVariant; varnt++) { for (int varnt = 0; varnt < _numVariant; varnt++) {
@ -527,33 +527,33 @@ void HugoEngine::initPlaylist(bool playlist[kMaxTunes]) {
*/ */
void HugoEngine::initStatus() { void HugoEngine::initStatus() {
debugC(1, kDebugEngine, "initStatus"); debugC(1, kDebugEngine, "initStatus");
_status.storyModeFl = false; // Not in story mode _status._storyModeFl = false; // Not in story mode
_status.gameOverFl = false; // Hero not knobbled yet _status._gameOverFl = false; // Hero not knobbled yet
_status.lookFl = false; // Toolbar "look" button _status._lookFl = false; // Toolbar "look" button
_status.recallFl = false; // Toolbar "recall" button _status._recallFl = false; // Toolbar "recall" button
_status.newScreenFl = false; // Screen not just loaded _status._newScreenFl = false; // Screen not just loaded
_status.godModeFl = false; // No special cheats allowed _status._godModeFl = false; // No special cheats allowed
_status.showBoundariesFl = false; // Boundaries hidden by default _status._showBoundariesFl = false; // Boundaries hidden by default
_status.doQuitFl = false; _status._doQuitFl = false;
_status.skipIntroFl = false; _status._skipIntroFl = false;
_status.helpFl = false; _status._helpFl = false;
// Initialize every start of new game // Initialize every start of new game
_status.tick = 0; // Tick count _status._tick = 0; // Tick count
_status.viewState = kViewIdle; // View state _status._viewState = kViewIdle; // View state
// Strangerke - Suppress as related to playback // Strangerke - Suppress as related to playback
// _status.recordFl = false; // Not record mode // _status._recordFl = false; // Not record mode
// _status.playbackFl = false; // Not playback mode // _status._playbackFl = false; // Not playback mode
// Strangerke - Not used ? // Strangerke - Not used ?
// _status.mmtime = false; // Multimedia timer support // _status._mmtime = false; // Multimedia timer support
// _status.helpFl = false; // Not calling WinHelp() // _status._helpFl = false; // Not calling WinHelp()
// _status.demoFl = false; // Not demo mode // _status._demoFl = false; // Not demo mode
// _status.path[0] = 0; // Path to write files // _status._path[0] = 0; // Path to write files
// _status.screenWidth = 0; // Desktop screen width // _status._screenWidth = 0; // Desktop screen width
// _status.saveTick = 0; // Time of last save // _status._saveTick = 0; // Time of last save
// _status.saveSlot = 0; // Slot to save/restore game // _status._saveSlot = 0; // Slot to save/restore game
// _status.textBoxFl = false; // Not processing a text box // _status._textBoxFl = false; // Not processing a text box
} }
/** /**
@ -587,7 +587,7 @@ void HugoEngine::resetConfig() {
void HugoEngine::initialize() { void HugoEngine::initialize() {
debugC(1, kDebugEngine, "initialize"); debugC(1, kDebugEngine, "initialize");
_maze.enabledFl = false; _maze._enabledFl = false;
_line[0] = '\0'; _line[0] = '\0';
_sound->initSound(); _sound->initSound();
@ -679,10 +679,10 @@ void HugoEngine::calcMaxScore() {
void HugoEngine::endGame() { void HugoEngine::endGame() {
debugC(1, kDebugEngine, "endGame"); debugC(1, kDebugEngine, "endGame");
if (_boot.registered != kRegRegistered) if (_boot._registered != kRegRegistered)
Utils::notifyBox(_text->getTextEngine(kEsAdvertise)); Utils::notifyBox(_text->getTextEngine(kEsAdvertise));
Utils::notifyBox(Common::String::format("%s\n%s", _episode, getCopyrightString())); Utils::notifyBox(Common::String::format("%s\n%s", _episode, getCopyrightString()));
_status.viewState = kViewExit; _status._viewState = kViewExit;
} }
bool HugoEngine::canLoadGameStateCurrently() { bool HugoEngine::canLoadGameStateCurrently() {
@ -690,7 +690,7 @@ bool HugoEngine::canLoadGameStateCurrently() {
} }
bool HugoEngine::canSaveGameStateCurrently() { bool HugoEngine::canSaveGameStateCurrently() {
return (_status.viewState == kViewPlay); return (_status._viewState == kViewPlay);
} }
int8 HugoEngine::getTPS() const { int8 HugoEngine::getTPS() const {

View file

@ -171,20 +171,20 @@ enum seqTextEngine {
struct HugoGameDescription; struct HugoGameDescription;
struct status_t { // Game status (not saved) struct status_t { // Game status (not saved)
bool storyModeFl; // Game is telling story - no commands bool _storyModeFl; // Game is telling story - no commands
bool gameOverFl; // Game is over - hero knobbled bool _gameOverFl; // Game is over - hero knobbled
bool lookFl; // Toolbar "look" button pressed bool _lookFl; // Toolbar "look" button pressed
bool recallFl; // Toolbar "recall" button pressed bool _recallFl; // Toolbar "recall" button pressed
bool newScreenFl; // New screen just loaded in dib_a bool _newScreenFl; // New screen just loaded in dib_a
bool godModeFl; // Allow DEBUG features in live version bool _godModeFl; // Allow DEBUG features in live version
bool showBoundariesFl; // Flag used to show and hide boundaries, bool _showBoundariesFl; // Flag used to show and hide boundaries,
// used by the console // used by the console
bool doQuitFl; bool _doQuitFl;
bool skipIntroFl; bool _skipIntroFl;
bool helpFl; bool _helpFl;
uint32 tick; // Current time in ticks uint32 _tick; // Current time in ticks
vstate_t viewState; // View state machine vstate_t _viewState; // View state machine
int16 song; // Current song int16 _song; // Current song
// Strangerke - Suppress as related to playback // Strangerke - Suppress as related to playback
// bool playbackFl; // Game is in playback mode // bool playbackFl; // Game is in playback mode

View file

@ -98,7 +98,7 @@ void intro_v1d::introInit() {
bool intro_v1d::introPlay() { bool intro_v1d::introPlay() {
byte introSize = getIntroSize(); byte introSize = getIntroSize();
if (_vm->getGameStatus().skipIntroFl) if (_vm->getGameStatus()._skipIntroFl)
return true; return true;
if (introTicks < introSize) { if (introTicks < introSize) {
@ -117,20 +117,20 @@ bool intro_v1d::introPlay() {
error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 8"); error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 8");
char buffer[80]; char buffer[80];
if (_vm->_boot.registered == kRegRegistered) if (_vm->_boot._registered == kRegRegistered)
strcpy(buffer, "Registered Version"); strcpy(buffer, "Registered Version");
else if (_vm->_boot.registered == kRegShareware) else if (_vm->_boot._registered == kRegShareware)
strcpy(buffer, "Shareware Version"); strcpy(buffer, "Shareware Version");
else if (_vm->_boot.registered == kRegFreeware) else if (_vm->_boot._registered == kRegFreeware)
strcpy(buffer, "Freeware Version"); strcpy(buffer, "Freeware Version");
else 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, buffer, 0, 163, 320, _TLIGHTMAGENTA, Graphics::kTextAlignCenter);
font.drawString(&surf, _vm->getCopyrightString(), 0, 176, 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"))) { if ((*_vm->_boot._distrib != '\0') && (scumm_stricmp(_vm->_boot._distrib, "David P. Gray"))) {
sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); sprintf(buffer, "Distributed by %s.", _vm->_boot._distrib);
font.drawString(&surf, buffer, 0, 75, 320, _TMAGENTA, Graphics::kTextAlignCenter); 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))) if (!font.loadFromFON("TMSRB.FON", Graphics::WinFontDirEntry("Tms Rmn", 8)))
error("Unable to load font TMSRB.FON, face 'Tms Rmn', size 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()); sprintf(buffer, "%s Registered Version", _vm->getCopyrightString());
else else
sprintf(buffer, "%s Shareware Version", _vm->getCopyrightString()); sprintf(buffer, "%s Shareware Version", _vm->getCopyrightString());
font.drawString(&surf, buffer, 0, 186, 320, _TLIGHTRED, Graphics::kTextAlignCenter); 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 // 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); font.drawString(&surf, buffer, 0, 1, 320, _TLIGHTRED, Graphics::kTextAlignCenter);
} }
@ -294,7 +294,7 @@ void intro_v3d::introInit() {
surf.format = Graphics::PixelFormat::createFormatCLUT8(); surf.format = Graphics::PixelFormat::createFormatCLUT8();
char buffer[128]; char buffer[128];
if (_vm->_boot.registered) if (_vm->_boot._registered)
sprintf(buffer, "%s Registered Version", _vm->getCopyrightString()); sprintf(buffer, "%s Registered Version", _vm->getCopyrightString());
else else
sprintf(buffer,"%s Shareware Version", _vm->getCopyrightString()); 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); font.drawString(&surf, buffer, 0, 190, 320, _TBROWN, 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"))) {
sprintf(buffer, "Distributed by %s.", _vm->_boot.distrib); sprintf(buffer, "Distributed by %s.", _vm->_boot._distrib);
font.drawString(&surf, buffer, 0, 0, 320, _TBROWN, Graphics::kTextAlignCenter); 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 * Called every tick. Returns TRUE when complete
*/ */
bool intro_v3d::introPlay() { bool intro_v3d::introPlay() {
if (_vm->getGameStatus().skipIntroFl) if (_vm->getGameStatus()._skipIntroFl)
return true; return true;
if (introTicks < getIntroSize()) { if (introTicks < getIntroSize()) {
@ -356,7 +356,7 @@ intro_v1w::~intro_v1w() {
} }
void intro_v1w::preNewGame() { void intro_v1w::preNewGame() {
_vm->getGameStatus().viewState = kViewIntroInit; _vm->getGameStatus()._viewState = kViewIntroInit;
} }
void intro_v1w::introInit() { void intro_v1w::introInit() {
@ -416,7 +416,7 @@ void intro_v3w::introInit() {
* Called every tick. Returns TRUE when complete * Called every tick. Returns TRUE when complete
*/ */
bool intro_v3w::introPlay() { bool intro_v3w::introPlay() {
if (_vm->getGameStatus().skipIntroFl) if (_vm->getGameStatus()._skipIntroFl)
return true; return true;
if (introTicks < getIntroSize()) { if (introTicks < getIntroSize()) {

View file

@ -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->_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 _vm->_object->updateImages(); // Add objects back into display list for restore
_inventoryState = kInventoryOff; _inventoryState = kInventoryOff;
gameStatus.viewState = kViewPlay; gameStatus._viewState = kViewPlay;
} }
break; break;
case kInventoryDown: // Icon bar moving down case kInventoryDown: // Icon bar moving down

View file

@ -154,7 +154,7 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in
status_t &gameStatus = _vm->getGameStatus(); 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; return;
int16 inventObjId = _vm->_inventory->getInventoryObjId(); 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 } else { // Clicked over viewport object
object_t *obj = &_vm->_object->_objects[objId]; object_t *obj = &_vm->_object->_objects[objId];
int16 x, y; int16 x, y;
switch (obj->viewx) { // Where to walk to switch (obj->_viewx) { // Where to walk to
case -1: // Walk to object position case -1: // Walk to object position
if (_vm->_object->findObjectSpace(obj, &x, &y)) if (_vm->_object->findObjectSpace(obj, &x, &y))
foundFl = _vm->_route->startRoute(kRouteGet, objId, 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 _vm->_object->useObject(objId); // Pick up or use object
break; break;
default: // Walk to view point if possible default: // Walk to view point if possible
if (!_vm->_route->startRoute(kRouteGet, objId, obj->viewx, obj->viewy)) { if (!_vm->_route->startRoute(kRouteGet, objId, obj->_viewx, obj->_viewy)) {
if (_vm->_hero->cycling == kCycleInvisible) // If invisible do if (_vm->_hero->_cycling == kCycleInvisible) // If invisible do
_vm->_object->useObject(objId); // immediate use _vm->_object->useObject(objId); // immediate use
else else
Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there 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(); 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; return;
switch (objId) { switch (objId) {
@ -254,7 +254,7 @@ void MouseHandler::processLeftClick(const int16 objId, const int16 cx, const int
_vm->_object->lookObject(obj); _vm->_object->lookObject(obj);
} else { } else {
bool foundFl = false; // TRUE if route found to object 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 case -1: // Walk to object position
if (_vm->_object->findObjectSpace(obj, &x, &y)) if (_vm->_object->findObjectSpace(obj, &x, &y))
foundFl = _vm->_route->startRoute(kRouteLook, objId, 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); _vm->_object->lookObject(obj);
break; break;
default: // Walk to view point if possible default: // Walk to view point if possible
if (!_vm->_route->startRoute(kRouteLook, objId, obj->viewx, obj->viewy)) { if (!_vm->_route->startRoute(kRouteLook, objId, obj->_viewx, obj->_viewy)) {
if (_vm->_hero->cycling == kCycleInvisible) // If invisible do if (_vm->_hero->_cycling == kCycleInvisible) // If invisible do
_vm->_object->lookObject(obj); // immediate decription _vm->_object->lookObject(obj); // immediate decription
else else
Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there
@ -286,14 +286,14 @@ void MouseHandler::mouseHandler() {
status_t &gameStatus = _vm->getGameStatus(); status_t &gameStatus = _vm->getGameStatus();
istate_t inventState = _vm->_inventory->getInventoryState(); istate_t inventState = _vm->_inventory->getInventoryState();
if ((gameStatus.viewState != kViewPlay) && (inventState != kInventoryActive)) if ((gameStatus._viewState != kViewPlay) && (inventState != kInventoryActive))
return; return;
int16 cx = getMouseX(); int16 cx = getMouseX();
int16 cy = getMouseY(); int16 cy = getMouseY();
// gameStatus.cx = cx; // Save cursor coords // gameStatus._cx = cx; // Save cursor coords
// gameStatus.cy = cy; // gameStatus._cy = cy;
// Don't process if outside client area // Don't process if outside client area
if ((cx < 0) || (cx > kXPix) || (cy < kDibOffY) || (cy > kViewSizeY + kDibOffY)) 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 if (objId == -1) // No match, check rest of view
objId = _vm->_object->findObject(cx, cy); objId = _vm->_object->findObject(cx, cy);
if (objId >= 0) { // Got a match if (objId >= 0) { // Got a match
// Display object name next to cursor (unless CURSOR_NOCHAR) // Display object name next to cursor (unless CURSOR_NOCHAR)
// Note test for swapped hero name // 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) if (name[0] != kCursorNochar)
cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE); cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE);
@ -378,7 +378,7 @@ void MouseHandler::loadHotspots(Common::ReadStream &in) {
void MouseHandler::drawHotspots() const { void MouseHandler::drawHotspots() const {
for (int i = 0; _hotspots[i].screenIndex >= 0; i++) { for (int i = 0; _hotspots[i].screenIndex >= 0; i++) {
hotspot_t *hotspot = &_hotspots[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); _vm->_screen->drawRectangle(false, hotspot->x1, hotspot->y1, hotspot->x2, hotspot->y2, _TLIGHTRED);
} }
} }

View file

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

View file

@ -35,14 +35,14 @@
namespace Hugo { namespace Hugo {
struct target_t { // Secondary target for action struct target_t { // Secondary target for action
uint16 nounIndex; // Secondary object uint16 _nounIndex; // Secondary object
uint16 verbIndex; // Action on secondary object uint16 _verbIndex; // Action on secondary object
}; };
struct uses_t { // Define uses of certain objects struct uses_t { // Define uses of certain objects
int16 objId; // Primary object int16 _objId; // Primary object
uint16 dataIndex; // String if no secondary object matches uint16 _dataIndex; // String if no secondary object matches
target_t *targets; // List of secondary targets target_t *_targets; // List of secondary targets
}; };
class ObjectHandler { class ObjectHandler {

View file

@ -64,7 +64,7 @@ void ObjectHandler_v1d::updateImages() {
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[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; objindex[num_objs++] = i;
} }
@ -75,27 +75,27 @@ void ObjectHandler_v1d::updateImages() {
for (int i = 0; i < num_objs; i++) { for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]]; object_t *obj = &_objects[objindex[i]];
// Count down inter-frame timer // Count down inter-frame timer
if (obj->frameTimer) if (obj->_frameTimer)
obj->frameTimer--; obj->_frameTimer--;
if (obj->cycling > kCycleAlmostInvisible) { // Only if visible if (obj->_cycling > kCycleAlmostInvisible) { // Only if visible
switch (obj->cycling) { switch (obj->_cycling) {
case kCycleNotCycling: case kCycleNotCycling:
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, false); _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, false);
break; break;
case kCycleForward: case kCycleForward:
if (obj->frameTimer) // Not time to see next frame yet if (obj->_frameTimer) // Not time to see next frame yet
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, false); _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, false);
else else
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, false); _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr->_nextSeqPtr, false);
break; break;
case kCycleBackward: { case kCycleBackward: {
seq_t *seqPtr = obj->currImagePtr; seq_t *seqPtr = obj->_currImagePtr;
if (!obj->frameTimer) { // Show next frame if (!obj->_frameTimer) { // Show next frame
while (seqPtr->nextSeqPtr != obj->currImagePtr) while (seqPtr->_nextSeqPtr != obj->_currImagePtr)
seqPtr = seqPtr->nextSeqPtr; seqPtr = seqPtr->_nextSeqPtr;
} }
_vm->_screen->displayFrame(obj->x, obj->y, seqPtr, false); _vm->_screen->displayFrame(obj->_x, obj->_y, seqPtr, false);
break; break;
} }
default: default:
@ -109,28 +109,28 @@ void ObjectHandler_v1d::updateImages() {
// Cycle any animating objects // Cycle any animating objects
for (int i = 0; i < num_objs; i++) { for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]]; object_t *obj = &_objects[objindex[i]];
if (obj->cycling != kCycleInvisible) { if (obj->_cycling != kCycleInvisible) {
// Only if it's visible // Only if it's visible
if (obj->cycling == kCycleAlmostInvisible) if (obj->_cycling == kCycleAlmostInvisible)
obj->cycling = kCycleInvisible; obj->_cycling = kCycleInvisible;
// Now Rotate to next picture in sequence // Now Rotate to next picture in sequence
switch (obj->cycling) { switch (obj->_cycling) {
case kCycleNotCycling: case kCycleNotCycling:
break; break;
case kCycleForward: case kCycleForward:
if (!obj->frameTimer) { if (!obj->_frameTimer) {
// Time to step to next frame // 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 // Find out if this is last frame of sequence
// If so, reset frame_timer and decrement n_cycle // If so, reset frame_timer and decrement n_cycle
if (obj->frameInterval || obj->cycleNumb) { if (obj->_frameInterval || obj->_cycleNumb) {
obj->frameTimer = obj->frameInterval; obj->_frameTimer = obj->_frameInterval;
for (int j = 0; j < obj->seqNumb; j++) { for (int j = 0; j < obj->_seqNumb; j++) {
if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) { if (obj->_currImagePtr->_nextSeqPtr == obj->_seqList[j]._seqPtr) {
if (obj->cycleNumb) { // Decr cycleNumb if Non-continous if (obj->_cycleNumb) { // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb) if (!--obj->_cycleNumb)
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
} }
@ -138,20 +138,20 @@ void ObjectHandler_v1d::updateImages() {
} }
break; break;
case kCycleBackward: { case kCycleBackward: {
if (!obj->frameTimer) { if (!obj->_frameTimer) {
// Time to step to prev frame // Time to step to prev frame
seq_t *seqPtr = obj->currImagePtr; seq_t *seqPtr = obj->_currImagePtr;
while (obj->currImagePtr->nextSeqPtr != seqPtr) while (obj->_currImagePtr->_nextSeqPtr != seqPtr)
obj->currImagePtr = obj->currImagePtr->nextSeqPtr; obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr;
// Find out if this is first frame of sequence // Find out if this is first frame of sequence
// If so, reset frame_timer and decrement n_cycle // If so, reset frame_timer and decrement n_cycle
if (obj->frameInterval || obj->cycleNumb) { if (obj->_frameInterval || obj->_cycleNumb) {
obj->frameTimer = obj->frameInterval; obj->_frameTimer = obj->_frameInterval;
for (int j = 0; j < obj->seqNumb; j++) { for (int j = 0; j < obj->_seqNumb; j++) {
if (obj->currImagePtr == obj->seqList[j].seqPtr) { if (obj->_currImagePtr == obj->_seqList[j]._seqPtr) {
if (obj->cycleNumb){ // Decr cycleNumb if Non-continous if (obj->_cycleNumb){ // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb) if (!--obj->_cycleNumb)
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
} }
@ -162,8 +162,8 @@ void ObjectHandler_v1d::updateImages() {
default: default:
break; break;
} }
obj->oldx = obj->x; obj->_oldx = obj->_x;
obj->oldy = obj->y; obj->_oldy = obj->_y;
} }
} }
} }
@ -184,161 +184,161 @@ void ObjectHandler_v1d::moveObjects() {
// Don't store foreground or background objects // Don't store foreground or background objects
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) { if (obj->_screenIndex == *_vm->_screen_p) {
switch (obj->pathType) { switch (obj->_pathType) {
case kPathChase: { case kPathChase: {
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; 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 dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1;
if (abs(dx) <= 1) if (abs(dx) <= 1)
obj->vx = 0; obj->_vx = 0;
else 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) if (abs(dy) <= 1)
obj->vy = 0; obj->_vy = 0;
else 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) // Set first image in sequence (if multi-seq object)
if (obj->seqNumb == 4) { if (obj->_seqNumb == 4) {
if (!obj->vx) { // Got 4 directions if (!obj->_vx) { // Got 4 directions
if (obj->vx != obj->oldvx) {// vx just stopped if (obj->_vx != obj->_oldvx) {// vx just stopped
if (dy > 0) if (dy > 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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) if (dx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
} }
if (obj->vx || obj->vy) { if (obj->_vx || obj->_vy) {
if (obj->seqNumb > 1) if (obj->_seqNumb > 1)
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
} else { } else {
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
boundaryCollision(obj); // Must have got hero! boundaryCollision(obj); // Must have got hero!
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
break; break;
} }
case kPathWander: case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath;
// Set first image in sequence (if multi-seq object) // Set first image in sequence (if multi-seq object)
if (obj->seqNumb > 1) { if (obj->_seqNumb > 1) {
if (!obj->vx && (obj->seqNumb > 2)) { if (!obj->_vx && (obj->_seqNumb > 2)) {
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (obj->vy > 0) if (obj->_vy > 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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 (obj->vx > 0) if (obj->_vx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
if (obj->vx || obj->vy) if (obj->_vx || obj->_vy)
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
else else
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
} }
break; break;
default: default:
; // Really, nothing ; // Really, nothing
} }
// Store boundaries // Store boundaries
if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating))
storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2);
} }
} }
// Move objects, allowing for boundaries // Move objects, allowing for boundaries
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object 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 // Only process if it's moving
// Do object movement. Delta_x,y return allowed movement in x,y // Do object movement. Delta_x,y return allowed movement in x,y
// to move as close to a boundary as possible without crossing it. // 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 // object coordinates
int x1 = obj->x + currImage->x1; // Left edge of object int x1 = obj->_x + currImage->_x1; // Left edge of object
int x2 = obj->x + currImage->x2; // Right edge int x2 = obj->_x + currImage->_x2; // Right edge
int y1 = obj->y + currImage->y1; // Top edge int y1 = obj->_y + currImage->_y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom 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 clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = deltaX(x1, x2, obj->vx, y2); int dx = deltaX(x1, x2, obj->_vx, y2);
if (dx != obj->vx) { if (dx != obj->_vx) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); boundaryCollision(obj);
obj->vx = 0; obj->_vx = 0;
} }
int dy = deltaY(x1, x2, obj->vy, y2); int dy = deltaY(x1, x2, obj->_vy, y2);
if (dy != obj->vy) { if (dy != obj->_vy) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); 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 storeBoundary(x1, x2, y2); // Re-store our own boundary
obj->x += dx; // Update object position obj->_x += dx; // Update object position
obj->y += dy; obj->_y += dy;
// Don't let object go outside screen // Don't let object go outside screen
if (x1 < kEdge) if (x1 < kEdge)
obj->x = kEdge2; obj->_x = kEdge2;
if (x2 > (kXPix - kEdge)) if (x2 > (kXPix - kEdge))
obj->x = kXPix - kEdge2 - (x2 - x1); obj->_x = kXPix - kEdge2 - (x2 - x1);
if (y1 < kEdge) if (y1 < kEdge)
obj->y = kEdge2; obj->_y = kEdge2;
if (y2 > (kYPix - kEdge)) if (y2 > (kYPix - kEdge))
obj->y = kYPix - kEdge2 - (y2 - y1); obj->_y = kYPix - kEdge2 - (y2 - y1);
if ((obj->vx == 0) && (obj->vy == 0)) if ((obj->_vx == 0) && (obj->_vy == 0))
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
// Clear all object baselines from the boundary file. // Clear all object baselines from the boundary file.
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) 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); clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2);
} }
// If maze mode is enabled, do special maze processing // If maze mode is enabled, do special maze processing
if (_vm->_maze.enabledFl) { if (_vm->_maze._enabledFl) {
seq_t *currImage = _vm->_hero->currImagePtr;// Get ptr to current image seq_t *currImage = _vm->_hero->_currImagePtr;// Get ptr to current image
// hero coordinates // hero coordinates
int x1 = _vm->_hero->x + currImage->x1; // Left edge of object int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object
int x2 = _vm->_hero->x + currImage->x2; // Right edge int x2 = _vm->_hero->_x + currImage->_x2; // Right edge
int y1 = _vm->_hero->y + currImage->y1; // Top edge int y1 = _vm->_hero->_y + currImage->_y1; // Top edge
int y2 = _vm->_hero->y + currImage->y2; // Bottom edge int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge
_vm->_scheduler->processMaze(x1, x2, y1, y2); _vm->_scheduler->processMaze(x1, x2, y1, y2);
} }
@ -355,11 +355,11 @@ void ObjectHandler_v1d::swapImages(int objIndex1, int objIndex2) {
seqList_t tmpSeqList[kMaxSeqNumb]; seqList_t tmpSeqList[kMaxSeqNumb];
int seqListSize = sizeof(seqList_t) * kMaxSeqNumb; int seqListSize = sizeof(seqList_t) * kMaxSeqNumb;
memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); memmove(tmpSeqList, _objects[objIndex1]._seqList, seqListSize);
memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); memmove(_objects[objIndex1]._seqList, _objects[objIndex2]._seqList, seqListSize);
memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); memmove(_objects[objIndex2]._seqList, tmpSeqList, seqListSize);
_objects[objIndex1].currImagePtr = _objects[objIndex1].seqList[0].seqPtr; _objects[objIndex1]._currImagePtr = _objects[objIndex1]._seqList[0]._seqPtr;
_objects[objIndex2].currImagePtr = _objects[objIndex2].seqList[0].seqPtr; _objects[objIndex2]._currImagePtr = _objects[objIndex2]._seqList[0]._seqPtr;
_vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex; _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 obj1 will home in on object obj2
object_t *obj1 = &_objects[objIndex1]; object_t *obj1 = &_objects[objIndex1];
object_t *obj2 = &_objects[objIndex2]; object_t *obj2 = &_objects[objIndex2];
obj1->pathType = kPathAuto; obj1->_pathType = kPathAuto;
int dx = obj1->x + obj1->currImagePtr->x1 - obj2->x - obj2->currImagePtr->x1; int dx = obj1->_x + obj1->_currImagePtr->_x1 - obj2->_x - obj2->_currImagePtr->_x1;
int dy = obj1->y + obj1->currImagePtr->y1 - obj2->y - obj2->currImagePtr->y1; int dy = obj1->_y + obj1->_currImagePtr->_y1 - obj2->_y - obj2->_currImagePtr->_y1;
if (dx == 0) // Don't EVER divide by zero! if (dx == 0) // Don't EVER divide by zero!
dx = 1; dx = 1;
@ -377,11 +377,11 @@ void ObjectHandler_v1d::homeIn(int objIndex1, const int objIndex2, const int8 ob
dy = 1; dy = 1;
if (abs(dx) > abs(dy)) { if (abs(dx) > abs(dy)) {
obj1->vx = objDx * -sign<int8>(dx); obj1->_vx = objDx * -sign<int8>(dx);
obj1->vy = abs((objDy * dy) / dx) * -sign<int8>(dy); obj1->_vy = abs((objDy * dy) / dx) * -sign<int8>(dy);
} else { } else {
obj1->vy = objDy * sign<int8>(dy); obj1->_vy = objDy * sign<int8>(dy);
obj1->vx = abs((objDx * dx) / dy) * sign<int8>(dx); obj1->_vx = abs((objDx * dx) / dy) * sign<int8>(dx);
} }
} }
} // End of namespace Hugo } // End of namespace Hugo

View file

@ -64,7 +64,7 @@ void ObjectHandler_v1w::updateImages() {
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[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; objindex[num_objs++] = i;
} }
@ -75,27 +75,27 @@ void ObjectHandler_v1w::updateImages() {
for (int i = 0; i < num_objs; i++) { for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]]; object_t *obj = &_objects[objindex[i]];
// Count down inter-frame timer // Count down inter-frame timer
if (obj->frameTimer) if (obj->_frameTimer)
obj->frameTimer--; obj->_frameTimer--;
if (obj->cycling > kCycleAlmostInvisible) { // Only if visible if (obj->_cycling > kCycleAlmostInvisible) { // Only if visible
switch (obj->cycling) { switch (obj->_cycling) {
case kCycleNotCycling: 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; break;
case kCycleForward: case kCycleForward:
if (obj->frameTimer) // Not time to see next frame yet if (obj->_frameTimer) // Not time to see next frame yet
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, obj->_priority == kPriorityOverOverlay);
else 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; break;
case kCycleBackward: { case kCycleBackward: {
seq_t *seqPtr = obj->currImagePtr; seq_t *seqPtr = obj->_currImagePtr;
if (!obj->frameTimer) { // Show next frame if (!obj->_frameTimer) { // Show next frame
while (seqPtr->nextSeqPtr != obj->currImagePtr) while (seqPtr->_nextSeqPtr != obj->_currImagePtr)
seqPtr = seqPtr->nextSeqPtr; 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; break;
} }
default: default:
@ -107,28 +107,28 @@ void ObjectHandler_v1w::updateImages() {
// Cycle any animating objects // Cycle any animating objects
for (int i = 0; i < num_objs; i++) { for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]]; object_t *obj = &_objects[objindex[i]];
if (obj->cycling != kCycleInvisible) { if (obj->_cycling != kCycleInvisible) {
// Only if it's visible // Only if it's visible
if (obj->cycling == kCycleAlmostInvisible) if (obj->_cycling == kCycleAlmostInvisible)
obj->cycling = kCycleInvisible; obj->_cycling = kCycleInvisible;
// Now Rotate to next picture in sequence // Now Rotate to next picture in sequence
switch (obj->cycling) { switch (obj->_cycling) {
case kCycleNotCycling: case kCycleNotCycling:
break; break;
case kCycleForward: case kCycleForward:
if (!obj->frameTimer) { if (!obj->_frameTimer) {
// Time to step to next frame // 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 // Find out if this is last frame of sequence
// If so, reset frame_timer and decrement n_cycle // If so, reset frame_timer and decrement n_cycle
if (obj->frameInterval || obj->cycleNumb) { if (obj->_frameInterval || obj->_cycleNumb) {
obj->frameTimer = obj->frameInterval; obj->_frameTimer = obj->_frameInterval;
for (int j = 0; j < obj->seqNumb; j++) { for (int j = 0; j < obj->_seqNumb; j++) {
if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) { if (obj->_currImagePtr->_nextSeqPtr == obj->_seqList[j]._seqPtr) {
if (obj->cycleNumb) { // Decr cycleNumb if Non-continous if (obj->_cycleNumb) { // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb) if (!--obj->_cycleNumb)
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
} }
@ -136,20 +136,20 @@ void ObjectHandler_v1w::updateImages() {
} }
break; break;
case kCycleBackward: { case kCycleBackward: {
if (!obj->frameTimer) { if (!obj->_frameTimer) {
// Time to step to prev frame // Time to step to prev frame
seq_t *seqPtr = obj->currImagePtr; seq_t *seqPtr = obj->_currImagePtr;
while (obj->currImagePtr->nextSeqPtr != seqPtr) while (obj->_currImagePtr->_nextSeqPtr != seqPtr)
obj->currImagePtr = obj->currImagePtr->nextSeqPtr; obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr;
// Find out if this is first frame of sequence // Find out if this is first frame of sequence
// If so, reset frame_timer and decrement n_cycle // If so, reset frame_timer and decrement n_cycle
if (obj->frameInterval || obj->cycleNumb) { if (obj->_frameInterval || obj->_cycleNumb) {
obj->frameTimer = obj->frameInterval; obj->_frameTimer = obj->_frameInterval;
for (int j = 0; j < obj->seqNumb; j++) { for (int j = 0; j < obj->_seqNumb; j++) {
if (obj->currImagePtr == obj->seqList[j].seqPtr) { if (obj->_currImagePtr == obj->_seqList[j]._seqPtr) {
if (obj->cycleNumb){ // Decr cycleNumb if Non-continous if (obj->_cycleNumb){ // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb) if (!--obj->_cycleNumb)
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
} }
@ -160,8 +160,8 @@ void ObjectHandler_v1w::updateImages() {
default: default:
break; break;
} }
obj->oldx = obj->x; obj->_oldx = obj->_x;
obj->oldy = obj->y; obj->_oldy = obj->_y;
} }
} }
} }
@ -181,174 +181,174 @@ void ObjectHandler_v1w::moveObjects() {
// Don't store foreground or background objects // Don't store foreground or background objects
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) { if (obj->_screenIndex == *_vm->_screen_p) {
switch (obj->pathType) { switch (obj->_pathType) {
case kPathChase: case kPathChase:
case kPathChase2: { 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 if (radius < 0) // If radius infinity, use closer value
radius = kStepDx; radius = kStepDx;
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; 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 dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1;
if (abs(dx) <= radius) if (abs(dx) <= radius)
obj->vx = 0; obj->_vx = 0;
else 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) if (abs(dy) <= radius)
obj->vy = 0; obj->_vy = 0;
else 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) // Set first image in sequence (if multi-seq object)
switch (obj->seqNumb) { switch (obj->_seqNumb) {
case 4: case 4:
if (!obj->vx) { // Got 4 directions if (!obj->_vx) { // Got 4 directions
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (dy >= 0) if (dy >= 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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) if (dx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
break; break;
case 3: case 3:
case 2: case 2:
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (dx > 0) // Left & right only if (dx > 0) // Left & right only
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
break; break;
} }
if (obj->vx || obj->vy) { if (obj->_vx || obj->_vy) {
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
} else { } else {
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
boundaryCollision(obj); // Must have got hero! boundaryCollision(obj); // Must have got hero!
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
break; break;
} }
case kPathWander2: case kPathWander2:
case kPathWander: case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath;
// Set first image in sequence (if multi-seq object) // Set first image in sequence (if multi-seq object)
if (obj->seqNumb > 1) { if (obj->_seqNumb > 1) {
if (!obj->vx && (obj->seqNumb >= 4)) { if (!obj->_vx && (obj->_seqNumb >= 4)) {
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (obj->vy > 0) if (obj->_vy > 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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 (obj->vx > 0) if (obj->_vx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
} }
if (obj->vx || obj->vy) if (obj->_vx || obj->_vy)
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
break; break;
default: default:
; // Really, nothing ; // Really, nothing
} }
// Store boundaries // Store boundaries
if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating))
storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2);
} }
} }
// Move objects, allowing for boundaries // Move objects, allowing for boundaries
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object 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 // Only process if it's moving
// Do object movement. Delta_x,y return allowed movement in x,y // Do object movement. Delta_x,y return allowed movement in x,y
// to move as close to a boundary as possible without crossing it. // 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 // object coordinates
int x1 = obj->x + currImage->x1; // Left edge of object int x1 = obj->_x + currImage->_x1; // Left edge of object
int x2 = obj->x + currImage->x2; // Right edge int x2 = obj->_x + currImage->_x2; // Right edge
int y1 = obj->y + currImage->y1; // Top edge int y1 = obj->_y + currImage->_y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom 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 clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = deltaX(x1, x2, obj->vx, y2); int dx = deltaX(x1, x2, obj->_vx, y2);
if (dx != obj->vx) { if (dx != obj->_vx) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); boundaryCollision(obj);
obj->vx = 0; obj->_vx = 0;
} }
int dy = deltaY(x1, x2, obj->vy, y2); int dy = deltaY(x1, x2, obj->_vy, y2);
if (dy != obj->vy) { if (dy != obj->_vy) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); 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 storeBoundary(x1, x2, y2); // Re-store our own boundary
obj->x += dx; // Update object position obj->_x += dx; // Update object position
obj->y += dy; obj->_y += dy;
// Don't let object go outside screen // Don't let object go outside screen
if (x1 < kEdge) if (x1 < kEdge)
obj->x = kEdge2; obj->_x = kEdge2;
if (x2 > (kXPix - kEdge)) if (x2 > (kXPix - kEdge))
obj->x = kXPix - kEdge2 - (x2 - x1); obj->_x = kXPix - kEdge2 - (x2 - x1);
if (y1 < kEdge) if (y1 < kEdge)
obj->y = kEdge2; obj->_y = kEdge2;
if (y2 > (kYPix - kEdge)) 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)) if ((obj->_vx == 0) && (obj->_vy == 0) && (obj->_pathType != kPathWander2) && (obj->_pathType != kPathChase2))
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
// Clear all object baselines from the boundary file. // Clear all object baselines from the boundary file.
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) 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); clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2);
} }
// If maze mode is enabled, do special maze processing // If maze mode is enabled, do special maze processing
if (_vm->_maze.enabledFl) { if (_vm->_maze._enabledFl) {
seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image seq_t *currImage = _vm->_hero->_currImagePtr; // Get ptr to current image
// hero coordinates // hero coordinates
int x1 = _vm->_hero->x + currImage->x1; // Left edge of object int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object
int x2 = _vm->_hero->x + currImage->x2; // Right edge int x2 = _vm->_hero->_x + currImage->_x2; // Right edge
int y1 = _vm->_hero->y + currImage->y1; // Top edge int y1 = _vm->_hero->_y + currImage->_y1; // Top edge
int y2 = _vm->_hero->y + currImage->y2; // Bottom edge int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge
_vm->_scheduler->processMaze(x1, x2, y1, y2); _vm->_scheduler->processMaze(x1, x2, y1, y2);
} }
@ -367,15 +367,15 @@ void ObjectHandler_v1w::swapImages(int objIndex1, int objIndex2) {
seqList_t tmpSeqList[kMaxSeqNumb]; seqList_t tmpSeqList[kMaxSeqNumb];
int seqListSize = sizeof(seqList_t) * kMaxSeqNumb; int seqListSize = sizeof(seqList_t) * kMaxSeqNumb;
memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); memmove(tmpSeqList, _objects[objIndex1]._seqList, seqListSize);
memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); memmove(_objects[objIndex1]._seqList, _objects[objIndex2]._seqList, seqListSize);
memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); memmove(_objects[objIndex2]._seqList, tmpSeqList, seqListSize);
restoreSeq(&_objects[objIndex1]); 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; _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex;
// Make sure baseline stays constant // 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 } // End of namespace Hugo

View file

@ -64,7 +64,7 @@ void ObjectHandler_v2d::updateImages() {
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[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; objindex[num_objs++] = i;
} }
@ -75,27 +75,27 @@ void ObjectHandler_v2d::updateImages() {
for (int i = 0; i < num_objs; i++) { for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]]; object_t *obj = &_objects[objindex[i]];
// Count down inter-frame timer // Count down inter-frame timer
if (obj->frameTimer) if (obj->_frameTimer)
obj->frameTimer--; obj->_frameTimer--;
if (obj->cycling > kCycleAlmostInvisible) { // Only if visible if (obj->_cycling > kCycleAlmostInvisible) { // Only if visible
switch (obj->cycling) { switch (obj->_cycling) {
case kCycleNotCycling: 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; break;
case kCycleForward: case kCycleForward:
if (obj->frameTimer) // Not time to see next frame yet if (obj->_frameTimer) // Not time to see next frame yet
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); _vm->_screen->displayFrame(obj->_x, obj->_y, obj->_currImagePtr, obj->_priority == kPriorityOverOverlay);
else 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; break;
case kCycleBackward: { case kCycleBackward: {
seq_t *seqPtr = obj->currImagePtr; seq_t *seqPtr = obj->_currImagePtr;
if (!obj->frameTimer) { // Show next frame if (!obj->_frameTimer) { // Show next frame
while (seqPtr->nextSeqPtr != obj->currImagePtr) while (seqPtr->_nextSeqPtr != obj->_currImagePtr)
seqPtr = seqPtr->nextSeqPtr; 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; break;
} }
default: default:
@ -109,28 +109,28 @@ void ObjectHandler_v2d::updateImages() {
// Cycle any animating objects // Cycle any animating objects
for (int i = 0; i < num_objs; i++) { for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]]; object_t *obj = &_objects[objindex[i]];
if (obj->cycling != kCycleInvisible) { if (obj->_cycling != kCycleInvisible) {
// Only if it's visible // Only if it's visible
if (obj->cycling == kCycleAlmostInvisible) if (obj->_cycling == kCycleAlmostInvisible)
obj->cycling = kCycleInvisible; obj->_cycling = kCycleInvisible;
// Now Rotate to next picture in sequence // Now Rotate to next picture in sequence
switch (obj->cycling) { switch (obj->_cycling) {
case kCycleNotCycling: case kCycleNotCycling:
break; break;
case kCycleForward: case kCycleForward:
if (!obj->frameTimer) { if (!obj->_frameTimer) {
// Time to step to next frame // 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 // Find out if this is last frame of sequence
// If so, reset frame_timer and decrement n_cycle // If so, reset frame_timer and decrement n_cycle
if (obj->frameInterval || obj->cycleNumb) { if (obj->_frameInterval || obj->_cycleNumb) {
obj->frameTimer = obj->frameInterval; obj->_frameTimer = obj->_frameInterval;
for (int j = 0; j < obj->seqNumb; j++) { for (int j = 0; j < obj->_seqNumb; j++) {
if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) { if (obj->_currImagePtr->_nextSeqPtr == obj->_seqList[j]._seqPtr) {
if (obj->cycleNumb) { // Decr cycleNumb if Non-continous if (obj->_cycleNumb) { // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb) if (!--obj->_cycleNumb)
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
} }
@ -138,20 +138,20 @@ void ObjectHandler_v2d::updateImages() {
} }
break; break;
case kCycleBackward: { case kCycleBackward: {
if (!obj->frameTimer) { if (!obj->_frameTimer) {
// Time to step to prev frame // Time to step to prev frame
seq_t *seqPtr = obj->currImagePtr; seq_t *seqPtr = obj->_currImagePtr;
while (obj->currImagePtr->nextSeqPtr != seqPtr) while (obj->_currImagePtr->_nextSeqPtr != seqPtr)
obj->currImagePtr = obj->currImagePtr->nextSeqPtr; obj->_currImagePtr = obj->_currImagePtr->_nextSeqPtr;
// Find out if this is first frame of sequence // Find out if this is first frame of sequence
// If so, reset frame_timer and decrement n_cycle // If so, reset frame_timer and decrement n_cycle
if (obj->frameInterval || obj->cycleNumb) { if (obj->_frameInterval || obj->_cycleNumb) {
obj->frameTimer = obj->frameInterval; obj->_frameTimer = obj->_frameInterval;
for (int j = 0; j < obj->seqNumb; j++) { for (int j = 0; j < obj->_seqNumb; j++) {
if (obj->currImagePtr == obj->seqList[j].seqPtr) { if (obj->_currImagePtr == obj->_seqList[j]._seqPtr) {
if (obj->cycleNumb){ // Decr cycleNumb if Non-continous if (obj->_cycleNumb){ // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb) if (!--obj->_cycleNumb)
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
} }
@ -162,8 +162,8 @@ void ObjectHandler_v2d::updateImages() {
default: default:
break; break;
} }
obj->oldx = obj->x; obj->_oldx = obj->_x;
obj->oldy = obj->y; obj->_oldy = obj->_y;
} }
} }
} }
@ -184,174 +184,174 @@ void ObjectHandler_v2d::moveObjects() {
// Don't store foreground or background objects // Don't store foreground or background objects
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) { if (obj->_screenIndex == *_vm->_screen_p) {
switch (obj->pathType) { switch (obj->_pathType) {
case kPathChase: case kPathChase:
case kPathChase2: { 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 if (radius < 0) // If radius infinity, use closer value
radius = kStepDx; radius = kStepDx;
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; 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 dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1;
if (abs(dx) <= radius) if (abs(dx) <= radius)
obj->vx = 0; obj->_vx = 0;
else 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) if (abs(dy) <= radius)
obj->vy = 0; obj->_vy = 0;
else 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) // Set first image in sequence (if multi-seq object)
switch (obj->seqNumb) { switch (obj->_seqNumb) {
case 4: case 4:
if (!obj->vx) { // Got 4 directions if (!obj->_vx) { // Got 4 directions
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (dy > 0) if (dy > 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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) if (dx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
break; break;
case 3: case 3:
case 2: case 2:
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (dx > 0) // Left & right only if (dx > 0) // Left & right only
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
break; break;
} }
if (obj->vx || obj->vy) { if (obj->_vx || obj->_vy) {
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
} else { } else {
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
boundaryCollision(obj); // Must have got hero! boundaryCollision(obj); // Must have got hero!
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
break; break;
} }
case kPathWander2: case kPathWander2:
case kPathWander: case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath;
// Set first image in sequence (if multi-seq object) // Set first image in sequence (if multi-seq object)
if (obj->seqNumb > 1) { if (obj->_seqNumb > 1) {
if (!obj->vx && (obj->seqNumb >= 4)) { if (!obj->_vx && (obj->_seqNumb >= 4)) {
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (obj->vy > 0) if (obj->_vy > 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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 (obj->vx > 0) if (obj->_vx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
} }
if (obj->vx || obj->vy) if (obj->_vx || obj->_vy)
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
break; break;
default: default:
; // Really, nothing ; // Really, nothing
} }
// Store boundaries // Store boundaries
if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating))
storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2);
} }
} }
// Move objects, allowing for boundaries // Move objects, allowing for boundaries
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object 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 // Only process if it's moving
// Do object movement. Delta_x,y return allowed movement in x,y // Do object movement. Delta_x,y return allowed movement in x,y
// to move as close to a boundary as possible without crossing it. // 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 // object coordinates
int x1 = obj->x + currImage->x1; // Left edge of object int x1 = obj->_x + currImage->_x1; // Left edge of object
int x2 = obj->x + currImage->x2; // Right edge int x2 = obj->_x + currImage->_x2; // Right edge
int y1 = obj->y + currImage->y1; // Top edge int y1 = obj->_y + currImage->_y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom 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 clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = deltaX(x1, x2, obj->vx, y2); int dx = deltaX(x1, x2, obj->_vx, y2);
if (dx != obj->vx) { if (dx != obj->_vx) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); boundaryCollision(obj);
obj->vx = 0; obj->_vx = 0;
} }
int dy = deltaY(x1, x2, obj->vy, y2); int dy = deltaY(x1, x2, obj->_vy, y2);
if (dy != obj->vy) { if (dy != obj->_vy) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); 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 storeBoundary(x1, x2, y2); // Re-store our own boundary
obj->x += dx; // Update object position obj->_x += dx; // Update object position
obj->y += dy; obj->_y += dy;
// Don't let object go outside screen // Don't let object go outside screen
if (x1 < kEdge) if (x1 < kEdge)
obj->x = kEdge2; obj->_x = kEdge2;
if (x2 > (kXPix - kEdge)) if (x2 > (kXPix - kEdge))
obj->x = kXPix - kEdge2 - (x2 - x1); obj->_x = kXPix - kEdge2 - (x2 - x1);
if (y1 < kEdge) if (y1 < kEdge)
obj->y = kEdge2; obj->_y = kEdge2;
if (y2 > (kYPix - kEdge)) 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)) if ((obj->_vx == 0) && (obj->_vy == 0) && (obj->_pathType != kPathWander2) && (obj->_pathType != kPathChase2))
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
// Clear all object baselines from the boundary file. // Clear all object baselines from the boundary file.
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) 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); clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2);
} }
// If maze mode is enabled, do special maze processing // If maze mode is enabled, do special maze processing
if (_vm->_maze.enabledFl) { if (_vm->_maze._enabledFl) {
seq_t *currImage = _vm->_hero->currImagePtr; // Get ptr to current image seq_t *currImage = _vm->_hero->_currImagePtr; // Get ptr to current image
// hero coordinates // hero coordinates
int x1 = _vm->_hero->x + currImage->x1; // Left edge of object int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object
int x2 = _vm->_hero->x + currImage->x2; // Right edge int x2 = _vm->_hero->_x + currImage->_x2; // Right edge
int y1 = _vm->_hero->y + currImage->y1; // Top edge int y1 = _vm->_hero->_y + currImage->_y1; // Top edge
int y2 = _vm->_hero->y + currImage->y2; // Bottom edge int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge
_vm->_scheduler->processMaze(x1, x2, y1, y2); _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 obj1 will home in on object obj2
object_t *obj1 = &_objects[objIndex1]; object_t *obj1 = &_objects[objIndex1];
object_t *obj2 = &_objects[objIndex2]; object_t *obj2 = &_objects[objIndex2];
obj1->pathType = kPathAuto; obj1->_pathType = kPathAuto;
int dx = obj1->x + obj1->currImagePtr->x1 - obj2->x - obj2->currImagePtr->x1; int dx = obj1->_x + obj1->_currImagePtr->_x1 - obj2->_x - obj2->_currImagePtr->_x1;
int dy = obj1->y + obj1->currImagePtr->y1 - obj2->y - obj2->currImagePtr->y1; int dy = obj1->_y + obj1->_currImagePtr->_y1 - obj2->_y - obj2->_currImagePtr->_y1;
if (dx == 0) // Don't EVER divide by zero! if (dx == 0) // Don't EVER divide by zero!
dx = 1; dx = 1;
@ -371,11 +371,11 @@ void ObjectHandler_v2d::homeIn(const int objIndex1, const int objIndex2, const i
dy = 1; dy = 1;
if (abs(dx) > abs(dy)) { if (abs(dx) > abs(dy)) {
obj1->vx = objDx * -sign<int8>(dx); obj1->_vx = objDx * -sign<int8>(dx);
obj1->vy = abs((objDy * dy) / dx) * -sign<int8>(dy); obj1->_vy = abs((objDy * dy) / dx) * -sign<int8>(dy);
} else { } else {
obj1->vy = objDy * -sign<int8>(dy); obj1->_vy = objDy * -sign<int8>(dy);
obj1->vx = abs((objDx * dx) / dy) * -sign<int8>(dx); obj1->_vx = abs((objDx * dx) / dy) * -sign<int8>(dx);
} }
} }
} // End of namespace Hugo } // End of namespace Hugo

View file

@ -65,175 +65,175 @@ void ObjectHandler_v3d::moveObjects() {
// Don't store foreground or background objects // Don't store foreground or background objects
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) { if (obj->_screenIndex == *_vm->_screen_p) {
switch (obj->pathType) { switch (obj->_pathType) {
case kPathChase: case kPathChase:
case kPathChase2: { 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 if (radius < 0) // If radius infinity, use closer value
radius = kStepDx; radius = kStepDx;
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; 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 dy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - obj->_y - currImage->_y2 - 1;
if (abs(dx) <= radius) if (abs(dx) <= radius)
obj->vx = 0; obj->_vx = 0;
else 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) if (abs(dy) <= radius)
obj->vy = 0; obj->_vy = 0;
else 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) // Set first image in sequence (if multi-seq object)
switch (obj->seqNumb) { switch (obj->_seqNumb) {
case 4: case 4:
if (!obj->vx) { // Got 4 directions if (!obj->_vx) { // Got 4 directions
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (dy >= 0) if (dy >= 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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) if (dx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
break; break;
case 3: case 3:
case 2: case 2:
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (dx > 0) // Left & right only if (dx > 0) // Left & right only
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
break; break;
} }
if (obj->vx || obj->vy) { if (obj->_vx || obj->_vy) {
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
} else { } else {
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
boundaryCollision(obj); // Must have got hero! boundaryCollision(obj); // Must have got hero!
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
break; break;
} }
case kPathWander2: case kPathWander2:
case kPathWander: case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; obj->_vx = _vm->_rnd->getRandomNumber(obj->_vxPath << 1) - obj->_vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; obj->_vy = _vm->_rnd->getRandomNumber(obj->_vyPath << 1) - obj->_vyPath;
// Set first image in sequence (if multi-seq object) // Set first image in sequence (if multi-seq object)
if (obj->seqNumb > 1) { if (obj->_seqNumb > 1) {
if (!obj->vx && (obj->seqNumb >= 4)) { if (!obj->_vx && (obj->_seqNumb >= 4)) {
if (obj->vx != obj->oldvx) { // vx just stopped if (obj->_vx != obj->_oldvx) { // vx just stopped
if (obj->vy > 0) if (obj->_vy > 0)
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
else 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 (obj->vx > 0) if (obj->_vx > 0)
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
else else
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
} }
} }
obj->oldvx = obj->vx; obj->_oldvx = obj->_vx;
obj->oldvy = obj->vy; obj->_oldvy = obj->_vy;
currImage = obj->currImagePtr; // Get (new) ptr to current image currImage = obj->_currImagePtr; // Get (new) ptr to current image
} }
if (obj->vx || obj->vy) if (obj->_vx || obj->_vy)
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
break; break;
default: default:
; // Really, nothing ; // Really, nothing
} }
// Store boundaries // Store boundaries
if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) if ((obj->_cycling > kCycleAlmostInvisible) && (obj->_priority == kPriorityFloating))
storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); storeBoundary(obj->_x + currImage->_x1, obj->_x + currImage->_x2, obj->_y + currImage->_y2);
} }
} }
// Move objects, allowing for boundaries // Move objects, allowing for boundaries
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object 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 // Only process if it's moving
// Do object movement. Delta_x,y return allowed movement in x,y // Do object movement. Delta_x,y return allowed movement in x,y
// to move as close to a boundary as possible without crossing it. // 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 // object coordinates
int x1 = obj->x + currImage->x1; // Left edge of object int x1 = obj->_x + currImage->_x1; // Left edge of object
int x2 = obj->x + currImage->x2; // Right edge int x2 = obj->_x + currImage->_x2; // Right edge
int y1 = obj->y + currImage->y1; // Top edge int y1 = obj->_y + currImage->_y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom 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 clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary // Allowable motion wrt boundary
int dx = deltaX(x1, x2, obj->vx, y2); int dx = deltaX(x1, x2, obj->_vx, y2);
if (dx != obj->vx) { if (dx != obj->_vx) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); boundaryCollision(obj);
obj->vx = 0; obj->_vx = 0;
} }
int dy = deltaY(x1, x2, obj->vy, y2); int dy = deltaY(x1, x2, obj->_vy, y2);
if (dy != obj->vy) { if (dy != obj->_vy) {
// An object boundary collision! // An object boundary collision!
boundaryCollision(obj); 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 storeBoundary(x1, x2, y2); // Re-store our own boundary
obj->x += dx; // Update object position obj->_x += dx; // Update object position
obj->y += dy; obj->_y += dy;
// Don't let object go outside screen // Don't let object go outside screen
if (x1 < kEdge) if (x1 < kEdge)
obj->x = kEdge2; obj->_x = kEdge2;
if (x2 > (kXPix - kEdge)) if (x2 > (kXPix - kEdge))
obj->x = kXPix - kEdge2 - (x2 - x1); obj->_x = kXPix - kEdge2 - (x2 - x1);
if (y1 < kEdge) if (y1 < kEdge)
obj->y = kEdge2; obj->_y = kEdge2;
if (y2 > (kYPix - kEdge)) 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)) if ((obj->_vx == 0) && (obj->_vy == 0) && (obj->_pathType != kPathWander2) && (obj->_pathType != kPathChase2))
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
} }
} }
// Clear all object baselines from the boundary file. // Clear all object baselines from the boundary file.
for (int i = 0; i < _numObj; i++) { for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; // Get pointer to object object_t *obj = &_objects[i]; // Get pointer to object
seq_t *currImage = obj->currImagePtr; // Get ptr to current image seq_t *currImage = obj->_currImagePtr; // Get ptr to current image
if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) 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); clearBoundary(obj->_oldx + currImage->_x1, obj->_oldx + currImage->_x2, obj->_oldy + currImage->_y2);
} }
// If maze mode is enabled, do special maze processing // If maze mode is enabled, do special maze processing
if (_vm->_maze.enabledFl) { if (_vm->_maze._enabledFl) {
seq_t *currImage = _vm->_hero->currImagePtr;// Get ptr to current image seq_t *currImage = _vm->_hero->_currImagePtr;// Get ptr to current image
// hero coordinates // hero coordinates
int x1 = _vm->_hero->x + currImage->x1; // Left edge of object int x1 = _vm->_hero->_x + currImage->_x1; // Left edge of object
int x2 = _vm->_hero->x + currImage->x2; // Right edge int x2 = _vm->_hero->_x + currImage->_x2; // Right edge
int y1 = _vm->_hero->y + currImage->y1; // Top edge int y1 = _vm->_hero->_y + currImage->_y1; // Top edge
int y2 = _vm->_hero->y + currImage->y2; // Bottom edge int y2 = _vm->_hero->_y + currImage->_y2; // Bottom edge
_vm->_scheduler->processMaze(x1, x2, y1, y2); _vm->_scheduler->processMaze(x1, x2, y1, y2);
} }
@ -252,15 +252,15 @@ void ObjectHandler_v3d::swapImages(int objIndex1, int objIndex2) {
seqList_t tmpSeqList[kMaxSeqNumb]; seqList_t tmpSeqList[kMaxSeqNumb];
int seqListSize = sizeof(seqList_t) * kMaxSeqNumb; int seqListSize = sizeof(seqList_t) * kMaxSeqNumb;
memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); memmove(tmpSeqList, _objects[objIndex1]._seqList, seqListSize);
memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); memmove(_objects[objIndex1]._seqList, _objects[objIndex2]._seqList, seqListSize);
memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); memmove(_objects[objIndex2]._seqList, tmpSeqList, seqListSize);
restoreSeq(&_objects[objIndex1]); 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; _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex;
// Make sure baseline stays constant // 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 } // End of namespace Hugo

View file

@ -58,21 +58,21 @@ Parser::~Parser() {
} }
uint16 Parser::getCmdDefaultVerbIdx(const uint16 index) const { uint16 Parser::getCmdDefaultVerbIdx(const uint16 index) const {
return _cmdList[index][0].verbIndex; return _cmdList[index][0]._verbIndex;
} }
/** /**
* Read a cmd structure from Hugo.dat * Read a cmd structure from Hugo.dat
*/ */
void Parser::readCmd(Common::ReadStream &in, cmd &curCmd) { void Parser::readCmd(Common::ReadStream &in, cmd &curCmd) {
curCmd.verbIndex = in.readUint16BE(); curCmd._verbIndex = in.readUint16BE();
curCmd.reqIndex = in.readUint16BE(); curCmd._reqIndex = in.readUint16BE();
curCmd.textDataNoCarryIndex = in.readUint16BE(); curCmd._textDataNoCarryIndex = in.readUint16BE();
curCmd.reqState = in.readByte(); curCmd._reqState = in.readByte();
curCmd.newState = in.readByte(); curCmd._newState = in.readByte();
curCmd.textDataWrongIndex = in.readUint16BE(); curCmd._textDataWrongIndex = in.readUint16BE();
curCmd.textDataDoneIndex = in.readUint16BE(); curCmd._textDataDoneIndex = in.readUint16BE();
curCmd.actIndex = 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) { void Parser::readBG(Common::ReadStream &in, background_t &curBG) {
curBG.verbIndex = in.readUint16BE(); curBG._verbIndex = in.readUint16BE();
curBG.nounIndex = in.readUint16BE(); curBG._nounIndex = in.readUint16BE();
curBG.commentIndex = in.readSint16BE(); curBG._commentIndex = in.readSint16BE();
curBG.matchFl = (in.readByte() != 0); curBG._matchFl = (in.readByte() != 0);
curBG.roomState = in.readByte(); curBG._roomState = in.readByte();
curBG.bonusIndex = in.readByte(); curBG._bonusIndex = in.readByte();
} }
/** /**
@ -165,11 +165,11 @@ const char *Parser::useBG(const char *name) {
debugC(1, kDebugEngine, "useBG(%s)", name); debugC(1, kDebugEngine, "useBG(%s)", name);
objectList_t p = _backgroundObjects[*_vm->_screen_p]; objectList_t p = _backgroundObjects[*_vm->_screen_p];
for (int i = 0; p[i].verbIndex != 0; i++) { for (int i = 0; p[i]._verbIndex != 0; i++) {
if ((name == _vm->_text->getNoun(p[i].nounIndex, 0) && if ((name == _vm->_text->getNoun(p[i]._nounIndex, 0) &&
p[i].verbIndex != _vm->_look) && p[i]._verbIndex != _vm->_look) &&
((p[i].roomState == kStateDontCare) || (p[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) ((p[i]._roomState == kStateDontCare) || (p[i]._roomState == _vm->_screenStates[*_vm->_screen_p])))
return _vm->_text->getVerb(p[i].verbIndex, 0); return _vm->_text->getVerb(p[i]._verbIndex, 0);
} }
return 0; return 0;
@ -222,7 +222,7 @@ void Parser::charHandler() {
_cmdLine[--_cmdLineIndex] = '\0'; _cmdLine[--_cmdLineIndex] = '\0';
break; break;
case Common::KEYCODE_RETURN: // EOL, pass line to line handler 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 // Remove inventory bar if active
if (_vm->_inventory->getInventoryState() == kInventoryActive) if (_vm->_inventory->getInventoryState() == kInventoryActive)
_vm->_inventory->setInventoryState(kInventoryUp); _vm->_inventory->setInventoryState(kInventoryUp);
@ -248,9 +248,9 @@ void Parser::charHandler() {
_cmdLineCursor = (_cmdLineCursor == '_') ? ' ' : '_'; _cmdLineCursor = (_cmdLineCursor == '_') ? ' ' : '_';
// See if recall button pressed // See if recall button pressed
if (gameStatus.recallFl) { if (gameStatus._recallFl) {
// Copy previous line to current cmdline // Copy previous line to current cmdline
gameStatus.recallFl = false; gameStatus._recallFl = false;
strcpy(_cmdLine, _vm->_line); strcpy(_cmdLine, _vm->_line);
_cmdLineIndex = strlen(_cmdLine); _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"); 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 // See if "look" button pressed
if (gameStatus.lookFl) { if (gameStatus._lookFl) {
command("look around"); command("look around");
gameStatus.lookFl = false; gameStatus._lookFl = false;
} }
} }
@ -288,8 +288,8 @@ void Parser::keyHandler(Common::Event event) {
_vm->_file->restoreGame(0); _vm->_file->restoreGame(0);
break; break;
case Common::KEYCODE_s: case Common::KEYCODE_s:
if (gameStatus.viewState == kViewPlay) { if (gameStatus._viewState == kViewPlay) {
if (gameStatus.gameOverFl) if (gameStatus._gameOverFl)
_vm->gameOverMsg(); _vm->gameOverMsg();
else else
_vm->_file->saveGame(-1, Common::String()); _vm->_file->saveGame(-1, Common::String());
@ -304,8 +304,8 @@ void Parser::keyHandler(Common::Event event) {
// Process key down event - called from OnKeyDown() // Process key down event - called from OnKeyDown()
switch (nChar) { // Set various toggle states switch (nChar) { // Set various toggle states
case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT
if (gameStatus.viewState == kViewIntro) if (gameStatus._viewState == kViewIntro)
gameStatus.skipIntroFl = true; gameStatus._skipIntroFl = true;
else { else {
if (_vm->_inventory->getInventoryState() == kInventoryActive) // Remove inventory, if displayed if (_vm->_inventory->getInventoryState() == kInventoryActive) // Remove inventory, if displayed
_vm->_inventory->setInventoryState(kInventoryUp); _vm->_inventory->setInventoryState(kInventoryUp);
@ -333,7 +333,7 @@ void Parser::keyHandler(Common::Event event) {
break; break;
case Common::KEYCODE_F1: // User Help (DOS) case Common::KEYCODE_F1: // User Help (DOS)
if (_checkDoubleF1Fl) if (_checkDoubleF1Fl)
gameStatus.helpFl = true; gameStatus._helpFl = true;
else else
_vm->_screen->userHelp(); _vm->_screen->userHelp();
_checkDoubleF1Fl = !_checkDoubleF1Fl; _checkDoubleF1Fl = !_checkDoubleF1Fl;
@ -343,11 +343,11 @@ void Parser::keyHandler(Common::Event event) {
_vm->_sound->toggleMusic(); _vm->_sound->toggleMusic();
break; break;
case Common::KEYCODE_F3: // Repeat last line case Common::KEYCODE_F3: // Repeat last line
gameStatus.recallFl = true; gameStatus._recallFl = true;
break; break;
case Common::KEYCODE_F4: // Save game case Common::KEYCODE_F4: // Save game
if (gameStatus.viewState == kViewPlay) { if (gameStatus._viewState == kViewPlay) {
if (gameStatus.gameOverFl) if (gameStatus._gameOverFl)
_vm->gameOverMsg(); _vm->gameOverMsg();
else else
_vm->_file->saveGame(-1, Common::String()); _vm->_file->saveGame(-1, Common::String());
@ -366,7 +366,7 @@ void Parser::keyHandler(Common::Event event) {
warning("STUB: F9 (DOS) - BossKey"); warning("STUB: F9 (DOS) - BossKey");
break; break;
default: // Any other key default: // Any other key
if (!gameStatus.storyModeFl) { // Keyboard disabled if (!gameStatus._storyModeFl) { // Keyboard disabled
// Add printable keys to ring buffer // Add printable keys to ring buffer
uint16 bnext = _putIndex + 1; uint16 bnext = _putIndex + 1;
if (bnext >= sizeof(_ringBuffer)) 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 for (int i = 0; i < _vm->_object->_numObj; i++) { // Find widths of 2 columns
if (_vm->_object->isCarried(i)) { 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 if (index++ & 1) // Right hand column
len2 = (len > len2) ? len : len2; len2 = (len > len2) ? len : len2;
else else
@ -473,9 +473,9 @@ void Parser::showDosInventory() const {
for (int i = 0; i < _vm->_object->_numObj; i++) { // Assign strings for (int i = 0; i < _vm->_object->_numObj; i++) { // Assign strings
if (_vm->_object->isCarried(i)) { if (_vm->_object->isCarried(i)) {
if (index++ & 1) 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 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) if (index & 1)

View file

@ -48,14 +48,14 @@ enum seqTextParser {
* The following determines how a verb is acted on, for an object * The following determines how a verb is acted on, for an object
*/ */
struct cmd { struct cmd {
uint16 verbIndex; // the verb uint16 _verbIndex; // the verb
uint16 reqIndex; // ptr to list of required objects uint16 _reqIndex; // ptr to list of required objects
uint16 textDataNoCarryIndex; // ptr to string if any of above not carried uint16 _textDataNoCarryIndex; // ptr to string if any of above not carried
byte reqState; // required state for verb to be done byte _reqState; // required state for verb to be done
byte newState; // new states if verb done byte _newState; // new states if verb done
uint16 textDataWrongIndex; // ptr to string if wrong state uint16 _textDataWrongIndex; // ptr to string if wrong state
uint16 textDataDoneIndex; // ptr to string if verb done uint16 _textDataDoneIndex; // ptr to string if verb done
uint16 actIndex; // Ptr to action list 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. * "don't understand" we produce an interesting msg to keep user sane.
*/ */
struct background_t { struct background_t {
uint16 verbIndex; uint16 _verbIndex;
uint16 nounIndex; uint16 _nounIndex;
int commentIndex; // Index of comment produced on match int _commentIndex; // Index of comment produced on match
bool matchFl; // TRUE if noun must match when present bool _matchFl; // TRUE if noun must match when present
byte roomState; // "State" of room. Comments might differ. byte _roomState; // "State" of room. Comments might differ.
byte bonusIndex; // Index of bonus score (0 = no bonus) byte _bonusIndex; // Index of bonus score (0 = no bonus)
}; };
typedef background_t *objectList_t; typedef background_t *objectList_t;

View file

@ -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 { 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); 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; 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; return false;
} else if (obj->carriedFl) { // Object is being carried } else if (obj->_carriedFl) { // Object is being carried
return true; return true;
} else if (obj->screenIndex != *_vm->_screen_p) { // Not in same screen } else if (obj->_screenIndex != *_vm->_screen_p) { // Not in same screen
if (obj->objValue) if (obj->_objValue)
strcpy (comment, _vm->_text->getTextParser(kCmtAny4)); strcpy (comment, _vm->_text->getTextParser(kCmtAny4));
return false; return false;
} }
if (obj->cycling == kCycleInvisible) { if (obj->_cycling == kCycleInvisible) {
if (obj->seqNumb) { // There is an image if (obj->_seqNumb) { // There is an image
strcpy(comment, _vm->_text->getTextParser(kCmtAny5)); strcpy(comment, _vm->_text->getTextParser(kCmtAny5));
return false; return false;
} else { // No image, assume visible } else { // No image, assume visible
if ((obj->radius < 0) || if ((obj->_radius < 0) ||
((abs(obj->x - _vm->_hero->x) <= obj->radius) && ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) &&
(abs(obj->y - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { (abs(obj->_y - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) {
return true; return true;
} else { } else {
// User is either not close enough (stationary, valueless objects) // User is either not close enough (stationary, valueless objects)
// or is not carrying it (small, portable objects of value) // or is not carrying it (small, portable objects of value)
if (noun) { // Don't say unless object specified 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)); strcpy(comment, _vm->_text->getTextParser(kCmtAny4));
else else
strcpy(comment, _vm->_text->getTextParser(kCmtClose)); 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) || if ((obj->_radius < 0) ||
((abs(obj->x - _vm->_hero->x) <= obj->radius) && ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) &&
(abs(obj->y + obj->currImagePtr->y2 - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { (abs(obj->_y + obj->_currImagePtr->_y2 - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) {
return true; return true;
} else { } else {
// User is either not close enough (stationary, valueless objects) // User is either not close enough (stationary, valueless objects)
// or is not carrying it (small, portable objects of value) // or is not carrying it (small, portable objects of value)
if (noun) { // Don't say unless object specified 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)); strcpy(comment, _vm->_text->getTextParser(kCmtAny4));
else else
strcpy(comment, _vm->_text->getTextParser(kCmtClose)); 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) { bool Parser_v1d::isGenericVerb_v1(const char *word, object_t *obj) {
debugC(1, kDebugParser, "isGenericVerb(%s, object_t *obj)", word); debugC(1, kDebugParser, "isGenericVerb(%s, object_t *obj)", word);
if (!obj->genericCmd) if (!obj->_genericCmd)
return false; return false;
// Following is equivalent to switch, but couldn't do one // Following is equivalent to switch, but couldn't do one
if (word == _vm->_text->getVerb(_vm->_look, 0)) { if (word == _vm->_text->getVerb(_vm->_look, 0)) {
if ((LOOK & obj->genericCmd) == LOOK) if ((LOOK & obj->_genericCmd) == LOOK)
Utils::notifyBox(_vm->_text->getTextData(obj->dataIndex)); Utils::notifyBox(_vm->_text->getTextData(obj->_dataIndex));
else else
Utils::notifyBox(_vm->_text->getTextParser(kTBUnusual_1d)); Utils::notifyBox(_vm->_text->getTextParser(kTBUnusual_1d));
} else if (word == _vm->_text->getVerb(_vm->_take, 0)) { } else if (word == _vm->_text->getVerb(_vm->_take, 0)) {
if (obj->carriedFl) if (obj->_carriedFl)
Utils::notifyBox(_vm->_text->getTextParser(kTBHave)); Utils::notifyBox(_vm->_text->getTextParser(kTBHave));
else if ((TAKE & obj->genericCmd) == TAKE) else if ((TAKE & obj->_genericCmd) == TAKE)
takeObject(obj); 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)); Utils::notifyBox(_vm->_text->getTextParser(kTBNoUse));
else else
return false; return false;
} else if (word == _vm->_text->getVerb(_vm->_drop, 0)) { } else if (word == _vm->_text->getVerb(_vm->_drop, 0)) {
if (!obj->carriedFl) if (!obj->_carriedFl)
Utils::notifyBox(_vm->_text->getTextParser(kTBDontHave)); Utils::notifyBox(_vm->_text->getTextParser(kTBDontHave));
else if ((DROP & obj->genericCmd) == DROP) else if ((DROP & obj->_genericCmd) == DROP)
dropObject(obj); dropObject(obj);
else else
Utils::notifyBox(_vm->_text->getTextParser(kTBNeed)); 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); debugC(1, kDebugParser, "isObjectVerb(%s, object_t *obj)", word);
// First, find matching verb in cmd list // 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 if (!cmdIndex) // No commands for this obj
return false; return false;
int i; int i;
for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd 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? if (!strcmp(word, _vm->_text->getVerb(_cmdList[cmdIndex][i]._verbIndex, 0))) // Is this verb catered for?
break; break;
} }
if (_cmdList[cmdIndex][i].verbIndex == 0) // No if (_cmdList[cmdIndex][i]._verbIndex == 0) // No
return false; return false;
// Verb match found, check all required objects are being carried // Verb match found, check all required objects are being carried
cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd
if (cmnd->reqIndex) { // At least 1 thing in list if (cmnd->_reqIndex) { // At least 1 thing in list
uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects uint16 *reqs = _arrayReqs[cmnd->_reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) { // for each obj for (i = 0; reqs[i]; i++) { // for each obj
if (!_vm->_object->isCarrying(reqs[i])) { if (!_vm->_object->isCarrying(reqs[i])) {
Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataNoCarryIndex)); Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataNoCarryIndex));
return true; return true;
} }
} }
} }
// Required objects are present, now check state is correct // Required objects are present, now check state is correct
if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)){ if ((obj->_state != cmnd->_reqState) && (cmnd->_reqState != kStateDontCare)){
Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataWrongIndex)); Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataWrongIndex));
return true; return true;
} }
// Everything checked. Change the state and carry out any actions // 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 if (cmnd->_reqState != kStateDontCare) // Don't change new state if required state didn't care
obj->state = cmnd->newState; obj->_state = cmnd->_newState;
Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataDoneIndex)); Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataDoneIndex));
_vm->_scheduler->insertActionList(cmnd->actIndex); _vm->_scheduler->insertActionList(cmnd->_actIndex);
// Special case if verb is Take or Drop. Assume additional generic actions // 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))) if ((word == _vm->_text->getVerb(_vm->_take, 0)) || (word == _vm->_text->getVerb(_vm->_drop, 0)))
isGenericVerb_v1(word, obj); isGenericVerb_v1(word, obj);
@ -237,9 +237,9 @@ bool Parser_v1d::isBackgroundWord_v1(const char *noun, const char *verb, objectL
if (!noun) if (!noun)
return false; return false;
for (int i = 0; obj[i].verbIndex; i++) { 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))) { 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)); Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex));
return true; 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) { void Parser_v1d::takeObject(object_t *obj) {
debugC(1, kDebugParser, "takeObject(object_t *obj)"); debugC(1, kDebugParser, "takeObject(object_t *obj)");
obj->carriedFl = true; obj->_carriedFl = true;
if (obj->seqNumb) // Don't change if no image to display if (obj->_seqNumb) // Don't change if no image to display
obj->cycling = kCycleAlmostInvisible; 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) { void Parser_v1d::dropObject(object_t *obj) {
debugC(1, kDebugParser, "dropObject(object_t *obj)"); debugC(1, kDebugParser, "dropObject(object_t *obj)");
obj->carriedFl = false; obj->_carriedFl = false;
obj->screenIndex = *_vm->_screen_p; obj->_screenIndex = *_vm->_screen_p;
if (obj->seqNumb) // Don't change if no image to display if (obj->_seqNumb) // Don't change if no image to display
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
obj->x = _vm->_hero->x - 1; obj->_x = _vm->_hero->_x - 1;
obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1; obj->_y = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2 - 1;
_vm->adjustScore(-obj->objValue); _vm->adjustScore(-obj->_objValue);
Utils::notifyBox(_vm->_text->getTextParser(kTBOk)); 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 { 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); 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; return false;
if (testNounFl && !noun) if (testNounFl && !noun)
return false; return false;
for (int i = 0; obj[i].verbIndex; i++) { 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))) { 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)); Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex));
return true; return true;
} }
} }
@ -310,7 +310,7 @@ void Parser_v1d::lineHandler() {
// Toggle God Mode // Toggle God Mode
if (!strncmp(_vm->_line, "PPG", 3)) { if (!strncmp(_vm->_line, "PPG", 3)) {
_vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl; gameStatus._godModeFl = !gameStatus._godModeFl;
return; return;
} }
@ -321,7 +321,7 @@ void Parser_v1d::lineHandler() {
// fetch <object name> Hero carries named object // fetch <object name> Hero carries named object
// fetch all Hero carries all possible objects // fetch all Hero carries all possible objects
// find <object name> Takes hero to screen containing named object // 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 // Special code to allow me to go straight to any screen
if (strstr(_vm->_line, "goto")) { if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) { 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 // Special code to allow me to get objects from anywhere
if (strstr(_vm->_line, "fetch all")) { if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
} }
return; return;
@ -343,7 +343,7 @@ void Parser_v1d::lineHandler() {
if (strstr(_vm->_line, "fetch")) { if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
return; return;
} }
@ -353,8 +353,8 @@ void Parser_v1d::lineHandler() {
// Special code to allow me to goto objects // Special code to allow me to goto objects
if (strstr(_vm->_line, "find")) { if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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))) { 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); _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex);
return; return;
} }
} }
@ -369,7 +369,7 @@ void Parser_v1d::lineHandler() {
// SAVE/RESTORE // SAVE/RESTORE
if (!strcmp("save", _vm->_line)) { if (!strcmp("save", _vm->_line)) {
if (gameStatus.gameOverFl) if (gameStatus._gameOverFl)
_vm->gameOverMsg(); _vm->gameOverMsg();
else else
_vm->_file->saveGame(-1, Common::String()); _vm->_file->saveGame(-1, Common::String());
@ -387,7 +387,7 @@ void Parser_v1d::lineHandler() {
if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return; return;
if (gameStatus.gameOverFl) { if (gameStatus._gameOverFl) {
// No commands allowed! // No commands allowed!
_vm->gameOverMsg(); _vm->gameOverMsg();
return; return;
@ -425,8 +425,8 @@ void Parser_v1d::lineHandler() {
void Parser_v1d::showInventory() const { void Parser_v1d::showInventory() const {
status_t &gameStatus = _vm->getGameStatus(); status_t &gameStatus = _vm->getGameStatus();
if (gameStatus.viewState == kViewPlay) { if (gameStatus._viewState == kViewPlay) {
if (gameStatus.gameOverFl) if (gameStatus._gameOverFl)
_vm->gameOverMsg(); _vm->gameOverMsg();
else else
showDosInventory(); showDosInventory();

View file

@ -61,7 +61,7 @@ void Parser_v1w::lineHandler() {
// Toggle God Mode // Toggle God Mode
if (!strncmp(_vm->_line, "PPG", 3)) { if (!strncmp(_vm->_line, "PPG", 3)) {
_vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl; gameStatus._godModeFl = !gameStatus._godModeFl;
return; return;
} }
@ -72,7 +72,7 @@ void Parser_v1w::lineHandler() {
// fetch <object name> Hero carries named object // fetch <object name> Hero carries named object
// fetch all Hero carries all possible objects // fetch all Hero carries all possible objects
// find <object name> Takes hero to screen containing named object // 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 // Special code to allow me to go straight to any screen
if (strstr(_vm->_line, "goto")) { if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) { 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 // Special code to allow me to get objects from anywhere
if (strstr(_vm->_line, "fetch all")) { if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
} }
return; return;
@ -94,7 +94,7 @@ void Parser_v1w::lineHandler() {
if (strstr(_vm->_line, "fetch")) { if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
return; return;
} }
@ -104,8 +104,8 @@ void Parser_v1w::lineHandler() {
// Special code to allow me to goto objects // Special code to allow me to goto objects
if (strstr(_vm->_line, "find")) { if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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))) { 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); _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex);
return; return;
} }
} }
@ -121,12 +121,12 @@ void Parser_v1w::lineHandler() {
} }
// SAVE/RESTORE // SAVE/RESTORE
if (!strcmp("save", _vm->_line) && gameStatus.viewState == kViewPlay) { if (!strcmp("save", _vm->_line) && gameStatus._viewState == kViewPlay) {
_vm->_file->saveGame(-1, Common::String()); _vm->_file->saveGame(-1, Common::String());
return; 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); _vm->_file->restoreGame(-1);
return; return;
} }
@ -137,7 +137,7 @@ void Parser_v1w::lineHandler() {
if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return; return;
if (gameStatus.gameOverFl) { if (gameStatus._gameOverFl) {
// No commands allowed! // No commands allowed!
_vm->gameOverMsg(); _vm->gameOverMsg();
return; return;
@ -148,7 +148,7 @@ void Parser_v1w::lineHandler() {
// Test for nearby objects referenced explicitly // Test for nearby objects referenced explicitly
for (int i = 0; i < _vm->_object->_numObj; i++) { for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[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)) if (isObjectVerb_v3(obj, farComment) || isGenericVerb_v3(obj, farComment))
return; return;
} }
@ -158,7 +158,7 @@ void Parser_v1w::lineHandler() {
// Note comment is unused if not near. // Note comment is unused if not near.
for (int i = 0; i < _vm->_object->_numObj; i++) { for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[i]; object_t *obj = &_vm->_object->_objects[i];
if (obj->verbOnlyFl) { if (obj->_verbOnlyFl) {
char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects
if (isObjectVerb_v3(obj, contextComment) || isGenericVerb_v3(obj, contextComment)) if (isObjectVerb_v3(obj, contextComment) || isGenericVerb_v3(obj, contextComment))
return; return;
@ -185,7 +185,7 @@ void Parser_v1w::lineHandler() {
// Nothing matches. Report recognition success to user. // Nothing matches. Report recognition success to user.
const char *verb = findVerb(); const char *verb = findVerb();
const char *noun = findNoun(); 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)); Utils::notifyBox(_vm->_text->getTextParser(kTBMaze));
_vm->_object->showTakeables(); _vm->_object->showTakeables();
} else if (verb && noun) { // A combination I didn't think of } else if (verb && noun) { // A combination I didn't think of
@ -202,14 +202,14 @@ void Parser_v1w::lineHandler() {
void Parser_v1w::showInventory() const { void Parser_v1w::showInventory() const {
status_t &gameStatus = _vm->getGameStatus(); status_t &gameStatus = _vm->getGameStatus();
istate_t inventState = _vm->_inventory->getInventoryState(); istate_t inventState = _vm->_inventory->getInventoryState();
if (gameStatus.gameOverFl) { if (gameStatus._gameOverFl) {
_vm->gameOverMsg(); _vm->gameOverMsg();
} else if ((inventState == kInventoryOff) && (gameStatus.viewState == kViewPlay)) { } else if ((inventState == kInventoryOff) && (gameStatus._viewState == kViewPlay)) {
_vm->_inventory->setInventoryState(kInventoryDown); _vm->_inventory->setInventoryState(kInventoryDown);
gameStatus.viewState = kViewInvent; gameStatus._viewState = kViewInvent;
} else if (inventState == kInventoryActive) { } else if (inventState == kInventoryActive) {
_vm->_inventory->setInventoryState(kInventoryUp); _vm->_inventory->setInventoryState(kInventoryUp);
gameStatus.viewState = kViewInvent; gameStatus._viewState = kViewInvent;
} }
} }

View file

@ -60,7 +60,7 @@ void Parser_v2d::lineHandler() {
// Toggle God Mode // Toggle God Mode
if (!strncmp(_vm->_line, "PPG", 3)) { if (!strncmp(_vm->_line, "PPG", 3)) {
_vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl; gameStatus._godModeFl = !gameStatus._godModeFl;
return; return;
} }
@ -71,7 +71,7 @@ void Parser_v2d::lineHandler() {
// fetch <object name> Hero carries named object // fetch <object name> Hero carries named object
// fetch all Hero carries all possible objects // fetch all Hero carries all possible objects
// find <object name> Takes hero to screen containing named object // 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 // Special code to allow me to go straight to any screen
if (strstr(_vm->_line, "goto")) { if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) { 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 // Special code to allow me to get objects from anywhere
if (strstr(_vm->_line, "fetch all")) { if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
} }
return; return;
@ -93,7 +93,7 @@ void Parser_v2d::lineHandler() {
if (strstr(_vm->_line, "fetch")) { if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
return; return;
} }
@ -103,8 +103,8 @@ void Parser_v2d::lineHandler() {
// Special code to allow me to goto objects // Special code to allow me to goto objects
if (strstr(_vm->_line, "find")) { if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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))) { 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); _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex);
return; return;
} }
} }
@ -119,7 +119,7 @@ void Parser_v2d::lineHandler() {
// SAVE/RESTORE // SAVE/RESTORE
if (!strcmp("save", _vm->_line)) { if (!strcmp("save", _vm->_line)) {
if (gameStatus.gameOverFl) if (gameStatus._gameOverFl)
_vm->gameOverMsg(); _vm->gameOverMsg();
else else
_vm->_file->saveGame(-1, Common::String()); _vm->_file->saveGame(-1, Common::String());
@ -137,7 +137,7 @@ void Parser_v2d::lineHandler() {
if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return; return;
if (gameStatus.gameOverFl) { if (gameStatus._gameOverFl) {
// No commands allowed! // No commands allowed!
_vm->gameOverMsg(); _vm->gameOverMsg();
return; return;
@ -172,7 +172,7 @@ void Parser_v2d::lineHandler() {
&& !isCatchallVerb_v1(false, noun, verb, _catchallList)) { && !isCatchallVerb_v1(false, noun, verb, _catchallList)) {
if (*farComment != '\0') { // An object matched but not near enough if (*farComment != '\0') { // An object matched but not near enough
Utils::notifyBox(farComment); 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)); Utils::notifyBox(_vm->_text->getTextParser(kTBMaze));
_vm->_object->showTakeables(); _vm->_object->showTakeables();
} else if (verb && noun) { // A combination I didn't think of } else if (verb && noun) { // A combination I didn't think of

View file

@ -60,7 +60,7 @@ void Parser_v3d::lineHandler() {
// Toggle God Mode // Toggle God Mode
if (!strncmp(_vm->_line, "PPG", 3)) { if (!strncmp(_vm->_line, "PPG", 3)) {
_vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh); _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl; gameStatus._godModeFl = !gameStatus._godModeFl;
return; return;
} }
@ -71,7 +71,7 @@ void Parser_v3d::lineHandler() {
// fetch <object name> Hero carries named object // fetch <object name> Hero carries named object
// fetch all Hero carries all possible objects // fetch all Hero carries all possible objects
// find <object name> Takes hero to screen containing named object // 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 // Special code to allow me to go straight to any screen
if (strstr(_vm->_line, "goto")) { if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) { 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 // Special code to allow me to get objects from anywhere
if (strstr(_vm->_line, "fetch all")) { if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
} }
return; return;
@ -93,7 +93,7 @@ void Parser_v3d::lineHandler() {
if (strstr(_vm->_line, "fetch")) { if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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]); takeObject(&_vm->_object->_objects[i]);
return; return;
} }
@ -103,8 +103,8 @@ void Parser_v3d::lineHandler() {
// Special code to allow me to goto objects // Special code to allow me to goto objects
if (strstr(_vm->_line, "find")) { if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) { 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))) { 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); _vm->_scheduler->newScreen(_vm->_object->_objects[i]._screenIndex);
return; return;
} }
} }
@ -121,7 +121,7 @@ void Parser_v3d::lineHandler() {
// SAVE/RESTORE // SAVE/RESTORE
if (!strcmp("save", _vm->_line)) { if (!strcmp("save", _vm->_line)) {
if (gameStatus.gameOverFl) if (gameStatus._gameOverFl)
_vm->gameOverMsg(); _vm->gameOverMsg();
else else
_vm->_file->saveGame(-1, Common::String()); _vm->_file->saveGame(-1, Common::String());
@ -139,7 +139,7 @@ void Parser_v3d::lineHandler() {
if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces! if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return; return;
if (gameStatus.gameOverFl) { if (gameStatus._gameOverFl) {
// No commands allowed! // No commands allowed!
_vm->gameOverMsg(); _vm->gameOverMsg();
return; return;
@ -150,7 +150,7 @@ void Parser_v3d::lineHandler() {
// Test for nearby objects referenced explicitly // Test for nearby objects referenced explicitly
for (int i = 0; i < _vm->_object->_numObj; i++) { for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[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)) if (isObjectVerb_v3(obj, farComment) || isGenericVerb_v3(obj, farComment))
return; return;
} }
@ -160,7 +160,7 @@ void Parser_v3d::lineHandler() {
// Note comment is unused if not near. // Note comment is unused if not near.
for (int i = 0; i < _vm->_object->_numObj; i++) { for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[i]; object_t *obj = &_vm->_object->_objects[i];
if (obj->verbOnlyFl) { if (obj->_verbOnlyFl) {
char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects
if (isObjectVerb_v3(obj, contextComment) || isGenericVerb_v3(obj, contextComment)) if (isObjectVerb_v3(obj, contextComment) || isGenericVerb_v3(obj, contextComment))
return; return;
@ -208,47 +208,47 @@ bool Parser_v3d::isObjectVerb_v3(object_t *obj, char *comment) {
debugC(1, kDebugParser, "isObjectVerb(object_t *obj, %s)", comment); debugC(1, kDebugParser, "isObjectVerb(object_t *obj, %s)", comment);
// First, find matching verb in cmd list // 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 if (cmdIndex == 0) // No commands for this obj
return false; return false;
int i; int i;
for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd 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? if (isWordPresent(_vm->_text->getVerbArray(_cmdList[cmdIndex][i]._verbIndex))) // Was this verb used?
break; break;
} }
if (_cmdList[cmdIndex][i].verbIndex == 0) // No verbs used. if (_cmdList[cmdIndex][i]._verbIndex == 0) // No verbs used.
return false; return false;
// Verb match found. Check if object is Near // 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)) if (!isNear_v3(obj, verb, comment))
return false; return false;
// Check all required objects are being carried // Check all required objects are being carried
cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd
if (cmnd->reqIndex) { // At least 1 thing in list if (cmnd->_reqIndex) { // At least 1 thing in list
uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects uint16 *reqs = _arrayReqs[cmnd->_reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) { // for each obj for (i = 0; reqs[i]; i++) { // for each obj
if (!_vm->_object->isCarrying(reqs[i])) { if (!_vm->_object->isCarrying(reqs[i])) {
Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataNoCarryIndex)); Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataNoCarryIndex));
return true; return true;
} }
} }
} }
// Required objects are present, now check state is correct // Required objects are present, now check state is correct
if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)) { if ((obj->_state != cmnd->_reqState) && (cmnd->_reqState != kStateDontCare)) {
Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataWrongIndex)); Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataWrongIndex));
return true; return true;
} }
// Everything checked. Change the state and carry out any actions // 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 if (cmnd->_reqState != kStateDontCare) // Don't change new state if required state didn't care
obj->state = cmnd->newState; obj->_state = cmnd->_newState;
Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataDoneIndex)); Utils::notifyBox(_vm->_text->getTextData(cmnd->_textDataDoneIndex));
_vm->_scheduler->insertActionList(cmnd->actIndex); _vm->_scheduler->insertActionList(cmnd->_actIndex);
// See if any additional generic actions // 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))) 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) { bool Parser_v3d::isGenericVerb_v3(object_t *obj, char *comment) {
debugC(1, kDebugParser, "isGenericVerb(object_t *obj, %s)", comment); debugC(1, kDebugParser, "isGenericVerb(object_t *obj, %s)", comment);
if (!obj->genericCmd) if (!obj->_genericCmd)
return false; return false;
// Following is equivalent to switch, but couldn't do one // 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)) { if (isWordPresent(_vm->_text->getVerbArray(_vm->_look)) && isNear_v3(obj, _vm->_text->getVerb(_vm->_look, 0), comment)) {
// Test state-dependent look before general look // Test state-dependent look before general look
if ((obj->genericCmd & LOOK_S) == LOOK_S) { if ((obj->_genericCmd & LOOK_S) == LOOK_S) {
Utils::notifyBox(_vm->_text->getTextData(obj->stateDataIndex[obj->state])); Utils::notifyBox(_vm->_text->getTextData(obj->_stateDataIndex[obj->_state]));
} else { } else {
if ((LOOK & obj->genericCmd) == LOOK) { if ((LOOK & obj->_genericCmd) == LOOK) {
if (obj->dataIndex != 0) if (obj->_dataIndex != 0)
Utils::notifyBox(_vm->_text->getTextData(obj->dataIndex)); Utils::notifyBox(_vm->_text->getTextData(obj->_dataIndex));
else else
return false; return false;
} else { } 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)) { } 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)); Utils::notifyBox(_vm->_text->getTextParser(kTBHave));
else if ((TAKE & obj->genericCmd) == TAKE) else if ((TAKE & obj->_genericCmd) == TAKE)
takeObject(obj); takeObject(obj);
else if (obj->cmdIndex) // No comment if possible commands else if (obj->_cmdIndex) // No comment if possible commands
return false; 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)); Utils::notifyBox(_vm->_text->getTextParser(kTBNoUse));
else else
return false; return false;
} else if (isWordPresent(_vm->_text->getVerbArray(_vm->_drop))) { } 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)); Utils::notifyBox(_vm->_text->getTextParser(kTBDontHave));
else if (obj->carriedFl && ((DROP & obj->genericCmd) == DROP)) else if (obj->_carriedFl && ((DROP & obj->_genericCmd) == DROP))
dropObject(obj); dropObject(obj);
else if (obj->cmdIndex == 0) else if (obj->_cmdIndex == 0)
Utils::notifyBox(_vm->_text->getTextParser(kTBNeed)); Utils::notifyBox(_vm->_text->getTextParser(kTBNeed));
else else
return false; 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 { 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); 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; return true;
if (obj->screenIndex != *_vm->_screen_p) { if (obj->_screenIndex != *_vm->_screen_p) {
// Not in same screen // Not in same screen
if (obj->objValue) if (obj->_objValue)
strcpy(comment, _vm->_text->getTextParser(kCmtAny1)); strcpy(comment, _vm->_text->getTextParser(kCmtAny1));
else else
strcpy(comment, _vm->_text->getTextParser(kCmtAny2)); strcpy(comment, _vm->_text->getTextParser(kCmtAny2));
return false; return false;
} }
if (obj->cycling == kCycleInvisible) { if (obj->_cycling == kCycleInvisible) {
if (obj->seqNumb) { if (obj->_seqNumb) {
// There is an image // There is an image
strcpy(comment, _vm->_text->getTextParser(kCmtAny3)); strcpy(comment, _vm->_text->getTextParser(kCmtAny3));
return false; return false;
} else { } else {
// No image, assume visible // No image, assume visible
if ((obj->radius < 0) || if ((obj->_radius < 0) ||
((abs(obj->x - _vm->_hero->x) <= obj->radius) && ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) &&
(abs(obj->y - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { (abs(obj->_y - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) {
return true; return true;
} else { } else {
// User is not close enough // 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)); strcpy(comment, _vm->_text->getTextParser(kCmtAny1));
else else
strcpy(comment, _vm->_text->getTextParser(kCmtClose)); 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) || if ((obj->_radius < 0) ||
((abs(obj->x - _vm->_hero->x) <= obj->radius) && ((abs(obj->_x - _vm->_hero->_x) <= obj->_radius) &&
(abs(obj->y + obj->currImagePtr->y2 - _vm->_hero->y - _vm->_hero->currImagePtr->y2) <= obj->radius))) { (abs(obj->_y + obj->_currImagePtr->_y2 - _vm->_hero->_y - _vm->_hero->_currImagePtr->_y2) <= obj->_radius))) {
return true; return true;
} else { } else {
// User is not close enough // 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)); strcpy(comment, _vm->_text->getTextParser(kCmtAny1));
else else
strcpy(comment, _vm->_text->getTextParser(kCmtClose)); 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) { void Parser_v3d::takeObject(object_t *obj) {
debugC(1, kDebugParser, "takeObject(object_t *obj)"); debugC(1, kDebugParser, "takeObject(object_t *obj)");
obj->carriedFl = true; obj->_carriedFl = true;
if (obj->seqNumb) { // Don't change if no image to display if (obj->_seqNumb) { // Don't change if no image to display
obj->cycling = kCycleInvisible; obj->_cycling = kCycleInvisible;
} }
_vm->adjustScore(obj->objValue); _vm->adjustScore(obj->_objValue);
if (obj->seqNumb > 0) // If object has an image, force walk to dropped if (obj->_seqNumb > 0) // If object has an image, force walk to dropped
obj->viewx = -1; // (possibly moved) object next time taken! obj->_viewx = -1; // (possibly moved) object next time taken!
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)));
} }
/** /**
@ -388,16 +388,16 @@ void Parser_v3d::takeObject(object_t *obj) {
void Parser_v3d::dropObject(object_t *obj) { void Parser_v3d::dropObject(object_t *obj) {
debugC(1, kDebugParser, "dropObject(object_t *obj)"); debugC(1, kDebugParser, "dropObject(object_t *obj)");
obj->carriedFl = false; obj->_carriedFl = false;
obj->screenIndex = *_vm->_screen_p; obj->_screenIndex = *_vm->_screen_p;
if ((obj->seqNumb > 1) || (obj->seqList[0].imageNbr > 1)) if ((obj->_seqNumb > 1) || (obj->_seqList[0]._imageNbr > 1))
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
else else
obj->cycling = kCycleNotCycling; obj->_cycling = kCycleNotCycling;
obj->x = _vm->_hero->x - 1; obj->_x = _vm->_hero->_x - 1;
obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 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; obj->_y = (obj->_y + obj->_currImagePtr->_y2 < kYPix) ? obj->_y : kYPix - obj->_currImagePtr->_y2 - 10;
_vm->adjustScore(-obj->objValue); _vm->adjustScore(-obj->_objValue);
Utils::notifyBox(_vm->_text->getTextParser(kTBOk)); 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 { bool Parser_v3d::isCatchallVerb_v3(objectList_t obj) const {
debugC(1, kDebugParser, "isCatchallVerb(object_list_t obj)"); debugC(1, kDebugParser, "isCatchallVerb(object_list_t obj)");
if (_vm->_maze.enabledFl) if (_vm->_maze._enabledFl)
return false; return false;
for (int i = 0; obj[i].verbIndex != 0; i++) { for (int i = 0; obj[i]._verbIndex != 0; i++) {
if (isWordPresent(_vm->_text->getVerbArray(obj[i].verbIndex)) && obj[i].nounIndex == 0 && if (isWordPresent(_vm->_text->getVerbArray(obj[i]._verbIndex)) && obj[i]._nounIndex == 0 &&
(!obj[i].matchFl || !findNoun()) && (!obj[i]._matchFl || !findNoun()) &&
((obj[i].roomState == kStateDontCare) || ((obj[i]._roomState == kStateDontCare) ||
(obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) { (obj[i]._roomState == _vm->_screenStates[*_vm->_screen_p]))) {
Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex));
_vm->_scheduler->processBonus(obj[i].bonusIndex); _vm->_scheduler->processBonus(obj[i]._bonusIndex);
// If this is LOOK (without a noun), show any takeable objects // 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(); _vm->_object->showTakeables();
return true; return true;
@ -438,16 +438,16 @@ bool Parser_v3d::isCatchallVerb_v3(objectList_t obj) const {
bool Parser_v3d::isBackgroundWord_v3(objectList_t obj) const { bool Parser_v3d::isBackgroundWord_v3(objectList_t obj) const {
debugC(1, kDebugParser, "isBackgroundWord(object_list_t obj)"); debugC(1, kDebugParser, "isBackgroundWord(object_list_t obj)");
if (_vm->_maze.enabledFl) if (_vm->_maze._enabledFl)
return false; return false;
for (int i = 0; obj[i].verbIndex != 0; i++) { for (int i = 0; obj[i]._verbIndex != 0; i++) {
if (isWordPresent(_vm->_text->getVerbArray(obj[i].verbIndex)) && if (isWordPresent(_vm->_text->getVerbArray(obj[i]._verbIndex)) &&
isWordPresent(_vm->_text->getNounArray(obj[i].nounIndex)) && isWordPresent(_vm->_text->getNounArray(obj[i]._nounIndex)) &&
((obj[i].roomState == kStateDontCare) || ((obj[i]._roomState == kStateDontCare) ||
(obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) { (obj[i]._roomState == _vm->_screenStates[*_vm->_screen_p]))) {
Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); Utils::notifyBox(_vm->_file->fetchString(obj[i]._commentIndex));
_vm->_scheduler->processBonus(obj[i].bonusIndex); _vm->_scheduler->processBonus(obj[i]._bonusIndex);
return true; return true;
} }
} }

View file

@ -67,35 +67,35 @@ void Route::setDirection(const uint16 keyCode) {
switch (keyCode) { switch (keyCode) {
case Common::KEYCODE_UP: case Common::KEYCODE_UP:
case Common::KEYCODE_KP8: case Common::KEYCODE_KP8:
obj->currImagePtr = obj->seqList[SEQ_UP].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_UP]._seqPtr;
break; break;
case Common::KEYCODE_DOWN: case Common::KEYCODE_DOWN:
case Common::KEYCODE_KP2: case Common::KEYCODE_KP2:
obj->currImagePtr = obj->seqList[SEQ_DOWN].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_DOWN]._seqPtr;
break; break;
case Common::KEYCODE_LEFT: case Common::KEYCODE_LEFT:
case Common::KEYCODE_KP4: case Common::KEYCODE_KP4:
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
break; break;
case Common::KEYCODE_RIGHT: case Common::KEYCODE_RIGHT:
case Common::KEYCODE_KP6: case Common::KEYCODE_KP6:
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
break; break;
case Common::KEYCODE_HOME: case Common::KEYCODE_HOME:
case Common::KEYCODE_KP7: case Common::KEYCODE_KP7:
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
break; break;
case Common::KEYCODE_END: case Common::KEYCODE_END:
case Common::KEYCODE_KP1: case Common::KEYCODE_KP1:
obj->currImagePtr = obj->seqList[SEQ_LEFT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_LEFT]._seqPtr;
break; break;
case Common::KEYCODE_PAGEUP: case Common::KEYCODE_PAGEUP:
case Common::KEYCODE_KP9: case Common::KEYCODE_KP9:
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
break; break;
case Common::KEYCODE_PAGEDOWN: case Common::KEYCODE_PAGEDOWN:
case Common::KEYCODE_KP3: case Common::KEYCODE_KP3:
obj->currImagePtr = obj->seqList[SEQ_RIGHT].seqPtr; obj->_currImagePtr = obj->_seqList[SEQ_RIGHT]._seqPtr;
break; break;
} }
} }
@ -109,66 +109,66 @@ void Route::setWalk(const uint16 direction) {
object_t *obj = _vm->_hero; // Pointer to hero object 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; return;
if (!obj->vx && !obj->vy) if (!obj->_vx && !obj->_vy)
_oldWalkDirection = 0; // Fix for consistant restarts _oldWalkDirection = 0; // Fix for consistant restarts
if (direction != _oldWalkDirection) { if (direction != _oldWalkDirection) {
// Direction has changed // Direction has changed
setDirection(direction); // Face new direction setDirection(direction); // Face new direction
obj->vx = obj->vy = 0; obj->_vx = obj->_vy = 0;
switch (direction) { // And set correct velocity switch (direction) { // And set correct velocity
case Common::KEYCODE_UP: case Common::KEYCODE_UP:
case Common::KEYCODE_KP8: case Common::KEYCODE_KP8:
obj->vy = -kStepDy; obj->_vy = -kStepDy;
break; break;
case Common::KEYCODE_DOWN: case Common::KEYCODE_DOWN:
case Common::KEYCODE_KP2: case Common::KEYCODE_KP2:
obj->vy = kStepDy; obj->_vy = kStepDy;
break; break;
case Common::KEYCODE_LEFT: case Common::KEYCODE_LEFT:
case Common::KEYCODE_KP4: case Common::KEYCODE_KP4:
obj->vx = -kStepDx; obj->_vx = -kStepDx;
break; break;
case Common::KEYCODE_RIGHT: case Common::KEYCODE_RIGHT:
case Common::KEYCODE_KP6: case Common::KEYCODE_KP6:
obj->vx = kStepDx; obj->_vx = kStepDx;
break; break;
case Common::KEYCODE_HOME: case Common::KEYCODE_HOME:
case Common::KEYCODE_KP7: case Common::KEYCODE_KP7:
obj->vx = -kStepDx; obj->_vx = -kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to DY // Note: in v1 Dos and v2 Dos, obj->vy is set to DY
obj->vy = -kStepDy / 2; obj->_vy = -kStepDy / 2;
break; break;
case Common::KEYCODE_END: case Common::KEYCODE_END:
case Common::KEYCODE_KP1: case Common::KEYCODE_KP1:
obj->vx = -kStepDx; obj->_vx = -kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to -DY // Note: in v1 Dos and v2 Dos, obj->vy is set to -DY
obj->vy = kStepDy / 2; obj->_vy = kStepDy / 2;
break; break;
case Common::KEYCODE_PAGEUP: case Common::KEYCODE_PAGEUP:
case Common::KEYCODE_KP9: case Common::KEYCODE_KP9:
obj->vx = kStepDx; obj->_vx = kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to -DY // Note: in v1 Dos and v2 Dos, obj->vy is set to -DY
obj->vy = -kStepDy / 2; obj->_vy = -kStepDy / 2;
break; break;
case Common::KEYCODE_PAGEDOWN: case Common::KEYCODE_PAGEDOWN:
case Common::KEYCODE_KP3: case Common::KEYCODE_KP3:
obj->vx = kStepDx; obj->_vx = kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to DY // Note: in v1 Dos and v2 Dos, obj->vy is set to DY
obj->vy = kStepDy / 2; obj->_vy = kStepDy / 2;
break; break;
} }
_oldWalkDirection = direction; _oldWalkDirection = direction;
obj->cycling = kCycleForward; obj->_cycling = kCycleForward;
} else { } else {
// Same key twice - halt hero // Same key twice - halt hero
obj->vy = 0; obj->_vy = 0;
obj->vx = 0; obj->_vx = 0;
_oldWalkDirection = 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) if (y <= 0 || y >= kYPix - 1)
return; return;
if (_vm->_hero->x < x1) { if (_vm->_hero->_x < x1) {
// Hero x not in segment, search x1..x2 // Hero x not in segment, search x1..x2
// Find all segments above current // Find all segments above current
for (x = x1; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x <= x2; x++) { 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) if (_boundaryMap[y + 1][x] == 0)
segment(x, y + 1); 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 // Hero x not in segment, search x1..x2
// Find all segments above current // Find all segments above current
for (x = x2; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x >= x1; x--) { for (x = x2; !(_routeFoundFl || _fullStackFl || _fullSegmentFl) && x >= x1; x--) {
@ -257,22 +257,22 @@ void Route::segment(int16 x, int16 y) {
} else { } else {
// Organize search around hero x position - this gives // Organize search around hero x position - this gives
// better chance for more direct route. // 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) if (_boundaryMap[y - 1][x] == 0)
segment(x, y - 1); 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) if (_boundaryMap[y - 1][x] == 0)
segment(x, y - 1); 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) if (_boundaryMap[y + 1][x] == 0)
segment(x, y + 1); 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) if (_boundaryMap[y + 1][x] == 0)
segment(x, y + 1); segment(x, y + 1);
} }
@ -327,16 +327,16 @@ bool Route::findRoute(const int16 cx, const int16 cy) {
_destY = cy; // Destination coords _destY = cy; // Destination coords
_destX = cx; // Destination coords _destX = cx; // Destination coords
int16 herox1 = _vm->_hero->x + _vm->_hero->currImagePtr->x1; // 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 herox2 = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x2; // Hero baseline
int16 heroy = _vm->_hero->y + _vm->_hero->currImagePtr->y2; // Hero baseline int16 heroy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2; // Hero baseline
// Store all object baselines into objbound (except hero's = [0]) // Store all object baselines into objbound (except hero's = [0])
object_t *obj; // Ptr to object object_t *obj; // Ptr to object
int i; int i;
for (i = 1, obj = &_vm->_object->_objects[i]; i < _vm->_object->_numObj; i++, obj++) { 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)) 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); _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 // 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 // Clear all object baselines from objbound
for (i = 0, obj = _vm->_object->_objects; i < _vm->_object->_numObj; i++, obj++) { 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)) 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); _vm->_object->clearBoundary(obj->_oldx + obj->_currImagePtr->_x1, obj->_oldx + obj->_currImagePtr->_x2, obj->_oldy + obj->_currImagePtr->_y2);
} }
// Search from hero to destination // Search from hero to destination
@ -433,18 +433,18 @@ void Route::processRoute() {
return; return;
// Current hero position // Current hero position
int16 herox = _vm->_hero->x + _vm->_hero->currImagePtr->x1; int16 herox = _vm->_hero->_x + _vm->_hero->_currImagePtr->_x1;
int16 heroy = _vm->_hero->y + _vm->_hero->currImagePtr->y2; int16 heroy = _vm->_hero->_y + _vm->_hero->_currImagePtr->_y2;
Point *routeNode = &_route[_routeIndex]; Point *routeNode = &_route[_routeIndex];
// Arrived at node? // Arrived at node?
if (abs(herox - routeNode->x) < kStepDx + 1 && abs(heroy - routeNode->y) < kStepDy) { if (abs(herox - routeNode->x) < kStepDx + 1 && abs(heroy - routeNode->y) < kStepDy) {
// kStepDx too low // kStepDx too low
// Close enough - position hero exactly // Close enough - position hero exactly
_vm->_hero->x = _vm->_hero->oldx = routeNode->x - _vm->_hero->currImagePtr->x1; _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->_y = _vm->_hero->_oldy = routeNode->y - _vm->_hero->_currImagePtr->_y2;
_vm->_hero->vx = _vm->_hero->vy = 0; _vm->_hero->_vx = _vm->_hero->_vy = 0;
_vm->_hero->cycling = kCycleNotCycling; _vm->_hero->_cycling = kCycleNotCycling;
// Arrived at final node? // Arrived at final node?
if (--_routeIndex < 0) { if (--_routeIndex < 0) {
@ -458,7 +458,7 @@ void Route::processRoute() {
_vm->_object->lookObject(&_vm->_object->_objects[_routeObjId]); _vm->_object->lookObject(&_vm->_object->_objects[_routeObjId]);
turnedFl = false; turnedFl = false;
} else { } else {
setDirection(_vm->_object->_objects[_routeObjId].direction); setDirection(_vm->_object->_objects[_routeObjId]._direction);
_routeIndex++; // Come round again _routeIndex++; // Come round again
turnedFl = true; turnedFl = true;
} }
@ -468,7 +468,7 @@ void Route::processRoute() {
_vm->_object->useObject(_routeObjId); _vm->_object->useObject(_routeObjId);
turnedFl = false; turnedFl = false;
} else { } else {
setDirection(_vm->_object->_objects[_routeObjId].direction); setDirection(_vm->_object->_objects[_routeObjId]._direction);
_routeIndex++; // Come round again _routeIndex++; // Come round again
turnedFl = true; turnedFl = true;
} }
@ -477,7 +477,7 @@ void Route::processRoute() {
break; 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 // Set direction of travel if at a node
// Note realignment when changing to (thinner) up/down sprite, // Note realignment when changing to (thinner) up/down sprite,
// otherwise hero could bump into boundaries along route. // otherwise hero could bump into boundaries along route.
@ -487,10 +487,10 @@ void Route::processRoute() {
setWalk(Common::KEYCODE_LEFT); setWalk(Common::KEYCODE_LEFT);
} else if (heroy < routeNode->y) { } else if (heroy < routeNode->y) {
setWalk(Common::KEYCODE_DOWN); 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) { } else if (heroy > routeNode->y) {
setWalk(Common::KEYCODE_UP); 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); debugC(1, kDebugRoute, "startRoute(%d, %d, %d, %d)", routeType, objId, cx, cy);
// Don't attempt to walk if user does not have control // Don't attempt to walk if user does not have control
if (_vm->_hero->pathType != kPathUser) if (_vm->_hero->_pathType != kPathUser)
return false; return false;
// if inventory showing, make it go away // 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 bool foundFl = false; // TRUE if route found ok
if ((foundFl = findRoute(cx, cy))) { // Found a route? if ((foundFl = findRoute(cx, cy))) { // Found a route?
_routeIndex = _routeListIndex; // Node index _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; return foundFl;

View file

@ -112,7 +112,7 @@ void Scheduler::insertActionList(const uint16 actIndex) {
uint32 Scheduler::getWinTicks() const { uint32 Scheduler::getWinTicks() const {
debugC(5, kDebugSchedule, "getWinTicks()"); 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) { void Scheduler::processMaze(const int x1, const int x2, const int y1, const int y2) {
debugC(1, kDebugSchedule, "processMaze"); debugC(1, kDebugSchedule, "processMaze");
if (x1 < _vm->_maze.x1) { if (x1 < _vm->_maze._x1) {
// Exit west // Exit west
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - 1; _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - 1;
_actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x2 - kShiftSize - (x2 - x1); _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x2 - kShiftSize - (x2 - x1);
_actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y; _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->_y;
_vm->_route->resetRoute(); _vm->_route->resetRoute();
insertActionList(_alNewscrIndex); insertActionList(_alNewscrIndex);
} else if (x2 > _vm->_maze.x2) { } else if (x2 > _vm->_maze._x2) {
// Exit east // Exit east
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + 1; _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + 1;
_actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x1 + kShiftSize; _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x1 + kShiftSize;
_actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y; _actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->_y;
_vm->_route->resetRoute(); _vm->_route->resetRoute();
insertActionList(_alNewscrIndex); insertActionList(_alNewscrIndex);
} else if (y1 < _vm->_maze.y1 - kShiftSize) { } else if (y1 < _vm->_maze._y1 - kShiftSize) {
// Exit north // Exit north
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _vm->_maze.size; _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _vm->_maze._size;
_actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x3; _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x3;
_actListArr[_alNewscrIndex][0].a2.y = _vm->_maze.y2 - kShiftSize - (y2 - y1); _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze._y2 - kShiftSize - (y2 - y1);
_vm->_route->resetRoute(); _vm->_route->resetRoute();
insertActionList(_alNewscrIndex); insertActionList(_alNewscrIndex);
} else if (y2 > _vm->_maze.y2 - kShiftSize / 2) { } else if (y2 > _vm->_maze._y2 - kShiftSize / 2) {
// Exit south // Exit south
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _vm->_maze.size; _actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _vm->_maze._size;
_actListArr[_alNewscrIndex][0].a2.x = _vm->_maze.x4; _actListArr[_alNewscrIndex][0].a2.x = _vm->_maze._x4;
_actListArr[_alNewscrIndex][0].a2.y = _vm->_maze.y1 + kShiftSize; _actListArr[_alNewscrIndex][0].a2.y = _vm->_maze._y1 + kShiftSize;
_vm->_route->resetRoute(); _vm->_route->resetRoute();
insertActionList(_alNewscrIndex); insertActionList(_alNewscrIndex);
} }
@ -1144,7 +1144,7 @@ void Scheduler::insertAction(act *action) {
break; break;
// Workaround: When dying, switch to storyMode in order to block the keyboard. // Workaround: When dying, switch to storyMode in order to block the keyboard.
case GAMEOVER: case GAMEOVER:
_vm->getGameStatus().storyModeFl = true; _vm->getGameStatus()._storyModeFl = true;
// No break on purpose // No break on purpose
default: default:
curEvent->localActionFl = true; // Rest are for current screen only curEvent->localActionFl = true; // Rest are for current screen only
@ -1205,12 +1205,12 @@ event_t *Scheduler::doAction(event_t *curEvent) {
insertActionList(action->a0.actIndex); insertActionList(action->a0.actIndex);
break; break;
case START_OBJ: // act1: Start an object cycling case START_OBJ: // act1: Start an object cycling
_vm->_object->_objects[action->a1.objIndex].cycleNumb = action->a1.cycleNumb; _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]._cycling = action->a1.cycle;
break; break;
case INIT_OBJXY: // act2: Initialize an object case INIT_OBJXY: // act2: Initialize an object
_vm->_object->_objects[action->a2.objIndex].x = action->a2.x; // Coordinates _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]._y = action->a2.y;
break; break;
case PROMPT: // act3: Prompt user for key phrase case PROMPT: // act3: Prompt user for key phrase
promptAction(action); promptAction(action);
@ -1225,21 +1225,21 @@ event_t *Scheduler::doAction(event_t *curEvent) {
_vm->_object->setCarry(action->a6.objIndex, action->a6.carriedFl); // carried status _vm->_object->setCarry(action->a6.objIndex, action->a6.carriedFl); // carried status
break; break;
case INIT_HF_COORD: // act7: Initialize an object to hero's "feet" coords 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]._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]._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]._screenIndex = *_vm->_screen_p; // Don't forget screen!
break; break;
case NEW_SCREEN: // act8: Start new screen case NEW_SCREEN: // act8: Start new screen
newScreen(action->a8.screenIndex); newScreen(action->a8.screenIndex);
break; break;
case INIT_OBJSTATE: // act9: Initialize an object state 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; break;
case INIT_PATH: // act10: Initialize an object path and velocity 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); _vm->_object->setPath(action->a10.objIndex, (path_t) action->a10.newPathType, action->a10.vxPath, action->a10.vyPath);
break; break;
case COND_R: // act11: action lists conditional on object state 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); insertActionList(action->a11.actPassIndex);
else else
insertActionList(action->a11.actFailIndex); insertActionList(action->a11.actFailIndex);
@ -1251,7 +1251,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
_vm->_object->swapImages(action->a13.objIndex1, action->a13.objIndex2); _vm->_object->swapImages(action->a13.objIndex1, action->a13.objIndex2);
break; break;
case COND_SCR: // act14: Conditional on current screen 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); insertActionList(action->a14.actPassIndex);
else else
insertActionList(action->a14.actFailIndex); 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 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 // 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 // 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; break;
case SET_STATE_BITS: // act17: OR mask with curr obj state 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; break;
case CLEAR_STATE_BITS: // act18: AND ~mask with curr obj state 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; break;
case TEST_STATE_BITS: // act19: If all bits set, do apass else afail 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); insertActionList(action->a19.actPassIndex);
else else
insertActionList(action->a19.actFailIndex); insertActionList(action->a19.actFailIndex);
@ -1282,12 +1282,12 @@ event_t *Scheduler::doAction(event_t *curEvent) {
case GAMEOVER: // act21: Game over! case GAMEOVER: // act21: Game over!
// NOTE: Must wait at least 1 tick before issuing this action if // NOTE: Must wait at least 1 tick before issuing this action if
// any objects are to be made invisible! // any objects are to be made invisible!
gameStatus.gameOverFl = true; gameStatus._gameOverFl = true;
break; break;
case INIT_HH_COORD: // act22: Initialize an object to hero's actual coords 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]._x = _vm->_hero->_x;
_vm->_object->_objects[action->a22.objIndex].y = _vm->_hero->y; _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]._screenIndex = *_vm->_screen_p;// Don't forget screen!
break; break;
case EXIT: // act23: Exit game back to DOS case EXIT: // act23: Exit game back to DOS
_vm->endGame(); _vm->endGame();
@ -1297,8 +1297,8 @@ event_t *Scheduler::doAction(event_t *curEvent) {
break; break;
case COND_BOX: // act25: Conditional on bounding box case COND_BOX: // act25: Conditional on bounding box
obj1 = &_vm->_object->_objects[action->a25.objIndex]; obj1 = &_vm->_object->_objects[action->a25.objIndex];
dx = obj1->x + obj1->currImagePtr->x1; dx = obj1->_x + obj1->_currImagePtr->_x1;
dy = obj1->y + obj1->currImagePtr->y2; dy = obj1->_y + obj1->_currImagePtr->_y2;
if ((dx >= action->a25.x1) && (dx <= action->a25.x2) && if ((dx >= action->a25.x1) && (dx <= action->a25.x2) &&
(dy >= action->a25.y1) && (dy <= action->a25.y2)) (dy >= action->a25.y1) && (dy <= action->a25.y2))
insertActionList(action->a25.actPassIndex); insertActionList(action->a25.actPassIndex);
@ -1312,10 +1312,10 @@ event_t *Scheduler::doAction(event_t *curEvent) {
_vm->_sound->playSound(action->a26.soundIndex, kSoundPriorityMedium); _vm->_sound->playSound(action->a26.soundIndex, kSoundPriorityMedium);
break; break;
case ADD_SCORE: // act27: Add object's value to score 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; break;
case SUB_SCORE: // act28: Subtract object's value from score 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; break;
case COND_CARRY: // act29: Conditional on object being carried case COND_CARRY: // act29: Conditional on object being carried
if (_vm->_object->isCarried(action->a29.objIndex)) if (_vm->_object->isCarried(action->a29.objIndex))
@ -1324,24 +1324,24 @@ event_t *Scheduler::doAction(event_t *curEvent) {
insertActionList(action->a29.actFailIndex); insertActionList(action->a29.actFailIndex);
break; break;
case INIT_MAZE: // act30: Enable and init maze structure case INIT_MAZE: // act30: Enable and init maze structure
_vm->_maze.enabledFl = true; _vm->_maze._enabledFl = true;
_vm->_maze.size = action->a30.mazeSize; _vm->_maze._size = action->a30.mazeSize;
_vm->_maze.x1 = action->a30.x1; _vm->_maze._x1 = action->a30.x1;
_vm->_maze.y1 = action->a30.y1; _vm->_maze._y1 = action->a30.y1;
_vm->_maze.x2 = action->a30.x2; _vm->_maze._x2 = action->a30.x2;
_vm->_maze.y2 = action->a30.y2; _vm->_maze._y2 = action->a30.y2;
_vm->_maze.x3 = action->a30.x3; _vm->_maze._x3 = action->a30.x3;
_vm->_maze.x4 = action->a30.x4; _vm->_maze._x4 = action->a30.x4;
_vm->_maze.firstScreenIndex = action->a30.firstScreenIndex; _vm->_maze._firstScreenIndex = action->a30.firstScreenIndex;
break; break;
case EXIT_MAZE: // act31: Disable maze mode case EXIT_MAZE: // act31: Disable maze mode
_vm->_maze.enabledFl = false; _vm->_maze._enabledFl = false;
break; break;
case INIT_PRIORITY: case INIT_PRIORITY:
_vm->_object->_objects[action->a32.objIndex].priority = action->a32.priority; _vm->_object->_objects[action->a32.objIndex]._priority = action->a32.priority;
break; break;
case INIT_SCREEN: case INIT_SCREEN:
_vm->_object->_objects[action->a33.objIndex].screenIndex = action->a33.screenIndex; _vm->_object->_objects[action->a33.objIndex]._screenIndex = action->a33.screenIndex;
break; break;
case AGSCHEDULE: // act34: Schedule a (global) action list case AGSCHEDULE: // act34: Schedule a (global) action list
insertActionList(action->a34.actIndex); insertActionList(action->a34.actIndex);
@ -1359,15 +1359,15 @@ event_t *Scheduler::doAction(event_t *curEvent) {
_vm->_screenStates[action->a37.screenIndex] = action->a37.newState; _vm->_screenStates[action->a37.screenIndex] = action->a37.newState;
break; break;
case INIT_LIPS: // act38: Position lips on object 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]._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]._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]._screenIndex = *_vm->_screen_p; // Don't forget screen!
_vm->_object->_objects[action->a38.lipsObjIndex].cycling = kCycleForward; _vm->_object->_objects[action->a38.lipsObjIndex]._cycling = kCycleForward;
break; break;
case INIT_STORY_MODE: // act39: Init story_mode flag case INIT_STORY_MODE: // act39: Init story_mode flag
// This is similar to the QUIET path mode, except that it is // This is similar to the QUIET path mode, except that it is
// independant of it and it additionally disables the ">" prompt // independant of it and it additionally disables the ">" prompt
gameStatus.storyModeFl = action->a39.storyModeFl; gameStatus._storyModeFl = action->a39.storyModeFl;
break; break;
case WARN: // act40: Text box (CF TEXT) case WARN: // act40: Text box (CF TEXT)
Utils::notifyBox(_vm->_file->fetchString(action->a40.stringIndex)); Utils::notifyBox(_vm->_file->fetchString(action->a40.stringIndex));
@ -1379,7 +1379,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
insertActionList(action->a41.actFailIndex); insertActionList(action->a41.actFailIndex);
break; break;
case TEXT_TAKE: // act42: Text box with "take" message 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; break;
case YESNO: // act43: Prompt user for Yes or No case YESNO: // act43: Prompt user for Yes or No
if (Utils::yesNoBox(_vm->_file->fetchString(action->a43.promptIndex))) 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); _vm->_mouse->setJumpExitFl(action->a46.jumpExitFl);
break; break;
case INIT_VIEW: // act47: Init object.viewx, viewy, dir 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]._viewx = action->a47.viewx;
_vm->_object->_objects[action->a47.objIndex].viewy = action->a47.viewy; _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]._direction = action->a47.direction;
break; break;
case INIT_OBJ_FRAME: // act48: Set seq,frame number to use 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 // 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 // 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++) 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; break;
case OLD_SONG: case OLD_SONG:
// Replaces ACT26 for DOS games. // Replaces ACT26 for DOS games.
@ -1644,6 +1644,6 @@ void Scheduler_v1w::runScheduler() {
while (curEvent && (curEvent->time <= ticker)) // While mature events found while (curEvent && (curEvent->time <= ticker)) // While mature events found
curEvent = doAction(curEvent); // Perform the action (returns next_p) 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 } // End of namespace Hugo

View file

@ -186,7 +186,7 @@ void SoundHandler::playMusic(int16 tune) {
uint16 size; // Size of sequence data uint16 size; // Size of sequence data
if (_vm->_config.musicFl) { if (_vm->_config.musicFl) {
_vm->getGameStatus().song = tune; _vm->getGameStatus()._song = tune;
seqPtr = _vm->_file->getSound(tune, &size); seqPtr = _vm->_file->getSound(tune, &size);
playMIDI(seqPtr, size); playMIDI(seqPtr, size);
free(seqPtr); free(seqPtr);
@ -245,7 +245,7 @@ void SoundHandler::checkMusic() {
return; return;
for (int i = 0; _vm->_defltTunes[i] != -1; i++) { 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) if (_vm->_defltTunes[i + 1] != -1)
playMusic(_vm->_defltTunes[i + 1]); playMusic(_vm->_defltTunes[i + 1]);
else else