aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2017-12-29 16:08:11 -0500
committerPaul Gilbert2017-12-29 16:08:11 -0500
commit4e11d05f7672f75180660402785c2a85500618c7 (patch)
tree53281252c129f46da444ca23d73dbdf128a1b6dc
parent47d95c6bcd28e765486f8de7e79ea84120196bc5 (diff)
downloadscummvm-rg350-4e11d05f7672f75180660402785c2a85500618c7.tar.gz
scummvm-rg350-4e11d05f7672f75180660402785c2a85500618c7.tar.bz2
scummvm-rg350-4e11d05f7672f75180660402785c2a85500618c7.zip
XEEN: Cleanup of give opcode and methods
-rw-r--r--engines/xeen/party.cpp9
-rw-r--r--engines/xeen/scripts.cpp87
-rw-r--r--engines/xeen/scripts.h6
3 files changed, 32 insertions, 70 deletions
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 49369e74be..f279b33f6d 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -1130,6 +1130,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int
}
} else {
_questItems[giveVal - 82]++;
+ return false;
}
return true;
}
@@ -1400,8 +1401,6 @@ bool Party::giveExt(int mode1, uint val1, int mode2, uint val2, int mode3, uint
Scripts &scripts = *g_vm->_scripts;
Sound &sound = *g_vm->_sound;
Character &c = party._activeParty[charId];
- int var1 = 0;
- bool retFlag = false;
if (intf._objNumber && !scripts._animCounter) {
MazeObject &obj = map._mobData._objects[intf._objNumber - 1];
@@ -1428,6 +1427,7 @@ bool Party::giveExt(int mode1, uint val1, int mode2, uint val2, int mode3, uint
g_vm->_mode = MODE_7;
c._experience += c.getCurrentLevel() * unlockBox * 10;
+ sound.playFX(10);
intf.draw3d(true, false);
Common::String msg = Common::String::format(Res.PICKS_THE_LOCK, c._name.c_str());
ErrorScroll::show(g_vm, msg);
@@ -1480,13 +1480,10 @@ bool Party::giveExt(int mode1, uint val1, int mode2, uint val2, int mode3, uint
break;
case 67:
- retFlag = true;
- // Intentional fall-through
-
default:
if (giveTake(0, 0, mode, val, charId))
return true;
- else if (retFlag)
+ else if (mode == 67)
return false;
break;
}
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index fde53b0091..ac08c1d9f9 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -348,7 +348,7 @@ bool Scripts::doOpcode(MazeEvent &event) {
&Scripts::cmdMoveObj, &Scripts::cmdTakeOrGive, &Scripts::cmdDoNothing,
&Scripts::cmdRemove, &Scripts::cmdSetChar, &Scripts::cmdSpawn,
&Scripts::cmdDoTownEvent, &Scripts::cmdExit, &Scripts::cmdAlterMap,
- &Scripts::cmdGiveExtended, &Scripts::cmdConfirmWord, &Scripts::cmdDamage,
+ &Scripts::cmdGiveMulti, &Scripts::cmdConfirmWord, &Scripts::cmdDamage,
&Scripts::cmdJumpRnd, &Scripts::cmdAlterEvent, &Scripts::cmdCallEvent,
&Scripts::cmdReturn, &Scripts::cmdSetVar, &Scripts::cmdTakeOrGive,
&Scripts::cmdTakeOrGive, &Scripts::cmdCutsceneEndClouds,
@@ -871,81 +871,46 @@ bool Scripts::cmdAlterMap(ParamsIterator &params) {
return true;
}
-bool Scripts::cmdGiveExtended(ParamsIterator &params) {
+bool Scripts::cmdGiveMulti(ParamsIterator &params) {
Party &party = *_vm->_party;
- int mode1, mode2, mode3;
- uint32 val1, val2, val3;
-
- _refreshIcons = true;
- mode1 = params.readByte();
- switch (mode1) {
- case 16:
- case 34:
- case 100:
- val1 = params.readUint32LE();
- break;
- case 25:
- case 35:
- case 101:
- case 106:
- val1 = params.readUint16LE();
- break;
- default:
- val1 = params.readByte();
- break;
- }
-
- mode2 = params.readByte();
- switch (mode2) {
- case 16:
- case 34:
- case 100:
- val2 = params.readUint32LE();
- break;
- case 25:
- case 35:
- case 101:
- case 106:
- val2 = params.readUint16LE();
- break;
- default:
- val2 = params.readByte();
- break;
- }
-
- mode3 = params.readByte();
- switch (mode3) {
- case 16:
- case 34:
- case 100:
- val3 = params.readUint32LE();
- break;
- case 25:
- case 35:
- case 101:
- case 106:
- val3 = params.readUint16LE();
- break;
- default:
- val3 = params.readByte();
- break;
+ int modes[3];
+ uint32 vals[3];
+
+ for (int idx = 0; idx < 3; ++idx) {
+ modes[idx] = params.readByte();
+ switch (modes[idx]) {
+ case 16:
+ case 34:
+ case 100:
+ vals[idx] = params.readUint32LE();
+ break;
+ case 25:
+ case 35:
+ case 101:
+ case 106:
+ vals[idx] = params.readUint16LE();
+ break;
+ default:
+ vals[idx] = params.readByte();
+ break;
+ }
}
_scriptExecuted = true;
- bool result = party.giveExt(mode1, val1, mode2, val2, mode3, val3,
+ bool result = party.giveExt(modes[0], vals[0], modes[1], vals[1], modes[2], vals[2],
(_charIndex > 0) ? _charIndex - 1 : 0);
if (result) {
if (_animCounter == 255) {
_animCounter = 0;
return cmdExit(params);
- } else if (mode1 == 67 || mode2 == 67 || mode3 == 67) {
+ } else if (modes[0] == 67 || modes[1] == 67 || modes[2] == 67) {
_animCounter = 1;
} else {
return cmdExit(params);
}
} else {
- if (mode1 == 67 || mode2 == 67 || mode3 == 67)
+ if (modes[0] == 67 || modes[1] == 67 || modes[2] == 67)
return cmdExit(params);
}
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index 4c81185c54..9332018092 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -54,7 +54,7 @@ enum Opcode {
OP_DoTownEvent = 0x11,
OP_Exit = 0x12,
OP_AfterMap = 0x13,
- OP_GiveExtended = 0x14,
+ OP_GiveMulti = 0x14,
OP_ConfirmWord = 0x15,
OP_Damage = 0x16,
OP_JumpRnd = 0x17,
@@ -312,9 +312,9 @@ private:
bool cmdAlterMap(ParamsIterator &params);
/**
- *
+ * Gives up to three different item/amounts to various character and/or party properties
*/
- bool cmdGiveExtended(ParamsIterator &params);
+ bool cmdGiveMulti(ParamsIterator &params);
/**
* Prompts the user to enter a word for passwords or mirror