2004-04-12 21:51:26 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:20:17 +00:00
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
2004-04-12 21:51:26 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2004-03-14 23:39:41 +00:00
|
|
|
|
|
|
|
#include "base/gameDetector.h"
|
|
|
|
#include "base/plugins.h"
|
|
|
|
#include "backends/fs/fs.h"
|
|
|
|
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/config-manager.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
|
|
|
|
|
|
|
#include "sound/mixer.h"
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
#include "saga/rscfile.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/gfx.h"
|
|
|
|
#include "saga/render.h"
|
|
|
|
#include "saga/actor.h"
|
|
|
|
#include "saga/animation.h"
|
2004-08-10 18:31:33 +00:00
|
|
|
#include "saga/console.h"
|
2004-08-10 19:00:30 +00:00
|
|
|
#include "saga/events.h"
|
2004-08-03 00:06:18 +00:00
|
|
|
#include "saga/font.h"
|
2004-08-06 01:39:17 +00:00
|
|
|
#include "saga/interface.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/isomap.h"
|
2005-05-23 02:23:34 +00:00
|
|
|
#include "saga/puzzle.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/script.h"
|
2004-08-04 20:28:57 +00:00
|
|
|
#include "saga/scene.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/sndres.h"
|
2004-08-03 01:07:34 +00:00
|
|
|
#include "saga/sprite.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/sound.h"
|
|
|
|
#include "saga/music.h"
|
2004-08-10 19:20:33 +00:00
|
|
|
#include "saga/palanim.h"
|
2005-01-18 15:01:21 +00:00
|
|
|
#include "saga/objectmap.h"
|
2005-07-19 19:05:52 +00:00
|
|
|
#include "saga/resnames.h"
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2004-11-15 03:03:48 +00:00
|
|
|
static const GameSettings saga_games[] = {
|
|
|
|
{"ite", "Inherit the Earth", 0},
|
|
|
|
{"ite-demo", "Inherit the Earth (Demo)", 0},
|
2004-11-18 22:54:15 +00:00
|
|
|
{"ihnm", "I Have No Mouth and I Must Scream", GF_DEFAULT_TO_1X_SCALER },
|
|
|
|
{"ihnm-demo", "I Have No Mouth and I Must Scream (Demo)", GF_DEFAULT_TO_1X_SCALER },
|
2004-11-15 03:03:48 +00:00
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2004-03-14 23:39:41 +00:00
|
|
|
GameList Engine_SAGA_gameList() {
|
2004-11-15 03:03:48 +00:00
|
|
|
GameList games;
|
|
|
|
const GameSettings *g = saga_games;
|
|
|
|
|
|
|
|
while (g->name) {
|
|
|
|
games.push_back(*g);
|
|
|
|
g++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return games;
|
2004-03-14 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DetectedGameList Engine_SAGA_detectGames(const FSList &fslist) {
|
2004-05-01 23:42:22 +00:00
|
|
|
return Saga::GAME_ProbeGame(fslist);
|
2004-03-14 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Engine *Engine_SAGA_create(GameDetector *detector, OSystem *syst) {
|
2004-03-15 01:59:06 +00:00
|
|
|
return new Saga::SagaEngine(detector, syst);
|
2004-03-14 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
2005-03-25 17:55:57 +00:00
|
|
|
REGISTER_PLUGIN(SAGA, "SAGA Engine")
|
2004-03-14 23:39:41 +00:00
|
|
|
|
|
|
|
namespace Saga {
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define MAX_TIME_DELTA 100
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-03-14 23:39:41 +00:00
|
|
|
SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst)
|
2005-05-23 18:53:36 +00:00
|
|
|
: Engine(syst),
|
|
|
|
_targetName(detector->_targetName) {
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
_leftMouseButtonPressed = _rightMouseButtonPressed = false;
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
_console = NULL;
|
2005-01-11 21:10:36 +00:00
|
|
|
_quit = false;
|
2004-12-03 19:15:44 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_resource = NULL;
|
2005-03-18 17:11:37 +00:00
|
|
|
_sndRes = NULL;
|
|
|
|
_events = NULL;
|
|
|
|
_font = NULL;
|
|
|
|
_sprite = NULL;
|
|
|
|
_anim = NULL;
|
|
|
|
_script = NULL;
|
|
|
|
_interface = NULL;
|
|
|
|
_actor = NULL;
|
|
|
|
_palanim = NULL;
|
|
|
|
_scene = NULL;
|
|
|
|
_isoMap = NULL;
|
|
|
|
_gfx = NULL;
|
|
|
|
_console = NULL;
|
|
|
|
_render = NULL;
|
|
|
|
_music = NULL;
|
|
|
|
_sound = NULL;
|
2005-05-23 02:23:34 +00:00
|
|
|
_puzzle = NULL;
|
2005-03-18 17:11:37 +00:00
|
|
|
|
2005-07-30 14:41:25 +00:00
|
|
|
_frameCount = 0;
|
|
|
|
|
2005-03-18 17:11:37 +00:00
|
|
|
|
2004-10-01 06:45:13 +00:00
|
|
|
// The Linux version of Inherit the Earth puts all data files in an
|
|
|
|
// 'itedata' sub-directory, except for voices.rsc
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "itedata/");
|
2004-10-01 06:45:13 +00:00
|
|
|
|
|
|
|
// The Windows version of Inherit the Earth puts various data files in
|
|
|
|
// other subdirectories.
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "graphics/");
|
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "music/");
|
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "sound/");
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2005-01-02 20:29:27 +00:00
|
|
|
// Mac CD Wyrmkeep
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "patch/");
|
2005-01-02 20:29:27 +00:00
|
|
|
|
2004-03-14 23:39:41 +00:00
|
|
|
// Setup mixer
|
|
|
|
if (!_mixer->isReady()) {
|
|
|
|
warning("Sound initialization failed.");
|
|
|
|
}
|
|
|
|
|
2005-05-10 23:48:48 +00:00
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2005-07-08 16:56:03 +00:00
|
|
|
_displayClip.left = _displayClip.top = 0;
|
2004-03-14 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SagaEngine::~SagaEngine() {
|
2005-07-19 19:05:52 +00:00
|
|
|
if (_scene != NULL) {
|
|
|
|
if (_scene->isSceneLoaded()) {
|
|
|
|
_scene->endScene();
|
|
|
|
}
|
2005-05-18 18:28:10 +00:00
|
|
|
}
|
2005-01-11 21:10:36 +00:00
|
|
|
|
2005-05-23 02:23:34 +00:00
|
|
|
delete _puzzle;
|
2005-04-24 18:26:12 +00:00
|
|
|
delete _sndRes;
|
|
|
|
delete _events;
|
|
|
|
delete _font;
|
|
|
|
delete _sprite;
|
|
|
|
delete _anim;
|
|
|
|
delete _script;
|
|
|
|
delete _interface;
|
|
|
|
delete _actor;
|
|
|
|
delete _palanim;
|
|
|
|
delete _scene;
|
|
|
|
delete _isoMap;
|
|
|
|
delete _render;
|
|
|
|
delete _music;
|
|
|
|
delete _sound;
|
|
|
|
delete _gfx;
|
|
|
|
delete _console;
|
2005-01-11 21:10:36 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
delete _resource;
|
2004-03-14 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SagaEngine::errorString(const char *buf1, char *buf2) {
|
|
|
|
strcpy(buf2, buf1);
|
|
|
|
}
|
|
|
|
|
2004-11-24 00:14:21 +00:00
|
|
|
int SagaEngine::init(GameDetector &detector) {
|
2004-08-04 18:07:57 +00:00
|
|
|
_soundEnabled = 1;
|
|
|
|
_musicEnabled = 1;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_resource = new Resource(this);
|
|
|
|
|
2004-11-15 03:03:48 +00:00
|
|
|
// Add some default directories
|
|
|
|
// Win32 demo & full game
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory("graphics");
|
|
|
|
Common::File::addDefaultDirectory("music");
|
|
|
|
Common::File::addDefaultDirectory("sound");
|
2004-11-15 03:03:48 +00:00
|
|
|
|
|
|
|
// Linux demo
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory("itedata");
|
2004-11-15 03:03:48 +00:00
|
|
|
|
|
|
|
// Mac demos & full game
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory("patch");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// Process command line
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// Detect game and open resource files
|
2005-07-19 19:05:52 +00:00
|
|
|
if (!initGame()) {
|
2005-03-18 17:11:37 +00:00
|
|
|
return FAILURE;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// Initialize engine modules
|
2004-04-28 23:54:40 +00:00
|
|
|
_sndRes = new SndRes(this);
|
2004-08-10 19:00:30 +00:00
|
|
|
_events = new Events(this);
|
2004-08-03 00:06:18 +00:00
|
|
|
_font = new Font(this);
|
2004-08-03 01:07:34 +00:00
|
|
|
_sprite = new Sprite(this);
|
2004-08-01 13:34:20 +00:00
|
|
|
_anim = new Anim(this);
|
2005-01-28 19:25:41 +00:00
|
|
|
_script = new Script(this);
|
2004-08-06 01:39:17 +00:00
|
|
|
_interface = new Interface(this); // requires script module
|
2004-08-02 15:47:42 +00:00
|
|
|
_actor = new Actor(this);
|
2004-08-10 19:20:33 +00:00
|
|
|
_palanim = new PalAnim(this);
|
2004-08-04 20:28:57 +00:00
|
|
|
_scene = new Scene(this);
|
2005-01-28 19:25:41 +00:00
|
|
|
_isoMap = new IsoMap(this);
|
2005-05-23 02:23:34 +00:00
|
|
|
_puzzle = new Puzzle(this);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// System initialization
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
_previousTicks = _system->getMillis();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-21 22:40:06 +00:00
|
|
|
// Initialize graphics
|
2005-07-19 19:05:52 +00:00
|
|
|
_gfx = new Gfx(this, _system, getDisplayWidth(), getDisplayHeight(), detector);
|
2004-10-21 22:40:06 +00:00
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
// Graphics driver should be initialized before console
|
|
|
|
_console = new Console(this);
|
|
|
|
|
2004-10-21 22:40:06 +00:00
|
|
|
// Graphics should be initialized before music
|
2004-12-02 00:33:42 +00:00
|
|
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_NATIVE | MDT_ADLIB | MDT_PREFER_NATIVE);
|
2004-10-21 22:40:06 +00:00
|
|
|
bool native_mt32 = (ConfMan.getBool("native_mt32") || (midiDriver == MD_MT32));
|
|
|
|
|
2004-11-20 17:19:15 +00:00
|
|
|
bool adlib = false;
|
|
|
|
|
2004-12-02 00:33:42 +00:00
|
|
|
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
|
2004-11-20 17:19:15 +00:00
|
|
|
if (!driver) {
|
2004-04-29 03:52:59 +00:00
|
|
|
driver = MidiDriver_ADLIB_create(_mixer);
|
2004-11-20 17:19:15 +00:00
|
|
|
adlib = true;
|
|
|
|
} else if (native_mt32)
|
2004-04-29 03:52:59 +00:00
|
|
|
driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_music = new Music(this, _mixer, driver, _musicEnabled);
|
2004-11-19 07:41:59 +00:00
|
|
|
_music->setNativeMT32(native_mt32);
|
2004-11-20 17:19:15 +00:00
|
|
|
_music->setAdlib(adlib);
|
2004-10-21 22:40:06 +00:00
|
|
|
|
2004-08-04 18:07:57 +00:00
|
|
|
if (!_musicEnabled) {
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(1, "Music disabled.");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2004-10-07 23:02:19 +00:00
|
|
|
_render = new Render(this, _system);
|
2004-07-31 23:00:48 +00:00
|
|
|
if (!_render->initialized()) {
|
2005-03-18 17:11:37 +00:00
|
|
|
return FAILURE;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// Initialize system specific sound
|
2004-08-04 18:07:57 +00:00
|
|
|
_sound = new Sound(this, _mixer, _soundEnabled);
|
|
|
|
if (!_soundEnabled) {
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(1, "Sound disabled.");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-18 10:45:36 +00:00
|
|
|
_interface->converseInit();
|
2005-01-19 00:02:25 +00:00
|
|
|
_script->setVerb(kVerbWalkTo);
|
2005-01-17 20:17:06 +00:00
|
|
|
|
2005-06-19 21:18:00 +00:00
|
|
|
_music->setVolume(-1, 1);
|
|
|
|
|
2005-03-18 17:11:37 +00:00
|
|
|
return SUCCESS;
|
2004-11-23 00:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int SagaEngine::go() {
|
|
|
|
int msec = 0;
|
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
_previousTicks = _system->getMillis();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
if (ConfMan.hasKey("start_scene")) {
|
2005-07-08 16:56:03 +00:00
|
|
|
_scene->changeScene(ConfMan.getInt("start_scene"), 0, kTransitionNoFade);
|
2005-08-04 10:48:54 +00:00
|
|
|
} else if (ConfMan.hasKey("boot_param")) {
|
|
|
|
if (getGameType() == GType_ITE)
|
2005-08-05 23:14:11 +00:00
|
|
|
_interface->addToInventory(_actor->objIndexToId(ITE_OBJ_MAGIC_HAT));
|
2005-08-04 10:48:54 +00:00
|
|
|
_scene->changeScene(ConfMan.getInt("boot_param"), 0, kTransitionNoFade);
|
|
|
|
} else if (ConfMan.hasKey("save_slot")) {
|
2005-06-02 22:14:57 +00:00
|
|
|
// First scene sets up palette
|
|
|
|
_scene->changeScene(getStartSceneNumber(), 0, kTransitionNoFade);
|
|
|
|
_events->handleEvents(0); // Process immediate events
|
|
|
|
|
|
|
|
char *fileName;
|
|
|
|
fileName = calcSaveFileName(ConfMan.getInt("save_slot"));
|
|
|
|
load(fileName);
|
|
|
|
_interface->setMode(kPanelMain);
|
|
|
|
} else {
|
|
|
|
_scene->startScene();
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 12:41:40 +00:00
|
|
|
uint32 currentTicks;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 21:49:52 +00:00
|
|
|
while (!_quit) {
|
2004-12-03 19:15:44 +00:00
|
|
|
if (_console->isAttached())
|
|
|
|
_console->onFrame();
|
|
|
|
|
2004-07-31 23:00:48 +00:00
|
|
|
if (_render->getFlags() & RF_RENDERPAUSE) {
|
2004-05-01 13:19:15 +00:00
|
|
|
// Freeze time while paused
|
2004-09-28 20:19:37 +00:00
|
|
|
_previousTicks = _system->getMillis();
|
2004-04-12 21:40:49 +00:00
|
|
|
} else {
|
2004-09-28 20:19:37 +00:00
|
|
|
currentTicks = _system->getMillis();
|
2004-08-02 12:41:40 +00:00
|
|
|
// Timer has rolled over after 49 days
|
|
|
|
if (currentTicks < _previousTicks)
|
|
|
|
msec = 0;
|
|
|
|
else {
|
|
|
|
msec = currentTicks - _previousTicks;
|
|
|
|
_previousTicks = currentTicks;
|
|
|
|
}
|
2004-10-27 21:32:28 +00:00
|
|
|
if (msec > MAX_TIME_DELTA) {
|
|
|
|
msec = MAX_TIME_DELTA;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-01-07 15:49:47 +00:00
|
|
|
|
2005-05-23 02:23:34 +00:00
|
|
|
// Since Puzzle is actorless, we do it here
|
2005-05-31 01:03:13 +00:00
|
|
|
if (_puzzle->isActive()) {
|
2005-05-23 02:23:34 +00:00
|
|
|
_actor->handleSpeech(msec);
|
2005-05-31 01:03:13 +00:00
|
|
|
} else if (!_scene->isInDemo() && getGameType() == GType_ITE) {
|
2005-05-23 02:23:34 +00:00
|
|
|
if (_interface->getMode() == kPanelMain ||
|
|
|
|
_interface->getMode() == kPanelConverse ||
|
|
|
|
_interface->getMode() == kPanelNull)
|
2005-01-06 15:29:17 +00:00
|
|
|
_actor->direct(msec);
|
2005-05-31 01:03:13 +00:00
|
|
|
}
|
2005-01-06 14:02:53 +00:00
|
|
|
|
2004-08-12 23:57:45 +00:00
|
|
|
_events->handleEvents(msec);
|
2004-12-21 06:49:07 +00:00
|
|
|
_script->executeThreads(msec);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2004-05-01 13:19:15 +00:00
|
|
|
// Per frame processing
|
2004-07-31 23:00:48 +00:00
|
|
|
_render->drawScene();
|
2004-09-28 20:19:37 +00:00
|
|
|
_system->delayMillis(10);
|
2004-05-01 13:19:15 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-01-11 21:10:36 +00:00
|
|
|
return 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-08 21:06:06 +00:00
|
|
|
void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) {
|
2005-01-08 20:30:07 +00:00
|
|
|
uint16 stringsCount;
|
|
|
|
size_t offset;
|
2005-01-18 15:01:21 +00:00
|
|
|
int i;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
if (stringsLength == 0) {
|
|
|
|
error("SagaEngine::loadStrings() Error loading strings list resource");
|
|
|
|
}
|
|
|
|
|
2005-01-08 21:06:06 +00:00
|
|
|
stringsTable.stringsPointer = (byte*)malloc(stringsLength);
|
|
|
|
memcpy(stringsTable.stringsPointer, stringsPointer, stringsLength);
|
2005-01-08 20:30:07 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
MemoryReadStreamEndian scriptS(stringsTable.stringsPointer, stringsLength, isBigEndian()); //TODO: get endianess from context
|
2005-01-08 20:30:07 +00:00
|
|
|
|
|
|
|
offset = scriptS.readUint16();
|
2005-01-18 15:01:21 +00:00
|
|
|
stringsCount = offset / 2;
|
|
|
|
stringsTable.strings = (const char **)malloc(stringsCount * sizeof(*stringsTable.strings));
|
2005-07-29 17:58:00 +00:00
|
|
|
i = 0;
|
2005-01-08 20:30:07 +00:00
|
|
|
scriptS.seek(0);
|
2005-01-18 15:01:21 +00:00
|
|
|
while (i < stringsCount) {
|
2005-01-08 20:30:07 +00:00
|
|
|
offset = scriptS.readUint16();
|
2005-01-18 15:01:21 +00:00
|
|
|
if (offset == stringsLength) {
|
|
|
|
stringsCount = i;
|
|
|
|
stringsTable.strings = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));
|
|
|
|
break;
|
|
|
|
}
|
2005-01-08 20:30:07 +00:00
|
|
|
if (offset > stringsLength) {
|
2005-01-18 15:01:21 +00:00
|
|
|
error("SagaEngine::loadStrings wrong strings table");
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
2005-01-08 21:06:06 +00:00
|
|
|
stringsTable.strings[i] = (const char *)stringsTable.stringsPointer + offset;
|
2005-04-22 14:11:04 +00:00
|
|
|
debug(9, "string[%i]=%s", i, stringsTable.strings[i]);
|
2005-01-18 15:01:21 +00:00
|
|
|
i++;
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
2005-01-18 15:01:21 +00:00
|
|
|
stringsTable.stringsCount = stringsCount;
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *SagaEngine::getObjectName(uint16 objectId) {
|
2005-01-18 21:13:44 +00:00
|
|
|
ActorData *actor;
|
|
|
|
ObjectData *obj;
|
2005-01-18 15:01:21 +00:00
|
|
|
const HitZone *hitZone;
|
|
|
|
switch (objectTypeId(objectId)) {
|
2005-03-07 11:49:59 +00:00
|
|
|
case kGameObjectObject:
|
|
|
|
obj = _actor->getObj(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
return _script->_mainStrings.getString(obj->_nameIndex);
|
2005-03-07 11:49:59 +00:00
|
|
|
break;
|
2005-07-29 17:58:00 +00:00
|
|
|
case kGameObjectActor:
|
|
|
|
actor = _actor->getActor(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
return _actor->_actorsStrings.getString(actor->_nameIndex);
|
2005-03-07 11:49:59 +00:00
|
|
|
break;
|
|
|
|
case kGameObjectHitZone:
|
2005-05-23 02:23:34 +00:00
|
|
|
hitZone = _scene->_objectMap->getHitZone(objectIdToIndex(objectId));
|
|
|
|
return _scene->_sceneStrings.getString(hitZone->getNameIndex());
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
2005-01-18 21:13:44 +00:00
|
|
|
warning("SagaEngine::getObjectName name not found for 0x%X", objectId);
|
2005-01-08 20:30:07 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
const char *SagaEngine::getTextString(int textStringId) {
|
2005-01-14 11:22:45 +00:00
|
|
|
const char *string;
|
2005-05-23 02:23:34 +00:00
|
|
|
int lang = getFeatures() & GF_LANG_DE ? 1 : 0;
|
2005-01-14 01:17:34 +00:00
|
|
|
|
2005-08-08 08:15:16 +00:00
|
|
|
string = ITEinterfaceTextStrings[lang][textStringId];
|
2005-01-14 11:22:45 +00:00
|
|
|
if (!string)
|
2005-08-08 08:15:16 +00:00
|
|
|
string = ITEinterfaceTextStrings[0][textStringId];
|
2005-01-14 11:22:45 +00:00
|
|
|
|
|
|
|
return string;
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
void SagaEngine::getExcuseInfo(int verb, const char *&textString, int &soundResourceId) {
|
|
|
|
textString = NULL; // TODO: i18n it !
|
|
|
|
switch (verb) {
|
2005-03-07 11:49:59 +00:00
|
|
|
case kVerbPickUp:
|
|
|
|
textString = "I can't pick that up.";
|
|
|
|
soundResourceId = RID_BOAR_VOICE_007;
|
|
|
|
break;
|
2005-07-29 17:58:00 +00:00
|
|
|
case kVerbLookAt:
|
|
|
|
textString = "I see nothing special about it.";
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_006;
|
|
|
|
break;
|
2005-07-29 17:58:00 +00:00
|
|
|
case kVerbOpen:
|
2005-03-07 11:49:59 +00:00
|
|
|
textString = "There's no place to open it.";
|
|
|
|
soundResourceId = RID_BOAR_VOICE_000;
|
|
|
|
break;
|
2005-07-29 17:58:00 +00:00
|
|
|
case kVerbClose:
|
|
|
|
textString = "There's no opening to close.";
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_002;
|
|
|
|
break;
|
2005-07-29 17:58:00 +00:00
|
|
|
case kVerbUse:
|
|
|
|
textString = "I don't know how to do that.";
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_005;
|
|
|
|
break;
|
2005-01-15 20:12:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-22 21:25:29 +00:00
|
|
|
} // End of namespace Saga
|