diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge2/bitmap.cpp | 12 | ||||
-rw-r--r-- | engines/cge2/cge2_main.cpp | 17 | ||||
-rw-r--r-- | engines/cge2/detection.cpp | 11 | ||||
-rw-r--r-- | engines/cge2/events.cpp | 9 | ||||
-rw-r--r-- | engines/cge2/inventory.cpp | 7 | ||||
-rw-r--r-- | engines/cge2/snail.cpp | 84 | ||||
-rw-r--r-- | engines/cge2/sound.cpp | 2 | ||||
-rw-r--r-- | engines/cge2/spare.cpp | 3 | ||||
-rw-r--r-- | engines/cge2/talk.cpp | 8 | ||||
-rw-r--r-- | engines/cge2/toolbar.cpp | 34 |
10 files changed, 90 insertions, 97 deletions
diff --git a/engines/cge2/bitmap.cpp b/engines/cge2/bitmap.cpp index 289e156ee8..bcc9e98913 100644 --- a/engines/cge2/bitmap.cpp +++ b/engines/cge2/bitmap.cpp @@ -201,14 +201,14 @@ BitmapPtr Bitmap::code(uint8 *map) { uint8 pix; for (j = bpl; j < _w; j += 4) { pix = bm[j]; - if (_v && pix != kPixelTransp) { + if (_v && (pix != kPixelTransp)) { if (j < _b[i]._skip) _b[i]._skip = j; if (j >= _b[i]._hide) _b[i]._hide = j + 1; } - if ((pix == kPixelTransp) != skip || cnt >= 0x3FF0) { // end of block + if (((pix == kPixelTransp) != skip) || (cnt >= 0x3FF0)) { // end of block cnt |= (skip) ? kBmpSKP : kBmpCPY; if (_v) WRITE_LE_UINT16(cp, cnt); // store block description uint16 @@ -228,9 +228,9 @@ BitmapPtr Bitmap::code(uint8 *map) { bm += _w; if (_w < kScrWidth) { - if (skip) { + if (skip) cnt += (kScrWidth - j + 3) / 4; - } else { + else { cnt |= kBmpCPY; if (_v) WRITE_LE_UINT16(cp, cnt); @@ -333,7 +333,7 @@ bool Bitmap::solidAt(V2D pos) { break; case kBmpREP: case kBmpCPY: - if (n - w <= n0 && n > n0) + if ((n - w <= n0) && (n > n0)) return true; break; } @@ -449,7 +449,7 @@ uint8 *Bitmap::makeSpeechBubbleTail(int which, uint8 colorSet[][4]) { } for (int i = 0; i < kDesignSize; i++) { - if (des[i] >= 1 && des[i] <= 3) + if ((des[i] >= 1) && (des[i] <= 3)) des[i] = colorSet[kCBSay][des[i]]; } diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index 8ee3d78ca3..cdf2aa648a 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -266,9 +266,8 @@ Sprite *CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) label = kNoByte; } - if (!shpcnt) { + if (!shpcnt) error("No shapes - %s", fname); - } } else // No sprite description: mono-shaped sprite with only .BMP file. ++shpcnt; @@ -596,12 +595,10 @@ void CGE2Engine::tick() { for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (spr->_time && (--spr->_time == 0)) - spr->tick(); + spr->tick(); - if (_waitRef) { - if (_waitRef == spr->_ref && spr->seqTest(_waitSeq)) - _waitRef = 0; - } + if (_waitRef && (_waitRef == spr->_ref) && spr->seqTest(_waitSeq)) + _waitRef = 0; } _mouse->tick(); @@ -951,10 +948,8 @@ Sprite *CGE2Engine::spriteAt(V2D pos) { Sprite *spr; for (spr = _vga->_showQ->last(); spr; spr = spr->_prev) { - if (!spr->_flags._hide && !spr->_flags._tran) { - if (spr->getShp()->solidAt(pos - spr->_pos2D)) - break; - } + if (!spr->_flags._hide && !spr->_flags._tran && (spr->getShp()->solidAt(pos - spr->_pos2D))) + break; } return spr; diff --git a/engines/cge2/detection.cpp b/engines/cge2/detection.cpp index 5fcbe2ed7a..a7b25d1e05 100644 --- a/engines/cge2/detection.cpp +++ b/engines/cge2/detection.cpp @@ -30,9 +30,9 @@ namespace CGE2 { bool CGE2MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { - if (desc) { + if (desc) *engine = new CGE2::CGE2Engine(syst, desc); - } + return desc != 0; } @@ -50,14 +50,13 @@ const ADGameDescription *CGE2MetaEngine::fallbackDetect(const FileMap &allFiles, static ADGameDescription desc; for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { - if (file->isDirectory()) { + if (file->isDirectory()) continue; - } + if (file->getName().equalsIgnoreCase("lang.eng")) { Common::File dataFile; - if (!dataFile.open(*file)) { + if (!dataFile.open(*file)) continue; - } desc.gameid = "sfinx"; desc.extra = "Sfinx English Alfa v0.1"; diff --git a/engines/cge2/events.cpp b/engines/cge2/events.cpp index cf6d3b0b61..7dd254d183 100644 --- a/engines/cge2/events.cpp +++ b/engines/cge2/events.cpp @@ -54,7 +54,7 @@ Sprite *Keyboard::setClient(Sprite *spr) { bool Keyboard::getKey(Common::Event &event) { Common::KeyCode keycode = event.kbd.keycode; - if (((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) && event.type == Common::EVENT_KEYDOWN) + if (((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) && (event.type == Common::EVENT_KEYDOWN)) _keyAlt = true; else _keyAlt = false; @@ -117,7 +117,7 @@ void Keyboard::newKeyboard(Common::Event &event) { if (!getKey(event)) return; - if ((event.type == Common::EVENT_KEYDOWN) && (_client)) { + if ((event.type == Common::EVENT_KEYDOWN) && _client) { CGE2Event &evt = _vm->_eventManager->getNextEvent(); evt._x = 0; evt._y = 0; @@ -253,7 +253,7 @@ void EventManager::handleEvents() { e._spritePtr = _vm->spriteAt(_vm->_mouse->_point); e._x += (_vm->_mouse->_siz.x >> 1); e._y -= _vm->_mouse->_siz.y; - if (_vm->_mouse->_hold && e._spritePtr != _vm->_mouse->_hold) { + if (_vm->_mouse->_hold && (e._spritePtr != _vm->_mouse->_hold)) { _vm->_mouse->_hold->touch(e._mask | kEventAttn, V2D(_vm, e._x - _vm->_mouse->_hold->_pos2D.x, e._y - _vm->_mouse->_hold->_pos2D.y), e._keyCode); } @@ -281,9 +281,10 @@ void EventManager::handleEvents() { void EventManager::clearEvent(Sprite *spr) { if (spr) { - for (uint16 e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % kEventMax) + for (uint16 e = _eventQueueTail; e != _eventQueueHead; e = (e + 1) % kEventMax) { if (_eventQueue[e]._spritePtr == spr) _eventQueue[e]._mask = 0; + } } else _eventQueueTail = _eventQueueHead; } diff --git a/engines/cge2/inventory.cpp b/engines/cge2/inventory.cpp index 7029a6494c..e62aa01e99 100644 --- a/engines/cge2/inventory.cpp +++ b/engines/cge2/inventory.cpp @@ -34,7 +34,7 @@ int CGE2Engine::findActivePocket(int ref) { for (int i = 0; i < kPocketMax; i++) { Sprite *spr = _heroTab[_sex]->_pocket[i]; if (ref >= 0) { - if (spr && spr->_ref == ref) + if (spr && (spr->_ref == ref)) return i; } else if (!spr) return i; @@ -45,13 +45,12 @@ int CGE2Engine::findActivePocket(int ref) { void CGE2Engine::selectPocket(int n) { Sprite **p = _heroTab[_sex]->_pocket; int &pp = _heroTab[_sex]->_pocPtr; - if (n < 0 || pp == n) { + if ((n < 0) || (pp == n)) { n = findActivePocket(-1); if (n >= 0) pp = n; - } else if (p[n]) { + } else if (p[n]) pp = n; - } } void CGE2Engine::pocFul() { diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp index 29747672ba..2cd5aca493 100644 --- a/engines/cge2/snail.cpp +++ b/engines/cge2/snail.cpp @@ -57,17 +57,16 @@ void CommandHandler::runCommand() { if (!_turbo && _vm->_soundStat._wait) { if (*(_vm->_soundStat._wait)) return; - else { - ++_vm->_soundStat._ref[0]; - if (_vm->_fx->exist(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0])) { - int16 oldRepeat = _vm->_sound->getRepeat(); - _vm->_sound->setRepeat(1); - _vm->_sound->play(Audio::Mixer::kSFXSoundType, _vm->_fx->load(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0]), _vm->_sound->_smpinf._span); - _vm->_sound->setRepeat(oldRepeat); - return; - } - _vm->_soundStat._wait = nullptr; + + ++_vm->_soundStat._ref[0]; + if (_vm->_fx->exist(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0])) { + int16 oldRepeat = _vm->_sound->getRepeat(); + _vm->_sound->setRepeat(1); + _vm->_sound->play(Audio::Mixer::kSFXSoundType, _vm->_fx->load(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0]), _vm->_sound->_smpinf._span); + _vm->_sound->setRepeat(oldRepeat); + return; } + _vm->_soundStat._wait = nullptr; } uint8 tmpHead = _head; @@ -77,6 +76,7 @@ void CommandHandler::runCommand() { if (!_turbo) { // only for the slower one if (_vm->_waitRef) break; + if (_timerExpiry) { // Delay in progress if (_timerExpiry > g_system->getMillis()) @@ -103,11 +103,12 @@ void CommandHandler::runCommand() { spr = (tailCmd._ref < 0) ? ((Sprite *)tailCmd._spritePtr) : _vm->locate(tailCmd._ref); Common::String sprStr; - if (spr && spr->_file && tailCmd._commandType != kCmdGhost) + if (spr && spr->_file && (tailCmd._commandType != kCmdGhost)) // In case of kCmdGhost _spritePtr stores a pointer to a Bitmap, not to a Sprite... sprStr = Common::String(spr->_file); else sprStr = "None"; + if (sprStr.empty()) sprStr = "None"; debugC(1, kCGE2DebugOpcode, "Command: %s; Ref: %d; Val: %d; Sprite: %s;", getComStr(tailCmd._commandType), tailCmd._ref, tailCmd._val, sprStr.c_str()); @@ -316,7 +317,7 @@ void CGE2Engine::snMidi(int val) { void CGE2Engine::snSeq(Sprite *spr, int val) { if (spr) { - if (isHero(spr) && val == 0) + if (isHero(spr) && (val == 0)) ((Hero*)spr)->park(); else spr->step(val); @@ -344,9 +345,8 @@ void CGE2Engine::snSend(Sprite *spr, int val) { // deactivating hide1(spr); spr->_flags._slav = false; - if (spr == _heroTab[_sex]->_ptr) - if (_heroTab[!_sex]->_ptr->_scene == _now) - switchHero(!_sex); + if ((spr == _heroTab[_sex]->_ptr) && (_heroTab[!_sex]->_ptr->_scene == _now)) + switchHero(!_sex); _spare->dispose(spr); } else { // activating @@ -496,9 +496,8 @@ void CGE2Engine::snGoto(Sprite *spr, int val) { } void CGE2Engine::snPort(Sprite *spr, int port) { - if (spr) { + if (spr) spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0); - } } void CGE2Engine::snMouse(bool on) { @@ -547,9 +546,8 @@ void CGE2Engine::snRmFTake(Sprite *spr) { } void CGE2Engine::snSetRef(Sprite *spr, int val) { - if (spr) { + if (spr) spr->_ref = val; - } } void CGE2Engine::snFlash(bool on) { @@ -812,10 +810,9 @@ void CGE2Engine::feedSnail(Sprite *spr, Action snq, Hero *hero) { } while (c < q) { - if (c->_commandType == kCmdWalk || c->_commandType == kCmdReach) { - if (c->_val == -1) - c->_val = spr->_ref; - } + if ((c->_val == -1) && (c->_commandType == kCmdWalk || c->_commandType == kCmdReach)) + c->_val = spr->_ref; + if (c->_commandType == kCmdNext) { Sprite *s; @@ -831,29 +828,28 @@ void CGE2Engine::feedSnail(Sprite *spr, Action snq, Hero *hero) { break; } - if (s) { - if (s->_actionCtrl[snq]._cnt) { - int v; - switch (c->_val) { - case -1: - v = int(c - comtab + 1); - break; - case -2: - v = int(c - comtab); - break; - case -3: - v = -1; - break; - default: - v = c->_val; - if ((v > 255) && s) - v = s->labVal(snq, v >> 8); - break; - } - if (v >= 0) - s->_actionCtrl[snq]._ptr = v; + if (s && s->_actionCtrl[snq]._cnt) { + int v; + switch (c->_val) { + case -1: + v = int(c - comtab + 1); + break; + case -2: + v = int(c - comtab); + break; + case -3: + v = -1; + break; + default: + v = c->_val; + if ((v > 255) && s) + v = s->labVal(snq, v >> 8); + break; } + if (v >= 0) + s->_actionCtrl[snq]._ptr = v; } + if (s == spr) break; } diff --git a/engines/cge2/sound.cpp b/engines/cge2/sound.cpp index cc148d6090..c34eb00c01 100644 --- a/engines/cge2/sound.cpp +++ b/engines/cge2/sound.cpp @@ -250,7 +250,7 @@ void MusicPlayer::sndMidiStart() { } void MusicPlayer::send(uint32 b) { - if ((b & 0xF0) == 0xC0 && !_isGM && !_nativeMT32) { + if (((b & 0xF0) == 0xC0) && !_isGM && !_nativeMT32) { b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8; } diff --git a/engines/cge2/spare.cpp b/engines/cge2/spare.cpp index 4ca29009d8..53f99e4e67 100644 --- a/engines/cge2/spare.cpp +++ b/engines/cge2/spare.cpp @@ -37,9 +37,10 @@ void Spare::sync(Common::Serializer &s) { size++; s.syncAsSint16LE(size); - for (uint i = 0; i < _container.size(); i++) + for (uint i = 0; i < _container.size(); i++) { if (_container[i]->_ref >= 141) _container[i]->sync(s); + } } else { int size; s.syncAsSint16LE(size); diff --git a/engines/cge2/talk.cpp b/engines/cge2/talk.cpp index dbdfc0d7ca..c39e064c22 100644 --- a/engines/cge2/talk.cpp +++ b/engines/cge2/talk.cpp @@ -186,7 +186,7 @@ void Talk::update(const char *text) { mh = 2 * vmarg + kFontHigh; mw = 0; for (const char *p = text; *p; p++) { - if (*p == '|' || *p == '\n') { + if ((*p == '|') || (*p == '\n')) { mh += kFontHigh + kTextLineSpace; if (k > mw) mw = k; @@ -208,9 +208,9 @@ void Talk::update(const char *text) { m = map + ln * mw + hmarg; while (*text) { - if (*text == '|' || *text == '\n') { + if ((*text == '|') || (*text == '\n')) m = map + (ln += kFontHigh + kTextLineSpace) * mw + hmarg; - } else { + else { int cw = _vm->_font->_widthArr[(unsigned char)*text]; uint8 *f = _vm->_font->_map + _vm->_font->_pos[(unsigned char)*text]; @@ -254,7 +254,7 @@ InfoLine::InfoLine(CGE2Engine *vm, uint16 w, ColorBank color) } void InfoLine::update(const char *text) { - if (!_realTime && text == _oldText) + if (!_realTime && (text == _oldText)) return; _oldText = text; diff --git a/engines/cge2/toolbar.cpp b/engines/cge2/toolbar.cpp index 5880dfce6a..4b328df6b0 100644 --- a/engines/cge2/toolbar.cpp +++ b/engines/cge2/toolbar.cpp @@ -115,17 +115,17 @@ void CGE2Engine::checkMusicSwitch() { bool mute = false; if (ConfMan.hasKey("mute")) mute = ConfMan.getBool("mute"); + bool musicMuted = mute; int musicVolume = ConfMan.getInt("music_volume"); if (!musicMuted) musicMuted = musicVolume == 0; - if (!musicMuted && !_music) { + if (!musicMuted && !_music) switchMusic(_music = true); - } - if (musicMuted && _music) { + + if (musicMuted && _music) switchMusic(_music = false); - } } void CGE2Engine::quit() { @@ -148,7 +148,7 @@ void CGE2Engine::quit() { void CGE2Engine::setVolume(int idx, int cnt) { if (cnt && _vol[idx]) { int p = _vol[idx]->_seqPtr + cnt; - if (p >= 0 && p < _vol[idx]->_seqCnt) { + if ((p >= 0) && (p < _vol[idx]->_seqCnt)) { _vol[idx]->step(p); int newVolume = p * kSoundStatetoNumRate; switch (idx) { @@ -171,28 +171,29 @@ void CGE2Engine::checkVolumeSwitches() { bool mute = false; if (ConfMan.hasKey("mute")) mute = ConfMan.getBool("mute"); + bool musicMuted = mute; int musicVolume = ConfMan.getInt("music_volume"); if (!musicMuted) musicMuted = musicVolume == 0; + bool sfxMuted = mute; int sfxVolume = ConfMan.getInt("sfx_volume"); if (!sfxMuted) sfxMuted = sfxVolume == 0; - if ((!musicMuted && !_music) || - (musicVolume != _oldMusicVolume && !musicMuted)) { + if ((!musicMuted && !_music) || (musicVolume != _oldMusicVolume && !musicMuted)) _vol[1]->step(musicVolume / kSoundNumtoStateRate); - } - if (musicMuted && _music) { + + if (musicMuted && _music) _vol[1]->step(0); - } if ((!sfxMuted && !_sfx) || (sfxVolume != _oldSfxVolume)) { _vol[0]->step(sfxVolume / kSoundNumtoStateRate); _oldSfxVolume = sfxVolume; _sfx = true; } + if (sfxMuted && _sfx) { _vol[0]->step(0); _sfx = false; @@ -220,9 +221,9 @@ void CGE2Engine::switchVox() { } void CGE2Engine::updateSpeechVolume() { - if (_sayVox) { + if (_sayVox) ConfMan.setInt("speech_volume", _oldSpeechVolume); - } else { + else { _oldSpeechVolume = ConfMan.getInt("speech_volume"); ConfMan.setInt("speech_volume", 0); } @@ -237,18 +238,18 @@ void CGE2Engine::checkSaySwitch() { bool mute = false; if (ConfMan.hasKey("mute")) mute = ConfMan.getBool("mute"); + bool speechMuted = mute; if (!speechMuted) { int speechVolume = ConfMan.getInt("speech_volume"); speechMuted = speechVolume == 0; } - if (!speechMuted && !_sayVox) { + if (!speechMuted && !_sayVox) switchVox(); - } - if (speechMuted && _sayVox) { + + if (speechMuted && _sayVox) switchVox(); - } } void CGE2Engine::initToolbar() { @@ -279,6 +280,7 @@ void CGE2Engine::initToolbar() { if (_vol[0]) initVolumeSwitch(_vol[0]); + if (_vol[1]) initVolumeSwitch(_vol[1]); } |