aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2017-03-22 04:50:37 +0200
committerFilippos Karapetis2017-03-22 04:50:37 +0200
commit2649e2b1fc9d0ab0d5d648602f3d6b936e94dbdb (patch)
treedba2cde344bca76897dfb2fefa74c96cfc56cbc1 /engines
parent83fef244fb4b9389278f3412d9ba446d6fc967a3 (diff)
downloadscummvm-rg350-2649e2b1fc9d0ab0d5d648602f3d6b936e94dbdb.tar.gz
scummvm-rg350-2649e2b1fc9d0ab0d5d648602f3d6b936e94dbdb.tar.bz2
scummvm-rg350-2649e2b1fc9d0ab0d5d648602f3d6b936e94dbdb.zip
FULLPIPE: Change genFileName() and loadFile() to use Common::String
Diffstat (limited to 'engines')
-rw-r--r--engines/fullpipe/scene.cpp25
-rw-r--r--engines/fullpipe/sound.cpp6
-rw-r--r--engines/fullpipe/sound.h4
-rw-r--r--engines/fullpipe/statics.cpp3
-rw-r--r--engines/fullpipe/utils.cpp12
-rw-r--r--engines/fullpipe/utils.h4
6 files changed, 21 insertions, 33 deletions
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp
index 3dc8acdbcd..cd563258dc 100644
--- a/engines/fullpipe/scene.cpp
+++ b/engines/fullpipe/scene.cpp
@@ -96,11 +96,11 @@ SceneTag::~SceneTag() {
}
void SceneTag::loadScene() {
- char *archname = genFileName(0, _sceneId, "nl");
+ Common::String archname = genFileName(0, _sceneId, "nl");
Common::Archive *arch = makeNGIArchive(archname);
- char *fname = genFileName(0, _sceneId, "sc");
+ Common::String fname = genFileName(0, _sceneId, "sc");
Common::SeekableReadStream *file = arch->createReadStreamForMember(fname);
@@ -116,9 +116,6 @@ void SceneTag::loadScene() {
delete file;
g_fp->_currArchive = 0;
-
- free(fname);
- free(archname);
}
Scene::Scene() {
@@ -166,7 +163,7 @@ bool Scene::load(MfcArchive &file) {
for (int i = 0; i < count; i++) {
int aniNum = file.readUint16LE();
- char *aniname = genFileName(0, aniNum, "ani");
+ Common::String aniname = genFileName(0, aniNum, "ani");
Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(aniname);
@@ -180,7 +177,6 @@ bool Scene::load(MfcArchive &file) {
_staticANIObjectList1.push_back(ani);
delete f;
- free(aniname);
}
count = file.readUint16LE();
@@ -188,7 +184,7 @@ bool Scene::load(MfcArchive &file) {
for (int i = 0; i < count; i++) {
int qNum = file.readUint16LE();
- char *qname = genFileName(0, qNum, "qu");
+ Common::String qname = genFileName(0, qNum, "qu");
Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(qname);
MfcArchive archive(f);
@@ -202,7 +198,6 @@ bool Scene::load(MfcArchive &file) {
_messageQueueList.push_back(mq);
delete f;
- free(qname);
}
count = file.readUint16LE();
@@ -227,33 +222,27 @@ bool Scene::load(MfcArchive &file) {
_palette = col;
}
- char *shdname = genFileName(0, _sceneId, "shd");
+ Common::String shdname = genFileName(0, _sceneId, "shd");
Shadows *shd = new Shadows();
if (shd->loadFile(shdname))
_shadows = shd;
- free(shdname);
-
- char *slsname = genFileName(0, _sceneId, "sls");
+ Common::String slsname = genFileName(0, _sceneId, "sls");
if (g_fp->_soundEnabled) {
_soundList = new SoundList();
if (g_fp->_flgSoundList) {
- char *nlname = genFileName(17, _sceneId, "nl");
+ Common::String nlname = genFileName(17, _sceneId, "nl");
_soundList->loadFile(slsname, nlname);
-
- free(nlname);
} else {
_soundList->loadFile(slsname, 0);
}
}
- free(slsname);
-
initStaticANIObjects();
if (file.size() - file.pos() > 0)
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index 187ed16fec..3be7b6e395 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -50,13 +50,13 @@ SoundList::~SoundList() {
free(_soundItems);
}
-bool SoundList::load(MfcArchive &file, char *fname) {
+bool SoundList::load(MfcArchive &file, Common::String fname) {
debugC(5, kDebugLoading, "SoundList::load()");
_soundItemsCount = file.readUint32LE();
_soundItems = (Sound **)calloc(_soundItemsCount, sizeof(Sound *));
- if (fname) {
+ if (!fname.empty()) {
_libHandle = (NGIArchive *)makeNGIArchive(fname);
} else {
_libHandle = 0;
@@ -73,7 +73,7 @@ bool SoundList::load(MfcArchive &file, char *fname) {
}
-bool SoundList::loadFile(const char *fname, char *libname) {
+bool SoundList::loadFile(Common::String fname, Common::String libname) {
Common::File file;
if (!file.open(fname))
diff --git a/engines/fullpipe/sound.h b/engines/fullpipe/sound.h
index bfc38829d6..ea1cf2c9bf 100644
--- a/engines/fullpipe/sound.h
+++ b/engines/fullpipe/sound.h
@@ -67,9 +67,9 @@ class SoundList : public CObject {
public:
SoundList();
~SoundList();
- virtual bool load(MfcArchive &file, char *fname);
+ virtual bool load(MfcArchive &file, Common::String fname);
virtual bool load(MfcArchive &file) { assert(0); return false; } // Disable base class
- bool loadFile(const char *fname, char *libname);
+ bool loadFile(Common::String fname, Common::String libname);
int getCount() { return _soundItemsCount; }
Sound *getSoundByIndex(int idx) { return _soundItems[idx]; }
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index 5032ca719f..8806ce9d05 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -223,7 +223,7 @@ bool StaticANIObject::load(MfcArchive &file) {
for (int i = 0; i < count; i++) {
int movNum = file.readUint16LE();
- char *movname = genFileName(_id, movNum, "mov");
+ Common::String movname = genFileName(_id, movNum, "mov");
Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(movname);
@@ -236,7 +236,6 @@ bool StaticANIObject::load(MfcArchive &file) {
_movements.push_back(mov);
delete f;
- free(movname);
}
Common::Point pt;
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp
index 689491d11d..ed30096b69 100644
--- a/engines/fullpipe/utils.cpp
+++ b/engines/fullpipe/utils.cpp
@@ -33,7 +33,7 @@
namespace Fullpipe {
-bool CObject::loadFile(const char *fname) {
+bool CObject::loadFile(Common::String fname) {
Common::File file;
if (!file.open(fname))
@@ -486,16 +486,16 @@ void MfcArchive::writeObject(CObject *obj) {
}
}
-char *genFileName(int superId, int sceneId, const char *ext) {
- char *s = (char *)calloc(256, 1);
+Common::String genFileName(int superId, int sceneId, const char *ext) {
+ Common::String s;
if (superId) {
- snprintf(s, 255, "%04d%04d.%s", superId, sceneId, ext);
+ s = Common::String::format("%04d%04d.%s", superId, sceneId, ext);
} else {
- snprintf(s, 255, "%04d.%s", sceneId, ext);
+ s = Common::String::format("%04d.%s", sceneId, ext);
}
- debugC(7, kDebugLoading, "genFileName: %s", s);
+ debugC(7, kDebugLoading, "genFileName: %s", s.c_str());
return s;
}
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 101fe20e1b..06b2872b54 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -117,7 +117,7 @@ public:
virtual void save(MfcArchive &out) { error("Not implemented for obj type: %d", _objtype); }
virtual ~CObject() {}
- bool loadFile(const char *fname);
+ bool loadFile(Common::String fname);
};
class ObList : public Common::List<CObject *>, public CObject {
@@ -180,7 +180,7 @@ class DWordArray : public Common::Array<int32>, public CObject {
virtual bool load(MfcArchive &file);
};
-char *genFileName(int superId, int sceneId, const char *ext);
+Common::String genFileName(int superId, int sceneId, const char *ext);
byte *transCyrillic(Common::String str);
} // End of namespace Fullpipe