From 81dc7cd98ff385fed4523f6b3f8ddc04ed7bea62 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 25 Dec 2015 13:12:11 +0100 Subject: WAGE: Implement World::move(Chr *chr, Scene *scene) --- engines/wage/entities.cpp | 2 ++ engines/wage/entities.h | 1 + engines/wage/script.cpp | 2 +- engines/wage/wage.cpp | 4 ++-- engines/wage/world.cpp | 40 ++++++++++++++++++++++++++++++++++++---- engines/wage/world.h | 2 +- 6 files changed, 43 insertions(+), 8 deletions(-) (limited to 'engines') 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 _objs; Common::List _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 _orderedChrs; Common::Array _orderedSounds; Patterns _patterns; - Scene _storageScene; + Scene *_storageScene; Chr *_player; //List moveListeners; -- cgit v1.2.3