diff options
author | Paul Gilbert | 2015-01-11 10:43:02 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-11 10:43:02 -0500 |
commit | 0b5f79afb7dbf0d2bcf3cb14747f93f348b1aaa5 (patch) | |
tree | bad0b5019f9182f7fc09187053c641bcc78a8b37 | |
parent | 49787629ffb86569faebd3155fd65c0cedea0bad (diff) | |
download | scummvm-rg350-0b5f79afb7dbf0d2bcf3cb14747f93f348b1aaa5.tar.gz scummvm-rg350-0b5f79afb7dbf0d2bcf3cb14747f93f348b1aaa5.tar.bz2 scummvm-rg350-0b5f79afb7dbf0d2bcf3cb14747f93f348b1aaa5.zip |
XEEN: Added loading of event data for maps
-rw-r--r-- | engines/xeen/map.cpp | 29 | ||||
-rw-r--r-- | engines/xeen/map.h | 4 | ||||
-rw-r--r-- | engines/xeen/module.mk | 1 | ||||
-rw-r--r-- | engines/xeen/party.h | 4 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 54 | ||||
-rw-r--r-- | engines/xeen/scripts.h | 119 |
6 files changed, 208 insertions, 3 deletions
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index e2050bdefb..d07ca2d363 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -842,12 +842,15 @@ void Map::load(int mapId) { } } + // Load any events for the new map + loadEvents(mapId); + + // Iterate through loading the given maze as well as the two successive + // mazes in each of the four cardinal directions bool isDarkCc = _vm->getGameID() == GType_DarkSide; MazeData *mazeData = &_mazeData[0]; bool textLoaded = false; - // Iterate through loading the given maze as well as the two successive - // mazes in each of the four cardinal directions for (int idx = 0; idx < 9; ++idx, ++mazeData) { mazeData->_mazeId = mapId; @@ -1032,6 +1035,28 @@ int Map::mazeLookup(const Common::Point &pt, int directionLayerIndex) { } } +/** + * Load the events for a new map + */ +void Map::loadEvents(int mapId) { + // Load events + Common::String filename = Common::String::format("maze%c%03d.evt", + (mapId >= 100) ? 'x' : '0', mapId); + File fEvents(filename); + _events.synchronize(fEvents); + fEvents.close(); + + // Load text data + filename = Common::String::format("aaze%c%03d.txt", + (mapId >= 100) ? 'x' : '0', mapId); + File fText(filename); + _events._text.resize(fText.size()); + fText.read(&_events._text[0], fText.size()); + + _events.synchronize(fText); + fText.close(); +} + void Map::cellFlagLookup(const Common::Point &pt) { Common::Point pos = pt; int mapId = _vm->_party._mazeId; diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 3a1073eda2..bc1b0245b9 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -27,6 +27,7 @@ #include "common/array.h" #include "common/rect.h" #include "xeen/party.h" +#include "xeen/scripts.h" #include "xeen/sprites.h" namespace Xeen { @@ -328,10 +329,13 @@ private: bool _currentSteppedOn; int _currentSurfaceId; + void loadEvents(int mapId); + void cellFlagLookup(const Common::Point &pt); public: bool _isOutdoors; MonsterObjectData _mobData; + MazeEvents _events; bool _currentIsGrate; bool _currentCantRest; bool _currentIsDrain; diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index 5cbb1bb064..076a31a916 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -20,6 +20,7 @@ MODULE_OBJS := \ resources.o \ saves.o \ screen.o \ + scripts.o \ sound.o \ sprites.o \ xeen.o \ diff --git a/engines/xeen/party.h b/engines/xeen/party.h index f1220c82e9..d8fe2ab79d 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -31,7 +31,9 @@ namespace Xeen { -enum Direction { DIR_NORTH = 0, DIR_EAST = 1, DIR_SOUTH = 2, DIR_WEST = 3 }; +enum Direction { + DIR_NORTH = 0, DIR_EAST = 1, DIR_SOUTH = 2, DIR_WEST = 3, DIR_ALL = 4 +}; enum Difficulty { ADVENTURER = 0, WARRIOR = 1 }; diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp new file mode 100644 index 0000000000..ee804317ec --- /dev/null +++ b/engines/xeen/scripts.cpp @@ -0,0 +1,54 @@ +/* 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. + * + */ + +#include "xeen/scripts.h" + +namespace Xeen { + +MazeEvent::MazeEvent() : _direction(DIR_ALL), _line(-1), _opcode(OP_None) { +} + +void MazeEvent::synchronize(Common::SeekableReadStream &s) { + int len = s.readByte(); + _position.x = s.readByte(); + _position.y = s.readByte(); + _direction = (Direction)s.readByte(); + _line = s.readByte(); + _opcode = (Opcode)s.readByte(); + + for (int i = 0; i < (len - 5); ++i) + _parameters.push_back(s.readByte()); +} + +/*------------------------------------------------------------------------*/ + +void MazeEvents::synchronize(Common::SeekableReadStream &s) { + MazeEvent e; + + clear(); + while (!s.eos()) { + e.synchronize(s); + push_back(e); + } +} + +} // End of namespace Xeen diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h new file mode 100644 index 0000000000..1ab08faa7e --- /dev/null +++ b/engines/xeen/scripts.h @@ -0,0 +1,119 @@ +/* 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. + * + */ + +#ifndef XEEN_SCRIPTS_H +#define XEEN_SCRIPTS_H + +#include "common/scummsys.h" +#include "common/system.h" +#include "common/stream.h" +#include "xeen/party.h" + +namespace Xeen { + +enum Opcode { + OP_None = 0x00, + OP_Display0x01 = 0x01, + OP_DoorTextSml = 0x02, + OP_DoorTextLrg = 0x03, + OP_SignText = 0x04, + OP_NPC = 0x05, + OP_PlayFX = 0x06, + OP_TeleportAndExit = 0x07, + OP_If_1 = 0x08, + OP_If_2 = 0x09, + OP_If3 = 0x0A, + OP_MoveObj = 0x0B, + OP_TakeOrGive = 0x0C, + OP_NoAction = 0x0D, + OP_Remove = 0x0E, + OP_SetChar = 0x0F, + OP_Spawn = 0x10, + OP_DoTownEvent = 0x11, + OP_Exit = 0x12, + OP_AfterMap = 0x13, + OP_GiveExtended = 0x14, + OP_ConfirmWord = 0x15, + OP_Damage = 0x16, + OP_JumpRnd = 0x17, + OP_AfterEvent = 0x18, + OP_CallEvent = 0x19, + OP_Return = 0x1A, + OP_SetVar = 0x1B, + OP_TakeOrGive_2 = 0x1C, + OP_TakeOrGive_3 = 0x1D, + OP_CutsceneEndClouds = 0x1E, + OP_TeleportAndContinue = 0x1F, + OP_WhoWill = 0x20, + OP_RndDamage = 0x21, + OP_MoveWallObj = 0x22, + OP_AlterCellFlag= 0x23, + OP_AlterHed = 0x24, + OP_DisplayStat = 0x25, + OP_TakeOrGive_4 = 0x26, + OP_SeatTextSml = 0x27, + OP_PlayEventVoc = 0x28, + OP_DisplayBottom = 0x29, + OP_IfMapFlag = 0x2A, + OP_SelRndChar = 0x2B, + OP_GiveEnchanted= 0x2C, + OP_ItemType = 0x2D, + OP_MakeNothingHere = 0x2E, + OP_NoAction_2 = 0x2F, + OP_ChooseNumeric= 0x30, + OP_DisplayBottomTwoLines = 0x31, + OP_DisplayLarge = 0x32, + OP_ExchObj = 0x33, + OP_FallToMap = 0x34, + OP_DisplayMain = 0x35, + OP_Goto = 0x36, + OP_ConfirmWord_2= 0x37, + OP_GotoRandom = 0x38, + OP_CutsceneEndDarkside = 0x39, + OP_CutsceneEdWorld = 0x3A, + OP_FlipWorld = 0x3B, + OP_PlayCD = 0x3C +}; + +class MazeEvent { +public: + Common::Point _position; + int _direction; + int _line; + Opcode _opcode; + Common::Array<byte> _parameters; +public: + MazeEvent(); + + void synchronize(Common::SeekableReadStream &s); +}; + +class MazeEvents : public Common::Array<MazeEvent> { +public: + Common::Array<byte> _text; +public: + void synchronize(Common::SeekableReadStream &s); +}; + +} // End of namespace Xeen + +#endif /* XEEN_SCRIPTS_H */ |