Skip to content

Commit

Permalink
TUCKER: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cyxx committed Feb 18, 2011
1 parent 0bffd77 commit 34f428e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
32 changes: 16 additions & 16 deletions engines/tucker/resource.cpp
Expand Up @@ -393,16 +393,16 @@ void TuckerEngine::loadBudSpr(int startOffset) {
switch (_flagsTable[137]) {
case 0:
if ((_gameFlags & kGameFlagDemo) != 0) {
sprintf(filename, "budl00_%d.pcx", frame + 1);
snprintf(filename, sizeof(filename), "budl00_%d.pcx", frame + 1);
} else {
sprintf(filename, "bud_%d.pcx", frame + 1);
snprintf(filename, sizeof(filename), "bud_%d.pcx", frame + 1);
}
break;
case 1:
sprintf(filename, "peg_%d.pcx", frame + 1);
snprintf(filename, sizeof(filename), "peg_%d.pcx", frame + 1);
break;
default:
sprintf(filename, "mac_%d.pcx", frame + 1);
snprintf(filename, sizeof(filename), "mac_%d.pcx", frame + 1);
break;
}
loadImage(filename, _loadTempBuf, 0);
Expand Down Expand Up @@ -483,25 +483,25 @@ void TuckerEngine::loadLoc() {

int i = _locationWidthTable[_locationNum];
_locationHeight = (_locationNum < 73) ? 140 : 200;
sprintf(filename, (i == 1) ? "loc%02d.pcx" : "loc%02da.pcx", _locationNum);
snprintf(filename, sizeof(filename), (i == 1) ? "loc%02d.pcx" : "loc%02da.pcx", _locationNum);
copyLocBitmap(filename, 0, false);
Graphics::copyRect(_quadBackgroundGfxBuf, 320, _locationBackgroundGfxBuf, 640, 320, _locationHeight);
if (_locationHeight == 200) {
return;
}
sprintf(filename, (i != 2) ? "path%02d.pcx" : "path%02da.pcx", _locationNum);
snprintf(filename, sizeof(filename), (i != 2) ? "path%02d.pcx" : "path%02da.pcx", _locationNum);
copyLocBitmap(filename, 0, true);
if (i > 1) {
sprintf(filename, "loc%02db.pcx", _locationNum);
snprintf(filename, sizeof(filename), "loc%02db.pcx", _locationNum);
copyLocBitmap(filename, 320, false);
Graphics::copyRect(_quadBackgroundGfxBuf + 44800, 320, _locationBackgroundGfxBuf + 320, 640, 320, _locationHeight);
if (i == 2) {
sprintf(filename, "path%02db.pcx", _locationNum);
snprintf(filename, sizeof(filename), "path%02db.pcx", _locationNum);
copyLocBitmap(filename, 320, true);
}
}
if (i > 2) {
sprintf(filename, "loc%02dc.pcx", _locationNum);
snprintf(filename, sizeof(filename), "loc%02dc.pcx", _locationNum);
copyLocBitmap(filename, 0, false);
Graphics::copyRect(_quadBackgroundGfxBuf + 89600, 320, _locationBackgroundGfxBuf, 640, 320, 140);
}
Expand All @@ -510,7 +510,7 @@ void TuckerEngine::loadLoc() {
loadImage("rochpath.pcx", _loadLocBufPtr, 0);
}
if (i > 3) {
sprintf(filename, "loc%02dd.pcx", _locationNum);
snprintf(filename, sizeof(filename), "loc%02dd.pcx", _locationNum);
copyLocBitmap(filename, 0, false);
Graphics::copyRect(_quadBackgroundGfxBuf + 134400, 320, _locationBackgroundGfxBuf + 320, 640, 320, 140);
}
Expand Down Expand Up @@ -541,10 +541,10 @@ void TuckerEngine::loadObj() {
_currentPartNum = _partNum;

char filename[40];
sprintf(filename, "objtxt%d.c", _partNum);
snprintf(filename, sizeof(filename), "objtxt%d.c", _partNum);
free(_objTxtBuf);
_objTxtBuf = loadFile(filename, 0);
sprintf(filename, "pt%dtext.c", _partNum);
snprintf(filename, sizeof(filename), "pt%dtext.c", _partNum);
free(_ptTextBuf);
_ptTextBuf = loadFile(filename, 0);
_characterSpeechDataPtr = _ptTextBuf;
Expand Down Expand Up @@ -585,7 +585,7 @@ void TuckerEngine::loadData() {
int offset = 0;
for (int i = 0; i < count; ++i) {
char filename[40];
sprintf(filename, "scrobj%d%d.pcx", _partNum, i);
snprintf(filename, sizeof(filename), "scrobj%d%d.pcx", _partNum, i);
loadImage(filename, _loadTempBuf, 0);
offset = loadDataHelper(offset, i);
}
Expand All @@ -604,7 +604,7 @@ int TuckerEngine::loadDataHelper(int offset, int index) {

void TuckerEngine::loadPanObj() {
char filename[40];
sprintf(filename, "panobjs%d.pcx", _partNum);
snprintf(filename, sizeof(filename), "panobjs%d.pcx", _partNum);
loadImage(filename, _loadTempBuf, 0);
int offset = 0;
for (int y = 0; y < 5; ++y) {
Expand Down Expand Up @@ -813,7 +813,7 @@ void TuckerEngine::loadSprA02_01() {
const int count = _sprA02LookupTable[_locationNum];
for (int i = 1; i < count + 1; ++i) {
char filename[40];
sprintf(filename, "sprites/a%02d_%02d.spr", _locationNum, i);
snprintf(filename, sizeof(filename), "sprites/a%02d_%02d.spr", _locationNum, i);
_sprA02Table[i] = loadFile(filename, 0);
}
_sprA02Table[0] = _sprA02Table[1];
Expand All @@ -832,7 +832,7 @@ void TuckerEngine::loadSprC02_01() {
const int count = _sprC02LookupTable[_locationNum];
for (int i = 1; i < count + 1; ++i) {
char filename[40];
sprintf(filename, "sprites/c%02d_%02d.spr", _locationNum, i);
snprintf(filename, sizeof(filename), "sprites/c%02d_%02d.spr", _locationNum, i);
_sprC02Table[i] = loadFile(filename, 0);
}
_sprC02Table[0] = _sprC02Table[1];
Expand Down
2 changes: 1 addition & 1 deletion engines/tucker/sequences.cpp
Expand Up @@ -119,7 +119,7 @@ void TuckerEngine::handleCreditsSequence() {
char filename[40];
if (num == 6) {
for (int i = 0; i < 16; ++i) {
sprintf(filename, "cogs%04d.pcx", i + 1);
snprintf(filename, sizeof(filename), "cogs%04d.pcx", i + 1);
loadImage(filename, imgBuf + i * 64000, 2);
}
} else {
Expand Down
25 changes: 11 additions & 14 deletions engines/tucker/tucker.cpp
Expand Up @@ -668,8 +668,8 @@ void TuckerEngine::updateCursorPos(int x, int y) {

void TuckerEngine::setCursorNum(int num) {
_cursorNum = num;
const int cursorW = 16;
const int cursorH = 16;
static const int cursorW = 16;
static const int cursorH = 16;
CursorMan.replaceCursor(_cursorGfxBuf + _cursorNum * 256, cursorW, cursorH, 1, 1, 0);
}

Expand Down Expand Up @@ -1090,17 +1090,15 @@ void TuckerEngine::stopSounds() {
}

void TuckerEngine::playSounds() {
for (int i = 0; i < 29; ++i) {
if (i < _locationSoundsCount) {
if (_locationSoundsTable[i].type == 1 || _locationSoundsTable[i].type == 2 || _locationSoundsTable[i].type == 5 ||
(_locationSoundsTable[i].type == 7 && _flagsTable[_locationSoundsTable[i].flagNum] == _locationSoundsTable[i].flagValueStartFx)) {
startSound(_locationSoundsTable[i].offset, i, _locationSoundsTable[i].volume);
}
for (int i = 0; i < _locationSoundsCount; ++i) {
if (_locationSoundsTable[i].type == 1 || _locationSoundsTable[i].type == 2 || _locationSoundsTable[i].type == 5 ||
(_locationSoundsTable[i].type == 7 && _flagsTable[_locationSoundsTable[i].flagNum] == _locationSoundsTable[i].flagValueStartFx)) {
startSound(_locationSoundsTable[i].offset, i, _locationSoundsTable[i].volume);
}
if (i < _locationMusicsCount) {
if (_locationMusicsTable[i].flag > 0) {
startMusic(_locationMusicsTable[i].offset, i, _locationMusicsTable[i].volume);
}
}
for (int i = 0; i < _locationMusicsCount; ++i) {
if (_locationMusicsTable[i].flag > 0) {
startMusic(_locationMusicsTable[i].offset, i, _locationMusicsTable[i].volume);
}
}
}
Expand Down Expand Up @@ -1422,15 +1420,14 @@ void TuckerEngine::redrawPanelOverBackground() {
}

void TuckerEngine::drawConversationTexts() {
int x = 0;
int y = 141;
int flag = 0;
for (int i = 0; i < _conversationOptionsCount; ++i) {
int color = 108;
if ((_mousePosY > y && _mousePosY < y + 11) || _nextTableToLoadIndex == i) {
color = 106;
}
drawSpeechText(x, y, _characterSpeechDataPtr, _instructionsActionsTable[i], color);
drawSpeechText(0, y, _characterSpeechDataPtr, _instructionsActionsTable[i], color);
if (_mousePosY > y && _mousePosY < _conversationOptionLinesCount * 10 + y + 1) {
_nextTableToLoadIndex = i;
flag = 1;
Expand Down

0 comments on commit 34f428e

Please sign in to comment.