From 71a97abfc235656647235ccd76687d2fd0b2333d Mon Sep 17 00:00:00 2001 From: Vincent Hamm Date: Wed, 27 Feb 2002 22:48:55 +0000 Subject: [PATCH] Added an option to specify the game data path svn-id: r3636 --- resource.cpp | 8 ++++---- scumm.h | 1 + scummvm.cpp | 12 +++++++++++- sound.cpp | 8 +++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/resource.cpp b/resource.cpp index 8cf84106ac0..f0c1329a3fc 100644 --- a/resource.cpp +++ b/resource.cpp @@ -64,9 +64,9 @@ void Scumm::openRoom(int room) { } if (!(_features & GF_SMALL_HEADER)) { if(_features & GF_AFTER_V7) - sprintf(buf, "%s.la%d", _exe_name, room==0 ? 0 : res.roomno[rtRoom][room]); + sprintf(buf, "%s%s.la%d", _gameDataPath, _exe_name, room==0 ? 0 : res.roomno[rtRoom][room]); else - sprintf(buf, "%s.%.3d", _exe_name, room==0 ? 0 : res.roomno[rtRoom][room]); + sprintf(buf, "%s%s.%.3d", _gameDataPath, _exe_name, room==0 ? 0 : res.roomno[rtRoom][room]); _encbyte = (_features & GF_USE_KEY) ? 0x69 : 0; } else if(!(_features & GF_SMALL_NAMES)) { if(room==0 || room>=900) { @@ -78,11 +78,11 @@ void Scumm::openRoom(int room) { askForDisk(buf); } else { - sprintf(buf, "%s//disk%.2d.lec",_exe_name,res.roomno[rtRoom][room]); + sprintf(buf, "%sdisk%.2d.lec",_gameDataPath,res.roomno[rtRoom][room]); _encbyte = 0x69; } } else { - sprintf(buf, "%s//%.2d.lfl",_exe_name,room); + sprintf(buf, "%s%.2d.lfl",_gameDataPath,room); if(_features & GF_OLD_BUNDLE) _encbyte = 0xFF; else diff --git a/scumm.h b/scumm.h index 9a14a1bbd05..16da3fae426 100644 --- a/scumm.h +++ b/scumm.h @@ -806,6 +806,7 @@ struct Scumm { void *_fileHandle; void *_sfxFile; char *_exe_name; + char *_gameDataPath; byte _saveLoadFlag; byte _saveLoadSlot; diff --git a/scummvm.cpp b/scummvm.cpp index e6b23a1b202..e99a2992a79 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -22,6 +22,7 @@ #include "stdafx.h" #include "scumm.h" #include "gui.h" +#include "string.h" void Scumm::initRandSeeds() { _randSeed1 = 0xA943DE35; @@ -192,6 +193,8 @@ void Scumm::scummMain(int argc, char **argv) { _maxHeapThreshold = 450000; _minHeapThreshold = 400000; + + _gameDataPath = NULL; parseCommandLine(argc, argv); @@ -203,6 +206,10 @@ void Scumm::scummMain(int argc, char **argv) { _features = GF_DEFAULT; } + if (!_gameDataPath) { + warning("No path was provided. Assuming that data file are in the current directory"); + } + if(_features & GF_AFTER_V7) setupScummVarsNew(); else @@ -401,12 +408,15 @@ void Scumm::parseCommandLine(int argc, char **argv) { case 'v': printf("ScummVM " SCUMMVM_VERSION "\nBuilt on " __DATE__ " " __TIME__ "\n"); exit(1); + case 'p': + _gameDataPath = argv[++i]; + break; default: ShowHelpAndExit:; printf( "ScummVM - Scumm Interpreter\n" "Syntax:\n" - "\tscummvm [-b] game\n" + "\tscummvm [-b] [-p path] game\n" "Flags:\n" "\tb - start in that room\n" "\tf - fullscreen mode\n"); diff --git a/sound.cpp b/sound.cpp index 0cd740b82b4..e9afac77a7f 100644 --- a/sound.cpp +++ b/sound.cpp @@ -376,10 +376,12 @@ void *Scumm::openSfxFile() { * That way, you can keep .sou files for multiple games in the * same directory */ - sprintf(buf, "%s.sou", _exe_name); + sprintf(buf, "%s%s.sou", _gameDataPath, _exe_name); file = fopen(buf, "rb"); - if (!file) - file = fopen("monster.sou", "rb"); + if (!file) { + sprintf(buf, "%smonster.sou", _gameDataPath, _exe_name); + file = fopen(buf, "rb"); + } return file; }