2007-07-29 14:24:31 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
#include "common/system.h"
|
2007-09-19 08:40:12 +00:00
|
|
|
#include "common/util.h"
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
#include "parallaction/parallaction.h"
|
2009-02-26 06:16:35 +00:00
|
|
|
#include "parallaction/exec.h"
|
2008-05-14 14:34:01 +00:00
|
|
|
#include "parallaction/input.h"
|
2009-03-23 17:42:08 +00:00
|
|
|
#include "parallaction/parser.h"
|
2008-08-31 06:14:45 +00:00
|
|
|
#include "parallaction/saveload.h"
|
2007-07-29 14:24:31 +00:00
|
|
|
#include "parallaction/sound.h"
|
2009-02-24 08:42:46 +00:00
|
|
|
#include "parallaction/walk.h"
|
2007-07-29 14:24:31 +00:00
|
|
|
|
|
|
|
namespace Parallaction {
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
|
2008-02-02 12:36:06 +00:00
|
|
|
const char *Parallaction_br::_partNames[] = {
|
2007-08-12 13:27:48 +00:00
|
|
|
"PART0",
|
|
|
|
"PART1",
|
|
|
|
"PART2",
|
|
|
|
"PART3",
|
|
|
|
"PART4"
|
|
|
|
};
|
|
|
|
|
2009-02-25 09:15:53 +00:00
|
|
|
Parallaction_br::Parallaction_br(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction(syst, gameDesc),
|
2009-03-14 17:02:28 +00:00
|
|
|
_locationParser(0), _programParser(0), _soundManI(0) {
|
2008-12-07 12:41:50 +00:00
|
|
|
}
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error Parallaction_br::init() {
|
2007-07-29 14:24:31 +00:00
|
|
|
|
|
|
|
_screenWidth = 640;
|
|
|
|
_screenHeight = 400;
|
|
|
|
|
2009-02-25 09:15:53 +00:00
|
|
|
if (getPlatform() == Common::kPlatformPC) {
|
|
|
|
if (getFeatures() & GF_DEMO) {
|
|
|
|
_disk = new DosDemoDisk_br(this);
|
2008-04-06 07:05:56 +00:00
|
|
|
} else {
|
2009-02-25 09:15:53 +00:00
|
|
|
_disk = new DosDisk_br(this);
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
2009-02-25 09:15:53 +00:00
|
|
|
_disk->setLanguage(2); // NOTE: language is now hardcoded to English. Original used command-line parameters.
|
2009-03-14 17:02:28 +00:00
|
|
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
|
|
|
|
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
|
|
|
|
_soundManI = new DosSoundMan_br(this, driver);
|
2008-04-06 07:05:56 +00:00
|
|
|
} else {
|
2009-02-25 09:15:53 +00:00
|
|
|
_disk = new AmigaDisk_br(this);
|
|
|
|
_disk->setLanguage(2); // NOTE: language is now hardcoded to English. Original used command-line parameters.
|
2009-03-15 06:07:57 +00:00
|
|
|
_soundManI = new AmigaSoundMan_br(this);
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
2007-07-29 14:24:31 +00:00
|
|
|
|
2009-02-25 09:15:53 +00:00
|
|
|
_disk->init();
|
2009-03-14 15:09:31 +00:00
|
|
|
_soundMan = new SoundMan(_soundManI);
|
2007-07-29 14:24:31 +00:00
|
|
|
|
2007-07-29 16:29:41 +00:00
|
|
|
initResources();
|
2007-08-11 17:25:57 +00:00
|
|
|
initFonts();
|
2008-05-10 11:11:03 +00:00
|
|
|
_locationParser = new LocationParser_br(this);
|
2008-06-03 00:49:27 +00:00
|
|
|
_locationParser->init();
|
2008-05-10 11:11:03 +00:00
|
|
|
_programParser = new ProgramParser_br(this);
|
2008-06-03 00:49:27 +00:00
|
|
|
_programParser->init();
|
2007-08-26 09:01:19 +00:00
|
|
|
|
2008-07-11 13:06:28 +00:00
|
|
|
_cmdExec = new CommandExec_br(this);
|
|
|
|
_programExec = new ProgramExec_br(this);
|
|
|
|
|
2009-02-24 08:42:46 +00:00
|
|
|
_walker = new PathWalker_BR;
|
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
_part = -1;
|
|
|
|
|
2008-07-04 00:29:21 +00:00
|
|
|
_subtitle[0] = -1;
|
|
|
|
_subtitle[1] = -1;
|
|
|
|
|
2009-03-02 08:36:42 +00:00
|
|
|
memset(_zoneFlags, 0, sizeof(_zoneFlags));
|
|
|
|
|
2008-11-16 13:06:40 +00:00
|
|
|
_countersNames = 0;
|
|
|
|
|
2008-08-31 06:14:45 +00:00
|
|
|
_saveLoad = new SaveLoad_br(this, _saveFileMan);
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
Parallaction::init();
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2007-07-29 14:24:31 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
Parallaction_br::~Parallaction_br() {
|
|
|
|
freeFonts();
|
2008-12-21 15:42:47 +00:00
|
|
|
freeCharacter();
|
2008-12-14 10:08:31 +00:00
|
|
|
|
2009-02-26 09:12:29 +00:00
|
|
|
delete _objects;
|
|
|
|
|
2008-12-07 12:41:50 +00:00
|
|
|
delete _locationParser;
|
|
|
|
delete _programParser;
|
2009-02-24 08:42:46 +00:00
|
|
|
|
2009-02-26 09:12:29 +00:00
|
|
|
_location._animations.remove(_char._ani);
|
|
|
|
|
2009-02-24 08:42:46 +00:00
|
|
|
delete _walker;
|
2007-08-11 17:25:57 +00:00
|
|
|
}
|
|
|
|
|
2007-07-29 18:49:24 +00:00
|
|
|
void Parallaction_br::callFunction(uint index, void* parm) {
|
|
|
|
assert(index < 6); // magic value 6 is maximum # of callables for Big Red Adventure
|
|
|
|
|
|
|
|
(this->*_callables[index])(parm);
|
|
|
|
}
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error Parallaction_br::go() {
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2008-08-20 04:02:12 +00:00
|
|
|
bool splash = true;
|
2008-02-05 10:24:22 +00:00
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
while (!shouldQuit()) {
|
2007-08-12 13:10:04 +00:00
|
|
|
|
2008-08-20 04:02:12 +00:00
|
|
|
if (getFeatures() & GF_DEMO) {
|
2008-08-31 05:18:25 +00:00
|
|
|
scheduleLocationSwitch("camalb.1");
|
2008-08-20 04:02:12 +00:00
|
|
|
_input->_inputMode = Input::kInputModeGame;
|
|
|
|
} else {
|
|
|
|
startGui(splash);
|
|
|
|
// don't show splash after first time
|
|
|
|
splash = false;
|
|
|
|
}
|
|
|
|
|
2008-02-02 12:36:06 +00:00
|
|
|
// initCharacter();
|
2007-08-12 13:10:04 +00:00
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
while (((_engineFlags & kEngineReturn) == 0) && (!shouldQuit())) {
|
2008-02-05 10:24:22 +00:00
|
|
|
runGame();
|
|
|
|
}
|
|
|
|
_engineFlags &= ~kEngineReturn;
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2008-08-31 09:30:16 +00:00
|
|
|
cleanupGame();
|
2007-08-12 13:10:04 +00:00
|
|
|
}
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2007-08-09 19:26:20 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
void Parallaction_br::freeFonts() {
|
|
|
|
delete _menuFont;
|
2008-10-11 02:23:13 +00:00
|
|
|
_menuFont = 0;
|
2009-02-26 09:12:29 +00:00
|
|
|
|
|
|
|
delete _dialogueFont;
|
2008-10-11 02:23:13 +00:00
|
|
|
_dialogueFont = 0;
|
2009-02-26 09:12:29 +00:00
|
|
|
|
|
|
|
// no need to delete _labelFont, since it is using the same buffer as _menuFont
|
2008-10-11 02:23:13 +00:00
|
|
|
_labelFont = 0;
|
2007-08-11 20:44:22 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 21:08:08 +00:00
|
|
|
|
2008-02-02 22:45:31 +00:00
|
|
|
void Parallaction_br::runPendingZones() {
|
2008-04-06 05:40:02 +00:00
|
|
|
ZonePtr z;
|
2008-02-02 22:45:31 +00:00
|
|
|
|
2008-07-29 12:59:55 +00:00
|
|
|
_cmdExec->runSuspended();
|
|
|
|
|
2008-02-02 22:45:31 +00:00
|
|
|
if (_activeZone) {
|
|
|
|
z = _activeZone; // speak Zone or sound
|
2009-02-26 10:44:01 +00:00
|
|
|
_activeZone.reset();
|
2009-02-23 12:17:25 +00:00
|
|
|
if (ACTIONTYPE(z) == kZoneSpeak) {
|
2008-07-21 06:08:30 +00:00
|
|
|
enterDialogueMode(z);
|
|
|
|
} else {
|
|
|
|
runZone(z); // FIXME: BRA doesn't handle sound yet
|
|
|
|
}
|
2008-02-02 22:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_activeZone2) {
|
|
|
|
z = _activeZone2; // speak Zone or sound
|
2009-02-26 10:44:01 +00:00
|
|
|
_activeZone2.reset();
|
2009-02-23 12:17:25 +00:00
|
|
|
if (ACTIONTYPE(z) == kZoneSpeak) {
|
2008-07-21 06:08:30 +00:00
|
|
|
enterDialogueMode(z);
|
|
|
|
} else {
|
|
|
|
runZone(z); // FIXME: BRA doesn't handle sound yet
|
|
|
|
}
|
2008-02-02 22:45:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-21 15:42:47 +00:00
|
|
|
void Parallaction_br::freeCharacter() {
|
|
|
|
_gfx->freeCharacterObjects();
|
|
|
|
|
|
|
|
delete _char._talk;
|
|
|
|
delete _char._ani->gfxobj;
|
|
|
|
|
|
|
|
_char._talk = 0;
|
|
|
|
_char._ani->gfxobj = 0;
|
|
|
|
}
|
|
|
|
|
2008-11-08 14:56:45 +00:00
|
|
|
void Parallaction_br::freeLocation(bool removeAll) {
|
2008-02-02 22:45:31 +00:00
|
|
|
// free open location stuff
|
|
|
|
clearSubtitles();
|
2008-07-28 14:23:49 +00:00
|
|
|
_subtitle[0] = _subtitle[1] = -1;
|
|
|
|
|
2009-03-02 06:14:25 +00:00
|
|
|
_localFlagNames->clear();
|
|
|
|
|
2008-12-21 15:42:47 +00:00
|
|
|
_gfx->freeLocationObjects();
|
|
|
|
|
2009-03-28 14:03:51 +00:00
|
|
|
// save zone and animation flags
|
|
|
|
ZoneList::iterator zit = _location._zones.begin();
|
|
|
|
for ( ; zit != _location._zones.end(); ++zit) {
|
|
|
|
restoreOrSaveZoneFlags(*zit, false);
|
|
|
|
}
|
|
|
|
AnimationList::iterator ait = _location._animations.begin();
|
|
|
|
for ( ; ait != _location._animations.end(); ++ait) {
|
|
|
|
restoreOrSaveZoneFlags(*ait, false);
|
|
|
|
}
|
|
|
|
|
2008-07-11 13:06:28 +00:00
|
|
|
_location._animations.remove(_char._ani);
|
2008-11-08 14:56:45 +00:00
|
|
|
_location.cleanup(removeAll);
|
2008-07-11 13:06:28 +00:00
|
|
|
_location._animations.push_front(_char._ani);
|
|
|
|
|
2008-08-21 12:11:24 +00:00
|
|
|
}
|
|
|
|
|
2008-08-31 09:30:16 +00:00
|
|
|
void Parallaction_br::cleanupGame() {
|
2008-11-08 14:56:45 +00:00
|
|
|
freeLocation(true);
|
2008-08-31 09:30:16 +00:00
|
|
|
|
2008-12-21 15:42:47 +00:00
|
|
|
freeCharacter();
|
2008-08-31 09:30:16 +00:00
|
|
|
|
|
|
|
delete _globalFlagsNames;
|
|
|
|
delete _objectsNames;
|
|
|
|
delete _countersNames;
|
|
|
|
|
|
|
|
_globalFlagsNames = 0;
|
|
|
|
_objectsNames = 0;
|
|
|
|
_countersNames = 0;
|
|
|
|
}
|
2008-08-21 12:11:24 +00:00
|
|
|
|
|
|
|
|
2009-02-26 14:42:03 +00:00
|
|
|
void Parallaction_br::changeLocation() {
|
|
|
|
if (_newLocationName.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char location[200];
|
|
|
|
strcpy(location, _newLocationName.c_str());
|
|
|
|
|
2008-08-31 05:18:25 +00:00
|
|
|
char *partStr = strrchr(location, '.');
|
|
|
|
if (partStr) {
|
2008-11-09 03:53:06 +00:00
|
|
|
cleanupGame();
|
|
|
|
|
2008-08-31 05:18:25 +00:00
|
|
|
int n = partStr - location;
|
2009-02-26 14:42:03 +00:00
|
|
|
location[n] = '\0';
|
2008-08-31 05:18:25 +00:00
|
|
|
|
|
|
|
_part = atoi(++partStr);
|
|
|
|
if (getFeatures() & GF_DEMO) {
|
|
|
|
assert(_part == 1);
|
|
|
|
} else {
|
|
|
|
assert(_part >= 0 && _part <= 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
_disk->selectArchive(_partNames[_part]);
|
2008-08-31 09:30:16 +00:00
|
|
|
|
|
|
|
memset(_counters, 0, ARRAYSIZE(_counters));
|
|
|
|
|
|
|
|
_globalFlagsNames = _disk->loadTable("global");
|
|
|
|
_objectsNames = _disk->loadTable("objects");
|
|
|
|
_countersNames = _disk->loadTable("counters");
|
|
|
|
|
|
|
|
// TODO: maybe handle this into Disk
|
|
|
|
if (getPlatform() == Common::kPlatformPC) {
|
2008-12-21 15:42:47 +00:00
|
|
|
_objects = _disk->loadObjects("icone.ico");
|
2008-08-31 09:30:16 +00:00
|
|
|
} else {
|
2009-03-15 09:29:25 +00:00
|
|
|
_objects = _disk->loadObjects("icons.ico", _part);
|
2008-08-31 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
parseLocation("common.slf");
|
2008-08-31 05:18:25 +00:00
|
|
|
}
|
|
|
|
|
2008-11-08 14:56:45 +00:00
|
|
|
freeLocation(false);
|
2008-02-02 22:45:31 +00:00
|
|
|
// load new location
|
2009-02-26 14:42:03 +00:00
|
|
|
strcpy(_location._name, location);
|
2008-02-02 22:45:31 +00:00
|
|
|
parseLocation(location);
|
2009-01-20 11:07:27 +00:00
|
|
|
|
|
|
|
if (_location._startPosition.x != -1000) {
|
2009-02-24 11:20:45 +00:00
|
|
|
_char._ani->setFoot(_location._startPosition);
|
2009-01-20 11:07:27 +00:00
|
|
|
_char._ani->setF(_location._startFrame);
|
|
|
|
}
|
|
|
|
|
2009-02-24 11:20:45 +00:00
|
|
|
// re-link the follower animation
|
|
|
|
setFollower(_followerName);
|
|
|
|
if (_follower) {
|
|
|
|
Common::Point p = _location._followerStartPosition;
|
|
|
|
if (p.x == -1000) {
|
|
|
|
_char._ani->getFoot(p);
|
|
|
|
}
|
|
|
|
_follower->setFoot(p);
|
|
|
|
_follower->setF(_location._followerStartFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
_location._startPosition.x = -1000;
|
|
|
|
_location._startPosition.y = -1000;
|
|
|
|
_location._followerStartPosition.x = -1000;
|
|
|
|
_location._followerStartPosition.y = -1000;
|
|
|
|
|
2009-03-23 00:56:05 +00:00
|
|
|
_gfx->setScrollPosX(0);
|
|
|
|
_gfx->setScrollPosY(0);
|
|
|
|
if (_char._ani->gfxobj) {
|
|
|
|
Common::Point foot;
|
|
|
|
_char._ani->getFoot(foot);
|
|
|
|
|
|
|
|
if (foot.x > 550)
|
|
|
|
_gfx->setScrollPosX(320);
|
|
|
|
|
|
|
|
if (foot.y > 350)
|
|
|
|
_gfx->setScrollPosY(foot.y - 350);
|
|
|
|
}
|
|
|
|
|
2008-08-21 12:11:24 +00:00
|
|
|
// kFlagsRemove is cleared because the character is visible by default.
|
|
|
|
// Commands can hide the character, anyway.
|
2008-07-25 08:27:44 +00:00
|
|
|
_char._ani->_flags &= ~kFlagsRemove;
|
2008-07-11 13:06:28 +00:00
|
|
|
_cmdExec->run(_location._commands);
|
2008-08-21 12:11:24 +00:00
|
|
|
|
|
|
|
doLocationEnterTransition();
|
|
|
|
|
2008-07-11 13:06:28 +00:00
|
|
|
_cmdExec->run(_location._aCommands);
|
2009-03-23 00:56:05 +00:00
|
|
|
|
|
|
|
// NOTE: music should not started here!
|
2009-03-14 17:02:28 +00:00
|
|
|
// TODO: implement the music commands which control music execution
|
|
|
|
_soundMan->execute(SC_PLAYMUSIC);
|
2008-02-02 21:22:05 +00:00
|
|
|
|
2008-02-02 22:45:31 +00:00
|
|
|
_engineFlags &= ~kEngineChangeLocation;
|
2009-02-26 14:42:03 +00:00
|
|
|
_newLocationName.clear();
|
2007-08-25 20:34:10 +00:00
|
|
|
}
|
|
|
|
|
2008-05-09 01:35:43 +00:00
|
|
|
// FIXME: Parallaction_br::parseLocation() is now a verbatim copy of the same routine from Parallaction_ns.
|
|
|
|
void Parallaction_br::parseLocation(const char *filename) {
|
|
|
|
debugC(1, kDebugParser, "parseLocation('%s')", filename);
|
|
|
|
|
|
|
|
allocateLocationSlot(filename);
|
|
|
|
Script *script = _disk->loadLocation(filename);
|
|
|
|
|
|
|
|
_locationParser->parse(script);
|
|
|
|
delete script;
|
|
|
|
|
|
|
|
// this loads animation scripts
|
2008-12-14 10:32:26 +00:00
|
|
|
AnimationList::iterator it = _location._animations.begin();
|
2009-02-25 08:53:58 +00:00
|
|
|
for ( ; it != _location._animations.end(); ++it) {
|
2008-05-09 01:35:43 +00:00
|
|
|
if ((*it)->_scriptName) {
|
|
|
|
loadProgram(*it, (*it)->_scriptName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(1, kDebugParser, "parseLocation('%s') done", filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-03 00:49:27 +00:00
|
|
|
void Parallaction_br::loadProgram(AnimationPtr a, const char *filename) {
|
|
|
|
debugC(1, kDebugParser, "loadProgram(Animation: %s, script: %s)", a->_name, filename);
|
|
|
|
|
|
|
|
Script *script = _disk->loadScript(filename);
|
|
|
|
ProgramPtr program(new Program);
|
|
|
|
program->_anim = a;
|
|
|
|
|
|
|
|
_programParser->parse(script, program);
|
|
|
|
|
|
|
|
delete script;
|
|
|
|
|
2008-12-14 10:32:26 +00:00
|
|
|
_location._programs.push_back(program);
|
2008-06-03 00:49:27 +00:00
|
|
|
|
|
|
|
debugC(1, kDebugParser, "loadProgram() done");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 01:35:43 +00:00
|
|
|
|
2007-08-25 20:34:10 +00:00
|
|
|
void Parallaction_br::changeCharacter(const char *name) {
|
2008-12-21 15:42:47 +00:00
|
|
|
|
2008-06-04 09:07:55 +00:00
|
|
|
const char *charName = _char.getName();
|
2008-07-25 08:27:44 +00:00
|
|
|
|
|
|
|
if (scumm_stricmp(charName, name)) {
|
2008-12-21 15:42:47 +00:00
|
|
|
freeCharacter();
|
|
|
|
|
2008-07-25 08:27:44 +00:00
|
|
|
debugC(1, kDebugExec, "changeCharacter(%s)", name);
|
|
|
|
|
|
|
|
_char.setName(name);
|
2008-12-21 15:42:47 +00:00
|
|
|
_char._ani->gfxobj = _gfx->loadCharacterAnim(name);
|
2008-07-25 08:27:44 +00:00
|
|
|
_char._talk = _disk->loadTalk(name);
|
2008-06-04 09:07:55 +00:00
|
|
|
}
|
2007-08-25 20:34:10 +00:00
|
|
|
|
2008-07-25 08:27:44 +00:00
|
|
|
_char._ani->_flags |= kFlagsActive;
|
2007-08-25 20:34:10 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 14:23:20 +00:00
|
|
|
bool Parallaction_br::counterExists(const Common::String &name) {
|
|
|
|
return Table::notFound != _countersNames->lookup(name.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
int Parallaction_br::getCounterValue(const Common::String &name) {
|
|
|
|
int index = _countersNames->lookup(name.c_str());
|
|
|
|
if (index != Table::notFound) {
|
|
|
|
return _counters[index - 1];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction_br::setCounterValue(const Common::String &name, int value) {
|
|
|
|
int index = _countersNames->lookup(name.c_str());
|
|
|
|
if (index != Table::notFound) {
|
|
|
|
_counters[index - 1] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction_br::testCounterCondition(const Common::String &name, int op, int value) {
|
|
|
|
int index = _countersNames->lookup(name.c_str());
|
|
|
|
if (index == Table::notFound) {
|
|
|
|
clearLocationFlags(kFlagsTestTrue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int c = _counters[index - 1];
|
|
|
|
|
|
|
|
// these definitions must match those in parser_br.cpp
|
|
|
|
#define CMD_TEST 25
|
|
|
|
#define CMD_TEST_GT 26
|
|
|
|
#define CMD_TEST_LT 27
|
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
switch (op) {
|
|
|
|
case CMD_TEST:
|
|
|
|
res = (c == value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMD_TEST_GT:
|
|
|
|
res = (c > value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CMD_TEST_LT:
|
|
|
|
res = (c < value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error("unknown operator in testCounterCondition");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
setLocationFlags(kFlagsTestTrue);
|
|
|
|
} else {
|
|
|
|
clearLocationFlags(kFlagsTestTrue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-24 08:42:46 +00:00
|
|
|
void Parallaction_br::updateWalkers() {
|
|
|
|
_walker->walk();
|
|
|
|
}
|
|
|
|
|
2009-02-24 09:18:20 +00:00
|
|
|
void Parallaction_br::scheduleWalk(int16 x, int16 y, bool fromUser) {
|
2009-02-24 08:42:46 +00:00
|
|
|
AnimationPtr a = _char._ani;
|
|
|
|
|
|
|
|
if ((a->_flags & kFlagsRemove) || (a->_flags & kFlagsActive) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_walker->setCharacterPath(a, x, y);
|
2009-02-24 09:18:20 +00:00
|
|
|
|
|
|
|
if (!fromUser) {
|
|
|
|
_walker->stopFollower();
|
|
|
|
} else {
|
|
|
|
if (_follower) {
|
|
|
|
_walker->setFollowerPath(_follower, x, y);
|
|
|
|
}
|
2009-02-24 08:42:46 +00:00
|
|
|
}
|
2009-02-24 09:18:20 +00:00
|
|
|
|
2009-02-24 08:42:46 +00:00
|
|
|
_engineFlags |= kEngineWalking;
|
|
|
|
}
|
2007-09-23 20:17:50 +00:00
|
|
|
|
2009-02-24 09:18:20 +00:00
|
|
|
void Parallaction_br::setFollower(const Common::String &name) {
|
|
|
|
if (name.empty()) {
|
|
|
|
_followerName.clear();
|
|
|
|
_follower.reset();
|
|
|
|
} else {
|
|
|
|
_followerName = name;
|
|
|
|
_follower = _location.findAnimation(name.c_str());
|
|
|
|
}
|
|
|
|
}
|
2007-09-23 20:17:50 +00:00
|
|
|
|
2009-03-02 08:36:42 +00:00
|
|
|
void Parallaction_br::restoreOrSaveZoneFlags(ZonePtr z, bool restore) {
|
|
|
|
if (restore) {
|
|
|
|
z->_flags = _zoneFlags[z->_locationIndex][z->_index];
|
|
|
|
} else {
|
|
|
|
_zoneFlags[z->_locationIndex][z->_index] = z->_flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
} // namespace Parallaction
|