Two segfault and several coding style related fixes

svn-id: r22954
This commit is contained in:
Sven Hesse 2006-06-06 15:43:44 +00:00
parent 9a46b6047d
commit bf86b9b022
8 changed files with 24 additions and 20 deletions

View file

@ -667,7 +667,7 @@ void Draw::drawSprite(int16 source, Video::SurfaceDesc * dest, int16 left,
void Draw::drawString(char *str, int16 x, int16 y, int16 color1, int16 color2, void Draw::drawString(char *str, int16 x, int16 y, int16 color1, int16 color2,
int16 transp, Video::SurfaceDesc *dest, Video::FontDesc *font) { int16 transp, Video::SurfaceDesc *dest, Video::FontDesc *font) {
while(*str != '\0') { while (*str != '\0') {
_vm->_video->drawLetter(*str, x, y, font, transp, color1, color2, dest); _vm->_video->drawLetter(*str, x, y, font, transp, color1, color2, dest);
if (font->extraData == 0) if (font->extraData == 0)
x += font->itemWidth; x += font->itemWidth;

View file

@ -144,7 +144,7 @@ void Draw_v2::printText(void) {
if ((_vm->_game->_totFileData[0x29] < 0x32) && (*ptr2 > 3) && (*ptr2 < 32)) if ((_vm->_game->_totFileData[0x29] < 0x32) && (*ptr2 > 3) && (*ptr2 < 32))
*ptr2 = 32; *ptr2 = 32;
switch(*ptr2) { switch (*ptr2) {
case 1: case 1:
break; break;
@ -202,7 +202,7 @@ void Draw_v2::printText(void) {
_backColor = 0; _backColor = 0;
_transparency = 1; _transparency = 1;
while(true) { while (true) {
if ((*ptr >= 1) && ((*ptr <= 7) || (*ptr == 10)) && (strPos != 0)) { if ((*ptr >= 1) && ((*ptr <= 7) || (*ptr == 10)) && (strPos != 0)) {
str[MAX(strPos, strPos2)] = 0; str[MAX(strPos, strPos2)] = 0;
strPosBak = strPos; strPosBak = strPos;
@ -352,7 +352,7 @@ void Draw_v2::printText(void) {
if (cmd == 0) { if (cmd == 0) {
val = READ_LE_UINT16(ptr2 + 18) * 4; val = READ_LE_UINT16(ptr2 + 18) * 4;
sprintf(buf, "%d", VAR_OFFSET(val)); sprintf(buf, "%d", VAR_OFFSET(val));
} else if(cmd == 1) { } else if (cmd == 1) {
val = READ_LE_UINT16(ptr2 + 18) * 4; val = READ_LE_UINT16(ptr2 + 18) * 4;
strcpy(buf, _vm->_global->_inter_variables + val); strcpy(buf, _vm->_global->_inter_variables + val);
} else { } else {

View file

@ -404,7 +404,10 @@ void Game::freeSoundSlot(int16 slot) {
if (_soundADL[slot]) { if (_soundADL[slot]) {
_vm->_music->stopPlay(); _vm->_music->stopPlay();
delete[] ((char *) _soundSamples[slot]); if (_soundFromExt[slot] == 1) {
delete[] ((char *) _soundSamples[slot]);
_soundFromExt[slot] = 0;
}
} else { } else {
char* data = _soundSamples[slot]->data; char* data = _soundSamples[slot]->data;
@ -2013,7 +2016,7 @@ Game::Imd *Game::loadImdFile(const char *path, Video::SurfaceDesc *surfDesc, int
delete imdPtr; delete imdPtr;
return 0; return 0;
} }
if(imdPtr->stdX != 0) { if (imdPtr->stdX != 0) {
_vm->_dataio->readData(handle, buf, 8); _vm->_dataio->readData(handle, buf, 8);
imdPtr->stdX = READ_LE_UINT16(buf); imdPtr->stdX = READ_LE_UINT16(buf);
imdPtr->stdY = READ_LE_UINT16(buf + 2); imdPtr->stdY = READ_LE_UINT16(buf + 2);
@ -2401,7 +2404,7 @@ int16 Game::viewImd(Game::Imd *imdPtr, int16 frame) {
} }
} else } else
retVal |= 0x800; retVal |= 0x800;
} while(var_4 != 0); } while (var_4 != 0);
if (byte_2DA60 != 0) { if (byte_2DA60 != 0) {
byte_2DA60 = 0; byte_2DA60 = 0;
@ -2567,7 +2570,7 @@ void Game::imdFrameUncompressor(byte *dest, byte *src) {
chunkCount = 1; chunkCount = 1;
chunkBitField = 0; chunkBitField = 0;
while(frameLength > 0) { while (frameLength > 0) {
chunkCount--; chunkCount--;
if (chunkCount == 0) { if (chunkCount == 0) {
tmp = *src++; tmp = *src++;

View file

@ -80,7 +80,7 @@ void Game_v1::playTot(int16 skipPlay) {
_vm->_draw->_fontToSprite[i].height = -1; _vm->_draw->_fontToSprite[i].height = -1;
} }
if(_vm->_features & GF_MAC) if (_vm->_features & GF_MAC)
_vm->_music->stopPlay(); _vm->_music->stopPlay();
else else
_vm->_cdrom->stopPlaying(); _vm->_cdrom->stopPlaying();

View file

@ -80,7 +80,7 @@ void Game_v2::playTot(int16 skipPlay) {
_vm->_draw->_fontToSprite[i].height = -1; _vm->_draw->_fontToSprite[i].height = -1;
} }
if(_vm->_features & GF_MAC) if (_vm->_features & GF_MAC)
_vm->_music->stopPlay(); _vm->_music->stopPlay();
else else
_vm->_cdrom->stopPlaying(); _vm->_cdrom->stopPlaying();
@ -481,14 +481,14 @@ int16 Game_v2::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
cursorRight = _vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth; cursorRight = _vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth;
if (cursorRight > (_word_2FC9E + sWidth)) if (cursorRight > (_word_2FC9E + sWidth))
_word_2FC9E = MIN(cursorRight - sWidth, width - sWidth); _word_2FC9E = MIN(cursorRight - sWidth, width - sWidth);
} else if(_vm->_global->_inter_mouseX < _word_2FC9E) } else if (_vm->_global->_inter_mouseX < _word_2FC9E)
_word_2FC9E = _vm->_global->_inter_mouseX; _word_2FC9E = _vm->_global->_inter_mouseX;
height = _vm->_draw->_frontSurface->height; height = _vm->_draw->_frontSurface->height;
if ((height > sHeight) && (_vm->_global->_inter_mouseY >= _word_2FC9C)) { if ((height > sHeight) && (_vm->_global->_inter_mouseY >= _word_2FC9C)) {
cursorBottom = _vm->_global->_inter_mouseY + _vm->_draw->_cursorHeight; cursorBottom = _vm->_global->_inter_mouseY + _vm->_draw->_cursorHeight;
if (cursorBottom > (_word_2FC9C + sHeight)) if (cursorBottom > (_word_2FC9C + sHeight))
_word_2FC9C = MIN(cursorBottom - sHeight, height - sHeight); _word_2FC9C = MIN(cursorBottom - sHeight, height - sHeight);
} else if(_vm->_global->_inter_mouseY < _word_2FC9C) } else if (_vm->_global->_inter_mouseY < _word_2FC9C)
_word_2FC9C = _vm->_global->_inter_mouseY; _word_2FC9C = _vm->_global->_inter_mouseY;
if ((oldWord_2FC9E != _word_2FC9E) || (oldWord_2FC9C != _word_2FC9C)) { if ((oldWord_2FC9E != _word_2FC9E) || (oldWord_2FC9C != _word_2FC9C)) {
if (_byte_2FC9B == 0) { if (_byte_2FC9B == 0) {
@ -499,7 +499,7 @@ int16 Game_v2::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
if ((_vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth) > if ((_vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth) >
(_word_2FC9E + sWidth)) (_word_2FC9E + sWidth))
_vm->_global->_inter_mouseX = _word_2FC9E + sWidth - _vm->_draw->_cursorWidth; _vm->_global->_inter_mouseX = _word_2FC9E + sWidth - _vm->_draw->_cursorWidth;
} else if(_vm->_global->_inter_mouseX < oldWord_2FC9E) } else if (_vm->_global->_inter_mouseX < oldWord_2FC9E)
_vm->_global->_inter_mouseX = oldWord_2FC9E; _vm->_global->_inter_mouseX = oldWord_2FC9E;
if ((_vm->_draw->_frontSurface->height > sHeight) && if ((_vm->_draw->_frontSurface->height > sHeight) &&
@ -507,7 +507,7 @@ int16 Game_v2::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
if ((_vm->_global->_inter_mouseY + _vm->_draw->_cursorHeight) > if ((_vm->_global->_inter_mouseY + _vm->_draw->_cursorHeight) >
(_word_2FC9C + sHeight)) (_word_2FC9C + sHeight))
_vm->_global->_inter_mouseY = _word_2FC9C + sHeight - _vm->_draw->_cursorHeight; _vm->_global->_inter_mouseY = _word_2FC9C + sHeight - _vm->_draw->_cursorHeight;
} else if(_vm->_global->_inter_mouseY < oldWord_2FC9E) } else if (_vm->_global->_inter_mouseY < oldWord_2FC9E)
_vm->_global->_inter_mouseY = _word_2FC9C; _vm->_global->_inter_mouseY = _word_2FC9C;
} else { } else {
if (oldWord_2FC9E > _word_2FC9E) { if (oldWord_2FC9E > _word_2FC9E) {

View file

@ -1821,6 +1821,7 @@ void Goblin::zeroObjects(void) {
void Goblin::freeAllObjects(void) { void Goblin::freeAllObjects(void) {
_vm->_util->deleteList(_objList); _vm->_util->deleteList(_objList);
_objList = 0;
freeObjects(); freeObjects();
} }
@ -2347,7 +2348,7 @@ void Goblin::sub_19BD3(void) {
anim0->field_10 = 6; anim0->field_10 = 6;
} }
if (anim1->someFlag == 0) { if (anim1->someFlag == 0) {
if((_word_2F9BA == 0) && (anim1->isStatic == 0)) { if ((_word_2F9BA == 0) && (anim1->isStatic == 0)) {
if ((VAR(_dword_2F9B2) == 0) && (di == 28)) { if ((VAR(_dword_2F9B2) == 0) && (di == 28)) {
di = _vm->_util->getRandom(3) + 24; di = _vm->_util->getRandom(3) + 24;
warning("GOB2 Stub! sub_195C7(1, di);"); warning("GOB2 Stub! sub_195C7(1, di);");
@ -2369,7 +2370,7 @@ void Goblin::sub_19BD3(void) {
if (VAR(18) != ((uint32) -1)) { if (VAR(18) != ((uint32) -1)) {
if (anim0->layer == 44) if (anim0->layer == 44)
anim0->field_10 = 4; anim0->field_10 = 4;
else if(anim0->layer == 45) else if (anim0->layer == 45)
anim0->field_10 = 0; anim0->field_10 = 0;
if (anim0->someFlag == 0) if (anim0->someFlag == 0)
anim0->field_10 = 6; anim0->field_10 = 6;
@ -2377,7 +2378,7 @@ void Goblin::sub_19BD3(void) {
if (VAR(19) != ((uint32) -1)) { if (VAR(19) != ((uint32) -1)) {
if (anim1->layer == 48) if (anim1->layer == 48)
anim1->field_10 = 4; anim1->field_10 = 4;
else if(anim1->layer == 49) else if (anim1->layer == 49)
anim1->field_10 = 0; anim1->field_10 = 0;
if (anim1->someFlag == 0) if (anim1->someFlag == 0)
anim1->field_10 = 6; anim1->field_10 = 6;

View file

@ -1253,7 +1253,7 @@ bool Inter_v2::o2_palLoad(char &cmdCount, int16 &counter, int16 &retFlag) {
cmd = *_vm->_global->_inter_execPtr++; cmd = *_vm->_global->_inter_execPtr++;
switch(cmd & 0x7f) { switch (cmd & 0x7f) {
case 48: case 48:
if ((_vm->_global->_videoMode < 0x32) || (_vm->_global->_videoMode > 0x63)) { if ((_vm->_global->_videoMode < 0x32) || (_vm->_global->_videoMode > 0x63)) {
_vm->_global->_inter_execPtr += 48; _vm->_global->_inter_execPtr += 48;
@ -1325,7 +1325,7 @@ bool Inter_v2::o2_palLoad(char &cmdCount, int16 &counter, int16 &retFlag) {
int dl = 0; int dl = 0;
for (i = 2; i < 18; i++) { for (i = 2; i < 18; i++) {
dl = 1; dl = 1;
if(_vm->_global->_inter_execPtr[i] != 0) if (_vm->_global->_inter_execPtr[i] != 0)
dl = 0; dl = 0;
} }
if (dl != 0) { if (dl != 0) {

View file

@ -1236,7 +1236,7 @@ void Mult_v2::animate(void) {
animData1->frame++; animData1->frame++;
if (animData1->frame >= if (animData1->frame >=
_vm->_scenery->_animations[(int)animData1->animation].layers[animData1->layer]->framesCount) { _vm->_scenery->_animations[(int)animData1->animation].layers[animData1->layer]->framesCount) {
switch(animData1->animType) { switch (animData1->animType) {
case 0: case 0:
animData1->frame = 0; animData1->frame = 0;
break; break;