aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-19 18:41:54 +0200
committerEinar Johan Trøan Sømåen2012-07-19 18:41:54 +0200
commitdef3cd92570ac8138441cd0e7492d0b7bdc61f91 (patch)
treea539b291613533c1912437dd678896320a856548
parent73feff111a98715e87f8e3d72232185650acdc7d (diff)
downloadscummvm-rg350-def3cd92570ac8138441cd0e7492d0b7bdc61f91.tar.gz
scummvm-rg350-def3cd92570ac8138441cd0e7492d0b7bdc61f91.tar.bz2
scummvm-rg350-def3cd92570ac8138441cd0e7492d0b7bdc61f91.zip
WINTERMUTE: Replace a few non-persistent CBArrays with Common::Array
-rw-r--r--engines/wintermute/Base/BFileManager.cpp48
-rw-r--r--engines/wintermute/Base/BFileManager.h9
-rw-r--r--engines/wintermute/Base/BSoundMgr.cpp18
-rw-r--r--engines/wintermute/Base/BSoundMgr.h3
-rw-r--r--engines/wintermute/Base/BSurfaceStorage.cpp18
-rw-r--r--engines/wintermute/Base/BSurfaceStorage.h5
-rw-r--r--engines/wintermute/Base/file/BDiskFile.cpp2
7 files changed, 51 insertions, 52 deletions
diff --git a/engines/wintermute/Base/BFileManager.cpp b/engines/wintermute/Base/BFileManager.cpp
index 00b44646f4..a0ba77482d 100644
--- a/engines/wintermute/Base/BFileManager.cpp
+++ b/engines/wintermute/Base/BFileManager.cpp
@@ -75,13 +75,13 @@ CBFileManager::~CBFileManager() {
//////////////////////////////////////////////////////////////////////////
bool CBFileManager::cleanup() {
// delete registered paths
- for (int i = 0; i < _singlePaths.getSize(); i++)
+ for (int i = 0; i < _singlePaths.size(); i++)
delete [] _singlePaths[i];
- _singlePaths.removeAll();
+ _singlePaths.clear();
- for (int i = 0; i < _packagePaths.getSize(); i++)
+ for (int i = 0; i < _packagePaths.size(); i++)
delete [] _packagePaths[i];
- _packagePaths.removeAll();
+ _packagePaths.clear();
// delete file entries
@@ -93,16 +93,16 @@ bool CBFileManager::cleanup() {
_files.clear();
// close open files
- for (int i = 0; i < _openFiles.getSize(); i++) {
+ for (int i = 0; i < _openFiles.size(); i++) {
delete _openFiles[i];
}
- _openFiles.removeAll();
+ _openFiles.clear();
// delete packages
- for (int i = 0; i < _packages.getSize(); i++)
+ for (int i = 0; i < _packages.size(); i++)
delete _packages[i];
- _packages.removeAll();
+ _packages.clear();
delete[] _basePath;
_basePath = NULL;
@@ -225,7 +225,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3
//////////////////////////////////////////////////////////////////////////
bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) {
// unmount all non-local packages
- for (int i = 0; i < _packages.getSize(); i++) {
+ for (int i = 0; i < _packages.size(); i++) {
if (_packages[i]->_cD > 0) _packages[i]->close();
}
@@ -249,10 +249,10 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) {
switch (type) {
case PATH_SINGLE:
- _singlePaths.add(buffer);
+ _singlePaths.push_back(buffer);
break;
case PATH_PACKAGE:
- _packagePaths.add(buffer);
+ _packagePaths.push_back(buffer);
break;
}
@@ -262,13 +262,13 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) {
//////////////////////////////////////////////////////////////////////////
bool CBFileManager::reloadPaths() {
// delete registered paths
- for (int i = 0; i < _singlePaths.getSize(); i++)
+ for (int i = 0; i < _singlePaths.size(); i++)
delete [] _singlePaths[i];
- _singlePaths.removeAll();
+ _singlePaths.clear();
- for (int i = 0; i < _packagePaths.getSize(); i++)
+ for (int i = 0; i < _packagePaths.size(); i++)
delete [] _packagePaths[i];
- _packagePaths.removeAll();
+ _packagePaths.clear();
return initPaths();
}
@@ -358,8 +358,8 @@ bool CBFileManager::registerPackages() {
}
}
#endif
- debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.getSize());
- _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.getSize());
+ debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size());
+ _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size());
return STATUS_OK;
}
@@ -424,7 +424,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search
pkg->_priority = hdr.Priority;
if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk
- _packages.add(pkg);
+ _packages.push_back(pkg);
// read file entries
@@ -511,7 +511,7 @@ Common::File *CBFileManager::openPackage(const Common::String &name) {
Common::File *ret = new Common::File();
char filename[MAX_PATH_LENGTH];
- for (int i = 0; i < _packagePaths.getSize(); i++) {
+ for (int i = 0; i < _packagePaths.size(); i++) {
sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION);
ret->open(filename);
if (ret->isOpen()) {
@@ -537,7 +537,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) {
Common::File *ret = NULL;
char filename[MAX_PATH_LENGTH];
- for (int i = 0; i < _singlePaths.getSize(); i++) {
+ for (int i = 0; i < _singlePaths.size(); i++) {
sprintf(filename, "%s%s", _singlePaths[i], name.c_str());
ret->open(filename);
if (ret->isOpen())
@@ -562,7 +562,7 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *fullname)
Common::File f;
bool found = false;
- for (int i = 0; i < _singlePaths.getSize(); i++) {
+ for (int i = 0; i < _singlePaths.size(); i++) {
sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str());
f.open(fullname);
if (f.isOpen()) {
@@ -625,17 +625,17 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena
#endif*/
Common::SeekableReadStream *file = openFileRaw(filename);
- if (file && keepTrackOf) _openFiles.add(file);
+ if (file && keepTrackOf) _openFiles.push_back(file);
return file;
}
//////////////////////////////////////////////////////////////////////////
bool CBFileManager::closeFile(Common::SeekableReadStream *File) {
- for (int i = 0; i < _openFiles.getSize(); i++) {
+ for (int i = 0; i < _openFiles.size(); i++) {
if (_openFiles[i] == File) {
delete _openFiles[i];
- _openFiles.removeAt(i);
+ _openFiles.remove_at(i);
return STATUS_OK;
}
}
diff --git a/engines/wintermute/Base/BFileManager.h b/engines/wintermute/Base/BFileManager.h
index aebaa6f3fc..53e55402cc 100644
--- a/engines/wintermute/Base/BFileManager.h
+++ b/engines/wintermute/Base/BFileManager.h
@@ -29,7 +29,6 @@
#ifndef WINTERMUTE_BFILEMANAGER_H
#define WINTERMUTE_BFILEMANAGER_H
-#include "engines/wintermute/coll_templ.h"
#include "engines/wintermute/Base/BFileEntry.h"
#include "common/archive.h"
#include "common/str.h"
@@ -68,10 +67,10 @@ public:
byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true);
CBFileManager(CBGame *inGame = NULL);
virtual ~CBFileManager();
- CBArray<char *, char *> _singlePaths;
- CBArray<char *, char *> _packagePaths;
- CBArray<CBPackage *, CBPackage *> _packages;
- CBArray<Common::SeekableReadStream *, Common::SeekableReadStream *> _openFiles;
+ Common::Array<char *> _singlePaths;
+ Common::Array<char * > _packagePaths;
+ Common::Array<CBPackage *> _packages;
+ Common::Array<Common::SeekableReadStream *> _openFiles;
Common::HashMap<Common::String, CBFileEntry *> _files;
private:
diff --git a/engines/wintermute/Base/BSoundMgr.cpp b/engines/wintermute/Base/BSoundMgr.cpp
index 98a5e69d7b..d4100df7aa 100644
--- a/engines/wintermute/Base/BSoundMgr.cpp
+++ b/engines/wintermute/Base/BSoundMgr.cpp
@@ -62,9 +62,9 @@ CBSoundMgr::~CBSoundMgr() {
//////////////////////////////////////////////////////////////////////////
bool CBSoundMgr::cleanup() {
- for (int i = 0; i < _sounds.getSize(); i++)
+ for (int i = 0; i < _sounds.size(); i++)
delete _sounds[i];
- _sounds.removeAll();
+ _sounds.clear();
#if 0
BASS_Free();
#endif
@@ -141,7 +141,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp
sound->updateVolume();
// register sound
- _sounds.add(sound);
+ _sounds.push_back(sound);
return sound;
@@ -157,17 +157,17 @@ bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) {
sound->updateVolume();
// register sound
- _sounds.add(sound);
+ _sounds.push_back(sound);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
bool CBSoundMgr::removeSound(CBSoundBuffer *sound) {
- for (int i = 0; i < _sounds.getSize(); i++) {
+ for (int i = 0; i < _sounds.size(); i++) {
if (_sounds[i] == sound) {
delete _sounds[i];
- _sounds.removeAt(i);
+ _sounds.remove_at(i);
return STATUS_OK;
}
}
@@ -227,7 +227,7 @@ byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) {
//////////////////////////////////////////////////////////////////////////
bool CBSoundMgr::setMasterVolume(byte value) {
_volumeMaster = value;
- for (int i = 0; i < _sounds.getSize(); i++) {
+ for (int i = 0; i < _sounds.size(); i++) {
_sounds[i]->updateVolume();
}
return STATUS_OK;
@@ -254,7 +254,7 @@ byte CBSoundMgr::getMasterVolume() {
//////////////////////////////////////////////////////////////////////////
bool CBSoundMgr::pauseAll(bool includingMusic) {
- for (int i = 0; i < _sounds.getSize(); i++) {
+ for (int i = 0; i < _sounds.size(); i++) {
if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) {
_sounds[i]->pause();
_sounds[i]->_freezePaused = true;
@@ -268,7 +268,7 @@ bool CBSoundMgr::pauseAll(bool includingMusic) {
//////////////////////////////////////////////////////////////////////////
bool CBSoundMgr::resumeAll() {
- for (int i = 0; i < _sounds.getSize(); i++) {
+ for (int i = 0; i < _sounds.size(); i++) {
if (_sounds[i]->_freezePaused) {
_sounds[i]->resume();
_sounds[i]->_freezePaused = false;
diff --git a/engines/wintermute/Base/BSoundMgr.h b/engines/wintermute/Base/BSoundMgr.h
index 13e3957fce..be5be87b59 100644
--- a/engines/wintermute/Base/BSoundMgr.h
+++ b/engines/wintermute/Base/BSoundMgr.h
@@ -32,6 +32,7 @@
#include "engines/wintermute/coll_templ.h"
#include "engines/wintermute/Base/BBase.h"
#include "audio/mixer.h"
+#include "common/array.h"
namespace WinterMute {
class CBSoundBuffer;
@@ -59,7 +60,7 @@ public:
bool _soundAvailable;
CBSoundMgr(CBGame *inGame);
virtual ~CBSoundMgr();
- CBArray<CBSoundBuffer *, CBSoundBuffer *> _sounds;
+ Common::Array<CBSoundBuffer *> _sounds;
void saveSettings();
};
diff --git a/engines/wintermute/Base/BSurfaceStorage.cpp b/engines/wintermute/Base/BSurfaceStorage.cpp
index 34721c40f6..56b59f714a 100644
--- a/engines/wintermute/Base/BSurfaceStorage.cpp
+++ b/engines/wintermute/Base/BSurfaceStorage.cpp
@@ -52,11 +52,11 @@ CBSurfaceStorage::~CBSurfaceStorage() {
//////////////////////////////////////////////////////////////////////////
bool CBSurfaceStorage::cleanup(bool warn) {
- for (int i = 0; i < _surfaces.getSize(); i++) {
+ for (int i = 0; i < _surfaces.size(); i++) {
if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount);
delete _surfaces[i];
}
- _surfaces.removeAll();
+ _surfaces.clear();
return STATUS_OK;
}
@@ -67,7 +67,7 @@ bool CBSurfaceStorage::initLoop() {
if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) {
_lastCleanupTime = _gameRef->_liveTimer;
sortSurfaces();
- for (int i = 0; i < _surfaces.getSize(); i++) {
+ for (int i = 0; i < _surfaces.size(); i++) {
if (_surfaces[i]->_lifeTime <= 0) break;
if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) {
@@ -82,12 +82,12 @@ bool CBSurfaceStorage::initLoop() {
//////////////////////////////////////////////////////////////////////
bool CBSurfaceStorage::removeSurface(CBSurface *surface) {
- for (int i = 0; i < _surfaces.getSize(); i++) {
+ for (int i = 0; i < _surfaces.size(); i++) {
if (_surfaces[i] == surface) {
_surfaces[i]->_referenceCount--;
if (_surfaces[i]->_referenceCount <= 0) {
delete _surfaces[i];
- _surfaces.removeAt(i);
+ _surfaces.remove_at(i);
}
break;
}
@@ -98,7 +98,7 @@ bool CBSurfaceStorage::removeSurface(CBSurface *surface) {
//////////////////////////////////////////////////////////////////////
CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) {
- for (int i = 0; i < _surfaces.getSize(); i++) {
+ for (int i = 0; i < _surfaces.size(); i++) {
if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) {
_surfaces[i]->_referenceCount++;
return _surfaces[i];
@@ -123,7 +123,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by
return NULL;
} else {
surface->_referenceCount = 1;
- _surfaces.add(surface);
+ _surfaces.push_back(surface);
return surface;
}
}
@@ -132,7 +132,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by
//////////////////////////////////////////////////////////////////////
bool CBSurfaceStorage::restoreAll() {
bool ret;
- for (int i = 0; i < _surfaces.getSize(); i++) {
+ for (int i = 0; i < _surfaces.size(); i++) {
ret = _surfaces[i]->restore();
if (ret != STATUS_OK) {
_gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed");
@@ -161,7 +161,7 @@ bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr)
//////////////////////////////////////////////////////////////////////////
bool CBSurfaceStorage::sortSurfaces() {
- qsort(_surfaces.getData(), _surfaces.getSize(), sizeof(CBSurface *), surfaceSortCB);
+ qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB);
return STATUS_OK;
}
diff --git a/engines/wintermute/Base/BSurfaceStorage.h b/engines/wintermute/Base/BSurfaceStorage.h
index 1e8074dc99..00ca38a7a1 100644
--- a/engines/wintermute/Base/BSurfaceStorage.h
+++ b/engines/wintermute/Base/BSurfaceStorage.h
@@ -29,9 +29,8 @@
#ifndef WINTERMUTE_BSURFACESTORAGE_H
#define WINTERMUTE_BSURFACESTORAGE_H
-
-#include "engines/wintermute/coll_templ.h"
#include "engines/wintermute/Base/BBase.h"
+#include "common/array.h"
namespace WinterMute {
class CBSurface;
@@ -50,7 +49,7 @@ public:
CBSurfaceStorage(CBGame *inGame);
virtual ~CBSurfaceStorage();
- CBArray<CBSurface *, CBSurface *> _surfaces;
+ Common::Array<CBSurface *> _surfaces;
};
} // end of namespace WinterMute
diff --git a/engines/wintermute/Base/file/BDiskFile.cpp b/engines/wintermute/Base/file/BDiskFile.cpp
index 4287458b8e..2a3386a005 100644
--- a/engines/wintermute/Base/file/BDiskFile.cpp
+++ b/engines/wintermute/Base/file/BDiskFile.cpp
@@ -50,7 +50,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileM
uint32 prefixSize = 0;
Common::SeekableReadStream *file = NULL;
- for (int i = 0; i < fileManager->_singlePaths.getSize(); i++) {
+ for (int i = 0; i < fileManager->_singlePaths.size(); i++) {
sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str());
correctSlashes(fullPath);
Common::File *tempFile = new Common::File();