mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-30 12:50:51 +00:00
some cleanup
svn-id: r10720
This commit is contained in:
parent
1f9497cb1f
commit
5301edc383
@ -25,6 +25,7 @@
|
||||
#include "base/engine.h"
|
||||
#include "base/gameDetector.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/file.h"
|
||||
#include "common/timer.h"
|
||||
#include "sound/mixer.h"
|
||||
|
||||
@ -32,13 +33,14 @@
|
||||
Engine *g_engine = 0;
|
||||
|
||||
Engine::Engine(GameDetector *detector, OSystem *syst)
|
||||
: _system(syst) {
|
||||
: _system(syst), _gameDataPath(ConfMan.get("path")) {
|
||||
g_engine = this;
|
||||
_mixer = detector->createMixer();
|
||||
|
||||
_gameDataPath = strdup(ConfMan.get("path").c_str()); // FIXME - leak. Just conver to a String?
|
||||
|
||||
_timer = g_timer;
|
||||
|
||||
// Set default file directory
|
||||
File::setDefaultDirectory(_gameDataPath);
|
||||
}
|
||||
|
||||
Engine::~Engine() {
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define ENGINE_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
#include "common/system.h"
|
||||
|
||||
extern const char *gScummVMVersion; // e.g. "0.4.1"
|
||||
@ -67,7 +68,7 @@ public:
|
||||
Timer * _timer;
|
||||
|
||||
protected:
|
||||
const char *_gameDataPath;
|
||||
const Common::String _gameDataPath;
|
||||
|
||||
public:
|
||||
Engine(GameDetector *detector, OSystem *syst);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "common/util.h"
|
||||
|
||||
|
||||
char *File::_defaultDirectory = 0;
|
||||
Common::String File::_defaultDirectory;
|
||||
|
||||
|
||||
FILE *File::fopenNoCase(const char *filename, const char *directory, const char *mode) {
|
||||
@ -119,9 +119,8 @@ FILE *File::fopenNoCase(const char *filename, const char *directory, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void File::setDefaultDirectory(const char *directory) {
|
||||
free(_defaultDirectory);
|
||||
_defaultDirectory = strdup(directory);
|
||||
void File::setDefaultDirectory(const Common::String &directory) {
|
||||
_defaultDirectory = directory;
|
||||
}
|
||||
|
||||
File::File() {
|
||||
@ -147,7 +146,7 @@ bool File::open(const char *filename, const char *directory, int mode, byte encb
|
||||
|
||||
// If no directory was specified, use the default directory (if any).
|
||||
if (directory == NULL)
|
||||
directory = _defaultDirectory ? _defaultDirectory : "";
|
||||
directory = _defaultDirectory.isEmpty() ? "" : _defaultDirectory.c_str();
|
||||
|
||||
clearIOFailed();
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
|
||||
class File {
|
||||
private:
|
||||
@ -35,7 +36,7 @@ private:
|
||||
|
||||
static FILE *fopenNoCase(const char *filename, const char *directory, const char *mode);
|
||||
|
||||
static char *_defaultDirectory;
|
||||
static Common::String _defaultDirectory;
|
||||
|
||||
public:
|
||||
enum {
|
||||
@ -43,10 +44,11 @@ public:
|
||||
kFileWriteMode = 2
|
||||
};
|
||||
|
||||
static void setDefaultDirectory(const char *directory);
|
||||
static void setDefaultDirectory(const Common::String &directory);
|
||||
|
||||
File();
|
||||
virtual ~File();
|
||||
bool open(const char *filename, const Common::String &directory) { return open(filename, directory.c_str()); }
|
||||
bool open(const char *filename, const char *directory = NULL, int mode = kFileReadMode, byte encbyte = 0);
|
||||
void close();
|
||||
bool isOpen();
|
||||
|
@ -43,14 +43,13 @@ const GameVersion Resource::_gameVersions[] = {
|
||||
{ "PE100", true, true, 0x000B40F5 }
|
||||
};
|
||||
|
||||
Resource::Resource(const char *datafilePath)
|
||||
: _resourceEntries(0), _resourceTable(NULL) {
|
||||
Resource::Resource(const Common::String &datafilePath)
|
||||
: _resourceEntries(0), _resourceTable(NULL), _datafilePath(datafilePath) {
|
||||
|
||||
_datafilePath = datafilePath;
|
||||
_resourceFile = new File();
|
||||
_resourceFile->open(dataFilename, _datafilePath);
|
||||
if (_resourceFile->isOpen() == false)
|
||||
error("Could not open resource file '%s%s'", _datafilePath, dataFilename);
|
||||
error("Could not open resource file '%s%s'", _datafilePath.c_str(), dataFilename);
|
||||
|
||||
|
||||
_gameVersion = detectGameVersion(_resourceFile->size());
|
||||
@ -62,7 +61,7 @@ Resource::Resource(const char *datafilePath)
|
||||
_resourceEntries = 1076;
|
||||
_resourceTable = _resourceTablePEM10;
|
||||
} else {
|
||||
error("Couldn't find tablefile '%s%s'", _datafilePath, tableFilename);
|
||||
error("Couldn't find tablefile '%s%s'", _datafilePath.c_str(), tableFilename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ struct GameVersion {
|
||||
class Resource {
|
||||
|
||||
public:
|
||||
Resource(const char *datafilePath);
|
||||
Resource(const Common::String &datafilePath);
|
||||
~Resource(void);
|
||||
uint8 *loadFile(const char *filename, uint32 skipBytes = 0);
|
||||
bool exists(const char *filename);
|
||||
@ -66,7 +66,7 @@ public:
|
||||
|
||||
protected:
|
||||
File *_resourceFile;
|
||||
const char *_datafilePath;
|
||||
const Common::String _datafilePath;
|
||||
const GameVersion *_gameVersion;
|
||||
uint32 _resourceEntries;
|
||||
ResourceEntry *_resourceTable;
|
||||
|
@ -2507,7 +2507,7 @@ byte *ScummEngine::get2byteCharPtr(int idx) {
|
||||
|
||||
const char *ScummEngine::getGameDataPath() const {
|
||||
#ifdef MACOSX
|
||||
if (_version == 8 && !memcmp(_gameDataPath, "/Volumes/MONKEY3_", 17)) {
|
||||
if (_version == 8 && _gameDataPath == "/Volumes/MONKEY3_") {
|
||||
// Special case for COMI on Mac OS X. The mount points on OS X depend
|
||||
// on the volume name. Hence if playing from CD, we'd get a problem.
|
||||
// So if loading of a resource file fails, we fall back to the (fixed)
|
||||
@ -2531,7 +2531,7 @@ const char *ScummEngine::getGameDataPath() const {
|
||||
}
|
||||
#endif
|
||||
|
||||
return _gameDataPath;
|
||||
return _gameDataPath.c_str();
|
||||
}
|
||||
|
||||
void ScummEngine::errorString(const char *buf1, char *buf2) {
|
||||
|
@ -235,11 +235,8 @@ int MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const char *gameDataPath, SoundMixer *mixer) {
|
||||
_game = game;
|
||||
_gameDataPath = gameDataPath;
|
||||
_mixer = mixer;
|
||||
|
||||
SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const Common::String &gameDataPath, SoundMixer *mixer)
|
||||
: _game(game), _gameDataPath(gameDataPath), _mixer(mixer) {
|
||||
_voice_index = 0;
|
||||
_ambient_index = 0;
|
||||
|
||||
@ -343,7 +340,7 @@ SimonSound::~SimonSound() {
|
||||
free(_offsets);
|
||||
}
|
||||
|
||||
void SimonSound::readSfxFile(const char *filename, const char *gameDataPath) {
|
||||
void SimonSound::readSfxFile(const char *filename, const Common::String &gameDataPath) {
|
||||
stopAll();
|
||||
|
||||
File *file = new File();
|
||||
@ -379,7 +376,7 @@ void SimonSound::loadSfxTable(File *gameFile, uint32 base) {
|
||||
_effects = new VocSound(_mixer, gameFile, base);
|
||||
}
|
||||
|
||||
void SimonSound::readVoiceFile(const char *filename, const char *gameDataPath) {
|
||||
void SimonSound::readVoiceFile(const char *filename, const Common::String &gameDataPath) {
|
||||
stopAll();
|
||||
|
||||
File *file = new File();
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "sound/mixer.h"
|
||||
#include "simon/intern.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace Simon {
|
||||
|
||||
@ -30,7 +31,7 @@ class BaseSound;
|
||||
class SimonSound {
|
||||
private:
|
||||
byte _game;
|
||||
const char *_gameDataPath;
|
||||
const Common::String _gameDataPath;
|
||||
|
||||
SoundMixer *_mixer;
|
||||
|
||||
@ -54,12 +55,12 @@ public:
|
||||
bool _voice_file;
|
||||
uint _ambient_playing;
|
||||
|
||||
SimonSound(const byte game, const GameSpecificSettings *gss, const char *gameDataPath, SoundMixer *mixer);
|
||||
SimonSound(const byte game, const GameSpecificSettings *gss, const Common::String &gameDataPath, SoundMixer *mixer);
|
||||
~SimonSound();
|
||||
|
||||
void readSfxFile(const char *filename, const char *gameDataPath);
|
||||
void readSfxFile(const char *filename, const Common::String &gameDataPath);
|
||||
void loadSfxTable(File *gameFile, uint32 base);
|
||||
void readVoiceFile(const char *filename, const char *gameDataPath);
|
||||
void readVoiceFile(const char *filename, const Common::String &gameDataPath);
|
||||
|
||||
void playVoice(uint sound);
|
||||
void playEffects(uint sound);
|
||||
|
@ -31,12 +31,9 @@
|
||||
static const char *dataFilename = "sky.dsk";
|
||||
static const char *dinnerFilename = "sky.dnr";
|
||||
|
||||
SkyDisk::SkyDisk(const char *gameDataPath) {
|
||||
SkyDisk::SkyDisk(const Common::String &gameDataPath) {
|
||||
_prefRoot = NULL;
|
||||
|
||||
// Set default file directory
|
||||
File::setDefaultDirectory(gameDataPath);
|
||||
|
||||
_dataDiskHandle = new File();
|
||||
_dnrHandle = new File();
|
||||
|
||||
@ -44,7 +41,7 @@ SkyDisk::SkyDisk(const char *gameDataPath) {
|
||||
|
||||
_dnrHandle->open(dinnerFilename);
|
||||
if (_dnrHandle->isOpen() == false)
|
||||
error("Could not open %s%s", gameDataPath, dinnerFilename);
|
||||
error("Could not open %s%s", gameDataPath.c_str(), dinnerFilename);
|
||||
|
||||
if (!(_dinnerTableEntries = _dnrHandle->readUint32LE()))
|
||||
error("Error reading from sky.dnr"); //even though it was opened correctly?!
|
||||
@ -57,7 +54,7 @@ SkyDisk::SkyDisk(const char *gameDataPath) {
|
||||
|
||||
_dataDiskHandle->open(dataFilename);
|
||||
if (_dataDiskHandle->isOpen() == false)
|
||||
error("Error opening %s%s", gameDataPath, dataFilename);
|
||||
error("Error opening %s%s", gameDataPath.c_str(), dataFilename);
|
||||
|
||||
printf("Found BASS version v0.0%d (%d dnr entries)\n", determineGameVersion(), _dinnerTableEntries);
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
|
||||
class File;
|
||||
|
||||
@ -38,7 +39,7 @@ struct PrefFile {
|
||||
|
||||
class SkyDisk {
|
||||
public:
|
||||
SkyDisk(const char *gameDataPath);
|
||||
SkyDisk(const Common::String &gameDataPath);
|
||||
~SkyDisk(void);
|
||||
|
||||
uint8 *loadFile(uint16 fileNr, uint8 *dest);
|
||||
|
@ -120,8 +120,6 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
|
||||
_mixer->setMusicVolume(256);
|
||||
|
||||
g_sound = _sound = new Sound(_mixer);
|
||||
|
||||
File::setDefaultDirectory(_gameDataPath);
|
||||
}
|
||||
|
||||
void Sword2Engine::errorString(const char *buf1, char *buf2) {
|
||||
|
Loading…
Reference in New Issue
Block a user