aboutsummaryrefslogtreecommitdiff
path: root/engines/cryomni3d
diff options
context:
space:
mode:
authorLe Philousophe2019-06-09 12:46:58 +0200
committerLe Philousophe2019-06-09 12:46:58 +0200
commita2f1700fc3ec7bf3a01fceac80ae5cbed813d5b0 (patch)
tree6fc0421705bd5da11718ac6adf643c3127d8c1c3 /engines/cryomni3d
parentb527b573cf2fd25085c0ea2dcd3c83a7182a1b74 (diff)
downloadscummvm-rg350-a2f1700fc3ec7bf3a01fceac80ae5cbed813d5b0.tar.gz
scummvm-rg350-a2f1700fc3ec7bf3a01fceac80ae5cbed813d5b0.tar.bz2
scummvm-rg350-a2f1700fc3ec7bf3a01fceac80ae5cbed813d5b0.zip
CRYOMNI3D: Fix various memory errors
Diffstat (limited to 'engines/cryomni3d')
-rw-r--r--engines/cryomni3d/versailles/documentation.cpp34
-rw-r--r--engines/cryomni3d/versailles/documentation.h2
-rw-r--r--engines/cryomni3d/versailles/engine.cpp2
-rw-r--r--engines/cryomni3d/versailles/menus.cpp2
4 files changed, 26 insertions, 14 deletions
diff --git a/engines/cryomni3d/versailles/documentation.cpp b/engines/cryomni3d/versailles/documentation.cpp
index c0acbc874f..a33e992962 100644
--- a/engines/cryomni3d/versailles/documentation.cpp
+++ b/engines/cryomni3d/versailles/documentation.cpp
@@ -280,6 +280,12 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
Image::BitmapDecoder bmpDecoder;
Common::File file;
+ Image::ImageDecoder *imageDecoder = _engine->loadHLZ("SOM1.HLZ");
+ if (!imageDecoder) {
+ return "";
+ }
+ const Graphics::Surface *bgFrame = imageDecoder->getSurface();
+
for (uint i = 0; i < ARRAYSIZE(categories); i++) {
if (!categories[i].bmp) {
// No BMP to load
@@ -296,12 +302,6 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
file.close();
}
- Image::ImageDecoder *imageDecoder = _engine->loadHLZ("SOM1.HLZ");
- if (!imageDecoder) {
- return "";
- }
- const Graphics::Surface *bgFrame = imageDecoder->getSurface();
-
Graphics::ManagedSurface docSurface;
docSurface.create(bgFrame->w, bgFrame->h, bgFrame->format);
docSurface.blitFrom(*bgFrame);
@@ -411,6 +411,10 @@ Common::String Versailles_Documentation::docAreaHandleSummary() {
_engine->showMouse(false);
+ for (uint i = 0; i < ARRAYSIZE(categories); i++) {
+ categories[i].highlightedImg.free();
+ }
+
delete imageDecoder;
if (selectedBox == 7) {
@@ -906,6 +910,12 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
Image::BitmapDecoder bmpDecoder;
Common::File file;
+ Image::ImageDecoder *imageDecoder = _engine->loadHLZ("PLANGR.HLZ");
+ if (!imageDecoder) {
+ return "";
+ }
+ const Graphics::Surface *bgFrame = imageDecoder->getSurface();
+
for (uint i = 0; i < ARRAYSIZE(areas); i++) {
if (areas[i].bmp) {
if (!file.open(areas[i].bmp)) {
@@ -938,12 +948,6 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
boxes.setupBox(ARRAYSIZE(areas), 639 - _sprites->getCursor(105).getWidth(),
479 - _sprites->getCursor(105).getHeight(), 640, 480);
- Image::ImageDecoder *imageDecoder = _engine->loadHLZ("PLANGR.HLZ");
- if (!imageDecoder) {
- return "";
- }
- const Graphics::Surface *bgFrame = imageDecoder->getSurface();
-
Graphics::ManagedSurface mapSurface;
mapSurface.create(bgFrame->w, bgFrame->h, bgFrame->format);
mapSurface.blitFrom(*bgFrame);
@@ -1052,6 +1056,10 @@ Common::String Versailles_Documentation::docAreaHandleGeneralMap() {
_engine->showMouse(false);
+ for (uint i = 0; i < ARRAYSIZE(areas); i++) {
+ areas[i].highlightedImg.free();
+ }
+
delete imageDecoder;
if (selectedBox == ARRAYSIZE(areas)) {
@@ -1538,6 +1546,8 @@ void Versailles_Documentation::drawRecordData(Graphics::ManagedSurface &surface,
_fontManager->setupBlock(blockCaption);
_fontManager->displayBlockText(caption);
+
+ delete imageDecoder;
}
void Versailles_Documentation::setupRecordBoxes(bool inDocArea, MouseBoxes &boxes) {
diff --git a/engines/cryomni3d/versailles/documentation.h b/engines/cryomni3d/versailles/documentation.h
index a1559f8880..1808956e2e 100644
--- a/engines/cryomni3d/versailles/documentation.h
+++ b/engines/cryomni3d/versailles/documentation.h
@@ -41,7 +41,7 @@ class Versailles_Documentation {
public:
Versailles_Documentation() : _engine(nullptr), _fontManager(nullptr), _messages(nullptr),
_linksData(nullptr), _linksSize(0) { }
- ~Versailles_Documentation() { delete _linksData; }
+ ~Versailles_Documentation() { delete [] _linksData; }
void init(const Sprites *sprites, FontManager *fontManager, const Common::StringArray *messages,
CryOmni3DEngine *engine);
diff --git a/engines/cryomni3d/versailles/engine.cpp b/engines/cryomni3d/versailles/engine.cpp
index ab9318f8c3..86f214dcbe 100644
--- a/engines/cryomni3d/versailles/engine.cpp
+++ b/engines/cryomni3d/versailles/engine.cpp
@@ -1607,7 +1607,7 @@ void CryOmni3DEngine_Versailles::playInGameVideo(const Common::String &filename,
unlockPalette();
if (restoreCursorPalette) {
// Restore cursors colors as 2 first ones may have been erased by the video
- setPalette(&_cursorPalette[3 * 240], 240, 248);
+ setPalette(&_cursorPalette[3 * 240], 240, 8);
// WORKAROUND: Don't mess with mouse when not restoring cursors palette
showMouse(true);
}
diff --git a/engines/cryomni3d/versailles/menus.cpp b/engines/cryomni3d/versailles/menus.cpp
index 6da7a856e2..6ce02f6a12 100644
--- a/engines/cryomni3d/versailles/menus.cpp
+++ b/engines/cryomni3d/versailles/menus.cpp
@@ -1073,6 +1073,8 @@ void CryOmni3DEngine_Versailles::displayCredits() {
}
}
showMouse(true);
+
+ delete imageDecoder;
}
} // End of namespace Versailles