[Scummvm-cvs-logs] SF.net SVN: scummvm:[50488] scummvm/trunk/engines/m4

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Tue Jun 29 12:40:24 CEST 2010


Revision: 50488
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50488&view=rev
Author:   dreammaster
Date:     2010-06-29 10:40:24 +0000 (Tue, 29 Jun 2010)

Log Message:
-----------
Bugfixes to reading in the animation font name correctly, as well as converted some Common::String usage to char buffers to fix incorrect String usage

Modified Paths:
--------------
    scummvm/trunk/engines/m4/animation.cpp
    scummvm/trunk/engines/m4/font.cpp
    scummvm/trunk/engines/m4/font.h

Modified: scummvm/trunk/engines/m4/animation.cpp
===================================================================
--- scummvm/trunk/engines/m4/animation.cpp	2010-06-29 10:39:13 UTC (rev 50487)
+++ scummvm/trunk/engines/m4/animation.cpp	2010-06-29 10:40:24 UTC (rev 50488)
@@ -57,10 +57,10 @@
 	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 @@
 	_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 @@
 		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");
 	}

Modified: scummvm/trunk/engines/m4/font.cpp
===================================================================
--- scummvm/trunk/engines/m4/font.cpp	2010-06-29 10:39:13 UTC (rev 50487)
+++ scummvm/trunk/engines/m4/font.cpp	2010-06-29 10:40:24 UTC (rev 50488)
@@ -35,27 +35,34 @@
 	_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 @@
 	_sysFont = false;
 
 	if (_vm->isM4())
-		setFontM4(filename.c_str());
+		setFontM4(filename);
 	else
-		setFontMads(filename.c_str());
+		setFontMads(filename);
 }
 
 void Font::setFontM4(const char *filename) {

Modified: scummvm/trunk/engines/m4/font.h
===================================================================
--- scummvm/trunk/engines/m4/font.h	2010-06-29 10:39:13 UTC (rev 50487)
+++ scummvm/trunk/engines/m4/font.h	2010-06-29 10:40:24 UTC (rev 50488)
@@ -59,7 +59,7 @@
 
 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 @@
 		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 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list