KYRA: (EOB) - fix some valgrind warnings

This commit is contained in:
athrxx 2011-09-13 21:46:23 +02:00 committed by Johannes Schickel
parent 816b40ebf8
commit 68ed8b9598
11 changed files with 49 additions and 30 deletions

View File

@ -183,7 +183,7 @@ EobCoreEngine::~EobCoreEngine() {
delete[] _itemTypes; delete[] _itemTypes;
if (_itemNames) { if (_itemNames) {
for (int i = 0; i < 130; i++) for (int i = 0; i < 130; i++)
delete _itemNames[i]; delete[] _itemNames[i];
} }
delete[] _itemNames; delete[] _itemNames;
delete[] _flyingObjects; delete[] _flyingObjects;
@ -218,6 +218,9 @@ EobCoreEngine::~EobCoreEngine() {
delete _gui; delete _gui;
_gui = 0; _gui = 0;
delete _screen;
_screen = 0;
delete[] _menuDefs; delete[] _menuDefs;
_menuDefs = 0; _menuDefs = 0;
@ -227,6 +230,8 @@ EobCoreEngine::~EobCoreEngine() {
_timer = 0; _timer = 0;
delete _debugger; delete _debugger;
_debugger = 0; _debugger = 0;
delete _txt;
_txt = 0;
} }
Common::Error EobCoreEngine::init() { Common::Error EobCoreEngine::init() {
@ -672,6 +677,8 @@ void EobCoreEngine::releaseItemsAndDecorationsShapes() {
delete []_firebeamShapes; delete []_firebeamShapes;
} }
delete[] _redSplatShape;
delete[] _greenSplatShape;
delete[] _deadCharShape; delete[] _deadCharShape;
delete[] _disabledCharGrid; delete[] _disabledCharGrid;
delete[] _blackBoxSmallGrid; delete[] _blackBoxSmallGrid;
@ -1214,18 +1221,15 @@ void EobCoreEngine::setWeaponSlotStatus(int charIndex, int mode, int slot) {
gui_drawCharPortraitWithStats(charIndex); gui_drawCharPortraitWithStats(charIndex);
} }
void EobCoreEngine::setupDialogueButtons(int presetfirst, int numStr, const char *str1, ...) { void EobCoreEngine::setupDialogueButtons(int presetfirst, int numStr, const char *str1, va_list &args) {
_dialogueNumButtons = numStr; _dialogueNumButtons = numStr;
_dialogueButtonString[0] = str1; _dialogueButtonString[0] = str1;
_dialogueHighlightedButton = 0; _dialogueHighlightedButton = 0;
va_list args;
va_start(args, str1);
const char **sp = va_arg(args, const char**);
va_end(args);
for (int i = 1; i < numStr; i++) { for (int i = 1; i < numStr; i++) {
if (sp[i - 1]) const char *tmp = va_arg(args, const char*);
_dialogueButtonString[i] = sp[i - 1]; if (tmp)
_dialogueButtonString[i] = tmp;
else else
_dialogueNumButtons = numStr = i; _dialogueNumButtons = numStr = i;
} }

View File

@ -757,7 +757,7 @@ protected:
bool _configHpBarGraphs; bool _configHpBarGraphs;
// text // text
void setupDialogueButtons(int presetfirst, int numStr, const char *str1, ...); void setupDialogueButtons(int presetfirst, int numStr, const char *str1, va_list &args);
void initDialogueSequence(); void initDialogueSequence();
void restoreAfterDialogueSequence(); void restoreAfterDialogueSequence();
void drawSequenceBitmap(const char *file, int destRect, int x1, int y1, int flags); void drawSequenceBitmap(const char *file, int destRect, int x1, int y1, int flags);

View File

@ -225,6 +225,8 @@ LoLEngine::~LoLEngine() {
_gui = 0; _gui = 0;
delete _tim; delete _tim;
_tim = 0; _tim = 0;
delete _txt;
_txt = 0;
delete[] _itemsInPlay; delete[] _itemsInPlay;
delete[] _itemProperties; delete[] _itemProperties;
@ -298,6 +300,8 @@ LoLEngine::~LoLEngine() {
_doorShapes[i] = 0; _doorShapes[i] = 0;
} }
releaseDecorations();
delete[] _automapShapes; delete[] _automapShapes;
for (Common::Array<const TIMOpcode*>::iterator i = _timIntroOpcodes.begin(); i != _timIntroOpcodes.end(); ++i) for (Common::Array<const TIMOpcode*>::iterator i = _timIntroOpcodes.begin(); i != _timIntroOpcodes.end(); ++i)

View File

@ -915,6 +915,7 @@ private:
void assignBlockObject(LevelBlockProperty *l, uint16 item); void assignBlockObject(LevelBlockProperty *l, uint16 item);
int assignLevelDecorationShapes(int index); int assignLevelDecorationShapes(int index);
uint8 *getLevelDecorationShapes(int index); uint8 *getLevelDecorationShapes(int index);
void releaseDecorations(int first = 0, int num = 400);
void restoreTempDataAdjustMonsterStrength(int index); void restoreTempDataAdjustMonsterStrength(int index);
void loadBlockProperties(const char *cmzFile); void loadBlockProperties(const char *cmzFile);
const uint8 *getBlockFileData(int levelIndex); const uint8 *getBlockFileData(int levelIndex);

View File

@ -149,9 +149,6 @@ LolEobBaseEngine::~LolEobBaseEngine() {
delete[] _levelDecorationData; delete[] _levelDecorationData;
delete[] _levelDecorationProperties; delete[] _levelDecorationProperties;
delete[] _levelBlockProperties; delete[] _levelBlockProperties;
delete _txt;
_txt = 0;
} }
Common::Error LolEobBaseEngine::init() { Common::Error LolEobBaseEngine::init() {

View File

@ -1092,18 +1092,22 @@ void EobCoreEngine::drawSceneShapes(int start) {
} }
void EobCoreEngine::drawDecorations(int index) { void EobCoreEngine::drawDecorations(int index) {
static const int16 *dscWalls[] = { 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, static const int16 *dscWalls[] = {
&_sceneDrawVarRight, &_sceneDrawVarDown, 0, &_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight,
&_sceneDrawVarLeft, 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, 0,
&_sceneDrawVarDown, 0, &_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, &_sceneDrawVarLeft,
&_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, 0, &_sceneDrawVarDown, &_sceneDrawVarLeft, 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight,
0, &_sceneDrawVarRight, &_sceneDrawVarDown, 0, 0, &_sceneDrawVarLeft &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, 0,
&_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, &_sceneDrawVarLeft,
&_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, 0,
&_sceneDrawVarDown, &_sceneDrawVarLeft, 0, &_sceneDrawVarRight,
&_sceneDrawVarDown, 0, 0, &_sceneDrawVarLeft
}; };
for (int i = 1; i >= 0; i--) { for (int i = 1; i >= 0; i--) {
int s = index * 2 + i; int s = index * 2 + i;
if (dscWalls[s]) { if (dscWalls[s]) {
int d = *dscWalls[s]; int16 d = *dscWalls[s];
int8 l = _wllShapeMap[_visibleBlocks[index]->walls[d]]; int8 l = _wllShapeMap[_visibleBlocks[index]->walls[d]];
uint8 *shapeData = 0; uint8 *shapeData = 0;

View File

@ -200,6 +200,7 @@ int LoLEngine::assignLevelDecorationShapes(int index) {
if (pv) { if (pv) {
_levelDecorationProperties[o].shapeIndex[i] = pv; _levelDecorationProperties[o].shapeIndex[i] = pv;
} else { } else {
releaseDecorations(_lvlShapeIndex, 1);
_levelDecorationShapes[_lvlShapeIndex] = getLevelDecorationShapes(t); _levelDecorationShapes[_lvlShapeIndex] = getLevelDecorationShapes(t);
p1[t] = _lvlShapeIndex; p1[t] = _lvlShapeIndex;
_levelDecorationProperties[o].shapeIndex[i] = _lvlShapeIndex++; _levelDecorationProperties[o].shapeIndex[i] = _lvlShapeIndex++;
@ -232,6 +233,13 @@ uint8 *LoLEngine::getLevelDecorationShapes(int shapeIndex) {
return res; return res;
} }
void LoLEngine::releaseDecorations(int first, int num) {
for (int i = first; i < (first + num); i++) {
delete[] _levelDecorationShapes[i];
_levelDecorationShapes[i] = 0;
}
}
void LoLEngine::loadBlockProperties(const char *cmzFile) { void LoLEngine::loadBlockProperties(const char *cmzFile) {
memset(_levelBlockProperties, 0, 1024 * sizeof(LevelBlockProperty)); memset(_levelBlockProperties, 0, 1024 * sizeof(LevelBlockProperty));
_screen->loadBitmap(cmzFile, 2, 2, 0); _screen->loadBitmap(cmzFile, 2, 2, 0);

View File

@ -848,7 +848,8 @@ void Screen::copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *
void Screen::copyPage(uint8 srcPage, uint8 dstPage) { void Screen::copyPage(uint8 srcPage, uint8 dstPage) {
uint8 *src = getPagePtr(srcPage); uint8 *src = getPagePtr(srcPage);
uint8 *dst = getPagePtr(dstPage); uint8 *dst = getPagePtr(dstPage);
memcpy(dst, src, SCREEN_W * SCREEN_H); if (src != dst)
memcpy(dst, src, SCREEN_W * SCREEN_H);
copyOverlayRegion(0, 0, 0, 0, SCREEN_W, SCREEN_H, srcPage, dstPage); copyOverlayRegion(0, 0, 0, 0, SCREEN_W, SCREEN_H, srcPage, dstPage);
if (dstPage == 0 || dstPage == 1) if (dstPage == 0 || dstPage == 1)

View File

@ -46,6 +46,7 @@ Screen_Eob::Screen_Eob(EobCoreEngine *vm, OSystem *system) : Screen(vm, system)
_gfxCol = 0; _gfxCol = 0;
_customDimTable = 0; _customDimTable = 0;
_dsTempPage = 0; _dsTempPage = 0;
_curDimIndex = 0;
} }
Screen_Eob::~Screen_Eob() { Screen_Eob::~Screen_Eob() {
@ -266,7 +267,7 @@ uint8 *Screen_Eob::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool no4b
uint8 *colorMap = new uint8[0x100]; uint8 *colorMap = new uint8[0x100];
memset (colorMap, 0xff, 0x100); memset (colorMap, 0xff, 0x100);
shapesize = h * (w << 2) + 0x14; shapesize = h * (w << 2) + 20;
shp = new uint8[shapesize]; shp = new uint8[shapesize];
memset (shp, 0, shapesize); memset (shp, 0, shapesize);
uint8 *dst = shp; uint8 *dst = shp;
@ -673,14 +674,13 @@ const uint8 *Screen_Eob::scaleShapeStep(const uint8 *shp) {
i = -i; i = -i;
_dsScaleTmp = (i << 4) | (i & 0x0f); _dsScaleTmp = (i << 4) | (i & 0x0f);
memcpy(d, shp, 16); for (int ii = 0; ii < 16; ii++)
d += 16; *d++ = *shp++;
shp += 16;
_dsDiv = w2 / 3; _dsDiv = w2 / 3;
_dsRem = w2 % 3; _dsRem = w2 % 3;
do { while (--h) {
scaleShapeProcessLine(d, shp); scaleShapeProcessLine(d, shp);
if (!--h) if (!--h)
break; break;
@ -688,7 +688,7 @@ const uint8 *Screen_Eob::scaleShapeStep(const uint8 *shp) {
if (!--h) if (!--h)
break; break;
shp += w2; shp += w2;
} while (--h); }
return (const uint8 *) _dsTempPage; return (const uint8 *) _dsTempPage;
} }
@ -1100,15 +1100,14 @@ void Screen_Eob::drawShapeSetPixel(uint8 * dst, uint8 c) {
void Screen_Eob::scaleShapeProcessLine(uint8 *&dst, const uint8 *&src) { void Screen_Eob::scaleShapeProcessLine(uint8 *&dst, const uint8 *&src) {
for (int i = 0; i < _dsDiv; i++) { for (int i = 0; i < _dsDiv; i++) {
*dst++ = *src++; *dst++ = *src++;
*dst++ = READ_BE_UINT16(src) >> 4; *dst++ = (READ_BE_UINT16(src) >> 4) & 0xff;
src += 2; src += 2;
} }
if (_dsRem == 1) { if (_dsRem == 1) {
*dst++ = *src++; *dst++ = *src++;
*dst++ = _dsScaleTmp; *dst++ = _dsScaleTmp;
} else if (_dsRem == 2) {
} if (_dsRem == 2) {
*dst++ = (src[0] & 0xf0) | (src[1] >> 4); *dst++ = (src[0] & 0xf0) | (src[1] >> 4);
src += 2; src += 2;
*dst++ = _dsScaleTmp; *dst++ = _dsScaleTmp;

View File

@ -893,6 +893,7 @@ TIMInterpreter_LoL::TIMInterpreter_LoL(LoLEngine *engine, Screen_v2 *screen_v2,
_screen = engine->_screen; _screen = engine->_screen;
delete _animator;
_animator = new TimAnimator(engine, screen_v2, system, true); _animator = new TimAnimator(engine, screen_v2, system, true);
_drawPage2 = 0; _drawPage2 = 0;

View File

@ -951,7 +951,7 @@ DarkmoonSequenceHelper::~DarkmoonSequenceHelper() {
delete _palettes[11]; delete _palettes[11];
for (int i = 0; i < 30; i++) for (int i = 0; i < 30; i++)
delete _shapes[i]; delete[] _shapes[i];
delete[] _shapes; delete[] _shapes;
_screen->clearCurPage(); _screen->clearCurPage();