diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/eobcommon.cpp | 20 | ||||
-rw-r--r-- | engines/kyra/eobcommon.h | 2 | ||||
-rw-r--r-- | engines/kyra/lol.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/lol.h | 1 | ||||
-rw-r--r-- | engines/kyra/loleobbase.cpp | 3 | ||||
-rw-r--r-- | engines/kyra/scene_eob.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/scene_lol.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 3 | ||||
-rw-r--r-- | engines/kyra/screen_eob.cpp | 17 | ||||
-rw-r--r-- | engines/kyra/script_tim.cpp | 1 | ||||
-rw-r--r-- | engines/kyra/sequences_eob2.cpp | 2 |
11 files changed, 49 insertions, 30 deletions
diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index 802907eba5..3bc145a398 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -183,7 +183,7 @@ EobCoreEngine::~EobCoreEngine() { delete[] _itemTypes; if (_itemNames) { for (int i = 0; i < 130; i++) - delete _itemNames[i]; + delete[] _itemNames[i]; } delete[] _itemNames; delete[] _flyingObjects; @@ -218,6 +218,9 @@ EobCoreEngine::~EobCoreEngine() { delete _gui; _gui = 0; + delete _screen; + _screen = 0; + delete[] _menuDefs; _menuDefs = 0; @@ -227,6 +230,8 @@ EobCoreEngine::~EobCoreEngine() { _timer = 0; delete _debugger; _debugger = 0; + delete _txt; + _txt = 0; } Common::Error EobCoreEngine::init() { @@ -672,6 +677,8 @@ void EobCoreEngine::releaseItemsAndDecorationsShapes() { delete []_firebeamShapes; } + delete[] _redSplatShape; + delete[] _greenSplatShape; delete[] _deadCharShape; delete[] _disabledCharGrid; delete[] _blackBoxSmallGrid; @@ -1214,18 +1221,15 @@ void EobCoreEngine::setWeaponSlotStatus(int charIndex, int mode, int slot) { 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; _dialogueButtonString[0] = str1; _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++) { - if (sp[i - 1]) - _dialogueButtonString[i] = sp[i - 1]; + const char *tmp = va_arg(args, const char*); + if (tmp) + _dialogueButtonString[i] = tmp; else _dialogueNumButtons = numStr = i; } diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index fcfc29f766..800716c81e 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -757,7 +757,7 @@ protected: bool _configHpBarGraphs; // 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 restoreAfterDialogueSequence(); void drawSequenceBitmap(const char *file, int destRect, int x1, int y1, int flags); diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 030b1dec7a..a8dfeb5b52 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -225,6 +225,8 @@ LoLEngine::~LoLEngine() { _gui = 0; delete _tim; _tim = 0; + delete _txt; + _txt = 0; delete[] _itemsInPlay; delete[] _itemProperties; @@ -298,6 +300,8 @@ LoLEngine::~LoLEngine() { _doorShapes[i] = 0; } + releaseDecorations(); + delete[] _automapShapes; for (Common::Array<const TIMOpcode*>::iterator i = _timIntroOpcodes.begin(); i != _timIntroOpcodes.end(); ++i) diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index e75d621cc3..ae3408eb1a 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -915,6 +915,7 @@ private: void assignBlockObject(LevelBlockProperty *l, uint16 item); int assignLevelDecorationShapes(int index); uint8 *getLevelDecorationShapes(int index); + void releaseDecorations(int first = 0, int num = 400); void restoreTempDataAdjustMonsterStrength(int index); void loadBlockProperties(const char *cmzFile); const uint8 *getBlockFileData(int levelIndex); diff --git a/engines/kyra/loleobbase.cpp b/engines/kyra/loleobbase.cpp index c2ec8da706..bcab2781a0 100644 --- a/engines/kyra/loleobbase.cpp +++ b/engines/kyra/loleobbase.cpp @@ -149,9 +149,6 @@ LolEobBaseEngine::~LolEobBaseEngine() { delete[] _levelDecorationData; delete[] _levelDecorationProperties; delete[] _levelBlockProperties; - - delete _txt; - _txt = 0; } Common::Error LolEobBaseEngine::init() { diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp index cf20429e2c..ce0cdf8b59 100644 --- a/engines/kyra/scene_eob.cpp +++ b/engines/kyra/scene_eob.cpp @@ -1092,18 +1092,22 @@ void EobCoreEngine::drawSceneShapes(int start) { } void EobCoreEngine::drawDecorations(int index) { - static const int16 *dscWalls[] = { 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, - &_sceneDrawVarRight, &_sceneDrawVarDown, 0, &_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, - &_sceneDrawVarLeft, 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, &_sceneDrawVarRight, - &_sceneDrawVarDown, 0, &_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, &_sceneDrawVarLeft, - &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, 0, &_sceneDrawVarDown, &_sceneDrawVarLeft, - 0, &_sceneDrawVarRight, &_sceneDrawVarDown, 0, 0, &_sceneDrawVarLeft + static const int16 *dscWalls[] = { + 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight, + &_sceneDrawVarDown, &_sceneDrawVarRight, &_sceneDrawVarDown, 0, + &_sceneDrawVarDown, &_sceneDrawVarLeft, &_sceneDrawVarDown, &_sceneDrawVarLeft, + 0, 0, &_sceneDrawVarDown, &_sceneDrawVarRight, + &_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--) { int s = index * 2 + i; if (dscWalls[s]) { - int d = *dscWalls[s]; + int16 d = *dscWalls[s]; int8 l = _wllShapeMap[_visibleBlocks[index]->walls[d]]; uint8 *shapeData = 0; diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp index d28477b148..e38e5ebc22 100644 --- a/engines/kyra/scene_lol.cpp +++ b/engines/kyra/scene_lol.cpp @@ -200,6 +200,7 @@ int LoLEngine::assignLevelDecorationShapes(int index) { if (pv) { _levelDecorationProperties[o].shapeIndex[i] = pv; } else { + releaseDecorations(_lvlShapeIndex, 1); _levelDecorationShapes[_lvlShapeIndex] = getLevelDecorationShapes(t); p1[t] = _lvlShapeIndex; _levelDecorationProperties[o].shapeIndex[i] = _lvlShapeIndex++; @@ -232,6 +233,13 @@ uint8 *LoLEngine::getLevelDecorationShapes(int shapeIndex) { 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) { memset(_levelBlockProperties, 0, 1024 * sizeof(LevelBlockProperty)); _screen->loadBitmap(cmzFile, 2, 2, 0); diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 79edfe9d72..f9a49e7a7b 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -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) { uint8 *src = getPagePtr(srcPage); 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); if (dstPage == 0 || dstPage == 1) diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp index 4161c757d8..8562e25480 100644 --- a/engines/kyra/screen_eob.cpp +++ b/engines/kyra/screen_eob.cpp @@ -46,6 +46,7 @@ Screen_Eob::Screen_Eob(EobCoreEngine *vm, OSystem *system) : Screen(vm, system) _gfxCol = 0; _customDimTable = 0; _dsTempPage = 0; + _curDimIndex = 0; } 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]; memset (colorMap, 0xff, 0x100); - shapesize = h * (w << 2) + 0x14; + shapesize = h * (w << 2) + 20; shp = new uint8[shapesize]; memset (shp, 0, shapesize); uint8 *dst = shp; @@ -673,14 +674,13 @@ const uint8 *Screen_Eob::scaleShapeStep(const uint8 *shp) { i = -i; _dsScaleTmp = (i << 4) | (i & 0x0f); - memcpy(d, shp, 16); - d += 16; - shp += 16; + for (int ii = 0; ii < 16; ii++) + *d++ = *shp++; _dsDiv = w2 / 3; _dsRem = w2 % 3; - do { + while (--h) { scaleShapeProcessLine(d, shp); if (!--h) break; @@ -688,7 +688,7 @@ const uint8 *Screen_Eob::scaleShapeStep(const uint8 *shp) { if (!--h) break; shp += w2; - } while (--h); + } 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) { for (int i = 0; i < _dsDiv; i++) { *dst++ = *src++; - *dst++ = READ_BE_UINT16(src) >> 4; + *dst++ = (READ_BE_UINT16(src) >> 4) & 0xff; src += 2; } if (_dsRem == 1) { *dst++ = *src++; *dst++ = _dsScaleTmp; - - } if (_dsRem == 2) { + } else if (_dsRem == 2) { *dst++ = (src[0] & 0xf0) | (src[1] >> 4); src += 2; *dst++ = _dsScaleTmp; diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp index 75977fc87c..7995ad21f1 100644 --- a/engines/kyra/script_tim.cpp +++ b/engines/kyra/script_tim.cpp @@ -893,6 +893,7 @@ TIMInterpreter_LoL::TIMInterpreter_LoL(LoLEngine *engine, Screen_v2 *screen_v2, _screen = engine->_screen; + delete _animator; _animator = new TimAnimator(engine, screen_v2, system, true); _drawPage2 = 0; diff --git a/engines/kyra/sequences_eob2.cpp b/engines/kyra/sequences_eob2.cpp index 58540fdc85..597d84d81c 100644 --- a/engines/kyra/sequences_eob2.cpp +++ b/engines/kyra/sequences_eob2.cpp @@ -951,7 +951,7 @@ DarkmoonSequenceHelper::~DarkmoonSequenceHelper() { delete _palettes[11]; for (int i = 0; i < 30; i++) - delete _shapes[i]; + delete[] _shapes[i]; delete[] _shapes; _screen->clearCurPage(); |