aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/animation.cpp40
-rw-r--r--engines/m4/font.cpp25
-rw-r--r--engines/m4/font.h8
3 files changed, 45 insertions, 28 deletions
diff --git a/engines/m4/animation.cpp b/engines/m4/animation.cpp
index 4dc645991e..192c096640 100644
--- a/engines/m4/animation.cpp
+++ b/engines/m4/animation.cpp
@@ -57,10 +57,10 @@ MadsAnimation::~MadsAnimation() {
if (_field12) {
_view->_spriteSlots.deleteSprites(_spriteListIndexes[_spriteListIndex]);
}
-
- delete _font;
}
+#define FILENAME_SIZE 13
+
/**
* Initialises and loads the data of an animation
*/
@@ -93,25 +93,35 @@ void MadsAnimation::initialise(const Common::String &filename, uint16 flags, M4S
_scrollTicks = animStream->readUint16LE();
animStream->skip(8);
- animStream->read(buffer, 13);
- _interfaceFile = Common::String(buffer, 13);
+ animStream->read(buffer, FILENAME_SIZE);
+ buffer[FILENAME_SIZE] = '\0';
+ _interfaceFile = Common::String(buffer);
for (int i = 0; i < 10; ++i) {
- animStream->read(buffer, 13);
- _spriteSetNames[i] = Common::String(buffer, 13);
+ animStream->read(buffer, FILENAME_SIZE);
+ buffer[FILENAME_SIZE] = '\0';
+ _spriteSetNames[i] = Common::String(buffer);
}
animStream->skip(81);
- animStream->read(buffer, 13);
- _lbmFilename = Common::String(buffer, 13);
- animStream->read(buffer, 13);
- _spritesFilename = Common::String(buffer, 13);
+ animStream->read(buffer, FILENAME_SIZE);
+ buffer[FILENAME_SIZE] = '\0';
+ _lbmFilename = Common::String(buffer);
+
+ animStream->skip(365);
+ animStream->read(buffer, FILENAME_SIZE);
+ buffer[FILENAME_SIZE] = '\0';
+ _spritesFilename = Common::String(buffer);
+
animStream->skip(48);
- animStream->read(buffer, 13);
- _soundName = Common::String(buffer, 13);
+ animStream->read(buffer, FILENAME_SIZE);
+ buffer[FILENAME_SIZE] = '\0';
+ _soundName = Common::String(buffer);
+
animStream->skip(26);
- animStream->read(buffer, 13);
- Common::String fontResource(buffer, 13);
+ animStream->read(buffer, FILENAME_SIZE);
+ buffer[FILENAME_SIZE] = '\0';
+ Common::String fontResource(buffer);
if (_animMode == 4)
flags |= 0x4000;
@@ -205,7 +215,7 @@ void MadsAnimation::initialise(const Common::String &filename, uint16 flags, M4S
fontName += fontResource;
if (fontName != "")
- _font = _vm->_font->getFont(fontName);
+ _font = _vm->_font->getFont(fontName.c_str());
else
warning("Attempted to set a font with an empty name");
}
diff --git a/engines/m4/font.cpp b/engines/m4/font.cpp
index 4afa158976..b5965732e5 100644
--- a/engines/m4/font.cpp
+++ b/engines/m4/font.cpp
@@ -35,27 +35,34 @@ FontManager::~FontManager() {
_entries.clear();
}
-Font *FontManager::getFont(const Common::String &filename) {
+Font *FontManager::getFont(const char *filename) {
+ // Append an extension if the filename doesn't already have one
+ char buffer[20];
+ strncpy(buffer, filename, 19);
+ if (!strchr(buffer, '.'))
+ strcat(buffer, ".ff");
+
// Check if the font is already loaded
- for (uint i = 0; i < _entries.size(); ++i)
- {
- if (_entries[i]->_filename.equals(filename))
+ for (uint i = 0; i < _entries.size(); ++i) {
+ if (!strcmp(_entries[i]->_filename, buffer))
return _entries[i];
}
- Font *f = new Font(_vm, filename);
+ Font *f = new Font(_vm, buffer);
_entries.push_back(f);
return f;
}
-void FontManager::setFont(const Common::String &filename) {
+void FontManager::setFont(const char *filename) {
_currentFont = getFont(filename);
}
//--------------------------------------------------------------------------
-Font::Font(MadsM4Engine *vm, const Common::String &filename) : _vm(vm), _filename(filename) {
+Font::Font(MadsM4Engine *vm, const char *filename) : _vm(vm) {
_sysFont = true;
+ strncpy(_filename, filename, 19);
+ _filename[19] = '\0';
//TODO: System font
_fontColors[0] = _vm->_palette->BLACK;
@@ -66,9 +73,9 @@ Font::Font(MadsM4Engine *vm, const Common::String &filename) : _vm(vm), _filenam
_sysFont = false;
if (_vm->isM4())
- setFontM4(filename.c_str());
+ setFontM4(filename);
else
- setFontMads(filename.c_str());
+ setFontMads(filename);
}
void Font::setFontM4(const char *filename) {
diff --git a/engines/m4/font.h b/engines/m4/font.h
index ca47848c61..19d15faa1e 100644
--- a/engines/m4/font.h
+++ b/engines/m4/font.h
@@ -59,7 +59,7 @@ namespace M4 {
class Font {
public:
- Font(MadsM4Engine *vm, const Common::String &filename);
+ Font(MadsM4Engine *vm, const char *filename);
~Font();
void setColour(uint8 colour);
@@ -73,7 +73,7 @@ public:
return write(surface, text, x, y, width, spaceWidth, _fontColors);
}
public:
- const Common::String _filename;
+ char _filename[20];
private:
void setFontM4(const char *filename);
void setFontMads(const char *filename);
@@ -108,8 +108,8 @@ public:
FontManager(MadsM4Engine *vm): _vm(vm) { _currentFont = NULL; }
~FontManager();
- Font *getFont(const Common::String &filename);
- void setFont(const Common::String &filename);
+ Font *getFont(const char *filename);
+ void setFont(const char *filename);
Font *current() {
assert(_currentFont);