aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
authorAlyssa Milburn2012-02-22 19:15:47 +0100
committerWillem Jan Palenstijn2012-02-23 22:37:21 +0100
commit6e70f7728915b766d647668a156b09f84a3c40cf (patch)
treecd3a2b7759ce90af4ab0aeb69a5f28575f2ea98b /engines/dreamweb
parent256d160679eb211e9a38fbcf18ee5fedd232fc72 (diff)
downloadscummvm-rg350-6e70f7728915b766d647668a156b09f84a3c40cf.tar.gz
scummvm-rg350-6e70f7728915b766d647668a156b09f84a3c40cf.tar.bz2
scummvm-rg350-6e70f7728915b766d647668a156b09f84a3c40cf.zip
DREAMWEB: Dynamically allocate GraphicsFile::_frames.
This avoids extra memory usage due to the previous commit.
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/dreamweb.h1
-rw-r--r--engines/dreamweb/structs.h6
-rw-r--r--engines/dreamweb/stubs.cpp8
3 files changed, 10 insertions, 5 deletions
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index c67dfb3660..f49c38371d 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -76,6 +76,7 @@ const unsigned int kSymbolx = 64;
const unsigned int kSymboly = 56;
const unsigned int kLengthofvars = 68;
const unsigned int kFrameBlocksize = 2080;
+const unsigned int kGraphicsFileFrameSize = 347; // ceil(2080 / sizeof(Frame))
const unsigned int kNumexobjects = 114;
const unsigned int kNumExTexts = kNumexobjects + 2;
const uint16 kExtextlen = 18000;
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index cedf2b6d76..24b67e317a 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -339,9 +339,9 @@ struct TextFile {
};
struct GraphicsFile {
- GraphicsFile() : _data(0) { }
+ GraphicsFile() : _data(0), _frames(0) { }
- Frame _frames[347];
+ Frame *_frames;
uint8 *_data;
const uint8 *getFrameData(unsigned int i) const {
@@ -351,6 +351,8 @@ struct GraphicsFile {
return _data + _frames[i].ptr();
}
void clear() {
+ delete[] _frames;
+ _frames = 0;
delete[] _data;
_data = 0;
}
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 4178fb489a..763bcb88fe 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -843,17 +843,18 @@ void DreamWebEngine::loadGraphicsFile(GraphicsFile &file, const char *fileName)
uint16 sizeInBytes = header.len(0);
assert(sizeInBytes >= kFrameBlocksize);
- delete[] file._data;
+ file.clear();
file._data = new uint8[sizeInBytes - kFrameBlocksize];
-
+ file._frames = new Frame[kGraphicsFileFrameSize];
f.read((uint8 *)file._frames, kFrameBlocksize);
f.read(file._data, sizeInBytes - kFrameBlocksize);
}
void DreamWebEngine::loadGraphicsSegment(GraphicsFile &file, Common::File &inFile, unsigned int len) {
assert(len >= kFrameBlocksize);
- delete[] file._data;
+ file.clear();
file._data = new uint8[len - kFrameBlocksize];
+ file._frames = new Frame[kGraphicsFileFrameSize];
inFile.read((uint8 *)file._frames, kFrameBlocksize);
inFile.read(file._data, len - kFrameBlocksize);
}
@@ -2257,6 +2258,7 @@ void DreamWebEngine::drawFloor() {
void DreamWebEngine::allocateBuffers() {
_exFrames.clear();
_exFrames._data = new uint8[kExframeslen];
+ _exFrames._frames = new Frame[kGraphicsFileFrameSize];
_exText.clear();
_exText._text = new char[kExtextlen];
}