diff options
author | Strangerke | 2015-12-21 01:27:50 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:35:32 +0100 |
commit | fa222f0ca878b3bf55b439ccf0e1e0849cecfe63 (patch) | |
tree | d83274c8d89d1c62a286804475fa81966882dea1 | |
parent | 2eeb027604a470b8e5410751962734b677d605f1 (diff) | |
download | scummvm-rg350-fa222f0ca878b3bf55b439ccf0e1e0849cecfe63.tar.gz scummvm-rg350-fa222f0ca878b3bf55b439ccf0e1e0849cecfe63.tar.bz2 scummvm-rg350-fa222f0ca878b3bf55b439ccf0e1e0849cecfe63.zip |
LAB: Make string check more readable, remove a useless c_str()
-rw-r--r-- | engines/lab/dispman.cpp | 33 | ||||
-rw-r--r-- | engines/lab/engine.cpp | 8 | ||||
-rw-r--r-- | engines/lab/lab.cpp | 2 | ||||
-rw-r--r-- | engines/lab/map.cpp | 4 | ||||
-rw-r--r-- | engines/lab/processroom.cpp | 18 |
5 files changed, 32 insertions, 33 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp index d493e935c5..59d725bbe4 100644 --- a/engines/lab/dispman.cpp +++ b/engines/lab/dispman.cpp @@ -231,7 +231,7 @@ void DisplayMan::createBox(uint16 y2) { } int DisplayMan::longDrawMessage(Common::String str) { - if (!str.size()) + if (str.empty()) return 0; _vm->_event->attachButtonList(nullptr); @@ -256,22 +256,23 @@ void DisplayMan::drawMessage(Common::String str) { return; } - if (str.size()) { - if ((textLength(_vm->_msgFont, str) > _vm->_utils->vgaScaleX(306))) { - longDrawMessage(str); - _lastMessageLong = true; - } else { - if (_longWinInFront) { - _longWinInFront = false; - drawPanel(); - } + if (str.empty()) + return; - _vm->_event->mouseHide(); - createBox(168); - drawText(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str); - _vm->_event->mouseShow(); - _lastMessageLong = false; + if ((textLength(_vm->_msgFont, str) > _vm->_utils->vgaScaleX(306))) { + longDrawMessage(str); + _lastMessageLong = true; + } else { + if (_longWinInFront) { + _longWinInFront = false; + drawPanel(); } + + _vm->_event->mouseHide(); + createBox(168); + drawText(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str); + _vm->_event->mouseShow(); + _lastMessageLong = false; } } @@ -857,7 +858,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi setPen(0); } // for j - if (!filename.size()) + if (filename.empty()) _vm->_curFileName = _vm->getPictName(closePtrList); else if (filename[0] > ' ') _vm->_curFileName = filename; diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index ee9ca429e6..6cf86c2a12 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -127,7 +127,7 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) { } if (_alternate) { - if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName != "") { + if ((curInv <= _numInv) && _conditions->in(curInv) && !_inventory[curInv]._bitmapName.empty()) { if ((curInv == kItemLamp) && _conditions->in(kCondLampOn)) // LAB: Labyrinth specific drawStaticMessage(kTextkLampOn); @@ -374,7 +374,7 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) { interfaceOff(); while (newInv && (newInv <= _numInv)) { - if (_conditions->in(newInv) && _inventory[newInv]._bitmapName != "") { + if (_conditions->in(newInv) && !_inventory[newInv]._bitmapName.empty()) { _nextFileName = getInvName(newInv); *curInv = newInv; break; @@ -968,7 +968,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI curInv++; } - if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName != "") + if ((curInv <= _numInv) && _conditions->in(curInv) && !_inventory[curInv]._bitmapName.empty()) _nextFileName = getInvName(curInv); break; @@ -1066,7 +1066,7 @@ void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &c if (_closeDataPtr == tmpClosePtr) { if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2))) drawStaticMessage(kTextNothing); - } else if (tmpClosePtr->_graphicName != "") { + } else if (!tmpClosePtr->_graphicName.empty()) { _anim->_doBlack = true; _closeDataPtr = tmpClosePtr; } else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2))) diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp index 5f3f40cce3..3336870fea 100644 --- a/engines/lab/lab.cpp +++ b/engines/lab/lab.cpp @@ -212,7 +212,7 @@ Common::String LabEngine::generateSaveFileName(uint slot) { } void LabEngine::drawStaticMessage(byte index) { - _graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str()); + _graphics->drawMessage(_resource->getStaticText((StaticText)index)); } void LabEngine::changeVolume(int delta) { diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 84da3596e8..63e3571b8f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -381,7 +381,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), textPrt); } - if (_rooms[curMsg]._roomMsg != "") + if (!_rooms[curMsg]._roomMsg.empty()) _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg.c_str()); if (fadeIn) @@ -509,7 +509,7 @@ void LabEngine::processMap(uint16 curRoom) { } if (oldMsg != curMsg) { - if (_rooms[curMsg]._roomMsg != "") + if (!_rooms[curMsg]._roomMsg.empty()) _resource->readViews(curMsg); const char *sptr; diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp index d467be9894..efabb8de7e 100644 --- a/engines/lab/processroom.cpp +++ b/engines/lab/processroom.cpp @@ -63,7 +63,7 @@ bool LabEngine::checkConditions(int16 *condition) { } ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) { - if (_rooms[roomNum]._roomMsg == "") + if (!_rooms[roomNum]._roomMsg.empty()) _resource->readViews(roomNum); ViewData *view = _rooms[roomNum]._view[direction]; @@ -131,17 +131,15 @@ Common::String LabEngine::getPictName(CloseDataPtr *closePtrList) { } void LabEngine::drawDirection(CloseDataPtr closePtr) { - if (closePtr && closePtr->_message != "") { - _graphics->drawMessage(closePtr->_message.c_str()); + if (closePtr && !closePtr->_message.empty()) { + _graphics->drawMessage(closePtr->_message); return; } Common::String message; - if (_rooms[_roomNum]._roomMsg != "") { - message = Common::String(_rooms[_roomNum]._roomMsg).c_str(); - message += ", "; - } + if (!_rooms[_roomNum]._roomMsg.empty()) + message = _rooms[_roomNum]._roomMsg + ", "; if (_direction == NORTH) message += _resource->getStaticText(kTextFacingNorth); @@ -152,7 +150,7 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) { else if (_direction == WEST) message += _resource->getStaticText(kTextFacingWest); - _graphics->drawMessage(message.c_str()); + _graphics->drawMessage(message); } uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) { @@ -201,7 +199,7 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b else target = _utils->rectScale(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2); - if (target.contains(pos) && closePtr->_graphicName != "") { + if (target.contains(pos) && !closePtr->_graphicName.empty()) { *closePtrList = closePtr; return; } @@ -267,7 +265,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) { break; case LOADDIFF: - if (actionList->_messages[0].size()) + if (!actionList->_messages[0].empty()) // Puts a file into memory _graphics->loadPict(actionList->_messages[0]); |