aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-25 13:12:11 +0100
committerEugene Sandulenko2015-12-27 15:41:02 +0100
commit81dc7cd98ff385fed4523f6b3f8ddc04ed7bea62 (patch)
treee87c1480e2345dbfa1024d0f67868b0d3b59b75a /engines
parent113a274027f41a4c51b8d5bbbf8fec46ce176bf0 (diff)
downloadscummvm-rg350-81dc7cd98ff385fed4523f6b3f8ddc04ed7bea62.tar.gz
scummvm-rg350-81dc7cd98ff385fed4523f6b3f8ddc04ed7bea62.tar.bz2
scummvm-rg350-81dc7cd98ff385fed4523f6b3f8ddc04ed7bea62.zip
WAGE: Implement World::move(Chr *chr, Scene *scene)
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/entities.cpp2
-rw-r--r--engines/wage/entities.h1
-rw-r--r--engines/wage/script.cpp2
-rw-r--r--engines/wage/wage.cpp4
-rw-r--r--engines/wage/world.cpp40
-rw-r--r--engines/wage/world.h2
6 files changed, 43 insertions, 8 deletions
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 8bde170fd4..0e7e4bc5e3 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -78,6 +78,8 @@ Scene::Scene(String name, Common::SeekableReadStream *data) {
_messages[Scene::EAST] = readPascalString(data);
_messages[Scene::WEST] = readPascalString(data);
_soundName = readPascalString(data);
+
+ _visited = false;
}
Obj::Obj(String name, Common::SeekableReadStream *data) : _currentOwner(NULL), _currentScene(NULL) {
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index d24252f575..66f966a65f 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -385,6 +385,7 @@ public:
String _soundName;
int _worldX;
int _worldY;
+ bool _visited;
Common::List<Obj *> _objs;
Common::List<Chr *> _chrs;
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 8b842f847a..3be74cc2c1 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -227,7 +227,7 @@ Script::Operand *Script::readOperand() {
case 0xA1:
return new Operand(_inputClick, CLICK_INPUT);
case 0xC0: // STORAGE@
- return new Operand(&_world->_storageScene, SCENE);
+ return new Operand(_world->_storageScene, SCENE);
case 0xC1: // SCENE@
return new Operand(_world->_player->_currentScene, SCENE);
case 0xC2: // PLAYER@
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 145a31692f..677737f4d5 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -162,9 +162,9 @@ Obj *WageEngine::getOffer() {
void WageEngine::performInitialSetup() {
for (int i = 0; i < _world->_orderedObjs.size(); i++)
- _world->move(_world->_orderedObjs[i], &_world->_storageScene);
+ _world->move(_world->_orderedObjs[i], _world->_storageScene);
for (int i = 0; i < _world->_orderedChrs.size(); i++)
- _world->move(_world->_orderedChrs[i], &_world->_storageScene);
+ _world->move(_world->_orderedChrs[i], _world->_storageScene);
for (int i = 0; i < _world->_orderedObjs.size(); i++) {
Obj *obj = _world->_orderedObjs[i];
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index c04fc14393..a99300e9c2 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -58,9 +58,11 @@
namespace Wage {
World::World(WageEngine *engine) {
- _storageScene._name = STORAGESCENE;
- _orderedScenes.push_back(&_storageScene);
- _scenes[STORAGESCENE] = &_storageScene;
+ _storageScene = new Scene;
+ _storageScene->_name = STORAGESCENE;
+
+ _orderedScenes.push_back(_storageScene);
+ _scenes[STORAGESCENE] = _storageScene;
_gameOverMessage = nullptr;
_saveBeforeQuitMessage = nullptr;
@@ -70,6 +72,10 @@ World::World(WageEngine *engine) {
_engine = engine;
}
+World::~World() {
+ delete _storageScene;
+}
+
bool World::loadWorld(Common::MacResManager *resMan) {
Common::MacResIDArray resArray;
Common::SeekableReadStream *res;
@@ -391,8 +397,34 @@ void World::move(Obj *obj, Scene *scene) {
_engine->onMove(obj, from, scene);
}
+bool ChrComparator(Chr *l, Chr *r) {
+ return l->_index < r->_index;
+}
+
void World::move(Chr *chr, Scene *scene) {
- warning("STUB: World::move(chr, scene)");
+ if (chr == NULL)
+ return;
+ Scene *from = chr->_currentScene;
+ if (from == scene)
+ return;
+ if (from != NULL)
+ from->_chrs.remove(chr);
+ scene->_chrs.push_back(chr);
+
+ Common::sort(scene->_chrs.begin(), scene->_chrs.end(), ChrComparator);
+
+ if (scene == _storageScene) {
+ warning("STUB: World::move (chrState)");
+ //chr.setState(new Chr.State(chr));
+ } else if (chr->_playerCharacter) {
+ scene->_visited = true;
+ warning("STUB: World::move (visits)");
+ //Context context = getPlayerContext();
+ //context.setVisits(context.getVisits() + 1);
+ }
+ chr->_currentScene = scene;
+
+ _engine->onMove(chr, from, scene);
}
Scene *World::getRandomScene() {
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 1bd71f16e7..ed933864c9 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -83,7 +83,7 @@ public:
Common::Array<Chr *> _orderedChrs;
Common::Array<Sound *> _orderedSounds;
Patterns _patterns;
- Scene _storageScene;
+ Scene *_storageScene;
Chr *_player;
//List<MoveListener> moveListeners;