aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2011-05-17 15:05:20 +0200
committerMax Horn2011-05-17 15:05:20 +0200
commitd84ae94b54e0aa2bdea740736dc65e35081c6f51 (patch)
tree37e9e1f49e1ddd8e03274d5fd9803770d8662f13
parent2149edbe5d5c4699eaaf826c7a769ab764548eac (diff)
downloadscummvm-rg350-d84ae94b54e0aa2bdea740736dc65e35081c6f51.tar.gz
scummvm-rg350-d84ae94b54e0aa2bdea740736dc65e35081c6f51.tar.bz2
scummvm-rg350-d84ae94b54e0aa2bdea740736dc65e35081c6f51.zip
SWORD1: Const correctness, code cleanup & simplification
-rw-r--r--engines/sword1/animation.cpp13
-rw-r--r--engines/sword1/animation.h13
-rw-r--r--engines/sword1/text.cpp4
-rw-r--r--engines/sword1/text.h4
4 files changed, 15 insertions, 19 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index dd9a9da1be..b66cc6b5a7 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -126,7 +126,7 @@ bool MoviePlayer::load(uint32 id) {
continue;
}
- _movieTexts.push_back(new MovieText(startFrame, endFrame, ptr));
+ _movieTexts.push_back(MovieText(startFrame, endFrame, ptr));
lastEnd = endFrame;
}
f.close();
@@ -161,8 +161,7 @@ void MoviePlayer::play() {
_textMan->releaseText(2, false);
- while (!_movieTexts.empty())
- delete _movieTexts.remove_at(_movieTexts.size() - 1);
+ _movieTexts.clear();
while (_snd->isSoundHandleActive(*_bgSoundHandle))
_system->delayMillis(100);
@@ -179,8 +178,8 @@ void MoviePlayer::play() {
void MoviePlayer::performPostProcessing(byte *screen) {
if (!_movieTexts.empty()) {
- if (_decoder->getCurFrame() == _movieTexts[0]->_startFrame) {
- _textMan->makeTextSprite(2, (uint8 *)_movieTexts[0]->_text, 600, LETTER_COL);
+ if (_decoder->getCurFrame() == _movieTexts.front()._startFrame) {
+ _textMan->makeTextSprite(2, (const uint8 *)_movieTexts.front()._text.c_str(), 600, LETTER_COL);
FrameHeader *frame = _textMan->giveSpriteData(2);
_textWidth = frame->width;
@@ -188,9 +187,9 @@ void MoviePlayer::performPostProcessing(byte *screen) {
_textX = 320 - _textWidth / 2;
_textY = 420 - _textHeight;
}
- if (_decoder->getCurFrame() == _movieTexts[0]->_endFrame) {
+ if (_decoder->getCurFrame() == _movieTexts.front()._endFrame) {
_textMan->releaseText(2, false);
- delete _movieTexts.remove_at(0);
+ _movieTexts.pop_front();
}
}
diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h
index 2fb274edda..fc3061bbf9 100644
--- a/engines/sword1/animation.h
+++ b/engines/sword1/animation.h
@@ -27,7 +27,7 @@
#include "video/smk_decoder.h"
#include "video/video_decoder.h"
-#include "common/array.h"
+#include "common/list.h"
#include "audio/audiostream.h"
@@ -45,14 +45,11 @@ class MovieText {
public:
uint16 _startFrame;
uint16 _endFrame;
- char *_text;
- MovieText(int startFrame, int endFrame, const char *text) {
+ Common::String _text;
+ MovieText(int startFrame, int endFrame, const Common::String &text) {
_startFrame = startFrame;
_endFrame = endFrame;
- _text = strdup(text);
- }
- ~MovieText() {
- free(_text);
+ _text = text;
}
};
@@ -80,7 +77,7 @@ protected:
Text *_textMan;
Audio::Mixer *_snd;
OSystem *_system;
- Common::Array<MovieText *> _movieTexts;
+ Common::List<MovieText> _movieTexts;
int _textX, _textY, _textWidth, _textHeight;
byte _white, _black;
DecoderType _decoderType;
diff --git a/engines/sword1/text.cpp b/engines/sword1/text.cpp
index 695b7bddbf..2d4b07020f 100644
--- a/engines/sword1/text.cpp
+++ b/engines/sword1/text.cpp
@@ -73,7 +73,7 @@ uint32 Text::lowTextManager(uint8 *ascii, int32 width, uint8 pen) {
return textObjId;
}
-void Text::makeTextSprite(uint8 slot, uint8 *text, uint16 maxWidth, uint8 pen) {
+void Text::makeTextSprite(uint8 slot, const uint8 *text, uint16 maxWidth, uint8 pen) {
LineInfo lines[MAX_LINES];
uint16 numLines = analyzeSentence(text, maxWidth, lines);
@@ -115,7 +115,7 @@ uint16 Text::charWidth(uint8 ch) {
return _resMan->getUint16(_resMan->fetchFrame(_font, ch - SPACE)->width);
}
-uint16 Text::analyzeSentence(uint8 *text, uint16 maxWidth, LineInfo *line) {
+uint16 Text::analyzeSentence(const uint8 *text, uint16 maxWidth, LineInfo *line) {
uint16 lineNo = 0;
bool firstWord = true;
diff --git a/engines/sword1/text.h b/engines/sword1/text.h
index 1afa0c7294..2224fbcac5 100644
--- a/engines/sword1/text.h
+++ b/engines/sword1/text.h
@@ -49,11 +49,11 @@ public:
~Text();
FrameHeader *giveSpriteData(uint32 textTarget);
uint32 lowTextManager(uint8 *text, int32 width, uint8 pen);
- void makeTextSprite(uint8 slot, uint8 *text, uint16 maxWidth, uint8 pen);
+ void makeTextSprite(uint8 slot, const uint8 *text, uint16 maxWidth, uint8 pen);
void releaseText(uint32 id, bool updateCount = true);
private:
- uint16 analyzeSentence(uint8 *text, uint16 maxWidth, LineInfo *info);
+ uint16 analyzeSentence(const uint8 *text, uint16 maxWidth, LineInfo *info);
uint16 charWidth(uint8 ch);
uint16 copyChar(uint8 ch, uint8 *sprPtr, uint16 sprWidth, uint8 pen);
uint8 *_font;