aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2017-12-18 18:10:50 -0500
committerPaul Gilbert2017-12-18 18:10:50 -0500
commit46b0101af4ae8b1b959609bdd2dc40e42e5ff08e (patch)
tree554c150de6a56abbb3dae83b2367b87ea0f3f63a
parent9664dc7c5d562a0b9f242d61f1af13df60ce72f5 (diff)
downloadscummvm-rg350-46b0101af4ae8b1b959609bdd2dc40e42e5ff08e.tar.gz
scummvm-rg350-46b0101af4ae8b1b959609bdd2dc40e42e5ff08e.tar.bz2
scummvm-rg350-46b0101af4ae8b1b959609bdd2dc40e42e5ff08e.zip
XEEN: Cleanup, formatting, and comments for scripts.cpp
-rw-r--r--engines/xeen/scripts.cpp26
-rw-r--r--engines/xeen/scripts.h167
2 files changed, 114 insertions, 79 deletions
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index cfdd9b7d42..12054082e5 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -133,12 +133,13 @@ Scripts::Scripts(XeenEngine *vm) : _vm(vm) {
int Scripts::checkEvents() {
Combat &combat = *_vm->_combat;
EventsManager &events = *_vm->_events;
+ FileManager &files = *_vm->_files;
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Sound &sound = *_vm->_sound;
Windows &windows = *_vm->_windows;
- bool isDarkCc = _vm->_files->_isDarkCc;
+ bool isDarkCc = files._isDarkCc;
_refreshIcons = false;
_itemType = 0;
@@ -273,11 +274,12 @@ int Scripts::checkEvents() {
void Scripts::openGrate(int wallVal, int action) {
Combat &combat = *_vm->_combat;
+ FileManager &files = *_vm->_files;
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Sound &sound = *_vm->_sound;
- bool isDarkCc = _vm->_files->_isDarkCc;
+ bool isDarkCc = files._isDarkCc;
if ((wallVal != 13 || map._currentGrateUnlocked) && (!isDarkCc || wallVal != 9 ||
map.mazeData()._wallKind != 2)) {
@@ -913,6 +915,7 @@ bool Scripts::cmdGiveExtended(ParamsIterator &params) {
}
bool Scripts::cmdConfirmWord(ParamsIterator &params) {
+ FileManager &files = *_vm->_files;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
int inputType = params.readByte();
@@ -933,21 +936,21 @@ bool Scripts::cmdConfirmWord(ParamsIterator &params) {
_mirrorId = StringInput::show(_vm, inputType, msg1, msg2, _event->_opcode);
if (_mirrorId) {
- if (_mirrorId == 33 && _vm->_files->_isDarkCc) {
+ if (_mirrorId == 33 && files._isDarkCc) {
doEndGame2();
- } else if (_mirrorId == 34 && _vm->_files->_isDarkCc) {
+ } else if (_mirrorId == 34 && files._isDarkCc) {
doWorldEnd();
- } else if (_mirrorId == 35 && _vm->_files->_isDarkCc &&
+ } else if (_mirrorId == 35 && files._isDarkCc &&
_vm->getGameID() == GType_WorldOfXeen) {
doEndGame();
- } else if (_mirrorId == 40 && !_vm->_files->_isDarkCc) {
+ } else if (_mirrorId == 40 && !files._isDarkCc) {
doEndGame();
- } else if (_mirrorId == 60 && !_vm->_files->_isDarkCc) {
+ } else if (_mirrorId == 60 && !files._isDarkCc) {
doEndGame2();
- } else if (_mirrorId == 61 && !_vm->_files->_isDarkCc) {
+ } else if (_mirrorId == 61 && !files._isDarkCc) {
doWorldEnd();
} else {
- if (_mirrorId == 59 && !_vm->_files->_isDarkCc) {
+ if (_mirrorId == 59 && !files._isDarkCc) {
for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) {
XeenItem &item = party._treasure._weapons[idx];
if (!item._id) {
@@ -1436,6 +1439,7 @@ void Scripts::doEnding(const Common::String &endStr, int v2) {
}
bool Scripts::ifProc(int action, uint32 val, int mode, int charIndex) {
+ FileManager &files = *_vm->_files;
Party &party = *_vm->_party;
Character &ps = party._activeParty[charIndex];
uint v = 0;
@@ -1533,7 +1537,7 @@ bool Scripts::ifProc(int action, uint32 val, int mode, int charIndex) {
break;
}
case 20:
- if (_vm->_files->_isDarkCc)
+ if (files._isDarkCc)
val += 256;
assert(val < 512);
v = party._gameFlags[val / 256][val % 256] ? val : 0xffffffff;
@@ -1776,7 +1780,7 @@ bool Scripts::ifProc(int action, uint32 val, int mode, int charIndex) {
break;
case 104:
// Get value of quest flag
- v = party._questFlags[_vm->_files->_isDarkCc][val] ? val : 0xffffffff;
+ v = party._questFlags[files._isDarkCc][val] ? val : 0xffffffff;
break;
case 105:
// Test number of Megacredits in party. Only used by King's Engineer in Castle Burlock
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index 51db67bfa8..457d4b76c2 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -34,71 +34,74 @@
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_If1 = 0x08,
- OP_If2 = 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_SelectRandomChar = 0x2B,
- OP_GiveEnchanted= 0x2C,
- OP_ItemType = 0x2D,
- OP_MakeNothingHere = 0x2E,
- OP_NoAction_2 = 0x2F,
- OP_ChooseNumeric= 0x30,
+ 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_If1 = 0x08,
+ OP_If2 = 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_SelectRandomChar = 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
+ 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 XeenEngine;
+/**
+ * Encapsulates the parameters passed to script opcodes
+ */
class EventParameters : public Common::Array<byte> {
public:
class Iterator {
@@ -110,23 +113,23 @@ public:
Iterator(const Iterator &it) : _data(it._data), _index(0) {}
/**
- * Return a byte
- */
+ * Return a byte
+ */
byte readByte();
/**
- * Return a signed byte
- */
+ * Return a signed byte
+ */
int8 readShort() { return (int8)readByte(); }
/**
- * Return a word
- */
+ * Return a word
+ */
uint16 readUint16LE();
/**
- * Return a 32-bit dword
- */
+ * Return a 32-bit dword
+ */
uint32 readUint32LE();
};
public:
@@ -138,6 +141,9 @@ public:
}
};
+/**
+ * Represents a single event, an instruction of a script
+ */
class MazeEvent {
public:
Common::Point _position;
@@ -148,22 +154,37 @@ public:
public:
MazeEvent();
+ /**
+ * Synchronizes the data for the item
+ */
void synchronize(Common::Serializer &s);
};
+/**
+ * Represents an entire script that can be triggered within the maze
+ */
class MazeEvents : public Common::Array<MazeEvent> {
public:
Common::StringArray _text;
public:
+ /**
+ * Synchronizes the data for the item
+ */
void synchronize(XeenSerializer &s);
};
+/**
+ * Holds a single entry in the stack of subroutine call return points
+ */
struct StackEntry : public Common::Point {
int line;
StackEntry(const Common::Point &pt, int l) : Common::Point(pt), line(l) {}
};
+/**
+ * Holds a single destination that the mirror can send the player to
+ */
struct MirrorEntry {
Common::String _name;
int _mapId;
@@ -175,6 +196,9 @@ struct MirrorEntry {
bool synchronize(Common::SeekableReadStream &s);
};
+/**
+ * Overall scripts manager
+ */
class Scripts {
private:
XeenEngine *_vm;
@@ -514,8 +538,15 @@ public:
public:
Scripts(XeenEngine *vm);
+ /**
+ * Checks the event list, triggering any scripts as needed. Also does a
+ * series of checks for updating party status
+ */
int checkEvents();
+ /**
+ * Handles opening grates
+ */
void openGrate(int wallVal, int action);
};