Permalink
Browse files

XEEN: Cleanup of give opcode and methods

  • Loading branch information...
dreammaster committed Dec 29, 2017
1 parent 47d95c6 commit 4e11d05f7672f75180660402785c2a85500618c7
Showing with 32 additions and 70 deletions.
  1. +3 −6 engines/xeen/party.cpp
  2. +26 −61 engines/xeen/scripts.cpp
  3. +3 −3 engines/xeen/scripts.h
View
@@ -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;
}
View
@@ -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);
}
View
@@ -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 @@ class Scripts {
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

0 comments on commit 4e11d05

Please sign in to comment.