From 6595abcf144850cc23208db71ce0098d9921112e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 5 Feb 2015 20:17:16 -0500 Subject: XEEN: Moved _maeNames to a new Resources class --- engines/xeen/character.cpp | 17 ++++++++--------- engines/xeen/resources.cpp | 10 ++++++++++ engines/xeen/resources.h | 11 +++++++++++ engines/xeen/spells.cpp | 5 ----- engines/xeen/spells.h | 1 - engines/xeen/xeen.cpp | 3 +++ engines/xeen/xeen.h | 2 ++ 7 files changed, 34 insertions(+), 15 deletions(-) diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index ff85c97855..20cbfbd0fc 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -253,10 +253,10 @@ void WeaponItems::equipItem(int itemIndex) { */ Common::String WeaponItems::getFullDescription(int itemIndex, int displayNum) { XeenItem &i = operator[](itemIndex); - Spells &spells = *vm()->_spells; + Resources &res = *vm()->_resources; return Common::String::format("\f%02u%s%s%s\f%02u%s%s%s", displayNum, - !i._bonusFlags ? spells._maeNames[i._material] : "", + !i._bonusFlags ? res._maeNames[i._material] : "", (i._bonusFlags & ITEMFLAG_BROKEN) ? ITEM_BROKEN : "", (i._bonusFlags & ITEMFLAG_CURSED) ? ITEM_CURSED : "", WEAPON_NAMES[i._id], @@ -355,10 +355,10 @@ void ArmorItems::equipItem(int itemIndex) { */ Common::String ArmorItems::getFullDescription(int itemIndex, int displayNum) { XeenItem &i = operator[](itemIndex); - Spells &spells = *vm()->_spells; + Resources &res = *vm()->_resources; return Common::String::format("\f%02u%s%s%s\f%02u%s%s", displayNum, - !i._bonusFlags ? "" : spells._maeNames[i._material], + !i._bonusFlags ? "" : res._maeNames[i._material], (i._bonusFlags & ITEMFLAG_BROKEN) ? ITEM_BROKEN : "", (i._bonusFlags & ITEMFLAG_CURSED) ? ITEM_CURSED : "", ARMOR_NAMES[i._id], @@ -425,11 +425,11 @@ void AccessoryItems::equipItem(int itemIndex) { * the Items dialog */ Common::String AccessoryItems::getFullDescription(int itemIndex, int displayNum) { - Spells &spells = *vm()->_spells; XeenItem &i = operator[](itemIndex); + Resources &res = *vm()->_resources; return Common::String::format("\f%02u%s%s%s\f%02u%s%s", displayNum, - !i._bonusFlags ? "" : spells._maeNames[i._material], + !i._bonusFlags ? "" : res._maeNames[i._material], (i._bonusFlags & ITEMFLAG_BROKEN) ? ITEM_BROKEN : "", (i._bonusFlags & ITEMFLAG_CURSED) ? ITEM_CURSED : "", ARMOR_NAMES[i._id], @@ -446,10 +446,10 @@ Common::String AccessoryItems::getFullDescription(int itemIndex, int displayNum) */ Common::String MiscItems::getFullDescription(int itemIndex, int displayNum) { XeenItem &i = operator[](itemIndex); - Spells &spells = *vm()->_spells; + Resources &res = *vm()->_resources; return Common::String::format("\f%02u%s%s%s\f%02u%s%s", displayNum, - !i._bonusFlags ? "" : spells._maeNames[i._material], + !i._bonusFlags ? "" : res._maeNames[i._material], (i._bonusFlags & ITEMFLAG_BROKEN) ? ITEM_BROKEN : "", (i._bonusFlags & ITEMFLAG_CURSED) ? ITEM_CURSED : "", ARMOR_NAMES[i._id], @@ -458,7 +458,6 @@ Common::String MiscItems::getFullDescription(int itemIndex, int displayNum) { ); } - /*------------------------------------------------------------------------*/ InventoryItemsGroup::InventoryItemsGroup(InventoryItems &weapons, InventoryItems &armor, diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index b38868f7a4..5cd09cf422 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -22,9 +22,19 @@ #include "common/scummsys.h" #include "xeen/resources.h" +#include "xeen/files.h" namespace Xeen { +Resources::Resources() { + File f("mae.xen"); + while (f.pos() < f.size()) + _maeNames.push_back(f.readString()); + f.close(); +} + +/*------------------------------------------------------------------------*/ + const char *const CREDITS = "\013""012\010""000\003""c\014""35Designed and Directed By:\n" "\014""17Jon Van Caneghem\003""l\n" diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index e1f276b91c..8be195f34e 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -24,10 +24,21 @@ #define XEEN_RESOURCES_H #include "common/scummsys.h" +#include "common/str-array.h" #include "gui/debugger.h" namespace Xeen { +class Resources { +public: + // Magic and equipment names + Common::StringArray _maeNames; +public: + Resources(); +}; + +#define Res (*_vm->_resources) + extern const char *const CREDITS; extern const char *const OPTIONS_TITLE; diff --git a/engines/xeen/spells.cpp b/engines/xeen/spells.cpp index 5f1df6aef0..50e77668cd 100644 --- a/engines/xeen/spells.cpp +++ b/engines/xeen/spells.cpp @@ -38,11 +38,6 @@ void Spells::load() { while (f1.pos() < f1.size()) _spellNames.push_back(f1.readString()); f1.close(); - - File f2("mae.xen"); - while (f2.pos() < f2.size()) - _maeNames.push_back(f2.readString()); - f2.close(); } int Spells::calcSpellCost(int spellId, int expenseFactor) const { diff --git a/engines/xeen/spells.h b/engines/xeen/spells.h index 241d35dca7..c2f9737c80 100644 --- a/engines/xeen/spells.h +++ b/engines/xeen/spells.h @@ -121,7 +121,6 @@ private: void divineIntervention(); public: Common::StringArray _spellNames; - Common::StringArray _maeNames; int _lastCaster; public: Spells(XeenEngine *vm); diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index d7a85fbbf8..d34e8edb21 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -43,6 +43,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _interface = nullptr; _map = nullptr; _party = nullptr; + _resources = nullptr; _saves = nullptr; _screen = nullptr; _scripts = nullptr; @@ -72,6 +73,7 @@ XeenEngine::~XeenEngine() { delete _spells; delete _town; delete _eventData; + delete _resources; delete _files; } @@ -84,6 +86,7 @@ void XeenEngine::initialize() { // Create sub-objects of the engine _files = new FileManager(this); + _resources = new Resources(); _combat = new Combat(this); _debugger = new Debugger(this); _events = new EventsManager(this); diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 7f1a2cd0f0..af2044b212 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -39,6 +39,7 @@ #include "xeen/interface.h" #include "xeen/map.h" #include "xeen/party.h" +#include "xeen/resources.h" #include "xeen/saves.h" #include "xeen/screen.h" #include "xeen/scripts.h" @@ -139,6 +140,7 @@ public: Interface *_interface; Map *_map; Party *_party; + Resources *_resources; SavesManager *_saves; Screen *_screen; Scripts *_scripts; -- cgit v1.2.3