Skip to content

Commit

Permalink
SHERLOCK: Reduce the scope of some variables, add a couple of CHECKMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Jun 13, 2015
1 parent b87b081 commit 5887d92
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
3 changes: 1 addition & 2 deletions engines/sherlock/image_file.cpp
Expand Up @@ -570,7 +570,6 @@ void ImageFile3DO::load3DOCelRoomData(Common::SeekableReadStream &stream) {
uint32 ccbHeight = 0;
// cel data
uint32 celDataSize = 0;
byte *celDataPtr = NULL;

while (stream.pos() < streamSize) {
// 3DO sherlock holmes room data header
Expand Down Expand Up @@ -609,7 +608,7 @@ void ImageFile3DO::load3DOCelRoomData(Common::SeekableReadStream &stream) {
celDataSize = roomDataHeader_size - 68;

// read data into memory
celDataPtr = new byte[celDataSize];
byte *celDataPtr = new byte[celDataSize];

stream.read(celDataPtr, celDataSize);

Expand Down
2 changes: 1 addition & 1 deletion engines/sherlock/objects.cpp
Expand Up @@ -414,7 +414,6 @@ void Sprite::setObjTalkSequence(int seq) {

void Sprite::checkWalkGraphics() {
People &people = *_vm->_people;
int npcNum = -1;

if (_images == nullptr) {
freeAltGraphics();
Expand Down Expand Up @@ -450,6 +449,7 @@ void Sprite::checkWalkGraphics() {

// If there is no Alternate Sequence set, see if we need to load a new one
if (!_altSeq) {
int npcNum = -1;
// Find which NPC this is so we can check the name of the graphics loaded
for (int idx = 0; idx < MAX_CHARACTERS; ++idx) {
if (this == &people[idx]) {
Expand Down
6 changes: 2 additions & 4 deletions engines/sherlock/screen.cpp
Expand Up @@ -213,8 +213,6 @@ void Screen::fadeIntoScreen3DO(int speed) {
Events &events = *_vm->_events;
uint16 *currentScreenBasePtr = (uint16 *)getPixels();
uint16 *targetScreenBasePtr = (uint16 *)_backBuffer->getPixels();
uint16 *currentScreenPtr = NULL;
uint16 *targetScreenPtr = NULL;
uint16 currentScreenPixel = 0;
uint16 targetScreenPixel = 0;

Expand All @@ -236,8 +234,8 @@ void Screen::fadeIntoScreen3DO(int speed) {

do {
pixelsChanged = 0;
currentScreenPtr = currentScreenBasePtr;
targetScreenPtr = targetScreenBasePtr;
uint16 *currentScreenPtr = currentScreenBasePtr;
uint16 *targetScreenPtr = targetScreenBasePtr;

for (screenY = 0; screenY < screenHeight; screenY++) {
for (screenX = 0; screenX < screenWidth; screenX++) {
Expand Down
8 changes: 4 additions & 4 deletions engines/sherlock/tattoo/tattoo_map.cpp
Expand Up @@ -318,7 +318,6 @@ void TattooMap::checkMapNames(bool slamIt) {
Events &events = *_vm->_events;
Screen &screen = *_vm->_screen;
Common::Point mousePos = events.mousePos() + _currentScroll;
int dif = 10000;

// See if the mouse is pointing at any of the map locations
_bgFound = -1;
Expand Down Expand Up @@ -353,6 +352,7 @@ void TattooMap::checkMapNames(bool slamIt) {
if (width > 150) {
const char *s = desc.c_str();

int dif = 10000;
for (;;) {
// Move to end of next word
s = strchr(s, ' ');
Expand Down Expand Up @@ -409,10 +409,9 @@ void TattooMap::checkMapNames(bool slamIt) {
// The text needs to be split up over two lines
Common::String line1(desc.c_str(), space);
Common::String line2(space + 1);
int xp, yp;

// Draw the first line
xp = (width - screen.stringWidth(desc)) / 2;
int xp = (width - screen.stringWidth(desc)) / 2;
_textBuffer->writeString(line1, Common::Point(xp + 0, 0), BLACK);
_textBuffer->writeString(line1, Common::Point(xp + 1, 0), BLACK);
_textBuffer->writeString(line1, Common::Point(xp + 2, 0), BLACK);
Expand All @@ -423,8 +422,9 @@ void TattooMap::checkMapNames(bool slamIt) {
_textBuffer->writeString(line1, Common::Point(xp + 2, 2), BLACK);
_textBuffer->writeString(line1, Common::Point(xp + 1, 1), MAP_NAME_COLOR);

yp = screen.stringHeight(line2);
int yp = screen.stringHeight(line2);
xp = (width - screen.stringWidth(line2)) / 2;
// CHECKME: Shouldn't we use yp for drawing line2?
_textBuffer->writeString(line2, Common::Point(xp + 0, 0), BLACK);
_textBuffer->writeString(line2, Common::Point(xp + 1, 0), BLACK);
_textBuffer->writeString(line2, Common::Point(xp + 2, 0), BLACK);
Expand Down
12 changes: 5 additions & 7 deletions engines/sherlock/tattoo/tattoo_scene.cpp
Expand Up @@ -724,6 +724,7 @@ int TattooScene::getScaleVal(const Common::Point &pt) {
if (sz.contains(pos)) {
int n = (sz._bottomNumber - sz._topNumber) * 100 / sz.height() * (pos.y - sz.top) / 100 + sz._topNumber;
result = 25600L / n;
// CHECKME: Shouldn't we set 'found' at this place?
}
}

Expand All @@ -743,10 +744,6 @@ int TattooScene::getScaleVal(const Common::Point &pt) {
}

void TattooScene::setupBGArea(const byte cMap[PALETTE_SIZE]) {
int r, g, b;
byte c;
int cd, d;

// This requires that there is a 16 grayscale palette sequence in the palette that goes from lighter
// to darker as the palette numbers go up. The last palette entry in that run is specified by _bgColor
byte *p = &_lookupTable[0];
Expand All @@ -758,6 +755,7 @@ void TattooScene::setupBGArea(const byte cMap[PALETTE_SIZE]) {
p = &_lookupTable1[0];

for (int idx = 0; idx < PALETTE_COUNT; ++idx) {
int r, g, b;
switch (_currentScene) {
case 8:
r = cMap[idx * 3] * 4 / 5;
Expand All @@ -784,11 +782,11 @@ void TattooScene::setupBGArea(const byte cMap[PALETTE_SIZE]) {
break;
}

c = 0;
cd = (r - cMap[0]) * (r - cMap[0]) + (g - cMap[1]) * (g - cMap[1]) + (b - cMap[2]) * (b - cMap[2]);
byte c = 0;
int cd = (r - cMap[0]) * (r - cMap[0]) + (g - cMap[1]) * (g - cMap[1]) + (b - cMap[2]) * (b - cMap[2]);

for (int pal = 0; pal < PALETTE_COUNT; ++pal) {
d = (r - cMap[pal * 3]) * (r - cMap[pal * 3]) + (g - cMap[pal * 3 + 1]) * (g - cMap[pal * 3 + 1])
int d = (r - cMap[pal * 3]) * (r - cMap[pal * 3]) + (g - cMap[pal * 3 + 1]) * (g - cMap[pal * 3 + 1])
+ (b - cMap[pal * 3 + 2])*(b - cMap[pal * 3 + 2]);

if (d < cd) {
Expand Down

0 comments on commit 5887d92

Please sign in to comment.