aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/inventory.cpp54
-rw-r--r--engines/mads/inventory.h35
-rw-r--r--engines/mads/nebular/game_nebular.cpp14
-rw-r--r--engines/mads/nebular/nebular_scenes4.cpp29
-rw-r--r--engines/mads/nebular/nebular_scenes7.cpp5
5 files changed, 84 insertions, 53 deletions
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 79a8e87b2a..434d284244 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -31,16 +31,46 @@ void InventoryObject::synchronize(Common::Serializer &s) {
s.syncAsUint16LE(_roomNumber);
s.syncAsByte(_article);
s.syncAsByte(_vocabCount);
+ s.syncAsByte(_qualitiesCount);
+ s.skip(1);
- for (int i = 0; i < 3; ++i) {
+ for (int i = 0; i < MAX_VOCAB; ++i) {
+ s.syncAsUint16LE(_vocabList[i]._vocabId);
s.syncAsByte(_vocabList[i]._verbType);
s.syncAsByte(_vocabList[i]._prepType);
- s.syncAsUint16LE( _vocabList[i]._vocabId);
}
- s.skip(4); // field12
- s.syncBytes((byte *)&_mutilateString[0], 10);
- s.skip(16);
+ for (int i = 0; i < MAX_QUALITIES; ++i)
+ s.syncAsByte(_qualityId[i]);
+ for (int i = 0; i < MAX_QUALITIES; ++i)
+ s.syncAsSint32LE(_qualityValue[i]);
+}
+
+bool InventoryObject::hasQuality(int qualityId) const {
+ for (int i = 0; i < _qualitiesCount; ++i) {
+ if (_qualityId[i] == qualityId)
+ return true;
+ }
+
+ return false;
+}
+
+void InventoryObject::setQuality(int qualityId, int qualityValue) {
+ for (int i = 0; i < _qualitiesCount; ++i) {
+ if (_qualityId[i] == qualityId) {
+ _qualityValue[i] = qualityValue;
+ }
+ }
+}
+
+int InventoryObject::getQuality(int qualityId) const {
+ for (int i = 0; i < _qualitiesCount; ++i) {
+ if (_qualityId[i] == qualityId) {
+ return _qualityValue[i];
+ }
+ }
+
+ return 0;
}
/*------------------------------------------------------------------------*/
@@ -92,20 +122,6 @@ void InventoryObjects::synchronize(Common::Serializer &s) {
}
}
-void InventoryObjects::setQuality(int objIndex, int id, const byte *p) {
- // TODO: This whole method seems weird. Check it out more thoroughly once
- // more of the engine is implemented
- for (int i = 0; i < (int)size(); ++i) {
- InventoryObject &obj = (*this)[i];
- if (obj._vocabList[0]._verbType <= i)
- break;
-
- if (obj._mutilateString[6 + i] == id) {
- (*this)[objIndex]._objFolder = p;
- }
- }
-}
-
void InventoryObjects::setRoom(int objectId, int sceneNumber) {
InventoryObject &obj = (*this)[objectId];
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 9d79431050..7fb123e047 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -35,24 +35,46 @@ enum {
class MADSEngine;
+#define MAX_VOCAB 5
+#define MAX_QUALITIES 4
+
class InventoryObject {
public:
int _descId;
int _roomNumber;
int _article;
int _vocabCount;
+ int _qualitiesCount;
+ int syntax;
+
struct {
+ int _vocabId;
VerbType _verbType;
PrepType _prepType;
- int _vocabId;
- } _vocabList[3];
- char _mutilateString[10]; // ???
- const byte *_objFolder; // ???
+ } _vocabList[MAX_VOCAB];
+
+ int _qualityId[MAX_QUALITIES];
+ int _qualityValue[MAX_QUALITIES];
/**
* Synchronizes the data for a given object
*/
void synchronize(Common::Serializer &s);
+
+ /**
+ * Returns true if the given object has the specified quality
+ */
+ bool hasQuality(int qualityId) const;
+
+ /**
+ * Sets the quality value for a given quality Id
+ */
+ void setQuality(int qualityId, int qualityValue);
+
+ /**
+ * Gets the quality value for a given quality Id
+ */
+ int getQuality(int qualityId) const;
};
class InventoryObjects: public Common::Array<InventoryObject> {
@@ -85,11 +107,6 @@ public:
}
/**
- * Set the associated quality data for an inventory object
- */
- void setQuality(int objIndex, int id, const byte *p);
-
- /**
* Sets an item's scene number
*/
void setRoom(int objectId, int sceneNumber);
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 600c153088..1ec025c8e1 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -98,7 +98,7 @@ void GameNebular::initialiseGlobals() {
/* Section #4 variables */
_globals[kBadFirstIngredient] = -1;
- _objects.setQuality(OBJ_CHARGE_CASES, EXPLOSIVES_INSIDE, nullptr);
+ _objects[OBJ_CHARGE_CASES].setQuality(EXPLOSIVES_INSIDE, 0);
_globals[kHasPurchased] = false;
_globals[kBeenThruHelgaScene] = false;
_globals[kNextIngredient] = 0;
@@ -394,8 +394,7 @@ void GameNebular::doObjectAction() {
dialogs.showItem(id, 402);
} else {
int messageId = 800 + id;
- if (id == OBJ_CHARGE_CASES) {
- error("TODO: object_get_folder - loc_29B48");
+ if ((id == OBJ_CHARGE_CASES) && _objects[OBJ_CHARGE_CASES].getQuality(3) != 0) {
messageId = 860;
}
@@ -435,7 +434,14 @@ void GameNebular::doObjectAction() {
dialogs.show(_globals[kTopButtonPushed] ? 502 : 501);
} else if ((action.isAction(25, 106, 72) || action.isAction(VERB_PUT, 106, 72)) &&
_objects.isInInventory(OBJ_DETONATORS) && _objects.isInInventory(OBJ_CHARGE_CASES)) {
- error("TODO: loc_29DBA");
+ if (_objects[OBJ_CHARGE_CASES].getQuality(3)) {
+ _objects.setRoom(OBJ_CHARGE_CASES, 1);
+ _objects.setRoom(OBJ_DETONATORS, 1);
+ _objects.addToInventory(OBJ_BOMBS);
+ dialogs.showItem(OBJ_BOMBS, 403);
+ } else {
+ dialogs.show(405);
+ }
} else if (action.isAction(25, 106)) {
dialogs.show(470);
} else if ((action.isAction(25, 371, 43) || action.isAction(7, 371, 43) || action.isAction(25, 371, 42)
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 91c522cd25..e8e9596e9d 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -3513,8 +3513,7 @@ void Scene411::enter() {
_dialog3.setup(0x5D, 0x254, 0x260, 0x25C, 0x258, 0x262, -1);
_dialog4.setup(0x5E, 0x255, 0x261, 0x25D, 0x259, 0x262, -1);
- warning("TODO: Replace the next line by: if ((_globals[kNextIngredient] >= 4) && (!object_get_folder(OBJ_CHARGE_CASES, 3))) {");
- if (_globals[kNextIngredient] >= 4) {
+ if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
_scene->_hotspots.activate(0x3AB, false);
_scene->_hotspots.activate(0x30D, true);
} else {
@@ -3522,11 +3521,9 @@ void Scene411::enter() {
_scene->_hotspots.activate(0x3AB, true);
}
- warning("TODO: Replace the next line by: if ((!_globals[kNextIngredient] >= 4) && (object_get_folder(OBJ_CHARGE_CASES, 3))) {");
- if (!(_globals[kNextIngredient] >= 4))
+ if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], true, 6);
- else if (true) {
- warning("TODO: The previous if was: else if (!object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+ } else if (!_game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
switch (_globals[kNextIngredient]) {
case 1:
_vm->_sound->command(53);
@@ -3559,8 +3556,7 @@ void Scene411::enter() {
}
}
- warning("TODO: Replace the next if by: if ((_globals[kNextIngredient] >= 4) && (object_get_folder(OBJ_CHARGE_CASES, 3))) {");
- if (_globals[kNextIngredient] >= 4) {
+ if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], true, 6);
_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
}
@@ -3722,9 +3718,9 @@ void Scene411::actions() {
return;
}
- warning("TODO: add the following condition to the if statement: (!object_get_folder(OBJ_CHARGE_CASES, 3)) &&");
- if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, 0x3AB) || _action.isAction(VERB_PUT, 0x48, 0x3AB)) &&
- (_game._objects.isInInventory(OBJ_CHARGE_CASES))) {
+ if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, 0x3AB) || _action.isAction(VERB_PUT, 0x48, 0x3AB))
+ && !_game._objects[OBJ_CHARGE_CASES].getQuality(3)
+ && _game._objects.isInInventory(OBJ_CHARGE_CASES)) {
switch (_game._trigger) {
case 0:
_vm->_sound->command(10);
@@ -3764,7 +3760,7 @@ void Scene411::actions() {
_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
_game._player._visible = true;
_game._player._stepEnabled = true;
- warning("TODO: InventoryObjects_setData(OBJ_CHARGE_CASES, 3, true);");
+ _game._objects[OBJ_CHARGE_CASES].setQuality(3, 1);
_vm->_dialogs->showItem(OBJ_CHARGE_CASES, 41142);
break;
}
@@ -3927,15 +3923,12 @@ void Scene411::actions() {
else if ((_action.isAction(VERB_LOOK, 0x3A9)) && (_game._objects.isInRoom(OBJ_LECITHIN)))
_vm->_dialogs->show(41123);
else if (_action.isAction(VERB_LOOK, 0x30D)) {
- if (_globals[kNextIngredient] > 0) {
- warning("TODO: the if statement should be: if ((_globals[kNextIngredient] > 0) && !object_get_folder(OBJ_CHARGE_CASES, 3))");
+ if (_globals[kNextIngredient] > 0 && !_game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
_vm->_dialogs->show(41126);
- } else if (_globals[kNextIngredient] == 0) {
- warning("TODO: the if statement should be: else if ((_globals[kNextIngredient] == 0) || object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+ } else if (_globals[kNextIngredient] == 0 || _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
_vm->_dialogs->show(41125);
}
- } else if (_action.isAction(VERB_LOOK, 0x3AB)) {
- warning("TODO: The if statement should be if (_action.isAction(VERB_LOOK, 0x3AB) && !object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+ } else if (_action.isAction(VERB_LOOK, 0x3AB) && _game._objects[OBJ_CHARGE_CASES].getQuality(3) == 0) {
_vm->_dialogs->show(41127);
} else if (_action.isAction(VERB_TAKE, 0x30D))
_vm->_dialogs->show(41128);
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 94bb7b66b2..385141d318 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1785,9 +1785,8 @@ void Scene706::actions() {
}
if (_action.isAction(VERB_PUT, 0x344) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
- warning("Replace the next if when the function is implemented");
- warning("if (sub_13D46(_game._objects.getIdFromDesc(_action._activeAction._objectNameId), 0xA))");
- if (true)
+ int objectId = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
+ if (_game._objects[objectId].hasQuality(10))
_vm->_dialogs->show(70626);
else
_vm->_dialogs->show(70627);