From 6414ec92a2a3509946ae4ec35a3a77e76ad152df Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 23 Nov 2004 22:21:45 +0000 Subject: cleanup, follow code conventions svn-id: r15872 --- queen/bankman.cpp | 2 +- queen/command.cpp | 3 ++- queen/credits.cpp | 2 +- queen/cutaway.cpp | 4 ++-- queen/display.cpp | 62 +++++++++++++++++++++++++++--------------------------- queen/graphics.cpp | 22 +++++++++---------- queen/grid.cpp | 8 +++---- queen/logic.cpp | 14 +++++++----- queen/logic.h | 2 ++ queen/music.cpp | 6 +++--- queen/queen.cpp | 3 --- queen/resource.cpp | 2 +- queen/sound.cpp | 4 ++-- queen/talk.cpp | 2 +- queen/walk.cpp | 18 ++++++++-------- 15 files changed, 79 insertions(+), 75 deletions(-) diff --git a/queen/bankman.cpp b/queen/bankman.cpp index 28793e5446..a577a3548c 100644 --- a/queen/bankman.cpp +++ b/queen/bankman.cpp @@ -32,7 +32,7 @@ BankManager::BankManager(Resource *res) } BankManager::~BankManager() { - for(uint32 i = 0; i < MAX_BANKS_NUMBER; ++i) { + for (uint32 i = 0; i < MAX_BANKS_NUMBER; ++i) { close(i); } eraseFrames(true); diff --git a/queen/command.cpp b/queen/command.cpp index bb9efe4d93..4b32d43829 100644 --- a/queen/command.cpp +++ b/queen/command.cpp @@ -122,7 +122,8 @@ void CmdState::init() { } Command::Command(QueenEngine *vm) - : _cmdText((vm->resource()->getLanguage() == HEBREW), CmdText::COMMAND_Y_POS, vm), _vm(vm) { + : _cmdList(NULL), _cmdArea(NULL), _cmdObject(NULL), _cmdInventory(NULL), _cmdGameState(NULL), + _cmdText((vm->resource()->getLanguage() == HEBREW), CmdText::COMMAND_Y_POS, vm), _vm(vm) { } Command::~Command() { diff --git a/queen/credits.cpp b/queen/credits.cpp index 0310e50211..688c193ddf 100644 --- a/queen/credits.cpp +++ b/queen/credits.cpp @@ -95,7 +95,7 @@ void Credits::update() { /* wait until next room */ if (0 == _pause) _pause = -1; - for(i = 0; i < _count; i++) { + for (i = 0; i < _count; i++) { _vm->display()->textCurrentColor(_list[i].color); _vm->display()->setText(_list[i].x, _list[i].y, _list[i].text); } diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp index 0eaabb7ffc..1e8f390989 100644 --- a/queen/cutaway.cpp +++ b/queen/cutaway.cpp @@ -426,7 +426,7 @@ Cutaway::ObjectType Cutaway::getObjectType(CutawayObject &object) { if (object.fromObject > 0) { /* Copy FROM_OBJECT into OBJECT */ - if(object.objectNumber != object.fromObject) { + if (object.objectNumber != object.fromObject) { _vm->logic()->objectCopy(object.fromObject, object.objectNumber); } else { // Same object, so just turn it on! @@ -1130,7 +1130,7 @@ void Cutaway::updateGameState() { bool update = false; if (stateIndex > 0) { - if(_vm->logic()->gameState(stateIndex) == stateValue) + if (_vm->logic()->gameState(stateIndex) == stateValue) update = true; } else { _vm->logic()->gameState(ABS(stateIndex), stateValue); diff --git a/queen/display.cpp b/queen/display.cpp index 04b923105f..e6eebb11a4 100644 --- a/queen/display.cpp +++ b/queen/display.cpp @@ -279,25 +279,25 @@ void Display::palCustomColors(uint16 roomNum) { int i; switch (roomNum) { case 31: - for(i = 72; i < 84; i++) { + for (i = 72; i < 84; i++) { _pal.room[i * 3 + 1] = _pal.room[i * 3 + 1] * 90 / 100; _pal.room[i * 3 + 2] = _pal.room[i * 3 + 2] * 70 / 100; } break; case 29: - for(i = 72; i < 84; i++) { + for (i = 72; i < 84; i++) { _pal.room[i * 3 + 1] = _pal.room[i * 3 + 1] * 60 / 100; _pal.room[i * 3 + 2] = _pal.room[i * 3 + 2] * 60 / 100; } break; case 30: - for(i = 72; i < 84; i++) { + for (i = 72; i < 84; i++) { _pal.room[i * 3 + 0] = _pal.room[i * 3 + 0] * 60 / 100; _pal.room[i * 3 + 1] = _pal.room[i * 3 + 1] * 80 / 100; } break; case 28: - for(i = 72; i < 84; i++) { + for (i = 72; i < 84; i++) { _pal.room[i * 3 + 0] = _pal.room[i * 3 + 0] * 80 / 100; _pal.room[i * 3 + 2] = _pal.room[i * 3 + 1] * 60 / 100; } @@ -321,12 +321,12 @@ void Display::palCustomScroll(uint16 roomNum) { switch (roomNum) { case 123: { static int16 j = 0, jdir = 2; - for(i = 96; i < 111; ++i) { + for (i = 96; i < 111; ++i) { _pal.screen[i * 3 + 0] = MIN(255, _pal.room[i * 3 + 0] + j * 8); _pal.screen[i * 3 + 1] = MIN(255, _pal.room[i * 3 + 1] + j * 4); } j += jdir; - if(j <= 0 || j >= 18) { + if (j <= 0 || j >= 18) { jdir = -jdir; } loPal = 96; @@ -335,12 +335,12 @@ void Display::palCustomScroll(uint16 roomNum) { break; case 124: { static int16 j = 0,jdir = 2; - for(i = 80; i < 144; ++i) { + for (i = 80; i < 144; ++i) { _pal.screen[i * 3 + 0] = MIN(255, _pal.room[i * 3 + 0] + j * 8); _pal.screen[i * 3 + 1] = MIN(255, _pal.room[i * 3 + 1] + j * 4); } j += jdir; - if(j <= 0 || j >= 14) { + if (j <= 0 || j >= 14) { jdir = -jdir; if (_rnd.getRandomNumber(1)) { if (ABS(jdir) == 1) { @@ -361,7 +361,7 @@ void Display::palCustomScroll(uint16 roomNum) { hiPal = 95; break; case 100: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(128, 132); palScroll(133, 137); palScroll(138, 143); @@ -370,14 +370,14 @@ void Display::palCustomScroll(uint16 roomNum) { } break; case 102: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(112, 127); loPal = 112; hiPal = 127; } break; case 62: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(108, 119); loPal = 108; hiPal = 119; @@ -389,7 +389,7 @@ void Display::palCustomScroll(uint16 roomNum) { hiPal = 123; break; case 59: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(56, 63); loPal = 56; hiPal = 63; @@ -405,24 +405,24 @@ void Display::palCustomScroll(uint16 roomNum) { palScroll(88, 91); palScroll(92, 95); palScroll(128, 135); - if(scrollx & 1) { + if (scrollx & 1) { palScroll(136, 143); } loPal = 28; hiPal = 143; break; case 40: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(96, 103); } - if(scrollx & 3) { + if (scrollx & 3) { palScroll(104, 107); } loPal = 96; hiPal = 107; break; case 97: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(96, 107); palScroll(108, 122); loPal = 96; @@ -436,7 +436,7 @@ void Display::palCustomScroll(uint16 roomNum) { break; case 57: palScroll(128, 143); - if(scrollx & 1) { + if (scrollx & 1) { palScroll(96, 103); } loPal = 96; @@ -448,7 +448,7 @@ void Display::palCustomScroll(uint16 roomNum) { hiPal = 95; break; case 2: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(120, 127); loPal = 120; hiPal = 127; @@ -456,7 +456,7 @@ void Display::palCustomScroll(uint16 roomNum) { break; case 3: case 5: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(128, 135); palScroll(136, 143); loPal = 128; @@ -464,14 +464,14 @@ void Display::palCustomScroll(uint16 roomNum) { } break; case 7: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(119, 127); loPal = 119; hiPal = 127; } break; case 42: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(118, 127); palScroll(136, 143); loPal = 118; @@ -479,7 +479,7 @@ void Display::palCustomScroll(uint16 roomNum) { } break; case 4: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(32,47); } palScroll(64, 70); @@ -488,7 +488,7 @@ void Display::palCustomScroll(uint16 roomNum) { hiPal = 79; break; case 8: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(120, 127); } loPal = 120; @@ -496,7 +496,7 @@ void Display::palCustomScroll(uint16 roomNum) { break; case 12: case 64: - if(scrollx & 1) { + if (scrollx & 1) { palScroll(112, 119); palScroll(120, 127); loPal = 112; @@ -721,9 +721,9 @@ void Display::blit(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, const uin } } else if (!xflip) { // Masked bitmap unflipped while (h--) { - for(int i = 0; i < w; ++i) { + for (int i = 0; i < w; ++i) { uint8 b = *(srcBuf + i); - if(b != 0) { + if (b != 0) { *(dstBuf + i) = b; } } @@ -732,9 +732,9 @@ void Display::blit(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, const uin } } else { // Masked bitmap flipped while (h--) { - for(int i = 0; i < w; ++i) { + for (int i = 0; i < w; ++i) { uint8 b = *(srcBuf + i); - if(b != 0) { + if (b != 0) { *(dstBuf - i) = b; } } @@ -907,7 +907,7 @@ void Display::drawChar(uint16 x, uint16 y, uint8 color, const uint8 *chr) { uint8 c = *chr++; if (c != 0) { for (i = 0; i < 8; ++i) { - if(c & 0x80) { + if (c & 0x80) { *p = color; } ++p; @@ -969,9 +969,10 @@ void Display::blankScreen() { } void Display::blankScreenEffect1() { + static const int inc[] = { -1, 1 }; uint8 buf[32 * 32]; while (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) { - for(int i = 0; i < 2; ++i) { + for (int i = 0; i < 2; ++i) { uint16 x = _rnd.getRandomNumber(SCREEN_W - 32 - 2) + 1; uint16 y = _rnd.getRandomNumber(SCREEN_H - 32 - 2) + 1; uint8 *p = _screenBuf + SCREEN_W * y + x; @@ -982,7 +983,6 @@ void Display::blankScreenEffect1() { p += SCREEN_W; q += 32; } - const int inc[] = { -1, 1 }; x += inc[_rnd.getRandomNumber(1)]; y += inc[_rnd.getRandomNumber(1)]; _system->copyRectToScreen(buf, 32, x, y, 32, 32); diff --git a/queen/graphics.cpp b/queen/graphics.cpp index da1624f201..e4852791c9 100644 --- a/queen/graphics.cpp +++ b/queen/graphics.cpp @@ -86,26 +86,26 @@ void BobSlot::move(int16 dstx, int16 dsty, int16 spd) { } void BobSlot::moveOneStep() { - if(xmajor) { - if(x == endx) { + if (xmajor) { + if (x == endx) { y = endy; moving = false; } else { x += xdir; total += dy; - if(total > dx) { + if (total > dx) { y += ydir; total -= dx; } } } else { - if(y == endy) { + if (y == endy) { x = endx; moving = false; } else { y += ydir; total += dx; - if(total > dy) { + if (total > dy) { x += xdir; total -= dy; } @@ -116,7 +116,7 @@ void BobSlot::moveOneStep() { void BobSlot::animOneStep() { if (anim.string.buffer != NULL) { --anim.speed; - if(anim.speed <= 0) { + if (anim.speed <= 0) { // jump to next entry ++anim.string.curPos; uint16 nextFrame = anim.string.curPos->frame; @@ -131,7 +131,7 @@ void BobSlot::animOneStep() { } else { // normal looping animation --anim.speed; - if(anim.speed == 0) { + if (anim.speed == 0) { anim.speed = anim.speedBak; int16 nextFrame = frameNum + frameDir; @@ -259,7 +259,7 @@ void Graphics::drawBob(const BobSlot *bs, const BobFrame *bf, const Box *bbox, i const Box *box = (bs->box == BobSlot::_defaultBox) ? bbox : &bs->box; - if(w != 0 && h != 0 && box->intersects(x, y, w, h)) { + if (w != 0 && h != 0 && box->intersects(x, y, w, h)) { uint8 *src = bf->data; uint16 x_skip = 0; uint16 y_skip = 0; @@ -333,7 +333,7 @@ void Graphics::shrinkFrame(const BobFrame *bf, uint16 percentage) { uint8* dst = _shrinkBuffer.data; for (y = 0; y < new_h; ++y) { uint8 *p = bf->data + sh[y] * bf->width; - for(x = 0; x < new_w; ++x) { + for (x = 0; x < new_w; ++x) { *dst++ = *(p + sh[x]); } } @@ -400,13 +400,13 @@ void Graphics::drawBobs() { } void Graphics::clearBobs() { - for(int32 i = 0; i < ARRAYSIZE(_bobs); ++i) { + for (int32 i = 0; i < ARRAYSIZE(_bobs); ++i) { _bobs[i].clear(); } } void Graphics::stopBobs() { - for(int32 i = 0; i < ARRAYSIZE(_bobs); ++i) { + for (int32 i = 0; i < ARRAYSIZE(_bobs); ++i) { _bobs[i].moving = false; } } diff --git a/queen/grid.cpp b/queen/grid.cpp index 08c78c148e..e8984deff5 100644 --- a/queen/grid.cpp +++ b/queen/grid.cpp @@ -92,7 +92,7 @@ uint16 Grid::findZoneForPos(GridScreen screen, uint16 x, uint16 y) const { if (screen == GS_PANEL) { y -= ROOM_ZONE_HEIGHT; } - for(i = 1; i < MAX_ZONES_NUMBER; ++i) { + for (i = 1; i < MAX_ZONES_NUMBER; ++i) { const ZoneSlot *pzs = &_zones[screen][i]; if (pzs->valid && pzs->box.contains(x, y)) { return i; @@ -114,7 +114,7 @@ uint16 Grid::findAreaForPos(GridScreen screen, uint16 x, uint16 y) const { void Grid::clear(GridScreen screen) { debug(9, "Grid::clear(%d)", screen); - for(int i = 1; i < MAX_ZONES_NUMBER; ++i) { + for (int i = 1; i < MAX_ZONES_NUMBER; ++i) { _zones[screen][i].valid = false; } } @@ -161,7 +161,7 @@ void Grid::setupPanel() { } void Grid::drawZones() { - for(int i = 1; i < MAX_ZONES_NUMBER; ++i) { + for (int i = 1; i < MAX_ZONES_NUMBER; ++i) { const ZoneSlot *pzs = &_zones[GS_ROOM][i]; if (pzs->valid) { const Box *b = &pzs->box; @@ -227,7 +227,7 @@ uint16 Grid::findScale(uint16 x, uint16 y) const { uint16 room = _vm->logic()->currentRoom(); uint16 scale = 100; uint16 areaNum = findAreaForPos(GS_ROOM, x, y); - if(areaNum != 0) { + if (areaNum != 0) { scale = _area[room][areaNum].calcScale(y); } return scale; diff --git a/queen/logic.cpp b/queen/logic.cpp index 8cd7b2a3f8..777e7ec77d 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -68,6 +68,9 @@ Logic::Logic(QueenEngine *vm) memset(_talkSelected, 0, sizeof(_talkSelected)); _puzzleAttemptCount = 0; _journal = new Journal(vm); + _scene = 0; + memset(_gameState, 0, sizeof(_gameState)); + initialise(); } Logic::~Logic() { @@ -85,7 +88,7 @@ Logic::~Logic() { delete[] _graphicAnim; } -void Logic::start() { +void Logic::initialise() { int16 i; uint8 *jas = _vm->resource()->loadFile("QUEEN.JAS", 20); @@ -187,7 +190,7 @@ void Logic::start() { _currentRoom = _objectData[_entryObj].room; _entryObj = 0; - if(memcmp(ptr, _vm->resource()->JASVersion(), 5) != 0) { + if (memcmp(ptr, _vm->resource()->JASVersion(), 5) != 0) { warning("Unexpected queen.jas file format"); } @@ -250,10 +253,10 @@ void Logic::start() { for (i = 1; i <= _numAFile; i++) { _aFile.push_back(queen2jas.nextLine()); } +} +void Logic::start() { _vm->command()->clear(false); - _scene = 0; - memset(_gameState, 0, sizeof(_gameState)); _vm->display()->setupPanel(); _vm->graphics()->unpackControlBank(); _vm->graphics()->setupMouseCursor(); @@ -261,6 +264,7 @@ void Logic::start() { _vm->grid()->setupPanel(); _oldRoom = 0; + _newRoom = _currentRoom; } ObjectData* Logic::objectData(int index) const { @@ -285,7 +289,7 @@ uint16 Logic::findBob(uint16 obj) const { if (img <= -10) { // object has been turned off, but the image order hasn't been updated - if(_graphicData[-(img + 10)].lastFrame != 0) { + if (_graphicData[-(img + 10)].lastFrame != 0) { bobtype = 1; } } else if (img == -2) { diff --git a/queen/logic.h b/queen/logic.h index 590d1031ac..09cf76c02b 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -207,6 +207,8 @@ public: protected: + void initialise(); + void asmMakeJoeUseDress(); void asmMakeJoeUseNormalClothes(); void asmMakeJoeUseUnderwear(); diff --git a/queen/music.cpp b/queen/music.cpp index 19989e5048..9988026ebf 100644 --- a/queen/music.cpp +++ b/queen/music.cpp @@ -186,7 +186,7 @@ static const byte mt32_to_gm[128] = { if ((tuneList + 1) == 3) { _randomLoop = true; int i = 0; - while(Sound::_jungleList[i]) + while (Sound::_jungleList[i]) queueSong(Sound::_jungleList[i++] - 1); return; } @@ -211,10 +211,10 @@ static const byte mt32_to_gm[128] = { int i = 0; if (_numSongs == 40) { - while(Sound::_tuneDemo[tuneList].tuneNum[i]) + while (Sound::_tuneDemo[tuneList].tuneNum[i]) queueSong(Sound::_tuneDemo[tuneList].tuneNum[i++] - 1); } else { - while(Sound::_tune[tuneList].tuneNum[i]) + while (Sound::_tune[tuneList].tuneNum[i]) queueSong(Sound::_tune[tuneList].tuneNum[i++] - 1); } diff --git a/queen/queen.cpp b/queen/queen.cpp index 5057a4f19b..dffdf208a4 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -290,9 +290,6 @@ void QueenEngine::errorString(const char *buf1, char *buf2) { int QueenEngine::go() { _logic->start(); - _logic->oldRoom(0); - _logic->newRoom(_logic->currentRoom()); - _quit = false; while (!_quit) { // queen.c lines 4080-4104 diff --git a/queen/resource.cpp b/queen/resource.cpp index 7e358c3461..14324295e2 100644 --- a/queen/resource.cpp +++ b/queen/resource.cpp @@ -65,7 +65,7 @@ Resource::~Resource() { _resourceFile->close(); delete _resourceFile; - if(_resourceTable != _resourceTablePEM10) + if (_resourceTable != _resourceTablePEM10) delete[] _resourceTable; } diff --git a/queen/sound.cpp b/queen/sound.cpp index 04dfec2811..7ff117ec82 100644 --- a/queen/sound.cpp +++ b/queen/sound.cpp @@ -79,10 +79,10 @@ Sound *Sound::giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression) { void Sound::waitFinished(bool isSpeech) { if (isSpeech) - while(_speechHandle.isActive()) + while (_speechHandle.isActive()) _vm->input()->delay(10); else - while(_sfxHandle.isActive()) + while (_sfxHandle.isActive()) _vm->input()->delay(10); } diff --git a/queen/talk.cpp b/queen/talk.cpp index 0b8e852667..3abee8e01f 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -123,7 +123,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { int16 head = _dialogueTree[level][0].head; // TODO: split this loop in several functions - while(retval != -1) { + while (retval != -1) { char otherVoiceFilePrefix[MAX_STRING_SIZE]; _talkString[0][0] = '\0'; diff --git a/queen/walk.cpp b/queen/walk.cpp index f36c367180..a190f3bb5a 100644 --- a/queen/walk.cpp +++ b/queen/walk.cpp @@ -170,7 +170,7 @@ void Walk::animatePersonPrepare(const MovePersonData *mpd, int direction) { k *= ((k * ds) / pwd->area->box.yDiff()) / 2; } - if(ABS(pwd->dx) < k) { + if (ABS(pwd->dx) < k) { if (pwd->dy < 0) { if (mpd->walkBack1 > 0) { pwd->anim.set(mpd->walkBack1, mpd->walkBack2, DIR_BACK); @@ -182,7 +182,7 @@ void Walk::animatePersonPrepare(const MovePersonData *mpd, int direction) { } else if (pwd->dy > 0) { if (mpd->walkFront1 > 0) { pwd->anim.set(mpd->walkFront1, mpd->walkFront2, DIR_FRONT); - } else if(ABS(mpd->walkLeft1) == ABS(mpd->walkRight1)) { + } else if (ABS(mpd->walkLeft1) == ABS(mpd->walkRight1)) { if (pwd->dx < 0) { pwd->anim.set(mpd->walkLeft1, mpd->walkLeft2, DIR_FRONT); } else { @@ -272,7 +272,7 @@ int16 Walk::moveJoe(int direction, int16 endx, int16 endy, bool inCutaway) { debug(9, "Walk::moveJoe(%d, %d, %d, %d, %d) - old = %d, new = %d", direction, oldx, oldy, endx, endy, oldPos, newPos); // if in cutaway, allow Joe to walk anywhere - if(newPos == 0 && inCutaway) { + if (newPos == 0 && inCutaway) { incWalkData(oldx, oldy, endx, endy, oldPos); } else { if (calc(oldPos, newPos, oldx, oldy, endx, endy)) { @@ -470,10 +470,10 @@ int16 Walk::findAreaPosition(int16 *x, int16 *y, bool recalibrate) { // the X,Y coord to be in this area if (recalibrate) { b = &_roomArea[pos].box; - if(*x < b->x1) *x = b->x1; - if(*x > b->x2) *x = b->x2; - if(*y < b->y1) *y = b->y1; - if(*y > b->y2) *y = b->y2; + if (*x < b->x1) *x = b->x1; + if (*x > b->x2) *x = b->x2; + if (*y < b->y1) *y = b->y1; + if (*y > b->y2) *y = b->y2; } return pos; } @@ -486,7 +486,7 @@ uint16 Walk::findFreeArea(uint16 area) const { int b = _roomAreaCount - testArea; if (map & (1 << b)) { // connecting area, check if it's been struck off - if(!isAreaStruck(testArea)) { + if (!isAreaStruck(testArea)) { // legitimate connecting area, keep it freeArea = testArea; break; @@ -524,7 +524,7 @@ bool Walk::calcPath(uint16 oldArea, uint16 newArea) { ++_areaListCount; assert(_areaListCount < MAX_WALK_DATA); _areaList[_areaListCount] = area; - if(!isAreaStruck(area)) { + if (!isAreaStruck(area)) { ++_areaStrikeCount; assert(_areaStrikeCount < MAX_WALK_DATA); _areaStrike[_areaStrikeCount] = area; -- cgit v1.2.3