aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-25 12:49:47 +0100
committerEugene Sandulenko2015-12-27 15:41:02 +0100
commit5f2ef620c18b36fe0d480474135aa78eb9eb0c01 (patch)
tree79944e688a45bc14b2f59e86404ceea35c076070 /engines
parent59b2809f3740923cc63477a25eaabde2535f6f2e (diff)
downloadscummvm-rg350-5f2ef620c18b36fe0d480474135aa78eb9eb0c01.tar.gz
scummvm-rg350-5f2ef620c18b36fe0d480474135aa78eb9eb0c01.tar.bz2
scummvm-rg350-5f2ef620c18b36fe0d480474135aa78eb9eb0c01.zip
WAGE: Implemented World::move(Obj *obj, Chr *chr)
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/entities.cpp29
-rw-r--r--engines/wage/entities.h9
-rw-r--r--engines/wage/wage.cpp4
-rw-r--r--engines/wage/wage.h8
-rw-r--r--engines/wage/world.cpp15
5 files changed, 57 insertions, 8 deletions
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 6ec3b7c884..8bde170fd4 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -124,6 +124,33 @@ Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _
_sound = readPascalString(data);
}
+Chr *Obj::removeFromChr() {
+ if (_currentOwner != NULL) {
+ for (int i = _currentOwner->_inventory.size() - 1; i >= 0; i--)
+ if (_currentOwner->_inventory[i] == this)
+ _currentOwner->_inventory.remove_at(i);
+
+ for (int i = 0; i < Chr::NUMBER_OF_ARMOR_TYPES; i++) {
+ if (_currentOwner->_armor[i] == this) {
+ _currentOwner->_armor[i] = NULL;
+ }
+ }
+ }
+
+ return _currentOwner;
+}
+
+Designed *Obj::removeFromCharOrScene() {
+ Designed *from = removeFromChr();
+
+ if (_currentScene != NULL) {
+ _currentScene->_objs.remove(this);
+ from = _currentScene;
+ }
+
+ return from;
+}
+
Chr::Chr(String name, Common::SeekableReadStream *data) {
_name = name;
_classType = CHR;
@@ -207,7 +234,7 @@ WeaponArray *Chr::getWeapons() {
void Chr::wearObjs() {
for (int i = 0; i < _inventory.size(); i++)
- wearObjIfPossible(&_inventory[i]);
+ wearObjIfPossible(_inventory[i]);
}
int Chr::wearObjIfPossible(Obj *obj) {
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 7573cc81b1..d24252f575 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -201,7 +201,7 @@ public:
String _dyingWords;
Scene *_currentScene;
- Common::Array<Obj> _inventory;
+ Common::Array<Obj *> _inventory;
Obj *_armor[NUMBER_OF_ARMOR_TYPES];
@@ -354,6 +354,9 @@ public:
if (currentScene != NULL)
_currentOwner = NULL;
}
+
+ Chr *removeFromChr();
+ Designed *removeFromCharOrScene();
};
class Scene : public Designed {
@@ -383,8 +386,8 @@ public:
int _worldX;
int _worldY;
- Common::List<Obj> _objs;
- Common::List<Chr> _chrs;
+ Common::List<Obj *> _objs;
+ Common::List<Chr *> _chrs;
Scene() {}
Scene(String name, Common::SeekableReadStream *data);
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 615a7a0b75..145a31692f 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -210,4 +210,8 @@ void WageEngine::performInitialSetup() {
}
}
+void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
+ warning("STUB WageEngine::onMove()");
+}
+
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 91f4b67a8e..5a7d5a072d 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -61,10 +61,11 @@ struct ADGameDescription;
namespace Wage {
class Console;
-class World;
-class Scene;
-class Obj;
class Chr;
+class Designed;
+class Obj;
+class Scene;
+class World;
using Common::String;
@@ -131,6 +132,7 @@ public:
void appendText(String str);
Obj *getOffer();
void processEvents();
+ void onMove(Designed *what, Designed *from, Designed *to);
private:
Console *_console;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 8ae775ad12..a177d32930 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -352,8 +352,21 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
return NULL;
}
+bool ChrComparator(Obj *l, Obj *r) {
+ return l->_index < r->_index;
+}
+
void World::move(Obj *obj, Chr *chr) {
- warning("STUB: World::move(obj, chr)");
+ if (obj == NULL)
+ return;
+
+ Designed *from = obj->removeFromCharOrScene();
+ obj->_currentOwner = chr;
+ chr->_inventory.push_back(obj);
+
+ Common::sort(chr->_inventory.begin(), chr->_inventory.end(), ChrComparator);
+
+ _engine->onMove(obj, from, chr);
}
void World::move(Obj *obj, Scene *scene) {