aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-29 00:27:50 +0200
committerEinar Johan Trøan Sømåen2012-07-29 00:27:50 +0200
commit6dc1e09da93c0ba0507fd0ceadbbb504469deccc (patch)
treedae477f4ed7c6b9be7a5dd38174d81cdbae48c58 /engines/wintermute
parente841bf16d6b955f779e5e30535848bd650d22352 (diff)
downloadscummvm-rg350-6dc1e09da93c0ba0507fd0ceadbbb504469deccc.tar.gz
scummvm-rg350-6dc1e09da93c0ba0507fd0ceadbbb504469deccc.tar.bz2
scummvm-rg350-6dc1e09da93c0ba0507fd0ceadbbb504469deccc.zip
WINTERMUTE: Replace const char* with const Common::String & in fonts, gfx, particles, sound and files.
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/ad/ad_entity.cpp4
-rw-r--r--engines/wintermute/base/base.cpp8
-rw-r--r--engines/wintermute/base/base.h4
-rw-r--r--engines/wintermute/base/base_frame.cpp8
-rw-r--r--engines/wintermute/base/base_game.cpp4
-rw-r--r--engines/wintermute/base/base_sprite.cpp10
-rw-r--r--engines/wintermute/base/base_sprite.h2
-rw-r--r--engines/wintermute/base/base_sub_frame.cpp6
-rw-r--r--engines/wintermute/base/base_sub_frame.h2
-rw-r--r--engines/wintermute/base/base_surface_storage.cpp8
-rw-r--r--engines/wintermute/base/base_surface_storage.h2
-rw-r--r--engines/wintermute/base/font/base_font.cpp4
-rw-r--r--engines/wintermute/base/font/base_font.h4
-rw-r--r--engines/wintermute/base/font/base_font_bitmap.cpp8
-rw-r--r--engines/wintermute/base/font/base_font_bitmap.h2
-rw-r--r--engines/wintermute/base/font/base_font_storage.cpp6
-rw-r--r--engines/wintermute/base/font/base_font_storage.h2
-rw-r--r--engines/wintermute/base/font/base_font_truetype.cpp8
-rw-r--r--engines/wintermute/base/font/base_font_truetype.h2
-rw-r--r--engines/wintermute/base/gfx/base_surface.cpp7
-rw-r--r--engines/wintermute/base/gfx/base_surface.h2
-rw-r--r--engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp2
-rw-r--r--engines/wintermute/base/gfx/osystem/base_surface_osystem.h2
-rw-r--r--engines/wintermute/base/particles/part_emitter.cpp12
-rw-r--r--engines/wintermute/base/particles/part_emitter.h6
-rw-r--r--engines/wintermute/base/particles/part_particle.cpp4
-rw-r--r--engines/wintermute/base/particles/part_particle.h2
-rw-r--r--engines/wintermute/base/scriptables/script.cpp32
-rw-r--r--engines/wintermute/base/scriptables/script.h16
-rw-r--r--engines/wintermute/base/sound/base_sound.cpp50
-rw-r--r--engines/wintermute/base/sound/base_sound.h24
-rw-r--r--engines/wintermute/base/sound/base_sound_buffer.cpp17
-rw-r--r--engines/wintermute/base/sound/base_sound_buffer.h4
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.cpp9
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.h2
35 files changed, 117 insertions, 168 deletions
diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp
index 6fea297018..4d1641036a 100644
--- a/engines/wintermute/ad/ad_entity.cpp
+++ b/engines/wintermute/ad/ad_entity.cpp
@@ -1003,8 +1003,8 @@ bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent + 2, "SPRITE=\"%s\"\n", _sprite->getFilename());
}
- if (_subtype == ENTITY_SOUND && _sFX && _sFX->_soundFilename) {
- buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->_soundFilename);
+ if (_subtype == ENTITY_SOUND && _sFX && _sFX->getFilename()) {
+ buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sFX->getFilename());
buffer->putTextIndent(indent + 2, "SOUND_START_TIME=%d\n", _sFXStart);
buffer->putTextIndent(indent + 2, "SOUND_VOLUME=%d\n", _sFXVolume);
}
diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp
index d5163fa7a6..074bd0db68 100644
--- a/engines/wintermute/base/base.cpp
+++ b/engines/wintermute/base/base.cpp
@@ -54,7 +54,7 @@ BaseClass::~BaseClass() {
//////////////////////////////////////////////////////////////////////////
-const char *BaseClass::getEditorProp(const char *propName, const char *initVal) {
+Common::String BaseClass::getEditorProp(const Common::String &propName, const Common::String &initVal) {
_editorPropsIter = _editorProps.find(propName);
if (_editorPropsIter != _editorProps.end()) {
return _editorPropsIter->_value.c_str();
@@ -65,12 +65,12 @@ const char *BaseClass::getEditorProp(const char *propName, const char *initVal)
//////////////////////////////////////////////////////////////////////////
-bool BaseClass::setEditorProp(const char *propName, const char *propValue) {
- if (propName == NULL) {
+bool BaseClass::setEditorProp(const Common::String &propName, const Common::String &propValue) {
+ if (propName.size() == 0) {
return STATUS_FAILED;
}
- if (propValue == NULL) {
+ if (propValue.size() == 0) {
_editorProps.erase(propName);
} else {
_editorProps[propName] = propValue;
diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h
index 8c6aad12e6..dcd186be42 100644
--- a/engines/wintermute/base/base.h
+++ b/engines/wintermute/base/base.h
@@ -43,8 +43,8 @@ class BaseDynamicBuffer;
class BaseClass {
public:
bool _persistable;
- bool setEditorProp(const char *propName, const char *propValue);
- const char *getEditorProp(const char *propName, const char *initVal = NULL);
+ bool setEditorProp(const Common::String &propName, const Common::String &propValue);
+ Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = NULL);
BaseClass(TDynamicConstructor, TDynamicConstructor) {};
bool parseEditorProperty(byte *buffer, bool complete = true);
virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0);
diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp
index edbfe3447f..27e07790bb 100644
--- a/engines/wintermute/base/base_frame.cpp
+++ b/engines/wintermute/base/base_frame.cpp
@@ -367,8 +367,8 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY);
}
- if (_sound && _sound->_soundFilename) {
- buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename);
+ if (_sound && _sound->getFilename()) {
+ buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->getFilename());
}
buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE");
@@ -431,8 +431,8 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
if (strcmp(name, "GetSound") == 0) {
stack->correctParams(0);
- if (_sound && _sound->_soundFilename) {
- stack->pushString(_sound->_soundFilename);
+ if (_sound && _sound->getFilename()) {
+ stack->pushString(_sound->getFilename());
} else {
stack->pushNULL();
}
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index a7ea7fe95f..fdf638f94f 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -1247,10 +1247,10 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) {
stack->pushNULL();
} else {
- if (!_music[channel] || !_music[channel]->_soundFilename) {
+ if (!_music[channel] || !_music[channel]->getFilename()) {
stack->pushNULL();
} else {
- stack->pushString(_music[channel]->_soundFilename);
+ stack->pushString(_music[channel]->getFilename());
}
}
return STATUS_OK;
diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp
index 00af5bd960..6ab8e60a17 100644
--- a/engines/wintermute/base/base_sprite.cpp
+++ b/engines/wintermute/base/base_sprite.cpp
@@ -124,10 +124,10 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa
//////////////////////////////////////////////////////////////////////
-bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) {
+bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) {
Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename);
if (!file) {
- _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str());
if (_gameRef->_debugDebugMode) {
return loadFile("invalid_debug.bmp", lifeTime, cacheType);
} else {
@@ -146,7 +146,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c
BaseSubFrame *subframe = new BaseSubFrame(_gameRef);
subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true);
if (subframe->_surface == NULL) {
- _gameRef->LOG(0, "Error loading simple sprite '%s'", filename);
+ _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str());
ret = STATUS_FAILED;
delete frame;
delete subframe;
@@ -161,13 +161,13 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer) {
if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) {
- _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename);
+ _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str());
}
delete[] buffer;
}
}
- setFilename(filename);
+ setFilename(filename.c_str());
return ret;
}
diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h
index 084d7b2d70..952bff0017 100644
--- a/engines/wintermute/base/base_sprite.h
+++ b/engines/wintermute/base/base_sprite.h
@@ -67,7 +67,7 @@ public:
bool _paused;
bool _finished;
bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL);
- bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL);
+ bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL);
uint32 _lastFrameTime;
bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF);
bool _looping;
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index 17b5196f2a..6ce8c78b3b 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -594,7 +594,7 @@ const char *BaseSubFrame::scToString() {
//////////////////////////////////////////////////////////////////////////
-bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
+bool BaseSubFrame::setSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
if (_surface) {
_gameRef->_surfaceStorage->removeSurface(_surface);
_surface = NULL;
@@ -605,8 +605,8 @@ bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed,
_surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
if (_surface) {
- _surfaceFilename = new char[strlen(filename) + 1];
- strcpy(_surfaceFilename, filename);
+ _surfaceFilename = new char[filename.size() + 1];
+ strcpy(_surfaceFilename, filename.c_str());
_cKDefault = defaultCK;
_cKRed = ckRed;
diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h
index 52b1d76c01..023e306706 100644
--- a/engines/wintermute/base/base_sub_frame.h
+++ b/engines/wintermute/base/base_sub_frame.h
@@ -41,7 +41,7 @@ public:
bool _mirrorX;
bool _mirrorY;
bool _decoration;
- bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false);
+ bool setSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false);
bool setSurfaceSimple();
DECLARE_PERSISTENT(BaseSubFrame, BaseScriptable)
void setDefaultRect();
diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp
index c01c86c009..7d6f499012 100644
--- a/engines/wintermute/base/base_surface_storage.cpp
+++ b/engines/wintermute/base/base_surface_storage.cpp
@@ -100,17 +100,17 @@ bool BaseSurfaceStorage::removeSurface(BaseSurface *surface) {
//////////////////////////////////////////////////////////////////////
-BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
+BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
for (uint32 i = 0; i < _surfaces.size(); i++) {
- if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) {
+ if (scumm_stricmp(_surfaces[i]->getFileName(), filename.c_str()) == 0) {
_surfaces[i]->_referenceCount++;
return _surfaces[i];
}
}
if (!_gameRef->_fileManager->hasFile(filename)) {
- if (filename) {
- _gameRef->LOG(0, "Missing image: '%s'", filename);
+ if (filename.size()) {
+ _gameRef->LOG(0, "Missing image: '%s'", filename.c_str());
}
if (_gameRef->_debugDebugMode) {
return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h
index 13c4deb3db..c09b0a30ab 100644
--- a/engines/wintermute/base/base_surface_storage.h
+++ b/engines/wintermute/base/base_surface_storage.h
@@ -44,7 +44,7 @@ public:
//DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass);
bool restoreAll();
- BaseSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false);
+ BaseSurface *addSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false);
bool removeSurface(BaseSurface *surface);
BaseSurfaceStorage(BaseGame *inGame);
virtual ~BaseSurfaceStorage();
diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp
index 5087f1752d..4a5cd31002 100644
--- a/engines/wintermute/base/font/base_font.cpp
+++ b/engines/wintermute/base/font/base_font.cpp
@@ -151,7 +151,7 @@ bool BaseFont::persist(BasePersistenceManager *persistMgr) {
//////////////////////////////////////////////////////////////////////////
-BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const char *filename) {
+BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const Common::String &filename) {
if (isTrueType(gameRef, filename)) {
BaseFontTT *font = new BaseFontTT(gameRef);
if (font) {
@@ -179,7 +179,7 @@ TOKEN_DEF(FONT)
TOKEN_DEF(TTFONT)
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
-bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) {
+bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TTFONT)
diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h
index 695bce2af3..f1dc962565 100644
--- a/engines/wintermute/base/font/base_font.h
+++ b/engines/wintermute/base/font/base_font.h
@@ -48,12 +48,12 @@ public:
BaseFont(BaseGame *inGame);
virtual ~BaseFont();
- static BaseFont *createFromFile(BaseGame *game, const char *filename);
+ static BaseFont *createFromFile(BaseGame *game, const Common::String &filename);
private:
//bool loadBuffer(byte * Buffer);
//bool loadFile(const char* Filename);
- static bool isTrueType(BaseGame *game, const char *filename);
+ static bool isTrueType(BaseGame *game, const Common::String &filename);
};
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp
index e2c5fa881c..e7bf362b32 100644
--- a/engines/wintermute/base/font/base_font_bitmap.cpp
+++ b/engines/wintermute/base/font/base_font_bitmap.cpp
@@ -270,19 +270,19 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) {
//////////////////////////////////////////////////////////////////////
-bool BaseFontBitmap::loadFile(const char *filename) {
+bool BaseFontBitmap::loadFile(const Common::String &filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str());
return STATUS_FAILED;
}
bool ret;
- setFilename(filename);
+ setFilename(filename.c_str());
if (DID_FAIL(ret = loadBuffer(buffer))) {
- _gameRef->LOG(0, "Error parsing FONT file '%s'", filename);
+ _gameRef->LOG(0, "Error parsing FONT file '%s'", filename.c_str());
}
delete[] buffer;
diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h
index abf2d39aa0..fb992d2e9a 100644
--- a/engines/wintermute/base/font/base_font_bitmap.h
+++ b/engines/wintermute/base/font/base_font_bitmap.h
@@ -38,7 +38,7 @@ class BaseFontBitmap : public BaseFont {
public:
DECLARE_PERSISTENT(BaseFontBitmap, BaseFont)
bool loadBuffer(byte *Buffer);
- bool loadFile(const char *filename);
+ bool loadFile(const Common::String &filename);
virtual int getTextWidth(byte *text, int maxLength = -1);
virtual int getTextHeight(byte *text, int width);
virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1);
diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp
index bc4152131f..0c34a8822a 100644
--- a/engines/wintermute/base/font/base_font_storage.cpp
+++ b/engines/wintermute/base/font/base_font_storage.cpp
@@ -71,13 +71,13 @@ bool BaseFontStorage::initLoop() {
}
//////////////////////////////////////////////////////////////////////////
-BaseFont *BaseFontStorage::addFont(const char *filename) {
- if (!filename) {
+BaseFont *BaseFontStorage::addFont(const Common::String &filename) {
+ if (!filename.size()) {
return NULL;
}
for (int i = 0; i < _fonts.getSize(); i++) {
- if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) {
+ if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) {
_fonts[i]->_refCount++;
return _fonts[i];
}
diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h
index 3af9244ffe..3a39617c32 100644
--- a/engines/wintermute/base/font/base_font_storage.h
+++ b/engines/wintermute/base/font/base_font_storage.h
@@ -43,7 +43,7 @@ public:
DECLARE_PERSISTENT(BaseFontStorage, BaseClass)
bool cleanup(bool warn = false);
bool removeFont(BaseFont *font);
- BaseFont *addFont(const char *filename);
+ BaseFont *addFont(const Common::String &filename);
BaseFontStorage(BaseGame *inGame);
virtual ~BaseFontStorage();
BaseArray<BaseFont *> _fonts;
diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp
index 2dd436dc37..793c044839 100644
--- a/engines/wintermute/base/font/base_font_truetype.cpp
+++ b/engines/wintermute/base/font/base_font_truetype.cpp
@@ -292,19 +292,19 @@ int BaseFontTT::getLetterHeight() {
//////////////////////////////////////////////////////////////////////
-bool BaseFontTT::loadFile(const char *filename) {
+bool BaseFontTT::loadFile(const Common::String &filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer == NULL) {
- _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename);
+ _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str());
return STATUS_FAILED;
}
bool ret;
- setFilename(filename);
+ setFilename(filename.c_str());
if (DID_FAIL(ret = loadBuffer(buffer))) {
- _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename);
+ _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename.c_str());
}
delete[] buffer;
diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h
index 20ef531a46..a893e70ec0 100644
--- a/engines/wintermute/base/font/base_font_truetype.h
+++ b/engines/wintermute/base/font/base_font_truetype.h
@@ -105,7 +105,7 @@ public:
virtual int getLetterHeight();
bool loadBuffer(byte *buffer);
- bool loadFile(const char *filename);
+ bool loadFile(const Common::String &filename);
float getLineHeight() const {
return _lineHeight;
diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp
index 62ddece47c..28ac4e6973 100644
--- a/engines/wintermute/base/gfx/base_surface.cpp
+++ b/engines/wintermute/base/gfx/base_surface.cpp
@@ -59,13 +59,6 @@ BaseSurface::~BaseSurface() {
}
}
-
-//////////////////////////////////////////////////////////////////////
-bool BaseSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
- return STATUS_FAILED;
-}
-
-
//////////////////////////////////////////////////////////////////////
bool BaseSurface::restore() {
return STATUS_FAILED;
diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h
index 4f67f871dd..57a51ce3aa 100644
--- a/engines/wintermute/base/gfx/base_surface.h
+++ b/engines/wintermute/base/gfx/base_surface.h
@@ -56,7 +56,7 @@ public:
virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool restore();
- virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0;
+ virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0;
virtual bool create(int width, int height);
virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) {
return STATUS_FAILED;
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index d3209cb1c0..642f2179e6 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -90,7 +90,7 @@ bool hasTransparency(Graphics::Surface *surf) {
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
+bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
/* BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer); */
_filename = filename;
// const Graphics::Surface *surface = image->getSurface();
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index 8e4370892b..fe1d055026 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -41,7 +41,7 @@ public:
BaseSurfaceOSystem(BaseGame *inGame);
~BaseSurfaceOSystem();
- bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false);
+ bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false);
bool create(int width, int height);
bool isTransparentAt(int x, int y);
diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp
index f8c0c1a5cf..7389885f5a 100644
--- a/engines/wintermute/base/particles/part_emitter.cpp
+++ b/engines/wintermute/base/particles/part_emitter.cpp
@@ -403,11 +403,11 @@ bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int
}
//////////////////////////////////////////////////////////////////////////
-PartForce *PartEmitter::addForceByName(const char *name) {
+PartForce *PartEmitter::addForceByName(const Common::String &name) {
PartForce *force = NULL;
for (int i = 0; i < _forces.getSize(); i++) {
- if (scumm_stricmp(name, _forces[i]->getName()) == 0) {
+ if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) {
force = _forces[i];
break;
}
@@ -415,7 +415,7 @@ PartForce *PartEmitter::addForceByName(const char *name) {
if (!force) {
force = new PartForce(_gameRef);
if (force) {
- force->setName(name);
+ force->setName(name.c_str());
_forces.add(force);
}
}
@@ -424,7 +424,7 @@ PartForce *PartEmitter::addForceByName(const char *name) {
//////////////////////////////////////////////////////////////////////////
-bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) {
+bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength) {
PartForce *force = addForceByName(name);
if (!force) {
return STATUS_FAILED;
@@ -442,9 +442,9 @@ bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int pos
}
//////////////////////////////////////////////////////////////////////////
-bool PartEmitter::removeForce(const char *name) {
+bool PartEmitter::removeForce(const Common::String &name) {
for (int i = 0; i < _forces.getSize(); i++) {
- if (scumm_stricmp(name, _forces[i]->getName()) == 0) {
+ if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) {
delete _forces[i];
_forces.remove_at(i);
return STATUS_OK;
diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h
index 4e3b837a11..438dfff521 100644
--- a/engines/wintermute/base/particles/part_emitter.h
+++ b/engines/wintermute/base/particles/part_emitter.h
@@ -57,8 +57,8 @@ public:
bool setBorder(int x, int y, int width, int height);
bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom);
- bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength);
- bool removeForce(const char *name);
+ bool addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength);
+ bool removeForce(const Common::String &name);
BaseArray<PartForce *> _forces;
@@ -126,7 +126,7 @@ private:
char *_emitEvent;
BaseScriptHolder *_owner;
- PartForce *addForceByName(const char *name);
+ PartForce *addForceByName(const Common::String &name);
int static compareZ(const void *obj1, const void *obj2);
bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta);
bool updateInternal(uint32 currentTime, uint32 timerDelta);
diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp
index 0c0ec08ba9..2b05edd61f 100644
--- a/engines/wintermute/base/particles/part_particle.cpp
+++ b/engines/wintermute/base/particles/part_particle.cpp
@@ -70,8 +70,8 @@ PartParticle::~PartParticle(void) {
}
//////////////////////////////////////////////////////////////////////////
-bool PartParticle::setSprite(const char *filename) {
- if (_sprite && _sprite->getFilename() && scumm_stricmp(filename, _sprite->getFilename()) == 0) {
+bool PartParticle::setSprite(const Common::String &filename) {
+ if (_sprite && _sprite->getFilename() && scumm_stricmp(filename.c_str(), _sprite->getFilename()) == 0) {
_sprite->reset();
return STATUS_OK;
}
diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h
index 8b0c6eea36..44da85a559 100644
--- a/engines/wintermute/base/particles/part_particle.h
+++ b/engines/wintermute/base/particles/part_particle.h
@@ -72,7 +72,7 @@ public:
bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta);
bool display(PartEmitter *emitter);
- bool setSprite(const char *filename);
+ bool setSprite(const Common::String &filename);
bool fadeIn(uint32 currentTime, int fadeTime);
bool fadeOut(uint32 currentTime, int fadeTime);
diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp
index d8d4bc66da..29185edce6 100644
--- a/engines/wintermute/base/scriptables/script.cpp
+++ b/engines/wintermute/base/scriptables/script.cpp
@@ -277,14 +277,14 @@ bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScrip
//////////////////////////////////////////////////////////////////////////
-bool ScScript::createThread(ScScript *original, uint32 initIP, const char *eventName) {
+bool ScScript::createThread(ScScript *original, uint32 initIP, const Common::String &eventName) {
cleanup();
_thread = true;
_methodThread = false;
- _threadEvent = new char[strlen(eventName) + 1];
+ _threadEvent = new char[eventName.size() + 1];
if (_threadEvent) {
- strcpy(_threadEvent, eventName);
+ strcpy(_threadEvent, eventName.c_str());
}
// copy filename
@@ -329,7 +329,7 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event
//////////////////////////////////////////////////////////////////////////
-bool ScScript::createMethodThread(ScScript *original, const char *methodName) {
+bool ScScript::createMethodThread(ScScript *original, const Common::String &methodName) {
uint32 ip = original->getMethodPos(methodName);
if (ip == 0) {
return STATUS_FAILED;
@@ -339,9 +339,9 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) {
_thread = true;
_methodThread = true;
- _threadEvent = new char[strlen(methodName) + 1];
+ _threadEvent = new char[methodName.size() + 1];
if (_threadEvent) {
- strcpy(_threadEvent, methodName);
+ strcpy(_threadEvent, methodName.c_str());
}
// copy filename
@@ -1149,9 +1149,9 @@ bool ScScript::executeInstruction() {
//////////////////////////////////////////////////////////////////////////
-uint32 ScScript::getFuncPos(const char *name) {
+uint32 ScScript::getFuncPos(const Common::String &name) {
for (uint32 i = 0; i < _numFunctions; i++) {
- if (strcmp(name, _functions[i].name) == 0) {
+ if (name == _functions[i].name) {
return _functions[i].pos;
}
}
@@ -1160,9 +1160,9 @@ uint32 ScScript::getFuncPos(const char *name) {
//////////////////////////////////////////////////////////////////////////
-uint32 ScScript::getMethodPos(const char *name) {
+uint32 ScScript::getMethodPos(const Common::String &name) {
for (uint32 i = 0; i < _numMethods; i++) {
- if (strcmp(name, _methods[i].name) == 0) {
+ if (name == _methods[i].name) {
return _methods[i].pos;
}
}
@@ -1357,7 +1357,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) {
//////////////////////////////////////////////////////////////////////////
-ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) {
+ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unbreakable) {
//if (_state!=SCRIPT_PERSISTENT) return NULL;
uint32 pos = getEventPos(eventName);
@@ -1371,7 +1371,7 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
if (DID_SUCCEED(ret)) {
thread->_unbreakable = unbreakable;
_engine->_scripts.add(thread);
- _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName);
+ _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName.c_str());
return thread;
} else {
delete thread;
@@ -1385,9 +1385,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
//////////////////////////////////////////////////////////////////////////
-uint32 ScScript::getEventPos(const char *name) {
+uint32 ScScript::getEventPos(const Common::String &name) {
for (int i = _numEvents - 1; i >= 0; i--) {
- if (scumm_stricmp(name, _events[i].name) == 0) {
+ if (scumm_stricmp(name.c_str(), _events[i].name) == 0) {
return _events[i].pos;
}
}
@@ -1396,13 +1396,13 @@ uint32 ScScript::getEventPos(const char *name) {
//////////////////////////////////////////////////////////////////////////
-bool ScScript::canHandleEvent(const char *eventName) {
+bool ScScript::canHandleEvent(const Common::String &eventName) {
return getEventPos(eventName) != 0;
}
//////////////////////////////////////////////////////////////////////////
-bool ScScript::canHandleMethod(const char *methodName) {
+bool ScScript::canHandleMethod(const Common::String &methodName) {
return getMethodPos(methodName) != 0;
}
diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h
index 2ee1319acb..6b5fa1733b 100644
--- a/engines/wintermute/base/scriptables/script.h
+++ b/engines/wintermute/base/scriptables/script.h
@@ -62,11 +62,11 @@ public:
bool _freezable;
bool resume();
bool pause();
- bool canHandleEvent(const char *eventName);
- bool canHandleMethod(const char *methodName);
- bool createThread(ScScript *original, uint32 initIP, const char *eventName);
- bool createMethodThread(ScScript *original, const char *methodName);
- ScScript *invokeEventHandler(const char *eventName, bool unbreakable = false);
+ bool canHandleEvent(const Common::String &eventName);
+ bool canHandleMethod(const Common::String &methodName);
+ bool createThread(ScScript *original, uint32 initIP, const Common::String &eventName);
+ bool createMethodThread(ScScript *original, const Common::String &methodName);
+ ScScript *invokeEventHandler(const Common::String &eventName, bool unbreakable = false);
uint32 _timeSlice;
DECLARE_PERSISTENT(ScScript, BaseClass)
void runtimeError(const char *fmt, ...);
@@ -82,9 +82,9 @@ public:
TScriptState _state;
TScriptState _origState;
ScValue *getVar(char *name);
- uint32 getFuncPos(const char *name);
- uint32 getEventPos(const char *name);
- uint32 getMethodPos(const char *name);
+ uint32 getFuncPos(const Common::String &name);
+ uint32 getEventPos(const Common::String &name);
+ uint32 getMethodPos(const Common::String &name);
typedef struct {
uint32 magic;
uint32 version;
diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp
index 6151128624..7e32552d08 100644
--- a/engines/wintermute/base/sound/base_sound.cpp
+++ b/engines/wintermute/base/sound/base_sound.cpp
@@ -35,10 +35,9 @@ namespace WinterMute {
IMPLEMENT_PERSISTENT(BaseSound, false)
-//////////////////////////////////////////////////////////////////////////
BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) {
_sound = NULL;
- _soundFilename = NULL;
+ _soundFilename = "";
_soundType = Audio::Mixer::kSFXSoundType;
_soundStreamed = false;
@@ -54,32 +53,23 @@ BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) {
_sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0;
}
-
-//////////////////////////////////////////////////////////////////////////
BaseSound::~BaseSound() {
if (_sound) {
_gameRef->_soundMgr->removeSound(_sound);
}
_sound = NULL;
-
- delete[] _soundFilename;
- _soundFilename = NULL;
}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
+bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) {
if (_sound) {
_gameRef->_soundMgr->removeSound(_sound);
_sound = NULL;
}
- delete[] _soundFilename;
- _soundFilename = NULL;
+ _soundFilename = Common::String(); // Set empty
_sound = _gameRef->_soundMgr->addSound(filename, type, streamed);
if (_sound) {
- _soundFilename = new char[strlen(filename) + 1];
- strcpy(_soundFilename, filename);
+ _soundFilename = filename;
_soundType = type;
_soundStreamed = streamed;
@@ -90,8 +80,6 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setSoundSimple() {
_sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed);
if (_sound) {
@@ -112,9 +100,6 @@ bool BaseSound::setSoundSimple() {
}
}
-
-
-//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getLength() {
if (_sound) {
return _sound->getLength();
@@ -123,8 +108,6 @@ uint32 BaseSound::getLength() {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::play(bool looping) {
if (_sound) {
_soundPaused = false;
@@ -134,8 +117,6 @@ bool BaseSound::play(bool looping) {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::stop() {
if (_sound) {
_soundPaused = false;
@@ -145,8 +126,6 @@ bool BaseSound::stop() {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::pause(bool freezePaused) {
if (_sound) {
_soundPaused = true;
@@ -159,8 +138,6 @@ bool BaseSound::pause(bool freezePaused) {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::resume() {
if (_sound && _soundPaused) {
_soundPaused = false;
@@ -170,8 +147,6 @@ bool BaseSound::resume() {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::persist(BasePersistenceManager *persistMgr) {
if (persistMgr->getIsSaving() && _sound) {
_soundPlaying = _sound->isPlaying();
@@ -205,20 +180,14 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) {
return STATUS_OK;
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::isPlaying() {
return _sound && _sound->isPlaying();
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::isPaused() {
return _sound && _soundPaused;
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPositionTime(uint32 time) {
if (!_sound) {
return STATUS_FAILED;
@@ -231,8 +200,6 @@ bool BaseSound::setPositionTime(uint32 time) {
return ret;
}
-
-//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getPositionTime() {
if (!_sound) {
return 0;
@@ -245,7 +212,6 @@ uint32 BaseSound::getPositionTime() {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolumePercent(int percent) {
if (!_sound) {
return STATUS_FAILED;
@@ -254,7 +220,6 @@ bool BaseSound::setVolumePercent(int percent) {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolume(int volume) {
if (!_sound) {
return STATUS_FAILED;
@@ -263,7 +228,6 @@ bool BaseSound::setVolume(int volume) {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPrivateVolume(int volume) {
if (!_sound) {
return STATUS_FAILED;
@@ -273,7 +237,6 @@ bool BaseSound::setPrivateVolume(int volume) {
}
}
-//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolumePercent() {
if (!_sound) {
return 0;
@@ -282,7 +245,6 @@ int BaseSound::getVolumePercent() {
}
}
-//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolume() {
if (!_sound) {
return 0;
@@ -291,7 +253,6 @@ int BaseSound::getVolume() {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setLoopStart(uint32 pos) {
if (!_sound) {
return STATUS_FAILED;
@@ -301,7 +262,6 @@ bool BaseSound::setLoopStart(uint32 pos) {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPan(float pan) {
if (_sound) {
return _sound->setPan(pan);
@@ -310,8 +270,6 @@ bool BaseSound::setPan(float pan) {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, float param4) {
if (!_sound) {
return STATUS_OK;
diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h
index 7ea9f38f6c..cadba77bc8 100644
--- a/engines/wintermute/base/sound/base_sound.h
+++ b/engines/wintermute/base/sound/base_sound.h
@@ -40,7 +40,6 @@ class BaseSoundBuffer;
class BaseSound : public BaseClass {
public:
bool setPan(float pan);
- int _soundPrivateVolume;
int getVolume();
int getVolumePercent();
bool setVolumePercent(int percent);
@@ -49,31 +48,32 @@ public:
bool setLoopStart(uint32 pos);
uint32 getPositionTime();
bool setPositionTime(uint32 time);
- bool _soundPaused;
- bool _soundFreezePaused;
bool isPlaying();
bool isPaused();
- bool _soundPlaying;
- bool _soundLooping;
- uint32 _soundLoopStart;
- uint32 _soundPosition;
DECLARE_PERSISTENT(BaseSound, BaseClass)
bool resume();
bool pause(bool freezePaused = false);
bool stop();
bool play(bool looping = false);
uint32 getLength();
- bool _soundStreamed;
- Audio::Mixer::SoundType _soundType;
- char *_soundFilename;
+ const char *getFilename() { return _soundFilename.c_str(); }
bool setSoundSimple();
- bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
+ bool setSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
BaseSound(BaseGame *inGame);
virtual ~BaseSound();
bool applyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0);
-
private:
+ Common::String _soundFilename;
+ bool _soundStreamed;
+ Audio::Mixer::SoundType _soundType;
+ int _soundPrivateVolume;
+ uint32 _soundLoopStart;
+ uint32 _soundPosition;
+ bool _soundPlaying;
+ bool _soundLooping;
+ bool _soundPaused;
+ bool _soundFreezePaused;
TSFXType _sFXType;
float _sFXParam1;
float _sFXParam2;
diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp
index ed667592e9..5f36eb96d4 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.cpp
+++ b/engines/wintermute/base/sound/base_sound_buffer.cpp
@@ -56,7 +56,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) {
// _sync = NULL;
_streamed = false;
- _filename = NULL;
+ _filename = "";
_file = NULL;
_privateVolume = 255;
_volume = 255;
@@ -82,9 +82,6 @@ BaseSoundBuffer::~BaseSoundBuffer() {
}
delete _stream;
_stream = NULL;
-
- delete[] _filename;
- _filename = NULL;
}
@@ -95,13 +92,13 @@ void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 block
//////////////////////////////////////////////////////////////////////////
-bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
- debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload);
+bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) {
+ debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload);
// Load a file, but avoid having the File-manager handle the disposal of it.
_file = _gameRef->_fileManager->openFile(filename, true, false);
if (!_file) {
- _gameRef->LOG(0, "Error opening sound file '%s'", filename);
+ _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str());
return STATUS_FAILED;
}
Common::String strFilename(filename);
@@ -118,16 +115,16 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
_file = new Common::SeekableSubReadStream(_file, 0, waveSize);
_stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES);
} else {
- error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType);
+ error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename.c_str(), waveType);
}
}
} else {
- error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename);
+ error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename.c_str());
}
if (!_stream) {
return STATUS_FAILED;
}
- BaseUtils::setString(&_filename, filename);
+ _filename = filename;
return STATUS_OK;
}
diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h
index 107ceb87d7..7aec144283 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.h
+++ b/engines/wintermute/base/sound/base_sound_buffer.h
@@ -72,7 +72,7 @@ public:
void setType(Audio::Mixer::SoundType Type);
- bool loadFromFile(const char *filename, bool forceReload = false);
+ bool loadFromFile(const Common::String &filename, bool forceReload = false);
void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0);
bool applyFX(TSFXType type, float param1, float param2, float param3, float param4);
@@ -89,7 +89,7 @@ public:
int _privateVolume;
private:
uint32 _startPos;
- char *_filename;
+ Common::String _filename;
bool _streamed;
Common::SeekableReadStream *_file;
int _volume;
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index 4659c35ff7..8df9f299ef 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -89,13 +89,14 @@ bool BaseSoundMgr::initialize() {
}
//////////////////////////////////////////////////////////////////////////
-BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
+BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) {
if (!_soundAvailable) {
return NULL;
}
BaseSoundBuffer *sound;
+ Common::String useFilename = filename;
// try to switch WAV to OGG file (if available)
AnsiString ext = PathUtil::getExtension(filename);
if (StringUtil::compareNoCase(ext, "wav")) {
@@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
AnsiString newFile = PathUtil::combine(path, name + "ogg");
if (_gameRef->_fileManager->hasFile(newFile)) {
- filename = newFile.c_str();
+ useFilename = newFile;
}
}
@@ -117,9 +118,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
sound->setType(type);
- bool res = sound->loadFromFile(filename);
+ bool res = sound->loadFromFile(useFilename);
if (DID_FAIL(res)) {
- _gameRef->LOG(res, "Error loading sound '%s'", filename);
+ _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str());
delete sound;
return NULL;
}
diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h
index 464330c733..a2b8f2c9e9 100644
--- a/engines/wintermute/base/sound/base_sound_manager.h
+++ b/engines/wintermute/base/sound/base_sound_manager.h
@@ -53,7 +53,7 @@ public:
uint32 _volumeOriginal;
int _volumeMaster;
bool removeSound(BaseSoundBuffer *sound);
- BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
+ BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType);
bool initialize();
bool _soundAvailable;