From 3f6496d5b5b2caf0b935b27bca557ae53a880302 Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Sun, 23 Jan 2011 00:05:52 +0000 Subject: HUGO: Cleanup Suppress almost all defines, rename constants svn-id: r55451 --- engines/hugo/object_v1w.cpp | 93 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 47 deletions(-) (limited to 'engines/hugo/object_v1w.cpp') diff --git a/engines/hugo/object_v1w.cpp b/engines/hugo/object_v1w.cpp index e5716f8b8c..e93244536f 100644 --- a/engines/hugo/object_v1w.cpp +++ b/engines/hugo/object_v1w.cpp @@ -33,10 +33,9 @@ #include "common/system.h" #include "common/random.h" -#include "hugo/game.h" #include "hugo/hugo.h" +#include "hugo/game.h" #include "hugo/object.h" -#include "hugo/global.h" #include "hugo/display.h" #include "hugo/file.h" #include "hugo/route.h" @@ -63,11 +62,11 @@ void ObjectHandler_v1w::updateImages() { // Initialise the index array to visible objects in current screen int num_objs = 0; - byte objindex[MAXOBJECTS]; // Array of indeces to objects + byte objindex[kMaxObjNumb]; // Array of indeces to objects for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= ALMOST_INVISIBLE)) + if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= kCycleAlmostInvisible)) objindex[num_objs++] = i; } @@ -81,24 +80,24 @@ void ObjectHandler_v1w::updateImages() { if (obj->frameTimer) obj->frameTimer--; - if (obj->cycling > ALMOST_INVISIBLE) { // Only if visible + if (obj->cycling > kCycleAlmostInvisible) { // Only if visible switch (obj->cycling) { - case NOT_CYCLING: - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL); + case kCycleNotCycling: + _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); break; - case CYCLE_FORWARD: + case kCycleForward: if (obj->frameTimer) // Not time to see next frame yet - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL); + _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay); else - _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == OVEROVL); + _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == kPriorityOverOverlay); break; - case CYCLE_BACKWARD: { + case kCycleBackward: { seq_t *seqPtr = obj->currImagePtr; if (!obj->frameTimer) { // Show next frame while (seqPtr->nextSeqPtr != obj->currImagePtr) seqPtr = seqPtr->nextSeqPtr; } - _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == OVEROVL); + _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == kPriorityOverOverlay); break; } default: @@ -110,16 +109,16 @@ void ObjectHandler_v1w::updateImages() { // Cycle any animating objects for (int i = 0; i < num_objs; i++) { object_t *obj = &_objects[objindex[i]]; - if (obj->cycling != INVISIBLE) { + if (obj->cycling != kCycleInvisible) { // Only if it's visible - if (obj->cycling == ALMOST_INVISIBLE) - obj->cycling = INVISIBLE; + if (obj->cycling == kCycleAlmostInvisible) + obj->cycling = kCycleInvisible; // Now Rotate to next picture in sequence switch (obj->cycling) { - case NOT_CYCLING: + case kCycleNotCycling: break; - case CYCLE_FORWARD: + case kCycleForward: if (!obj->frameTimer) { // Time to step to next frame obj->currImagePtr = obj->currImagePtr->nextSeqPtr; @@ -131,14 +130,14 @@ void ObjectHandler_v1w::updateImages() { if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) { if (obj->cycleNumb) { // Decr cycleNumb if Non-continous if (!--obj->cycleNumb) - obj->cycling = NOT_CYCLING; + obj->cycling = kCycleNotCycling; } } } } } break; - case CYCLE_BACKWARD: { + case kCycleBackward: { if (!obj->frameTimer) { // Time to step to prev frame seq_t *seqPtr = obj->currImagePtr; @@ -152,7 +151,7 @@ void ObjectHandler_v1w::updateImages() { if (obj->currImagePtr == obj->seqList[j].seqPtr) { if (obj->cycleNumb){ // Decr cycleNumb if Non-continous if (!--obj->cycleNumb) - obj->cycling = NOT_CYCLING; + obj->cycling = kCycleNotCycling; } } } @@ -188,11 +187,11 @@ void ObjectHandler_v1w::moveObjects() { seq_t *currImage = obj->currImagePtr; // Get ptr to current image if (obj->screenIndex == *_vm->_screen_p) { switch (obj->pathType) { - case CHASE: - case CHASE2: { + case kPathChase: + case kPathChase2: { int8 radius = obj->radius; // Default to object's radius if (radius < 0) // If radius infinity, use closer value - radius = DX; + radius = kStepDx; // Allowable motion wrt boundary int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1; @@ -235,18 +234,18 @@ void ObjectHandler_v1w::moveObjects() { } if (obj->vx || obj->vy) { - obj->cycling = CYCLE_FORWARD; + obj->cycling = kCycleForward; } else { - obj->cycling = NOT_CYCLING; - _vm->boundaryCollision(obj); // Must have got hero! + obj->cycling = kCycleNotCycling; + _vm->boundaryCollision(obj); // Must have got hero! } obj->oldvx = obj->vx; obj->oldvy = obj->vy; currImage = obj->currImagePtr; // Get (new) ptr to current image break; } - case WANDER2: - case WANDER: + case kPathWander2: + case kPathWander: if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath; obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath; @@ -272,13 +271,13 @@ void ObjectHandler_v1w::moveObjects() { currImage = obj->currImagePtr; // Get (new) ptr to current image } if (obj->vx || obj->vy) - obj->cycling = CYCLE_FORWARD; + obj->cycling = kCycleForward; break; default: ; // Really, nothing } // Store boundaries - if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING)) + if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) _vm->storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2); } } @@ -298,7 +297,7 @@ void ObjectHandler_v1w::moveObjects() { int y1 = obj->y + currImage->y1; // Top edge int y2 = obj->y + currImage->y2; // Bottom edge - if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING)) + if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) _vm->clearBoundary(x1, x2, y2); // Clear our own boundary // Allowable motion wrt boundary @@ -316,24 +315,24 @@ void ObjectHandler_v1w::moveObjects() { obj->vy = 0; } - if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING)) + if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) _vm->storeBoundary(x1, x2, y2); // Re-store our own boundary obj->x += dx; // Update object position obj->y += dy; // Don't let object go outside screen - if (x1 < EDGE) - obj->x = EDGE2; - if (x2 > (XPIX - EDGE)) - obj->x = XPIX - EDGE2 - (x2 - x1); - if (y1 < EDGE) - obj->y = EDGE2; - if (y2 > (YPIX - EDGE)) - obj->y = YPIX - EDGE2 - (y2 - y1); - - if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != WANDER2) && (obj->pathType != CHASE2)) - obj->cycling = NOT_CYCLING; + if (x1 < kEdge) + obj->x = kEdge2; + if (x2 > (kXPix - kEdge)) + obj->x = kXPix - kEdge2 - (x2 - x1); + if (y1 < kEdge) + obj->y = kEdge2; + if (y2 > (kYPix - kEdge)) + obj->y = kYPix - kEdge2 - (y2 - y1); + + if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != kPathWander2) && (obj->pathType != kPathChase2)) + obj->cycling = kCycleNotCycling; } } @@ -341,7 +340,7 @@ void ObjectHandler_v1w::moveObjects() { for (int i = 0; i < _numObj; i++) { object_t *obj = &_objects[i]; // Get pointer to object seq_t *currImage = obj->currImagePtr; // Get ptr to current image - if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING)) + if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating)) _vm->clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2); } @@ -368,15 +367,15 @@ void ObjectHandler_v1w::swapImages(int objIndex1, int objIndex2) { saveSeq(&_objects[objIndex1]); - seqList_t tmpSeqList[MAX_SEQUENCES]; - int seqListSize = sizeof(seqList_t) * MAX_SEQUENCES; + seqList_t tmpSeqList[kMaxSeqNumb]; + int seqListSize = sizeof(seqList_t) * kMaxSeqNumb; memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize); memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize); memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize); restoreSeq(&_objects[objIndex1]); _objects[objIndex2].currImagePtr = _objects[objIndex2].seqList[0].seqPtr; - _vm->_heroImage = (_vm->_heroImage == HERO) ? objIndex2 : HERO; + _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex; // Make sure baseline stays constant _objects[objIndex1].y += _objects[objIndex2].currImagePtr->y2 - _objects[objIndex1].currImagePtr->y2; -- cgit v1.2.3