SHERLOCK: Reduce the scope of several variables.

This commit is contained in:
Strangerke 2015-09-14 00:23:07 +02:00
parent 4ee421f29d
commit dab5cd387d
12 changed files with 22 additions and 31 deletions

View File

@ -1269,7 +1269,6 @@ bool ScalpelEngine::play3doMovie(const Common::String &filename, const Common::P
Graphics::Surface tempSurface;
Common::Point framePos(pos.x, pos.y);
ImageFile3DO *frameImageFile = nullptr;
ImageFrame *frameImage = nullptr;
bool frameShown = false;
@ -1286,7 +1285,7 @@ bool ScalpelEngine::play3doMovie(const Common::String &filename, const Common::P
framePos.y -= 8; // frame is 8 pixels on left + top, and 7 pixels on right + bottom
}
frameImageFile = new ImageFile3DO("vidframe.cel", kImageFile3DOType_Cel);
ImageFile3DO *frameImageFile = new ImageFile3DO("vidframe.cel", kImageFile3DOType_Cel);
frameImage = &(*frameImageFile)[0];
}

View File

@ -1091,9 +1091,9 @@ void Scene::checkSceneFlags(bool flag) {
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &o = _bgShapes[idx];
bool objectFlag = true;
if (o._requiredFlag[0] || o._requiredFlag[1]) {
bool objectFlag = true;
if (o._requiredFlag[0] != 0)
objectFlag = _vm->readFlags(o._requiredFlag[0]);
if (o._requiredFlag[1] != 0)

View File

@ -77,7 +77,6 @@ void Darts::playDarts(GameType gameType) {
Screen &screen = *_vm->_screen;
int oldFontType = screen.fontNumber();
int playerNum = 0;
int roundStart, score;
int lastDart;
int numHits = 0;
bool gameOver = false;
@ -92,6 +91,7 @@ void Darts::playDarts(GameType gameType) {
initDarts();
while (!done && !_vm->shouldQuit()) {
int roundStart, score;
roundStart = score = (playerNum == 0) ? _score1 : _score2;
showNames(playerNum);
@ -143,7 +143,6 @@ void Darts::playDarts(GameType gameType) {
} else {
// check for cricket game over
bool allClosed = true;
int nOtherScore;
for (int y = 0; y < 7; y++) {
if (_cricketScore[playerNum][y] < 3)
@ -151,7 +150,7 @@ void Darts::playDarts(GameType gameType) {
}
if (allClosed) {
nOtherScore = (playerNum == 0) ? _score2 : _score1;
int nOtherScore = (playerNum == 0) ? _score2 : _score1;
if (score >= nOtherScore)
gameOver = true;
}
@ -561,11 +560,10 @@ void Darts::drawDartThrow(const Common::Point &dartPos, int computer) {
Events &events = *_vm->_events;
Screen &screen = *_vm->_screen;
int cx, cy;
int handCy;
int drawX = 0, drawY = 0, oldDrawX = 0, oldDrawY = 0;
int xSize = 0, ySize = 0, oldxSize = 0, oldySize = 0;
int handOCx, handOCy;
int ocx, ocy;
int handOCx = 0, handOCy = 0;
int ocx = 0, ocy = 0;
int handOldxSize, handOldySize;
int delta = 9;
int dartNum;
@ -576,7 +574,6 @@ void Darts::drawDartThrow(const Common::Point &dartPos, int computer) {
ImageFile &hands = !computer ? *_hand1 : *_hand2;
int numFrames = !computer ? 14 : 13;
ocx = ocy = handOCx = handOCy = 0;
oldxSize = oldySize = handOldxSize = handOldySize = 1;
cx = dartPos.x;
cy = SHERLOCK_SCREEN_HEIGHT - _handSize.y - 20;
@ -590,7 +587,7 @@ void Darts::drawDartThrow(const Common::Point &dartPos, int computer) {
for (int idx = 0; idx < numFrames; ++idx) {
_handSize.x = hands[idx]._offset.x + hands[idx]._width;
_handSize.y = hands[idx]._offset.y + hands[idx]._height;
handCy = SHERLOCK_SCREEN_HEIGHT - _handSize.y;
int handCy = SHERLOCK_SCREEN_HEIGHT - _handSize.y;
screen._backBuffer1.transBlitFrom(hands[idx], Common::Point(_handX, handCy));
screen.slamArea(_handX, handCy, _handSize.x + 1, _handSize.y);
@ -787,8 +784,6 @@ void Darts::getComputerNumber(int playerNum, Common::Point &targetPos) {
int score;
int aim = 0;
Common::Point pt;
bool done = false;
int cricketaimset = false;
bool shootBull = false;
score = (playerNum == 0) ? _score1 : _score2;
@ -799,6 +794,7 @@ void Darts::getComputerNumber(int playerNum, Common::Point &targetPos) {
if(score > 60)
shootBull = true;
} else {
bool cricketaimset = false;
if (_cricketScore[playerNum][6] < 3) {
// shoot at bull first
aim = CRICKET_VALUE[6];
@ -842,6 +838,7 @@ void Darts::getComputerNumber(int playerNum, Common::Point &targetPos) {
}
} else {
// Loop in case number does not exist on board
bool done = false;
do {
done = findNumberOnBoard(aim, pt);
--aim;

View File

@ -43,10 +43,10 @@ void TattooInventory::loadInv() {
Common::SeekableReadStream *stream = _vm->_res->load("invent.txt");
int count = stream->readByte();
char c;
for (int idx = 0; idx < count; ++idx) {
Common::String name;
char c;
while ((c = stream->readByte()) != 0)
name += c;

View File

@ -345,9 +345,9 @@ void TattooJournal::handleButtons() {
disableControls();
bool notFound = false;
int dir;
do {
int dir;
if ((dir = getFindName(notFound)) != 0) {
_savedIndex = _index;
_savedSub = _sub;

View File

@ -1010,7 +1010,6 @@ void TattooPerson::walkHolmesToNPC() {
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
TattooPerson &holmes = people[HOLMES];
int facing;
// Save the character's details
pushNPCPath();
@ -1073,9 +1072,8 @@ void TattooPerson::walkHolmesToNPC() {
if (!talk._talkToAbort) {
// Setup correct direction for Holmes to face
// See where Holmes is with respect to the NPC (x coords)
facing = (holmes._position.x < _position.x) ? STOP_RIGHT : STOP_LEFT;
int facing = (holmes._position.x < _position.x) ? STOP_RIGHT : STOP_LEFT;
// See where Holmes is with respect to the NPC (y coords)
if (holmes._position.y < (_position.y - (10 * FIXED_INT_MULTIPLIER))) {

View File

@ -809,13 +809,12 @@ void TattooScene::synchronize(Serializer &s) {
int TattooScene::closestZone(const Common::Point &pt) {
int zone = -1;
int dist = 9999;
int d;
for (uint idx = 0; idx < _zones.size(); ++idx) {
Common::Rect &r = _zones[idx];
// Check the distance from the point to the center of the zone
d = ABS(r.left + (r.width() / 2) - pt.x) + ABS(r.top + (r.height() / 2) - pt.y);
int d = ABS(r.left + (r.width() / 2) - pt.x) + ABS(r.top + (r.height() / 2) - pt.y);
if (d < dist) {
dist = d;
zone = idx;

View File

@ -85,7 +85,6 @@ void TattooUserInterface::lookAtObject() {
Talk &talk = *_vm->_talk;
Common::Point mousePos = events.mousePos();
Common::String desc;
int cAnimSpeed = 0;
_lookPos = mousePos;
_menuMode = LOOK_MODE;
@ -95,7 +94,7 @@ void TattooUserInterface::lookAtObject() {
} else {
// Check if there is a Look animation
if (_bgShape->_lookcAnim != 0) {
cAnimSpeed = _bgShape->_lookcAnim & 0xe0;
int cAnimSpeed = _bgShape->_lookcAnim & 0xe0;
cAnimSpeed >>= 5;
++cAnimSpeed;
@ -377,7 +376,6 @@ void TattooUserInterface::doStandardControl() {
TattooScene &scene = *(TattooScene *)_vm->_scene;
Talk &talk = *_vm->_talk;
Common::Point mousePos = events.mousePos();
bool noDesc = false;
// Don't do any input processing whilst the prolog is running
if (vm._runningProlog)
@ -458,6 +456,7 @@ void TattooUserInterface::doStandardControl() {
if (_arrowZone == -1 || events._rightReleased)
freeMenu();
bool noDesc = false;
if (_personFound) {
if (people[_bgFound - 1000]._description.empty() || people[_bgFound - 1000]._description.hasPrefix(" "))
noDesc = true;

View File

@ -253,7 +253,6 @@ bool WidgetFiles::getFilename() {
int done = 0;
bool blinkFlag = false;
int blinkCountdown = 0;
int width;
int cursorColor = 192;
byte color, textColor;
bool insert = true;
@ -285,7 +284,7 @@ bool WidgetFiles::getFilename() {
char currentChar = (index == (int)filename.size()) ? ' ' : filename[index];
Common::String charString = Common::String::format("%c", currentChar);
width = screen.charWidth(currentChar);
int width = screen.charWidth(currentChar);
// Wait for keypress
while (!events.kbHit()) {

View File

@ -45,7 +45,6 @@ void WidgetLab::handleEvents() {
Common::Point mousePos = events.mousePos();
WidgetBase::handleEvents();
bool noDesc = false;
// Handle drawing tooltips. If the user is dragging a lab item, display a tooltip for using the item
// on another. Otherwise, fall back on showing standard tooltips
@ -65,6 +64,7 @@ void WidgetLab::handleEvents() {
if (ui._arrowZone == -1 || events._rightReleased)
ui._tooltipWidget.setText("");
bool noDesc = false;
if (ui._bgFound != -1) {
if (ui._bgShape->_description.hasPrefix(" ") || ui._bgShape->_description.empty())
noDesc = true;

View File

@ -369,11 +369,11 @@ void WidgetTalk::handleEvents() {
void WidgetTalk::render(Highlight highlightMode) {
TattooTalk &talk = *(TattooTalk *)_vm->_talk;
int yp = 5;
int statementNum = 1;
byte color;
if (highlightMode != HL_SCROLLBAR_ONLY) {
int yp = 5;
int statementNum = 1;
// Draw all the statements
// Check whether scrolling has occurred, and if so, figure out what the starting
// number for the first visible statement will be
@ -392,7 +392,7 @@ void WidgetTalk::render(Highlight highlightMode) {
_surface.fillRect(Common::Rect(3, yp, _surface.w() - BUTTON_SIZE - 3, yp + _surface.fontHeight()), TRANSPARENCY);
// Different coloring based on whether the option has been previously chosen or not
color = (!talk._talkHistory[talk._converseNum][_statementLines[idx]._num]) ?
byte color = (!talk._talkHistory[talk._converseNum][_statementLines[idx]._num]) ?
INFO_TOP : INFO_BOTTOM;
if (_statementLines[idx]._num == _selector && highlightMode == HL_CHANGED_HIGHLIGHTS)

View File

@ -158,7 +158,6 @@ void WidgetVerbs::handleEvents() {
Talk &talk = *_vm->_talk;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
bool noDesc = false;
Common::String strLook = fixedText.getText(kFixedText_Look);
Common::String strTalk = fixedText.getText(kFixedText_Talk);
@ -184,6 +183,7 @@ void WidgetVerbs::handleEvents() {
ui._personFound = ui._bgFound >= 1000;
ui._bgShape = ui._personFound || ui._bgFound == -1 ? nullptr : &scene._bgShapes[ui._bgFound];
bool noDesc = false;
if (ui._personFound) {
if (people[ui._bgFound - 1000]._description.empty() || people[ui._bgFound - 1000]._description.hasPrefix(" "))
noDesc = true;