some more target<->game cleanup

svn-id: r10769
This commit is contained in:
Max Horn 2003-10-12 19:10:17 +00:00
parent 5325ed83cf
commit 31ba12c800
12 changed files with 36 additions and 39 deletions

View file

@ -559,11 +559,6 @@ bool GameDetector::detectGame() {
if (target) {
_game = *target;
if (ConfMan.hasKey("basename")) {
// FIXME: What is this good for?
// FIXME: This leaks now!
_game.gameName = strdup(ConfMan.get("basename").c_str());
}
printf("Trying to start game '%s'\n", _game.description);
return true;
} else {

View file

@ -21,6 +21,7 @@
#include "stdafx.h"
#include "common/file.h"
#include "common/str.h"
#include "common/util.h"
#include "scumm/actor.h"
@ -64,8 +65,8 @@ ScummDebugger::ScummDebugger(ScummEngine *s) {
DVar_Register("scumm_roomresource", &_vm->_roomResource, DVAR_INT, 0);
DVar_Register("scumm_vars", &_vm->_scummVars, DVAR_INTARRAY, _vm->_numVariables);
DVar_Register("scumm_gamename", &_vm->_game_name, DVAR_STRING, 0);
DVar_Register("scumm_exename", &_vm->_exe_name, DVAR_STRING, 0);
DVar_Register("scumm_gamename", &_vm->_targetName, DVAR_STRING, 0);
DVar_Register("scumm_exename", &_vm->_gameName, DVAR_STRING, 0);
DVar_Register("scumm_gameid", &_vm->_gameId, DVAR_INT, 0);
// Register commands
@ -325,7 +326,7 @@ bool ScummDebugger::RunCommand(const char *inputOrig) {
break;
// String
case DVAR_STRING:
Debug_Printf("(string)%s = %s\n", param[0], *(char **)_dvars[i].variable);
Debug_Printf("(string)%s = %s\n", param[0], ((Common::String *)_dvars[i].variable)->c_str());
break;
default:
Debug_Printf("%s = (unknown type)\n", param[0]);

View file

@ -83,18 +83,18 @@ void ScummEngine::openRoom(int room) {
if (!(_features & GF_SMALL_HEADER)) {
if (_features & GF_AFTER_HEV7) {
sprintf(buf, "%s.he%.1d", _exe_name, room == 0 ? 0 : 1);
sprintf(buf, "%s.he%.1d", _gameName.c_str(), room == 0 ? 0 : 1);
} else if (_version >= 7) {
if (room > 0 && (_version == 8))
VAR(VAR_CURRENTDISK) = res.roomno[rtRoom][room];
sprintf(buf, "%s.la%d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
sprintf(buf2, "%s.%.3d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
sprintf(buf, "%s.la%d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
sprintf(buf2, "%s.%.3d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
} else if (_features & GF_HUMONGOUS)
sprintf(buf, "%s.he%.1d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
sprintf(buf, "%s.he%.1d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
else {
sprintf(buf, "%s.%.3d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
sprintf(buf, "%s.%.3d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
if (_gameId == GID_SAMNMAX)
sprintf(buf2, "%s.sm%.1d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
sprintf(buf2, "%s.sm%.1d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
}
encByte = (_features & GF_USE_KEY) ? 0x69 : 0;

View file

@ -228,7 +228,7 @@ bool ScummEngine::loadState(int slot, bool compat, SaveFileManager *mgr) {
}
void ScummEngine::makeSavegameName(char *out, int slot, bool compatible) {
sprintf(out, "%s.%c%.2d", _game_name, compatible ? 'c' : 's', slot);
sprintf(out, "%s.%c%.2d", _targetName.c_str(), compatible ? 'c' : 's', slot);
}
void ScummEngine::listSavegames(bool *marks, int num, SaveFileManager *mgr) {

View file

@ -311,7 +311,7 @@ public:
void clearClickedStatus();
// Misc utility functions
const char *getExeName() const { return _exe_name; }
const char *getGameName() const { return _gameName.c_str(); }
const char *getGameDataPath() const;
// Cursor/palette
@ -556,8 +556,8 @@ protected:
File _fileHandle;
uint32 _fileOffset;
int _resourceHeaderSize;
char *_exe_name; // This is the name we use for opening resource files
char *_game_name; // This is the game the user calls it, so use for saving
Common::String _gameName; // This is the name we use for opening resource files
Common::String _targetName; // This is the game the user calls it, so use for saving
bool _dynamicRoomOffsets;
byte _resourceMapper[128];
uint32 _allocatedSize;

View file

@ -364,8 +364,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
_keyScriptKey = 0;
_keyScriptNo = 0;
_fileOffset = 0;
_exe_name = NULL;
_game_name = NULL;
_dynamicRoomOffsets = false;
memset(_resourceMapper, 0, sizeof(_resourceMapper));
_allocatedSize = 0;
@ -595,8 +593,13 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
_debugLevel = ConfMan.getInt("debuglevel");
_dumpScripts = detector->_dumpScripts;
_bootParam = ConfMan.getInt("boot_param");
_exe_name = strdup(detector->_game.gameName);
_game_name = strdup(detector->_targetName.c_str());
// Allow the user to override the game name with a custom string.
// This allows some game versions to work which use filenames
// differing from the regular version(s) of that game.
_gameName = ConfMan.hasKey("basename") ? ConfMan.get("basename") : detector->_game.gameName;
_targetName = detector->_targetName;
_gameId = detector->_game.id;
_version = detector->_game.version;
setFeatures(detector->_game.features);
@ -786,8 +789,6 @@ ScummEngine::~ScummEngine() {
free(_bitVars);
free(_newNames);
free(_classData);
free(_exe_name);
free(_game_name);
free(_roomStrips);
free(_languageIndex);

View file

@ -887,7 +887,7 @@ void SmushPlayer::updateScreen() {
#ifdef DUMP_SMUSH_FRAMES
char fileName[100];
// change path below for dump png files
sprintf(fileName, "/path/to/somethere/%s%04d.png", _scumm->getExeName, _frame);
sprintf(fileName, "/path/to/somethere/%s%04d.png", _scumm->getGameName(), _frame);
FILE *file = fopen(fileName, "wb");
if (file == NULL)
error("can't open file for writing png");

View file

@ -895,13 +895,13 @@ File *Sound::openSfxFile() {
char buf[256];
File *file = new File();
/* Try opening the file <_exe_name>.sou first, eg tentacle.sou.
/* Try opening the file <_gameName>.sou first, eg tentacle.sou.
* That way, you can keep .sou files for multiple games in the
* same directory */
offset_table = NULL;
#ifdef USE_MAD
sprintf(buf, "%s.so3", _scumm->getExeName());
sprintf(buf, "%s.so3", _scumm->getGameName());
if (!file->open(buf, _scumm->getGameDataPath())) {
file->open("monster.so3", _scumm->getGameDataPath());
}
@ -911,7 +911,7 @@ File *Sound::openSfxFile() {
#ifdef USE_VORBIS
if (!file->isOpen()) {
sprintf(buf, "%s.sog", _scumm->getExeName());
sprintf(buf, "%s.sog", _scumm->getGameName());
if (!file->open(buf, _scumm->getGameDataPath()))
file->open("monster.sog", _scumm->getGameDataPath());
if (file->isOpen())
@ -953,13 +953,13 @@ File *Sound::openSfxFile() {
return file;
}
sprintf(buf, "%s.sou", _scumm->getExeName());
sprintf(buf, "%s.sou", _scumm->getGameName());
if (!file->open(buf, _scumm->getGameDataPath())) {
file->open("monster.sou", _scumm->getGameDataPath());
}
if (!file->isOpen()) {
sprintf(buf, "%s.tlk", _scumm->getExeName());
sprintf(buf, "%s.tlk", _scumm->getGameName());
file->open(buf, _scumm->getGameDataPath(), 1, 0x69);
}
return file;

View file

@ -893,7 +893,7 @@ int32 OptionsDialog::writeOptionSettings(void) {
SaveFile *fp;
SaveFileManager *mgr = g_system->get_savefile_manager();
sprintf(filename, "%s-settings.dat", g_sword2->_gameName);
sprintf(filename, "%s-settings.dat", g_sword2->_targetName);
buff[0] = g_sound->getMusicVolume();
buff[1] = g_sound->getSpeechVolume();
@ -1483,7 +1483,7 @@ int32 Gui::readOptionSettings(void) {
SaveFile *fp;
SaveFileManager *mgr = g_system->get_savefile_manager();
sprintf(filename, "%s-settings.dat", g_sword2->_gameName);
sprintf(filename, "%s-settings.dat", g_sword2->_targetName);
if (!(fp = mgr->open_savefile(filename, g_sword2->getSavePath(), false)))
return 1;

View file

@ -241,7 +241,7 @@ uint32 SaveData(uint16 slotNo, uint8 *buffer, uint32 bufferSize) {
SaveFileManager *mgr = g_system->get_savefile_manager();
// construct filename
sprintf(saveFileName, "%s.%.3d", g_sword2->_gameName, slotNo);
sprintf(saveFileName, "%s.%.3d", g_sword2->_targetName, slotNo);
if (!(out = mgr->open_savefile(saveFileName, g_sword2->getSavePath(), true))) {
// error: couldn't open file
@ -304,7 +304,7 @@ uint32 RestoreData(uint16 slotNo, uint8 *buffer, uint32 bufferSize) {
uint32 itemsRead;
// construct filename
sprintf(saveFileName, "%s.%.3d", g_sword2->_gameName, slotNo);
sprintf(saveFileName, "%s.%.3d", g_sword2->_targetName, slotNo);
if (!(in = mgr->open_savefile(saveFileName, g_sword2->getSavePath(), false))) {
// error: couldn't open file
@ -469,7 +469,7 @@ uint32 GetSaveDescription(uint16 slotNo, uint8 *description) {
SaveFileManager *mgr = g_system->get_savefile_manager();
// construct filename
sprintf(saveFileName, "%s.%.3d", g_sword2->_gameName, slotNo);
sprintf(saveFileName, "%s.%.3d", g_sword2->_targetName, slotNo);
if (!(in = mgr->open_savefile(saveFileName, g_sword2->getSavePath(), false))) {
// error: couldn't open file
@ -492,7 +492,7 @@ bool SaveExists(uint16 slotNo) {
SaveFile *in;
// construct filename
sprintf(saveFileName, "%s.%.3d", g_sword2->_gameName, slotNo);
sprintf(saveFileName, "%s.%.3d", g_sword2->_targetName, slotNo);
if (!(in = mgr->open_savefile(saveFileName, g_sword2->getSavePath(), false))) {
delete mgr;

View file

@ -104,7 +104,7 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
g_sword2 = this;
_features = detector->_game.features;
_gameId = detector->_game.id;
_gameName = strdup(detector->_targetName.c_str());
_targetName = strdup(detector->_targetName.c_str());
_bootParam = ConfMan.getInt("boot_param");
_saveSlot = ConfMan.getInt("save_slot");
_debugLevel = ConfMan.getInt("debuglevel");
@ -123,7 +123,7 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
}
Sword2Engine::~Sword2Engine() {
free(_gameName);
free(_targetName);
delete _sound;
}

View file

@ -75,7 +75,7 @@ public:
GameDetector *_detector;
uint32 _features;
byte _gameId;
char *_gameName; // target name for saves
char *_targetName; // target name for saves
Sound *_sound;
Common::RandomSource _rnd;