diff options
author | Eugene Sandulenko | 2015-12-25 01:09:12 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2015-12-27 15:41:01 +0100 |
commit | d4afcf99f2b21319251fcb7e8a3de2854808e161 (patch) | |
tree | e24b53ecbb03a3b20d9d8092c1a609f99008866e /engines | |
parent | 35cce4123c61f8cfbc80ced25a9c7a3f9b46b6e7 (diff) | |
download | scummvm-rg350-d4afcf99f2b21319251fcb7e8a3de2854808e161.tar.gz scummvm-rg350-d4afcf99f2b21319251fcb7e8a3de2854808e161.tar.bz2 scummvm-rg350-d4afcf99f2b21319251fcb7e8a3de2854808e161.zip |
WAGE: Initial code for world initialization
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/entities.cpp | 5 | ||||
-rw-r--r-- | engines/wage/entities.h | 3 | ||||
-rw-r--r-- | engines/wage/wage.cpp | 56 | ||||
-rw-r--r-- | engines/wage/wage.h | 2 | ||||
-rw-r--r-- | engines/wage/world.cpp | 19 | ||||
-rw-r--r-- | engines/wage/world.h | 7 |
6 files changed, 87 insertions, 5 deletions
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index 15fbbb99a7..6ec3b7c884 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -205,6 +205,11 @@ WeaponArray *Chr::getWeapons() { return list; } +void Chr::wearObjs() { + for (int i = 0; i < _inventory.size(); i++) + wearObjIfPossible(&_inventory[i]); +} + int Chr::wearObjIfPossible(Obj *obj) { switch (obj->_type) { case Obj::HELMET: diff --git a/engines/wage/entities.h b/engines/wage/entities.h index 28ce42a365..7573cc81b1 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -201,7 +201,7 @@ public: String _dyingWords; Scene *_currentScene; - Common::List<Obj> _inventory; + Common::Array<Obj> _inventory; Obj *_armor[NUMBER_OF_ARMOR_TYPES]; @@ -279,6 +279,7 @@ public: return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0); } int wearObjIfPossible(Obj *obj); + void wearObjs(); }; class Weapon { diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index 1cf0dde8d9..173646b5bc 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -101,7 +101,7 @@ Common::Error WageEngine::run() { _resManager = new Common::MacResManager(); _resManager->open(getGameFile()); - _world = new World(); + _world = new World(this); if (!_world->loadWorld(_resManager)) return Common::kNoGameDataFoundError; @@ -110,6 +110,8 @@ Common::Error WageEngine::run() { screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); Common::Rect r(0, 0, screen.w, screen.h); + performInitialSetup(); + Common::String input("look"); _world->_player->_currentScene = _world->_orderedScenes[1]; @@ -158,5 +160,57 @@ Obj *WageEngine::getOffer() { return NULL; } +void WageEngine::performInitialSetup() { + for (int i = 0; i < _world->_orderedObjs.size(); i++) + _world->move(_world->_orderedObjs[i], &_world->_storageScene); + for (int i = 0; i < _world->_orderedChrs.size(); i++) + _world->move(_world->_orderedChrs[i], &_world->_storageScene); + + warning("STUB: performInitialSetup"); +/* + for (int i = 0; i < _world->_orderedObjs.size(); i++) + Obj obj = _world->_orderedObjs[i]; + if (!obj.getSceneOrOwner().equalsIgnoreCase(World.STORAGE)) { + String location = obj.getSceneOrOwner().toLowerCase(); + Scene scene = getSceneByName(location); + if (scene != null) { + world.move(obj, scene); + } else { + Chr chr = world.getChrs().get(location); + if (chr == null) { + // Note: PLAYER@ is not a valid target here. + System.err.printf("Couldn't move %s to %s\n", obj.getName(), obj.getSceneOrOwner()); + } else { + // TODO: Add check for max items. + world.move(obj, chr); + } + } + } + } +*/ + bool playerPlaced = false; + for (int i = 0; i < _world->_orderedChrs.size(); i++) { + Chr *chr = _world->_orderedChrs[i]; + if (!chr->_initialScene.equalsIgnoreCase(STORAGESCENE)) { + String key = chr->_initialScene; + key.toLowercase(); + if (_world->_scenes.contains(key)) { + _world->move(chr, _world->_scenes[key]); + + if (chr->_playerCharacter) + warning("Initial scene: %s", key.c_str()); + } else { + _world->move(chr, _world->getRandomScene()); + } + if (chr->_playerCharacter) { + playerPlaced = true; + } + } + chr->wearObjs(); + } + if (!playerPlaced) { + _world->move(_world->_player, _world->getRandomScene()); + } +} } // End of namespace Wage diff --git a/engines/wage/wage.h b/engines/wage/wage.h index 1e57ef5d5a..91f4b67a8e 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -108,6 +108,8 @@ public: private: bool loadWorld(Common::MacResManager *resMan); + void performInitialSetup(); + void wearObjs(Chr *chr); public: Common::RandomSource *_rnd; diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp index b404736d00..8ae775ad12 100644 --- a/engines/wage/world.cpp +++ b/engines/wage/world.cpp @@ -57,7 +57,7 @@ namespace Wage { -World::World() { +World::World(WageEngine *engine) { _storageScene._name = STORAGESCENE; _orderedScenes.push_back(&_storageScene); _scenes[STORAGESCENE] = &_storageScene; @@ -66,6 +66,8 @@ World::World() { _saveBeforeQuitMessage = nullptr; _saveBeforeCloseMessage = nullptr; _revertMessage = nullptr; + + _engine = engine; } bool World::loadWorld(Common::MacResManager *resMan) { @@ -351,7 +353,20 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res } void World::move(Obj *obj, Chr *chr) { - warning("STUB: World::move()"); + warning("STUB: World::move(obj, chr)"); +} + +void World::move(Obj *obj, Scene *scene) { + warning("STUB: World::move(obj, scene)"); +} + +void World::move(Chr *chr, Scene *scene) { + warning("STUB: World::move(chr, scene)"); +} + +Scene *World::getRandomScene() { + // Not including storage: + return _orderedScenes[1 + _engine->_rnd->getRandomNumber(_orderedScenes.size() - 1)]; } } // End of namespace Wage diff --git a/engines/wage/world.h b/engines/wage/world.h index 15a65d8681..1bd71f16e7 100644 --- a/engines/wage/world.h +++ b/engines/wage/world.h @@ -54,13 +54,18 @@ namespace Wage { class World { public: - World(); + World(WageEngine *engine); ~World(); bool loadWorld(Common::MacResManager *resMan); void loadExternalSounds(String fname); Common::String *loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex); void move(Obj *obj, Chr *chr); + void move(Obj *obj, Scene *scene); + void move(Chr *chr, Scene *scene); + Scene *getRandomScene(); + + WageEngine *_engine; String _name; String _aboutMessage; |